mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
Implement simple example application and clean up API
This commit is contained in:
parent
7a110ace10
commit
fc8046b9bd
7 changed files with 67 additions and 5 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -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",
|
||||
]
|
||||
|
|
10
Gir_Gst.toml
10
Gir_Gst.toml
|
@ -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]
|
||||
|
|
11
examples/Cargo.toml
Normal file
11
examples/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[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"
|
31
examples/src/launch.rs
Normal file
31
examples/src/launch.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue