forked from mirrors/gstreamer-rs
examples/tutorials: The get-XXX-tags
signals on playbin can return a None
taglist
This commit is contained in:
parent
1ffcea4da7
commit
27613a8901
3 changed files with 50 additions and 40 deletions
|
@ -75,18 +75,20 @@ fn example_main() {
|
||||||
// application is via properties, signals or action signals (or custom messages, events, queries).
|
// application is via properties, signals or action signals (or custom messages, events, queries).
|
||||||
// So what the following code does, is essentially asking playbin to tell us its already
|
// So what the following code does, is essentially asking playbin to tell us its already
|
||||||
// internally stored tag list for this stream index.
|
// internally stored tag list for this stream index.
|
||||||
let tags = playbin.emit_by_name::<gst::TagList>("get-audio-tags", &[&idx]);
|
let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-audio-tags", &[&idx]);
|
||||||
|
|
||||||
if let Some(artist) = tags.get::<gst::tags::Artist>() {
|
if let Some(tags) = tags {
|
||||||
println!(" Artist: {}", artist.get());
|
if let Some(artist) = tags.get::<gst::tags::Artist>() {
|
||||||
}
|
println!(" Artist: {}", artist.get());
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(title) = tags.get::<gst::tags::Title>() {
|
if let Some(title) = tags.get::<gst::tags::Title>() {
|
||||||
println!(" Title: {}", title.get());
|
println!(" Title: {}", title.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(album) = tags.get::<gst::tags::Album>() {
|
if let Some(album) = tags.get::<gst::tags::Album>() {
|
||||||
println!(" Album: {}", album.get());
|
println!(" Album: {}", album.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|
|
@ -42,24 +42,26 @@ mod tutorial5 {
|
||||||
|
|
||||||
let x = playbin.property::<i32>(propname);
|
let x = playbin.property::<i32>(propname);
|
||||||
for i in 0..x {
|
for i in 0..x {
|
||||||
let tags = playbin.emit_by_name::<gst::TagList>(signame, &[&i]);
|
let tags = playbin.emit_by_name::<Option<gst::TagList>>(signame, &[&i]);
|
||||||
|
|
||||||
textbuf.insert_at_cursor(&format!("{} stream {}:\n ", stype, i));
|
if let Some(tags) = tags {
|
||||||
|
textbuf.insert_at_cursor(&format!("{} stream {}:\n ", stype, i));
|
||||||
|
|
||||||
if let Some(codec) = tags.get::<gst::tags::VideoCodec>() {
|
if let Some(codec) = tags.get::<gst::tags::VideoCodec>() {
|
||||||
textbuf.insert_at_cursor(&format!(" codec: {} \n", codec.get()));
|
textbuf.insert_at_cursor(&format!(" codec: {} \n", codec.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(codec) = tags.get::<gst::tags::AudioCodec>() {
|
if let Some(codec) = tags.get::<gst::tags::AudioCodec>() {
|
||||||
textbuf.insert_at_cursor(&format!(" codec: {} \n", codec.get()));
|
textbuf.insert_at_cursor(&format!(" codec: {} \n", codec.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(lang) = tags.get::<gst::tags::LanguageCode>() {
|
if let Some(lang) = tags.get::<gst::tags::LanguageCode>() {
|
||||||
textbuf.insert_at_cursor(&format!(" language: {} \n", lang.get()));
|
textbuf.insert_at_cursor(&format!(" language: {} \n", lang.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(bitrate) = tags.get::<gst::tags::Bitrate>() {
|
if let Some(bitrate) = tags.get::<gst::tags::Bitrate>() {
|
||||||
textbuf.insert_at_cursor(&format!(" bitrate: {} \n", bitrate.get()));
|
textbuf.insert_at_cursor(&format!(" bitrate: {} \n", bitrate.get()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,35 +21,41 @@ fn analyze_streams(playbin: &gst::Element) {
|
||||||
);
|
);
|
||||||
|
|
||||||
for i in 0..n_video {
|
for i in 0..n_video {
|
||||||
let tags = playbin.emit_by_name::<gst::TagList>("get-video-tags", &[&i]);
|
let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-video-tags", &[&i]);
|
||||||
|
|
||||||
println!("video stream {}:", i);
|
if let Some(tags) = tags {
|
||||||
if let Some(codec) = tags.get::<gst::tags::VideoCodec>() {
|
println!("video stream {}:", i);
|
||||||
println!(" codec: {}", codec.get());
|
if let Some(codec) = tags.get::<gst::tags::VideoCodec>() {
|
||||||
|
println!(" codec: {}", codec.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..n_audio {
|
for i in 0..n_audio {
|
||||||
let tags = playbin.emit_by_name::<gst::TagList>("get-audio-tags", &[&i]);
|
let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-audio-tags", &[&i]);
|
||||||
|
|
||||||
println!("audio stream {}:", i);
|
if let Some(tags) = tags {
|
||||||
if let Some(codec) = tags.get::<gst::tags::AudioCodec>() {
|
println!("audio stream {}:", i);
|
||||||
println!(" codec: {}", codec.get());
|
if let Some(codec) = tags.get::<gst::tags::AudioCodec>() {
|
||||||
}
|
println!(" codec: {}", codec.get());
|
||||||
if let Some(codec) = tags.get::<gst::tags::LanguageCode>() {
|
}
|
||||||
println!(" language: {}", codec.get());
|
if let Some(codec) = tags.get::<gst::tags::LanguageCode>() {
|
||||||
}
|
println!(" language: {}", codec.get());
|
||||||
if let Some(codec) = tags.get::<gst::tags::Bitrate>() {
|
}
|
||||||
println!(" bitrate: {}", codec.get());
|
if let Some(codec) = tags.get::<gst::tags::Bitrate>() {
|
||||||
|
println!(" bitrate: {}", codec.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..n_text {
|
for i in 0..n_text {
|
||||||
let tags = playbin.emit_by_name::<gst::TagList>("get-text-tags", &[&i]);
|
let tags = playbin.emit_by_name::<Option<gst::TagList>>("get-text-tags", &[&i]);
|
||||||
|
|
||||||
println!("subtitle stream {}:", i);
|
if let Some(tags) = tags {
|
||||||
if let Some(codec) = tags.get::<gst::tags::LanguageCode>() {
|
println!("subtitle stream {}:", i);
|
||||||
println!(" language: {}", codec.get());
|
if let Some(codec) = tags.get::<gst::tags::LanguageCode>() {
|
||||||
|
println!(" language: {}", codec.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue