mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-02-16 11:05:20 +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"
|
version = "0.9.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
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]]
|
[[package]]
|
||||||
name = "glib"
|
name = "glib"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
|
|
|
@ -2,4 +2,5 @@
|
||||||
|
|
||||||
members = [
|
members = [
|
||||||
"gstreamer",
|
"gstreamer",
|
||||||
|
"examples",
|
||||||
]
|
]
|
||||||
|
|
10
Gir_Gst.toml
10
Gir_Gst.toml
|
@ -156,6 +156,16 @@ status = "generate"
|
||||||
[object.function.return]
|
[object.function.return]
|
||||||
bool_return_is_error = "Failed to set object name"
|
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]]
|
[[object.function]]
|
||||||
name = "set_parent"
|
name = "set_parent"
|
||||||
[object.function.return]
|
[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_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_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>;
|
//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() }
|
// unsafe { TODO: call ffi::gst_object_get_g_value_array() }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
fn get_name(&self) -> Option<String> {
|
fn get_name(&self) -> String {
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib_full(ffi::gst_object_get_name(self.to_glib_none().0))
|
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 {
|
unsafe {
|
||||||
from_glib_full(ffi::gst_object_get_path_string(self.to_glib_none().0))
|
from_glib_full(ffi::gst_object_get_path_string(self.to_glib_none().0))
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,15 @@ pub use glib::{
|
||||||
Value,
|
Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use auto::*;
|
|
||||||
mod auto;
|
mod auto;
|
||||||
|
pub use auto::*;
|
||||||
pub use auto::functions::{parse_launch, parse_bin_from_description};
|
pub use auto::functions::{parse_launch, parse_bin_from_description};
|
||||||
|
|
||||||
pub mod miniobject;
|
pub mod miniobject;
|
||||||
pub use miniobject::GstRc;
|
pub use miniobject::GstRc;
|
||||||
pub mod message;
|
pub mod message;
|
||||||
pub use message::Message;
|
pub use message::Message;
|
||||||
|
pub use message::MessageView;
|
||||||
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue