From b2c2163928e19bbd9441a4c90e4ccd82b8ee4318 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Fri, 20 Oct 2023 16:37:37 +0500 Subject: [PATCH] type to manage moof fragment sample queue --- src/muxer/hls/mp4/mod.rs | 15 +++++++++++---- src/muxer/hls/mp4/mp4muxer.rs | 2 +- src/muxer/hls/mp4/samples.rs | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/muxer/hls/mp4/samples.rs diff --git a/src/muxer/hls/mp4/mod.rs b/src/muxer/hls/mp4/mod.rs index 3cbbad5..9ca103b 100644 --- a/src/muxer/hls/mp4/mod.rs +++ b/src/muxer/hls/mp4/mod.rs @@ -1,5 +1,6 @@ mod mp4muxer; mod atoms; +mod samples; use std::sync::{mpsc, Arc}; use std::error::Error; @@ -8,9 +9,9 @@ use crate::util; pub struct MP4Muxer { v: mpsc::Receiver, - v_samples: Vec>, + v_samples: samples::SampleQueue, a: mpsc::Receiver, - a_samples: Vec>, + a_samples: samples::SampleQueue, metadata: Arc, err_in: mpsc::Sender>, } @@ -21,8 +22,14 @@ pub fn new_muxer(v: mpsc::Receiver, a: mpsc::Receiver { - 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)) }, _ => Err(Box::new(util::MuxerError::InvalidCodec)) diff --git a/src/muxer/hls/mp4/samples.rs b/src/muxer/hls/mp4/samples.rs new file mode 100644 index 0000000..db5c512 --- /dev/null +++ b/src/muxer/hls/mp4/samples.rs @@ -0,0 +1,20 @@ +pub struct Sample { + pub data: Vec, + pub size: u32, + pub flags: u32, +} + +pub struct SampleQueue { + pub queue: Vec, + pub default_duration: u32, +} + +impl SampleQueue { + pub fn push(&mut self, data: Vec, flags: u32) { + self.queue.push(Sample { + size: data.len() as u32, + data: data, + flags: flags, + }) + } +}