switch Chunks to use Arcs
This commit is contained in:
parent
d20081d9a1
commit
7f214920ae
2 changed files with 5 additions and 5 deletions
|
@ -9,8 +9,8 @@ use hyper::{Get, StatusCode};
|
||||||
use hyper::header::ContentType;
|
use hyper::header::ContentType;
|
||||||
use hyper::server::{Http, Request, Response, Service};
|
use hyper::server::{Http, Request, Response, Service};
|
||||||
use std::env::args;
|
use std::env::args;
|
||||||
use std::rc::Rc;
|
|
||||||
use std::net::ToSocketAddrs;
|
use std::net::ToSocketAddrs;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
const SRC_FILE: &'static [u8] = include_bytes!("../data/test1.webm");
|
const SRC_FILE: &'static [u8] = include_bytes!("../data/test1.webm");
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ impl Service for WebmServer {
|
||||||
fn call(&self, req: Request) -> Self::Future {
|
fn call(&self, req: Request) -> Self::Future {
|
||||||
let response = match (req.method(), req.path()) {
|
let response = match (req.method(), req.path()) {
|
||||||
(&Get, "/loop") => {
|
(&Get, "/loop") => {
|
||||||
let stream: BodyStream = Box::new(once(Ok(Chunk::Headers {bytes: Rc::new(SRC_FILE)})));
|
let stream: BodyStream = Box::new(once(Ok(Chunk::Headers {bytes: Arc::new(SRC_FILE)})));
|
||||||
Response::new()
|
Response::new()
|
||||||
.with_header(ContentType("video/webm".parse().unwrap()))
|
.with_header(ContentType("video/webm".parse().unwrap()))
|
||||||
.with_body(stream)
|
.with_body(stream)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::rc::Rc;
|
use std::sync::Arc;
|
||||||
use webm::*;
|
use webm::*;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum Chunk<B: AsRef<[u8]> = Vec<u8>> {
|
pub enum Chunk<B: AsRef<[u8]> = Vec<u8>> {
|
||||||
Headers {
|
Headers {
|
||||||
bytes: Rc<B>
|
bytes: Arc<B>
|
||||||
},
|
},
|
||||||
ClusterHead {
|
ClusterHead {
|
||||||
keyframe: bool,
|
keyframe: bool,
|
||||||
|
@ -15,7 +15,7 @@ pub enum Chunk<B: AsRef<[u8]> = Vec<u8>> {
|
||||||
bytes: [u8;16]
|
bytes: [u8;16]
|
||||||
},
|
},
|
||||||
ClusterBody {
|
ClusterBody {
|
||||||
bytes: Rc<B>
|
bytes: Arc<B>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue