launch.rs 893 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
extern crate gstreamer as gst;
use gst::*;

use std::u64;

fn main() {
    gst::init().unwrap();

    let pipeline = gst::parse_launch("audiotestsrc ! autoaudiosink").unwrap();
    let bus = pipeline.get_bus().unwrap();

    let ret = pipeline.set_state(gst::State::Playing);
    assert_ne!(ret, gst::StateChangeReturn::Failure);

    loop {
        let msg = match bus.timed_pop(u64::MAX) {
            None => break,
            Some(msg) => msg,
        };

        match msg.view() {
22
            MessageView::Eos => break,
23 24 25 26 27 28 29 30
            MessageView::Error(err) => {
                println!("Error from {}: {} ({:?})", msg.get_src().get_path_string(),
                    err.get_error(), err.get_debug());
                break;
            },
            _ => (),
        }
    }
31 32 33

    let ret = pipeline.set_state(gst::State::Null);
    assert_ne!(ret, gst::StateChangeReturn::Failure);
34
}