Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track names #202

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions symphonia-core/src/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,21 @@ pub struct CuePoint {

/// A `Track` is an independently coded media bitstream. A media format may contain multiple tracks
/// in one container. Each of those tracks are represented by one `Track`.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub struct Track {
/// A unique identifier for the track.
pub id: u32,
/// The codec parameters for the track.
pub codec_params: CodecParameters,
/// The language of the track. May be unknown.
pub language: Option<String>,
/// The name of the track. May be unknown.
pub name: Option<String>,
}

impl Track {
pub fn new(id: u32, codec_params: CodecParameters) -> Self {
Track { id, codec_params, language: None }
Track { id, codec_params, language: None, name: None }
}
}

Expand Down
2 changes: 2 additions & 0 deletions symphonia-format-mkv/src/demuxer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ impl FormatReader for MkvReader {
id: track_id,
codec_params: codec_params.clone(),
language: track.language,
name: track.name,
..Default::default()
});

states.insert(
Expand Down
6 changes: 6 additions & 0 deletions symphonia-format-mkv/src/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) struct TrackElement {
pub(crate) codec_private: Option<Box<[u8]>>,
pub(crate) audio: Option<AudioElement>,
pub(crate) default_duration: Option<u64>,
pub(crate) name: Option<String>,
}

impl Element for TrackElement {
Expand All @@ -36,6 +37,7 @@ impl Element for TrackElement {
let mut codec_private = None;
let mut codec_id = None;
let mut default_duration = None;
let mut name = None;

let mut it = header.children(reader);
while let Some(header) = it.read_header()? {
Expand All @@ -61,6 +63,9 @@ impl Element for TrackElement {
ElementType::DefaultDuration => {
default_duration = Some(it.read_u64()?);
}
ElementType::Name => {
name = Some(it.read_string()?);
}
other => {
log::debug!("ignored element {:?}", other);
}
Expand All @@ -75,6 +80,7 @@ impl Element for TrackElement {
codec_private,
audio,
default_duration,
name,
})
}
}
Expand Down