Commit fc8046b9 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Implement simple example application and clean up API

parent 7a110ace
......@@ -15,6 +15,14 @@ name = "bitflags"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "examples"
version = "0.1.0"
dependencies = [
"glib 0.1.3 (git+https://github.com/gtk-rs/glib)",
"gstreamer 0.1.0",
]
[[package]]
name = "glib"
version = "0.1.3"
......
......@@ -2,4 +2,5 @@
members = [
"gstreamer",
"examples",
]
......@@ -156,6 +156,16 @@ status = "generate"
[object.function.return]
bool_return_is_error = "Failed to set object name"
[[object.function]]
name = "get_name"
[object.function.return]
nullable = false
[[object.function]]
name = "get_path_string"
[object.function.return]
nullable = false
[[object.function]]
name = "set_parent"
[object.function.return]
......
[package]
name = "examples"
version = "0.1.0"
authors = ["Sebastian Dröge <sebastian@centricular.com>"]
[dependencies]
glib = { version = "0.1.3", git = "https://github.com/gtk-rs/glib" }
gstreamer = { path = "../gstreamer" }
[[bin]]
name = "launch"
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() {
MessageView::Eos(_) => break,
MessageView::Error(err) => {
println!("Error from {}: {} ({:?})", msg.get_src().get_path_string(),
err.get_error(), err.get_debug());
break;
},
_ => (),
}
}
}
......@@ -50,11 +50,11 @@ pub trait ObjectExt {
//fn get_g_value_array(&self, property_name: &str, timestamp: ClockTime, interval: ClockTime, values: /*Ignored*/&[&glib::Value]) -> bool;
fn get_name(&self) -> Option<String>;
fn get_name(&self) -> String;
fn get_parent(&self) -> Option<Object>;
fn get_path_string(&self) -> Option<String>;
fn get_path_string(&self) -> String;
//fn get_value(&self, property_name: &str, timestamp: ClockTime) -> /*Ignored*/Option<glib::Value>;
......@@ -117,7 +117,7 @@ impl<O: IsA<Object>> ObjectExt for O {
// unsafe { TODO: call ffi::gst_object_get_g_value_array() }
//}
fn get_name(&self) -> Option<String> {
fn get_name(&self) -> String {
unsafe {
from_glib_full(ffi::gst_object_get_name(self.to_glib_none().0))
}
......@@ -129,7 +129,7 @@ impl<O: IsA<Object>> ObjectExt for O {
}
}
fn get_path_string(&self) -> Option<String> {
fn get_path_string(&self) -> String {
unsafe {
from_glib_full(ffi::gst_object_get_path_string(self.to_glib_none().0))
}
......
......@@ -29,14 +29,15 @@ pub use glib::{
Value,
};
pub use auto::*;
mod auto;
pub use auto::*;
pub use auto::functions::{parse_launch, parse_bin_from_description};
pub mod miniobject;
pub use miniobject::GstRc;
pub mod message;
pub use message::Message;
pub use message::MessageView;
use std::ptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment