type to manage moof fragment sample queue
This commit is contained in:
parent
28a43ecdaa
commit
b2c2163928
3 changed files with 32 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
mod mp4muxer;
|
mod mp4muxer;
|
||||||
mod atoms;
|
mod atoms;
|
||||||
|
mod samples;
|
||||||
|
|
||||||
use std::sync::{mpsc, Arc};
|
use std::sync::{mpsc, Arc};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
@ -8,9 +9,9 @@ use crate::util;
|
||||||
|
|
||||||
pub struct MP4Muxer {
|
pub struct MP4Muxer {
|
||||||
v: mpsc::Receiver<util::NALUPacket>,
|
v: mpsc::Receiver<util::NALUPacket>,
|
||||||
v_samples: Vec<Vec<u8>>,
|
v_samples: samples::SampleQueue,
|
||||||
a: mpsc::Receiver<util::NALUPacket>,
|
a: mpsc::Receiver<util::NALUPacket>,
|
||||||
a_samples: Vec<Vec<u8>>,
|
a_samples: samples::SampleQueue,
|
||||||
metadata: Arc<util::Metadata>,
|
metadata: Arc<util::Metadata>,
|
||||||
err_in: mpsc::Sender<Box<dyn Error + Send + Sync>>,
|
err_in: mpsc::Sender<Box<dyn Error + Send + Sync>>,
|
||||||
}
|
}
|
||||||
|
@ -21,8 +22,14 @@ pub fn new_muxer(v: mpsc::Receiver<util::NALUPacket>, a: mpsc::Receiver<util::NA
|
||||||
a: a,
|
a: a,
|
||||||
metadata: metadata,
|
metadata: metadata,
|
||||||
err_in: err_in,
|
err_in: err_in,
|
||||||
v_samples: Vec::new(),
|
v_samples: samples::SampleQueue {
|
||||||
a_samples: Vec::new(),
|
queue: Vec::new(),
|
||||||
|
default_duration: 1000,
|
||||||
|
},
|
||||||
|
a_samples: samples::SampleQueue {
|
||||||
|
queue: Vec::new(),
|
||||||
|
default_duration: 960,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
muxer.gen_init()?;
|
muxer.gen_init()?;
|
||||||
return Ok(muxer);
|
return Ok(muxer);
|
||||||
|
|
|
@ -18,7 +18,7 @@ impl mp4::MP4Muxer {
|
||||||
let v_cc = self.v.recv()?;
|
let v_cc = self.v.recv()?;
|
||||||
return match v_cc.packet_type {
|
return match v_cc.packet_type {
|
||||||
util::NALUPacketType::Video(util::VideoCodec::AV1) => {
|
util::NALUPacketType::Video(util::VideoCodec::AV1) => {
|
||||||
self.v_samples.push(v_cc.packet_data.clone());
|
self.v_samples.push(v_cc.packet_data.clone(), 0x02000000);
|
||||||
Ok(get_av1_stsd(v_cc.packet_data, &self.metadata))
|
Ok(get_av1_stsd(v_cc.packet_data, &self.metadata))
|
||||||
},
|
},
|
||||||
_ => Err(Box::new(util::MuxerError::InvalidCodec))
|
_ => Err(Box::new(util::MuxerError::InvalidCodec))
|
||||||
|
|
20
src/muxer/hls/mp4/samples.rs
Normal file
20
src/muxer/hls/mp4/samples.rs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
pub struct Sample {
|
||||||
|
pub data: Vec<u8>,
|
||||||
|
pub size: u32,
|
||||||
|
pub flags: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SampleQueue {
|
||||||
|
pub queue: Vec<Sample>,
|
||||||
|
pub default_duration: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SampleQueue {
|
||||||
|
pub fn push(&mut self, data: Vec<u8>, flags: u32) {
|
||||||
|
self.queue.push(Sample {
|
||||||
|
size: data.len() as u32,
|
||||||
|
data: data,
|
||||||
|
flags: flags,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue