mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
Add prelude modules to all cratest that only re-export the traits
And use those in the examples instead of blanket * imports
This commit is contained in:
parent
767bd0537e
commit
f751afc0fb
19 changed files with 148 additions and 70 deletions
|
@ -1,7 +1,6 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
extern crate gstreamer_app as gst_app;
|
extern crate gstreamer_app as gst_app;
|
||||||
use gst_app::*;
|
|
||||||
extern crate gstreamer_audio as gst_audio;
|
extern crate gstreamer_audio as gst_audio;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
|
@ -15,7 +14,7 @@ use std::i32;
|
||||||
|
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
fn create_pipeline() -> Result<Pipeline, utils::ExampleError> {
|
fn create_pipeline() -> Result<gst::Pipeline, utils::ExampleError> {
|
||||||
gst::init().map_err(utils::ExampleError::InitFailed)?;
|
gst::init().map_err(utils::ExampleError::InitFailed)?;
|
||||||
let pipeline = gst::Pipeline::new(None);
|
let pipeline = gst::Pipeline::new(None);
|
||||||
let src = utils::create_element("audiotestsrc")?;
|
let src = utils::create_element("audiotestsrc")?;
|
||||||
|
@ -28,28 +27,28 @@ fn create_pipeline() -> Result<Pipeline, utils::ExampleError> {
|
||||||
utils::link_elements(&src, &sink)?;
|
utils::link_elements(&src, &sink)?;
|
||||||
|
|
||||||
let appsink = sink.clone()
|
let appsink = sink.clone()
|
||||||
.dynamic_cast::<AppSink>()
|
.dynamic_cast::<gst_app::AppSink>()
|
||||||
.expect("Sink element is expected to be an appsink!");
|
.expect("Sink element is expected to be an appsink!");
|
||||||
|
|
||||||
appsink.set_caps(&Caps::new_simple(
|
appsink.set_caps(&gst::Caps::new_simple(
|
||||||
"audio/x-raw",
|
"audio/x-raw",
|
||||||
&[
|
&[
|
||||||
("format", &gst_audio::AUDIO_FORMAT_S16.to_string()),
|
("format", &gst_audio::AUDIO_FORMAT_S16.to_string()),
|
||||||
("layout", &"interleaved"),
|
("layout", &"interleaved"),
|
||||||
("channels", &(1i32)),
|
("channels", &(1i32)),
|
||||||
("rate", &IntRange::<i32>::new(1, i32::MAX)),
|
("rate", &gst::IntRange::<i32>::new(1, i32::MAX)),
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
|
|
||||||
appsink.set_callbacks(AppSinkCallbacks::new(
|
appsink.set_callbacks(gst_app::AppSinkCallbacks::new(
|
||||||
/* eos */
|
/* eos */
|
||||||
|_| {},
|
|_| {},
|
||||||
/* new_preroll */
|
/* new_preroll */
|
||||||
|_| FlowReturn::Ok,
|
|_| gst::FlowReturn::Ok,
|
||||||
/* new_samples */
|
/* new_samples */
|
||||||
|appsink| {
|
|appsink| {
|
||||||
let sample = match appsink.pull_sample() {
|
let sample = match appsink.pull_sample() {
|
||||||
None => return FlowReturn::Eos,
|
None => return gst::FlowReturn::Eos,
|
||||||
Some(sample) => sample,
|
Some(sample) => sample,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +63,7 @@ fn create_pipeline() -> Result<Pipeline, utils::ExampleError> {
|
||||||
let samples = if let Ok(samples) = map.as_slice().as_slice_of::<i16>() {
|
let samples = if let Ok(samples) = map.as_slice().as_slice_of::<i16>() {
|
||||||
samples
|
samples
|
||||||
} else {
|
} else {
|
||||||
return FlowReturn::Error;
|
return gst::FlowReturn::Error;
|
||||||
};
|
};
|
||||||
|
|
||||||
let sum: f64 = samples
|
let sum: f64 = samples
|
||||||
|
@ -77,7 +76,7 @@ fn create_pipeline() -> Result<Pipeline, utils::ExampleError> {
|
||||||
let rms = (sum / (samples.len() as f64)).sqrt();
|
let rms = (sum / (samples.len() as f64)).sqrt();
|
||||||
println!("rms: {}", rms);
|
println!("rms: {}", rms);
|
||||||
|
|
||||||
FlowReturn::Ok
|
gst::FlowReturn::Ok
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -94,6 +93,8 @@ fn main_loop() -> Result<(), utils::ExampleError> {
|
||||||
.expect("Pipeline without bus. Shouldn't happen!");
|
.expect("Pipeline without bus. Shouldn't happen!");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let msg = match bus.timed_pop(u64::MAX) {
|
let msg = match bus.timed_pop(u64::MAX) {
|
||||||
None => break,
|
None => break,
|
||||||
Some(msg) => msg,
|
Some(msg) => msg,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
extern crate gstreamer_app as gst_app;
|
extern crate gstreamer_app as gst_app;
|
||||||
use gst_app::*;
|
|
||||||
extern crate gstreamer_video as gst_video;
|
extern crate gstreamer_video as gst_video;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
|
@ -14,7 +13,7 @@ pub mod utils;
|
||||||
const WIDTH: usize = 320;
|
const WIDTH: usize = 320;
|
||||||
const HEIGHT: usize = 240;
|
const HEIGHT: usize = 240;
|
||||||
|
|
||||||
fn create_pipeline() -> Result<(Pipeline, AppSrc), utils::ExampleError> {
|
fn create_pipeline() -> Result<(gst::Pipeline, gst_app::AppSrc), utils::ExampleError> {
|
||||||
gst::init().map_err(utils::ExampleError::InitFailed)?;
|
gst::init().map_err(utils::ExampleError::InitFailed)?;
|
||||||
|
|
||||||
let pipeline = gst::Pipeline::new(None);
|
let pipeline = gst::Pipeline::new(None);
|
||||||
|
@ -29,16 +28,16 @@ fn create_pipeline() -> Result<(Pipeline, AppSrc), utils::ExampleError> {
|
||||||
utils::link_elements(&videoconvert, &sink)?;
|
utils::link_elements(&videoconvert, &sink)?;
|
||||||
|
|
||||||
let appsrc = src.clone()
|
let appsrc = src.clone()
|
||||||
.dynamic_cast::<AppSrc>()
|
.dynamic_cast::<gst_app::AppSrc>()
|
||||||
.expect("Source element is expected to be an appsrc!");
|
.expect("Source element is expected to be an appsrc!");
|
||||||
|
|
||||||
let info = gst_video::VideoInfo::new(gst_video::VideoFormat::Bgrx, WIDTH as u32, HEIGHT as u32)
|
let info = gst_video::VideoInfo::new(gst_video::VideoFormat::Bgrx, WIDTH as u32, HEIGHT as u32)
|
||||||
.fps(Fraction::new(2, 1))
|
.fps(gst::Fraction::new(2, 1))
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
appsrc.set_caps(&info.to_caps().unwrap());
|
appsrc.set_caps(&info.to_caps().unwrap());
|
||||||
appsrc.set_property_format(Format::Time);
|
appsrc.set_property_format(gst::Format::Time);
|
||||||
appsrc.set_max_bytes(1);
|
appsrc.set_max_bytes(1);
|
||||||
appsrc.set_property_block(true);
|
appsrc.set_property_block(true);
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ fn main_loop() -> Result<(), utils::ExampleError> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if appsrc.push_buffer(buffer) != FlowReturn::Ok {
|
if appsrc.push_buffer(buffer) != gst::FlowReturn::Ok {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,6 +86,8 @@ fn main_loop() -> Result<(), utils::ExampleError> {
|
||||||
.expect("Pipeline without bus. Shouldn't happen!");
|
.expect("Pipeline without bus. Shouldn't happen!");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let msg = match bus.timed_pop(u64::MAX) {
|
let msg = match bus.timed_pop(u64::MAX) {
|
||||||
None => break,
|
None => break,
|
||||||
Some(msg) => msg,
|
Some(msg) => msg,
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
use glib::*;
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::u64;
|
use std::u64;
|
||||||
|
@ -21,7 +20,8 @@ fn main() {
|
||||||
let src = gst::ElementFactory::make("filesrc", None).unwrap();
|
let src = gst::ElementFactory::make("filesrc", None).unwrap();
|
||||||
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();
|
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();
|
||||||
|
|
||||||
src.set_property("location", &Value::from(uri)).unwrap();
|
src.set_property("location", &glib::Value::from(uri))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
pipeline.add_many(&[&src, &decodebin]).unwrap();
|
pipeline.add_many(&[&src, &decodebin]).unwrap();
|
||||||
gst::Element::link_many(&[&src, &decodebin]).unwrap();
|
gst::Element::link_many(&[&src, &decodebin]).unwrap();
|
||||||
|
@ -82,6 +82,8 @@ fn main() {
|
||||||
let bus = pipeline.get_bus().unwrap();
|
let bus = pipeline.get_bus().unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let msg = match bus.timed_pop(u64::MAX) {
|
let msg = match bus.timed_pop(u64::MAX) {
|
||||||
None => break,
|
None => break,
|
||||||
Some(msg) => msg,
|
Some(msg) => msg,
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
use glib::*;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
|
|
||||||
let main_loop = MainLoop::new(None, false);
|
let main_loop = glib::MainLoop::new(None, false);
|
||||||
|
|
||||||
let pipeline = gst::parse_launch("audiotestsrc ! fakesink").unwrap();
|
let pipeline = gst::parse_launch("audiotestsrc ! fakesink").unwrap();
|
||||||
let bus = pipeline.get_bus().unwrap();
|
let bus = pipeline.get_bus().unwrap();
|
||||||
|
@ -23,7 +22,7 @@ fn main() {
|
||||||
|
|
||||||
println!("sending eos");
|
println!("sending eos");
|
||||||
|
|
||||||
let ev = Event::new_eos().build();
|
let ev = gst::Event::new_eos().build();
|
||||||
pipeline.send_event(ev);
|
pipeline.send_event(ev);
|
||||||
|
|
||||||
glib::Continue(false)
|
glib::Continue(false)
|
||||||
|
@ -32,6 +31,8 @@ fn main() {
|
||||||
//bus.add_signal_watch();
|
//bus.add_signal_watch();
|
||||||
//bus.connect_message(move |_, msg| {
|
//bus.connect_message(move |_, msg| {
|
||||||
bus.add_watch(move |_, msg| {
|
bus.add_watch(move |_, msg| {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let main_loop = &main_loop_clone;
|
let main_loop = &main_loop_clone;
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Eos(..) => {
|
MessageView::Eos(..) => {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
use glib::*;
|
|
||||||
|
|
||||||
extern crate gio;
|
extern crate gio;
|
||||||
use gio::*;
|
use gio::prelude::*;
|
||||||
|
|
||||||
extern crate gtk;
|
extern crate gtk;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
@ -16,10 +15,10 @@ extern crate send_cell;
|
||||||
use send_cell::SendCell;
|
use send_cell::SendCell;
|
||||||
|
|
||||||
fn create_ui(app: >k::Application) {
|
fn create_ui(app: >k::Application) {
|
||||||
let pipeline = Pipeline::new(None);
|
let pipeline = gst::Pipeline::new(None);
|
||||||
let src = ElementFactory::make("videotestsrc", None).unwrap();
|
let src = gst::ElementFactory::make("videotestsrc", None).unwrap();
|
||||||
let (sink, widget) = if let Some(gtkglsink) = ElementFactory::make("gtkglsink", None) {
|
let (sink, widget) = if let Some(gtkglsink) = gst::ElementFactory::make("gtkglsink", None) {
|
||||||
let glsinkbin = ElementFactory::make("glsinkbin", None).unwrap();
|
let glsinkbin = gst::ElementFactory::make("glsinkbin", None).unwrap();
|
||||||
glsinkbin
|
glsinkbin
|
||||||
.set_property("sink", >kglsink.to_value())
|
.set_property("sink", >kglsink.to_value())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -27,7 +26,7 @@ fn create_ui(app: >k::Application) {
|
||||||
let widget = gtkglsink.get_property("widget").unwrap();
|
let widget = gtkglsink.get_property("widget").unwrap();
|
||||||
(glsinkbin, widget.get::<gtk::Widget>().unwrap())
|
(glsinkbin, widget.get::<gtk::Widget>().unwrap())
|
||||||
} else {
|
} else {
|
||||||
let sink = ElementFactory::make("gtksink", None).unwrap();
|
let sink = gst::ElementFactory::make("gtksink", None).unwrap();
|
||||||
let widget = sink.get_property("widget").unwrap();
|
let widget = sink.get_property("widget").unwrap();
|
||||||
(sink, widget.get::<gtk::Widget>().unwrap())
|
(sink, widget.get::<gtk::Widget>().unwrap())
|
||||||
};
|
};
|
||||||
|
@ -49,7 +48,7 @@ fn create_ui(app: >k::Application) {
|
||||||
let pipeline_clone = pipeline.clone();
|
let pipeline_clone = pipeline.clone();
|
||||||
gtk::timeout_add(500, move || {
|
gtk::timeout_add(500, move || {
|
||||||
let pipeline = &pipeline_clone;
|
let pipeline = &pipeline_clone;
|
||||||
let position = pipeline.query_position(Format::Time);
|
let position = pipeline.query_position(gst::Format::Time);
|
||||||
|
|
||||||
if let Some(position) = position {
|
if let Some(position) = position {
|
||||||
let mut seconds = position / 1_000_000_000;
|
let mut seconds = position / 1_000_000_000;
|
||||||
|
@ -86,6 +85,8 @@ fn create_ui(app: >k::Application) {
|
||||||
|
|
||||||
let app_clone = SendCell::new(app.clone());
|
let app_clone = SendCell::new(app.clone());
|
||||||
bus.add_watch(move |_, msg| {
|
bus.add_watch(move |_, msg| {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let app = app_clone.borrow();
|
let app = app_clone.borrow();
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Eos(..) => gtk::main_quit(),
|
MessageView::Eos(..) => gtk::main_quit(),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
use std::u64;
|
use std::u64;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
@ -10,12 +10,12 @@ fn main() {
|
||||||
|
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
|
|
||||||
let mut context = ParseContext::new();
|
let mut context = gst::ParseContext::new();
|
||||||
let pipeline =
|
let pipeline =
|
||||||
match gst::parse_launch_full(&pipeline_str, Some(&mut context), PARSE_FLAG_NONE) {
|
match gst::parse_launch_full(&pipeline_str, Some(&mut context), gst::PARSE_FLAG_NONE) {
|
||||||
Ok(pipeline) => pipeline,
|
Ok(pipeline) => pipeline,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if let Some(ParseError::NoSuchElement) = err.kind::<ParseError>() {
|
if let Some(gst::ParseError::NoSuchElement) = err.kind::<gst::ParseError>() {
|
||||||
println!("Missing element(s): {:?}", context.get_missing_elements());
|
println!("Missing element(s): {:?}", context.get_missing_elements());
|
||||||
} else {
|
} else {
|
||||||
println!("Failed to parse pipeline: {}", err);
|
println!("Failed to parse pipeline: {}", err);
|
||||||
|
@ -30,6 +30,8 @@ fn main() {
|
||||||
assert_ne!(ret, gst::StateChangeReturn::Failure);
|
assert_ne!(ret, gst::StateChangeReturn::Failure);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let msg = match bus.timed_pop(u64::MAX) {
|
let msg = match bus.timed_pop(u64::MAX) {
|
||||||
None => break,
|
None => break,
|
||||||
Some(msg) => msg,
|
Some(msg) => msg,
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
use glib::*;
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
@ -11,7 +10,7 @@ fn main() {
|
||||||
|
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
|
|
||||||
let main_loop = MainLoop::new(None, false);
|
let main_loop = glib::MainLoop::new(None, false);
|
||||||
|
|
||||||
let pipeline = gst::parse_launch(&pipeline_str).unwrap();
|
let pipeline = gst::parse_launch(&pipeline_str).unwrap();
|
||||||
let bus = pipeline.get_bus().unwrap();
|
let bus = pipeline.get_bus().unwrap();
|
||||||
|
@ -24,6 +23,8 @@ fn main() {
|
||||||
//bus.add_signal_watch();
|
//bus.add_signal_watch();
|
||||||
//bus.connect_message(move |_, msg| {
|
//bus.connect_message(move |_, msg| {
|
||||||
bus.add_watch(move |_, msg| {
|
bus.add_watch(move |_, msg| {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let main_loop = &main_loop_clone;
|
let main_loop = &main_loop_clone;
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Eos(..) => main_loop.quit(),
|
MessageView::Eos(..) => main_loop.quit(),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
extern crate gstreamer_audio as gst_audio;
|
extern crate gstreamer_audio as gst_audio;
|
||||||
|
|
||||||
extern crate byte_slice_cast;
|
extern crate byte_slice_cast;
|
||||||
|
@ -19,19 +19,19 @@ fn main() {
|
||||||
|
|
||||||
let src = pipeline
|
let src = pipeline
|
||||||
.clone()
|
.clone()
|
||||||
.dynamic_cast::<Bin>()
|
.dynamic_cast::<gst::Bin>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get_by_name("src")
|
.get_by_name("src")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let src_pad = src.get_static_pad("src").unwrap();
|
let src_pad = src.get_static_pad("src").unwrap();
|
||||||
src_pad.add_probe(PAD_PROBE_TYPE_BUFFER, |_, probe_info| {
|
src_pad.add_probe(gst::PAD_PROBE_TYPE_BUFFER, |_, probe_info| {
|
||||||
if let Some(PadProbeData::Buffer(ref buffer)) = probe_info.data {
|
if let Some(gst::PadProbeData::Buffer(ref buffer)) = probe_info.data {
|
||||||
let map = buffer.map_readable().unwrap();
|
let map = buffer.map_readable().unwrap();
|
||||||
|
|
||||||
let samples = if let Ok(samples) = map.as_slice().as_slice_of::<i16>() {
|
let samples = if let Ok(samples) = map.as_slice().as_slice_of::<i16>() {
|
||||||
samples
|
samples
|
||||||
} else {
|
} else {
|
||||||
return PadProbeReturn::Ok;
|
return gst::PadProbeReturn::Ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
let sum: f64 = samples
|
let sum: f64 = samples
|
||||||
|
@ -45,13 +45,15 @@ fn main() {
|
||||||
println!("rms: {}", rms);
|
println!("rms: {}", rms);
|
||||||
}
|
}
|
||||||
|
|
||||||
PadProbeReturn::Ok
|
gst::PadProbeReturn::Ok
|
||||||
});
|
});
|
||||||
|
|
||||||
let ret = pipeline.set_state(gst::State::Playing);
|
let ret = pipeline.set_state(gst::State::Playing);
|
||||||
assert_ne!(ret, gst::StateChangeReturn::Failure);
|
assert_ne!(ret, gst::StateChangeReturn::Failure);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let msg = match bus.timed_pop(u64::MAX) {
|
let msg = match bus.timed_pop(u64::MAX) {
|
||||||
None => break,
|
None => break,
|
||||||
Some(msg) => msg,
|
Some(msg) => msg,
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
use glib::*;
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::u64;
|
use std::u64;
|
||||||
|
@ -18,7 +17,9 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let playbin = gst::ElementFactory::make("playbin", None).unwrap();
|
let playbin = gst::ElementFactory::make("playbin", None).unwrap();
|
||||||
playbin.set_property("uri", &Value::from(uri)).unwrap();
|
playbin
|
||||||
|
.set_property("uri", &glib::Value::from(uri))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// For flags handling
|
// For flags handling
|
||||||
// let flags = playbin.get_property("flags").unwrap();
|
// let flags = playbin.get_property("flags").unwrap();
|
||||||
|
@ -41,17 +42,17 @@ fn main() {
|
||||||
.emit("get-audio-tags", &[&idx.to_value()])
|
.emit("get-audio-tags", &[&idx.to_value()])
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let tags = tags.get::<TagList>().unwrap();
|
let tags = tags.get::<gst::TagList>().unwrap();
|
||||||
|
|
||||||
if let Some(artist) = tags.get::<tags::Artist>() {
|
if let Some(artist) = tags.get::<gst::tags::Artist>() {
|
||||||
println!(" Artist: {}", artist.get().unwrap());
|
println!(" Artist: {}", artist.get().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(title) = tags.get::<tags::Title>() {
|
if let Some(title) = tags.get::<gst::tags::Title>() {
|
||||||
println!(" Title: {}", title.get().unwrap());
|
println!(" Title: {}", title.get().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(album) = tags.get::<tags::Album>() {
|
if let Some(album) = tags.get::<gst::tags::Album>() {
|
||||||
println!(" Album: {}", album.get().unwrap());
|
println!(" Album: {}", album.get().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +66,8 @@ fn main() {
|
||||||
assert_ne!(ret, gst::StateChangeReturn::Failure);
|
assert_ne!(ret, gst::StateChangeReturn::Failure);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let msg = match bus.timed_pop(u64::MAX) {
|
let msg = match bus.timed_pop(u64::MAX) {
|
||||||
None => break,
|
None => break,
|
||||||
Some(msg) => msg,
|
Some(msg) => msg,
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
|
#[cfg(feature = "gst-player")]
|
||||||
|
use gst::prelude::*;
|
||||||
|
|
||||||
#[cfg(feature = "gst-player")]
|
#[cfg(feature = "gst-player")]
|
||||||
extern crate gstreamer_player as gst_player;
|
extern crate gstreamer_player as gst_player;
|
||||||
|
#[cfg(feature = "gst-player")]
|
||||||
|
use gst_player::prelude::*;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
#[cfg(feature = "gst-player")]
|
|
||||||
use glib::ObjectExt;
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature = "gst-player")]
|
#[cfg(feature = "gst-player")]
|
||||||
fn main_loop(uri: &str) -> Result<(), utils::ExampleError> {
|
fn main_loop(uri: &str) -> Result<(), utils::ExampleError> {
|
||||||
gst::init().map_err(utils::ExampleError::InitFailed)?;
|
gst::init().map_err(utils::ExampleError::InitFailed)?;
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
use glib::*;
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
@ -11,7 +10,7 @@ fn main() {
|
||||||
|
|
||||||
gst::init().unwrap();
|
gst::init().unwrap();
|
||||||
|
|
||||||
let main_loop = MainLoop::new(None, false);
|
let main_loop = glib::MainLoop::new(None, false);
|
||||||
|
|
||||||
let pipeline = gst::parse_launch(&pipeline_str).unwrap();
|
let pipeline = gst::parse_launch(&pipeline_str).unwrap();
|
||||||
let bus = pipeline.get_bus().unwrap();
|
let bus = pipeline.get_bus().unwrap();
|
||||||
|
@ -23,12 +22,14 @@ fn main() {
|
||||||
|
|
||||||
let pipeline_clone = pipeline.clone();
|
let pipeline_clone = pipeline.clone();
|
||||||
glib::timeout_add_seconds(1, move || {
|
glib::timeout_add_seconds(1, move || {
|
||||||
|
use gst::QueryView;
|
||||||
|
|
||||||
let pipeline = &pipeline_clone;
|
let pipeline = &pipeline_clone;
|
||||||
|
|
||||||
//let pos = pipeline.query_position(Format::Time).unwrap_or(-1);
|
//let pos = pipeline.query_position(gst::Format::Time).unwrap_or(-1);
|
||||||
//let dur = pipeline.query_duration(Format::Time).unwrap_or(-1);
|
//let dur = pipeline.query_duration(gst::Format::Time).unwrap_or(-1);
|
||||||
let pos = {
|
let pos = {
|
||||||
let mut q = Query::new_position(Format::Time);
|
let mut q = gst::Query::new_position(gst::Format::Time);
|
||||||
pipeline.query(q.get_mut().unwrap());
|
pipeline.query(q.get_mut().unwrap());
|
||||||
match q.view() {
|
match q.view() {
|
||||||
QueryView::Position(ref p) => p.get().1,
|
QueryView::Position(ref p) => p.get().1,
|
||||||
|
@ -37,7 +38,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let dur = {
|
let dur = {
|
||||||
let mut q = Query::new_duration(Format::Time);
|
let mut q = gst::Query::new_duration(gst::Format::Time);
|
||||||
pipeline.query(q.get_mut().unwrap());
|
pipeline.query(q.get_mut().unwrap());
|
||||||
match q.view() {
|
match q.view() {
|
||||||
QueryView::Duration(ref p) => p.get().1,
|
QueryView::Duration(ref p) => p.get().1,
|
||||||
|
@ -53,6 +54,8 @@ fn main() {
|
||||||
//bus.add_signal_watch();
|
//bus.add_signal_watch();
|
||||||
//bus.connect_message(move |_, msg| {
|
//bus.connect_message(move |_, msg| {
|
||||||
bus.add_watch(move |_, msg| {
|
bus.add_watch(move |_, msg| {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let main_loop = &main_loop_clone;
|
let main_loop = &main_loop_clone;
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Eos(..) => main_loop.quit(),
|
MessageView::Eos(..) => main_loop.quit(),
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
use glib::*;
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::u64;
|
use std::u64;
|
||||||
|
@ -21,7 +20,8 @@ fn main() {
|
||||||
let src = gst::ElementFactory::make("filesrc", None).unwrap();
|
let src = gst::ElementFactory::make("filesrc", None).unwrap();
|
||||||
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();
|
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();
|
||||||
|
|
||||||
src.set_property("location", &Value::from(uri)).unwrap();
|
src.set_property("location", &glib::Value::from(uri))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
pipeline.add_many(&[&src, &decodebin]).unwrap();
|
pipeline.add_many(&[&src, &decodebin]).unwrap();
|
||||||
gst::Element::link_many(&[&src, &decodebin]).unwrap();
|
gst::Element::link_many(&[&src, &decodebin]).unwrap();
|
||||||
|
@ -53,6 +53,8 @@ fn main() {
|
||||||
let bus = pipeline.get_bus().unwrap();
|
let bus = pipeline.get_bus().unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
let msg = match bus.timed_pop(u64::MAX) {
|
let msg = match bus.timed_pop(u64::MAX) {
|
||||||
None => break,
|
None => break,
|
||||||
Some(msg) => msg,
|
Some(msg) => msg,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
#[cfg(feature = "tokio")]
|
#[cfg(feature = "tokio")]
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
#[cfg(feature = "tokio")]
|
#[cfg(feature = "tokio")]
|
||||||
extern crate futures;
|
extern crate futures;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
|
@ -41,3 +41,12 @@ mod app_src;
|
||||||
mod app_sink;
|
mod app_sink;
|
||||||
pub use app_src::AppSrcCallbacks;
|
pub use app_src::AppSrcCallbacks;
|
||||||
pub use app_sink::AppSinkCallbacks;
|
pub use app_sink::AppSinkCallbacks;
|
||||||
|
|
||||||
|
// Re-export all the traits in a prelude module, so that applications
|
||||||
|
// can always "use gst::prelude::*" without getting conflicts
|
||||||
|
pub mod prelude {
|
||||||
|
pub use glib::prelude::*;
|
||||||
|
pub use gst::prelude::*;
|
||||||
|
|
||||||
|
pub use auto::traits::*;
|
||||||
|
}
|
||||||
|
|
|
@ -65,3 +65,12 @@ pub fn audio_buffer_clip(
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-export all the traits in a prelude module, so that applications
|
||||||
|
// can always "use gst::prelude::*" without getting conflicts
|
||||||
|
pub mod prelude {
|
||||||
|
pub use glib::prelude::*;
|
||||||
|
pub use gst::prelude::*;
|
||||||
|
|
||||||
|
pub use auto::traits::*;
|
||||||
|
}
|
||||||
|
|
|
@ -46,3 +46,13 @@ mod player;
|
||||||
|
|
||||||
mod player_video_overlay_video_renderer;
|
mod player_video_overlay_video_renderer;
|
||||||
pub use player_video_overlay_video_renderer::PlayerVideoOverlayVideoRendererExtManual;
|
pub use player_video_overlay_video_renderer::PlayerVideoOverlayVideoRendererExtManual;
|
||||||
|
|
||||||
|
// Re-export all the traits in a prelude module, so that applications
|
||||||
|
// can always "use gst::prelude::*" without getting conflicts
|
||||||
|
pub mod prelude {
|
||||||
|
pub use glib::prelude::*;
|
||||||
|
pub use gst::prelude::*;
|
||||||
|
|
||||||
|
pub use auto::traits::*;
|
||||||
|
pub use player_video_overlay_video_renderer::PlayerVideoOverlayVideoRendererExtManual;
|
||||||
|
}
|
||||||
|
|
|
@ -42,3 +42,13 @@ mod video_frame;
|
||||||
pub use video_frame::VideoFrame;
|
pub use video_frame::VideoFrame;
|
||||||
mod video_overlay;
|
mod video_overlay;
|
||||||
pub use video_overlay::VideoOverlayExtManual;
|
pub use video_overlay::VideoOverlayExtManual;
|
||||||
|
|
||||||
|
// Re-export all the traits in a prelude module, so that applications
|
||||||
|
// can always "use gst::prelude::*" without getting conflicts
|
||||||
|
pub mod prelude {
|
||||||
|
pub use glib::prelude::*;
|
||||||
|
pub use gst::prelude::*;
|
||||||
|
|
||||||
|
pub use auto::traits::*;
|
||||||
|
pub use video_overlay::VideoOverlayExtManual;
|
||||||
|
}
|
||||||
|
|
|
@ -143,3 +143,24 @@ pub fn init() -> Result<(), glib::Error> {
|
||||||
|
|
||||||
pub const BUFFER_OFFSET_NONE: u64 = ffi::GST_BUFFER_OFFSET_NONE;
|
pub const BUFFER_OFFSET_NONE: u64 = ffi::GST_BUFFER_OFFSET_NONE;
|
||||||
pub const CLOCK_TIME_NONE: u64 = ffi::GST_CLOCK_TIME_NONE;
|
pub const CLOCK_TIME_NONE: u64 = ffi::GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
|
// Re-export all the traits in a prelude module, so that applications
|
||||||
|
// can always "use gst::prelude::*" without getting conflicts
|
||||||
|
pub mod prelude {
|
||||||
|
pub use glib::prelude::*;
|
||||||
|
|
||||||
|
pub use auto::traits::*;
|
||||||
|
|
||||||
|
pub use element::ElementExtManual;
|
||||||
|
pub use bin::BinExtManual;
|
||||||
|
pub use pad::PadExtManual;
|
||||||
|
pub use gobject::GObjectExtManualGst;
|
||||||
|
pub use child_proxy::ChildProxyExtManual;
|
||||||
|
pub use tag_setter::TagSetterExtManual;
|
||||||
|
pub use device_provider::DeviceProviderExtManual;
|
||||||
|
pub use clock::ClockExtManual;
|
||||||
|
pub use value::GstValueExt;
|
||||||
|
|
||||||
|
pub use tags::Tag;
|
||||||
|
pub use miniobject::MiniObject;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue