Skip to content

Commit

Permalink
Fix some catalog bugs involving the name. (kixelated#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
kixelated authored Jul 24, 2024
1 parent 0afcbfa commit 5cef5e8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion moq-catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Luke Curley"]
repository = "https://github.com/kixelated/moq-rs"
license = "MIT OR Apache-2.0"

version = "0.1.0"
version = "0.2.0"
edition = "2021"

keywords = ["quic", "http3", "webtransport", "media", "live"]
Expand Down
6 changes: 3 additions & 3 deletions moq-catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ pub struct Track {

pub name: String,

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

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

#[serde(skip_serializing_if = "Option::is_none")]
pub packaging: Option<TrackPackaging>,
Expand Down
2 changes: 1 addition & 1 deletion moq-pub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ categories = ["multimedia", "network-programming", "web-programming"]
[dependencies]
moq-native = { path = "../moq-native", version = "0.2" }
moq-transport = { path = "../moq-transport", version = "0.5" }
moq-catalog = { path = "../moq-catalog", version = "0.1" }
moq-catalog = { path = "../moq-catalog", version = "0.2" }

url = "2"
bytes = "1"
Expand Down
32 changes: 13 additions & 19 deletions moq-pub/src/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,6 @@ impl Media {
}

fn setup(&mut self, moov: &mp4::MoovBox, raw: Bytes) -> anyhow::Result<()> {
// Create a track for each track in the moov
for trak in &moov.traks {
let id = trak.tkhd.track_id;
let name = format!("{}.m4s", id);

let timescale = track_timescale(moov, id);
let handler = (&trak.mdia.hdlr.handler_type).try_into()?;

// Store the track publisher in a map so we can update it later.
let track = self.broadcast.create(&name).context("broadcast closed")?;
let track = Track::new(track, handler, timescale);
self.tracks.insert(id, track);
}

// Combine the ftyp+moov atoms into a single object.
let mut init = self.ftyp.clone().context("missing ftyp")?.to_vec();
init.extend_from_slice(&raw);
Expand All @@ -152,11 +138,17 @@ impl Media {

// Produce the catalog
for trak in &moov.traks {
let id = trak.tkhd.track_id;
let name = format!("{}.m4s", id);

let timescale = track_timescale(moov, id);
let handler = (&trak.mdia.hdlr.handler_type).try_into()?;

let mut selection_params = moq_catalog::SelectionParam::default();

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

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

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

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

tracks.push(track);

// Store the track publisher in a map so we can update it later.
let track = self.broadcast.create(&name).context("broadcast closed")?;
let track = Track::new(track, handler, timescale);
self.tracks.insert(id, track);
}

let catalog = moq_catalog::Root {
Expand Down

0 comments on commit 5cef5e8

Please sign in to comment.