Skip to content

Commit 5cef5e8

Browse files
authored
Fix some catalog bugs involving the name. (#178)
1 parent 0afcbfa commit 5cef5e8

File tree

5 files changed

+19
-25
lines changed

5 files changed

+19
-25
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

moq-catalog/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Luke Curley"]
55
repository = "https://github.com/kixelated/moq-rs"
66
license = "MIT OR Apache-2.0"
77

8-
version = "0.1.0"
8+
version = "0.2.0"
99
edition = "2021"
1010

1111
keywords = ["quic", "http3", "webtransport", "media", "live"]

moq-catalog/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ pub struct Track {
3131

3232
pub name: String,
3333

34-
#[serde(rename = "initTrack")]
34+
#[serde(rename = "initTrack", skip_serializing_if = "Option::is_none")]
3535
pub init_track: Option<String>,
3636

37-
#[serde(rename = "initData")]
38-
pub data_track: Option<String>,
37+
#[serde(rename = "initData", skip_serializing_if = "Option::is_none")]
38+
pub init_data: Option<String>,
3939

4040
#[serde(skip_serializing_if = "Option::is_none")]
4141
pub packaging: Option<TrackPackaging>,

moq-pub/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ categories = ["multimedia", "network-programming", "web-programming"]
1616
[dependencies]
1717
moq-native = { path = "../moq-native", version = "0.2" }
1818
moq-transport = { path = "../moq-transport", version = "0.5" }
19-
moq-catalog = { path = "../moq-catalog", version = "0.1" }
19+
moq-catalog = { path = "../moq-catalog", version = "0.2" }
2020

2121
url = "2"
2222
bytes = "1"

moq-pub/src/media.rs

+13-19
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,6 @@ impl Media {
127127
}
128128

129129
fn setup(&mut self, moov: &mp4::MoovBox, raw: Bytes) -> anyhow::Result<()> {
130-
// Create a track for each track in the moov
131-
for trak in &moov.traks {
132-
let id = trak.tkhd.track_id;
133-
let name = format!("{}.m4s", id);
134-
135-
let timescale = track_timescale(moov, id);
136-
let handler = (&trak.mdia.hdlr.handler_type).try_into()?;
137-
138-
// Store the track publisher in a map so we can update it later.
139-
let track = self.broadcast.create(&name).context("broadcast closed")?;
140-
let track = Track::new(track, handler, timescale);
141-
self.tracks.insert(id, track);
142-
}
143-
144130
// Combine the ftyp+moov atoms into a single object.
145131
let mut init = self.ftyp.clone().context("missing ftyp")?.to_vec();
146132
init.extend_from_slice(&raw);
@@ -152,11 +138,17 @@ impl Media {
152138

153139
// Produce the catalog
154140
for trak in &moov.traks {
141+
let id = trak.tkhd.track_id;
142+
let name = format!("{}.m4s", id);
143+
144+
let timescale = track_timescale(moov, id);
145+
let handler = (&trak.mdia.hdlr.handler_type).try_into()?;
146+
155147
let mut selection_params = moq_catalog::SelectionParam::default();
156148

157149
let mut track = moq_catalog::Track {
158-
init_track: Some("0.mp4".to_string()),
159-
data_track: Some(format!("{}.m4s", trak.tkhd.track_id)),
150+
init_track: Some(self.init.name.clone()),
151+
name: name.clone(),
160152
namespace: Some(self.broadcast.namespace.clone()),
161153
packaging: Some(moq_catalog::TrackPackaging::Cmaf),
162154
render_group: Some(1),
@@ -181,7 +173,6 @@ impl Media {
181173
let codec = rfc6381_codec::Codec::avc1(profile, constraints, level);
182174
let codec_str = codec.to_string();
183175

184-
track.name = format!("video_{}p", height);
185176
selection_params.codec = Some(codec_str);
186177
selection_params.width = Some(width.into());
187178
selection_params.height = Some(height.into());
@@ -197,7 +188,6 @@ impl Media {
197188
.dec_config;
198189
let codec_str = format!("mp4a.{:02x}.{}", desc.object_type_indication, desc.dec_specific.profile);
199190

200-
track.name = "audio".to_string();
201191
selection_params.codec = Some(codec_str);
202192
selection_params.channel_config = Some(mp4a.channelcount.to_string());
203193
selection_params.samplerate = Some(mp4a.samplerate.value().into());
@@ -211,7 +201,6 @@ impl Media {
211201
let vpcc = &vp09.vpcc;
212202
let codec_str = format!("vp09.0.{:02x}.{:02x}.{:02x}", vpcc.profile, vpcc.level, vpcc.bit_depth);
213203

214-
track.name = format!("video_{}p", vp09.height);
215204
selection_params.codec = Some(codec_str);
216205
selection_params.width = Some(vp09.width.into());
217206
selection_params.height = Some(vp09.height.into());
@@ -226,6 +215,11 @@ impl Media {
226215
track.selection_params = selection_params;
227216

228217
tracks.push(track);
218+
219+
// Store the track publisher in a map so we can update it later.
220+
let track = self.broadcast.create(&name).context("broadcast closed")?;
221+
let track = Track::new(track, handler, timescale);
222+
self.tracks.insert(id, track);
229223
}
230224

231225
let catalog = moq_catalog::Root {

0 commit comments

Comments
 (0)