mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-06-07 00:39:28 +00:00
10151b9f0d
Fixes https://github.com/sdroege/gstreamer-rs/pull/62 Fixes https://github.com/sdroege/gstreamer-rs/issues/58
50 lines
1.5 KiB
Rust
50 lines
1.5 KiB
Rust
extern crate gstreamer as gst;
|
|
use gst::prelude::*;
|
|
|
|
#[path = "../tutorials-common.rs"]
|
|
mod tutorials_common;
|
|
|
|
fn tutorial_main() {
|
|
// Initialize GStreamer
|
|
gst::init().unwrap();
|
|
|
|
// Build the pipeline
|
|
let uri =
|
|
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
|
|
let pipeline = gst::parse_launch(&format!("playbin uri={}", uri)).unwrap();
|
|
|
|
// Start playing
|
|
let ret = pipeline.set_state(gst::State::Playing);
|
|
assert_ne!(ret, gst::StateChangeReturn::Failure);
|
|
|
|
// Wait until error or EOS
|
|
let bus = pipeline.get_bus().unwrap();
|
|
while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) {
|
|
use gst::MessageView;
|
|
|
|
match msg.view() {
|
|
MessageView::Eos(..) => break,
|
|
MessageView::Error(err) => {
|
|
println!(
|
|
"Error from {}: {} ({:?})",
|
|
msg.get_src().get_path_string(),
|
|
err.get_error(),
|
|
err.get_debug()
|
|
);
|
|
break;
|
|
}
|
|
_ => (),
|
|
}
|
|
}
|
|
|
|
// Shutdown pipeline
|
|
let ret = pipeline.set_state(gst::State::Null);
|
|
assert_ne!(ret, gst::StateChangeReturn::Failure);
|
|
}
|
|
|
|
fn main() {
|
|
// tutorials_common::run is only required to set up the application environment on macOS
|
|
// (but not necessary in normal Cocoa applications where this is set up automatically)
|
|
tutorials_common::run(tutorial_main);
|
|
}
|