mirror of
https://github.com/nestriness/warp.git
synced 2025-12-11 09:25:39 +02:00
fix: catalog and init_track names conflicting due to different audio/video streams
This commit is contained in:
17
src/media.rs
17
src/media.rs
@@ -297,7 +297,7 @@ impl AudioStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_appsink(appsink: &gst_app::AppSink, mut broadcast: broadcast::Publisher, _is_video: bool) {
|
fn setup_appsink(appsink: &gst_app::AppSink, mut broadcast: broadcast::Publisher, is_video: bool) {
|
||||||
let state = Arc::new(Mutex::new(State {
|
let state = Arc::new(Mutex::new(State {
|
||||||
ftyp_atom: None,
|
ftyp_atom: None,
|
||||||
broadcast: broadcast.to_owned(),
|
broadcast: broadcast.to_owned(),
|
||||||
@@ -415,11 +415,13 @@ fn setup_appsink(appsink: &gst_app::AppSink, mut broadcast: broadcast::Publisher
|
|||||||
let moov = mp4::MoovBox::read_box(&mut reader, header.size)
|
let moov = mp4::MoovBox::read_box(&mut reader, header.size)
|
||||||
.expect("could not read the moov box");
|
.expect("could not read the moov box");
|
||||||
|
|
||||||
let uuid = Uuid::new_v4();
|
let type_name = if is_video { "video"} else { "audio"};
|
||||||
|
|
||||||
let init_name = format!("{}.mp4", uuid);
|
|
||||||
|
|
||||||
// Create the catalog track with a single segment.
|
// Create the catalog track with a single segment.
|
||||||
|
if !state.init.is_some() {
|
||||||
|
let init_name = format!("{}.mp4", type_name);
|
||||||
|
|
||||||
let mut init_track = broadcast
|
let mut init_track = broadcast
|
||||||
.create_track(&init_name)
|
.create_track(&init_name)
|
||||||
.expect("could not create the init broadcast track");
|
.expect("could not create the init broadcast track");
|
||||||
@@ -437,9 +439,7 @@ fn setup_appsink(appsink: &gst_app::AppSink, mut broadcast: broadcast::Publisher
|
|||||||
.final_fragment(VarInt::ZERO)
|
.final_fragment(VarInt::ZERO)
|
||||||
.expect("could not create the init fragment");
|
.expect("could not create the init fragment");
|
||||||
|
|
||||||
init_fragment.chunk(init.into()).expect(
|
init_fragment.chunk(init.into()).expect("could not insert the moov+ftyp box into the init fragment");
|
||||||
"could not insert the moov+ftyp box into the init fragment",
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut tracks = HashMap::new();
|
let mut tracks = HashMap::new();
|
||||||
|
|
||||||
@@ -463,9 +463,7 @@ fn setup_appsink(appsink: &gst_app::AppSink, mut broadcast: broadcast::Publisher
|
|||||||
tracks.insert(id, track);
|
tracks.insert(id, track);
|
||||||
}
|
}
|
||||||
|
|
||||||
let uuid = Uuid::new_v4();
|
let catalog_name = format!(".catalog_{}", type_name);
|
||||||
|
|
||||||
let catalog_name = format!(".catalog.{}", uuid);
|
|
||||||
|
|
||||||
let mut catalog = broadcast
|
let mut catalog = broadcast
|
||||||
.create_track(&catalog_name)
|
.create_track(&catalog_name)
|
||||||
@@ -480,6 +478,7 @@ fn setup_appsink(appsink: &gst_app::AppSink, mut broadcast: broadcast::Publisher
|
|||||||
state.init = Some(init_track);
|
state.init = Some(init_track);
|
||||||
state.tracks = Some(tracks);
|
state.tracks = Some(tracks);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ATOM_TYPE_MOOF => {
|
ATOM_TYPE_MOOF => {
|
||||||
// state.moof_atom = Some(atom);
|
// state.moof_atom = Some(atom);
|
||||||
// println!("moof_atom");
|
// println!("moof_atom");
|
||||||
|
|||||||
Reference in New Issue
Block a user