forked from mirrors/gstreamer-rs
examples: Update for new GLib boxed deriving API
This commit is contained in:
parent
8bb64bb825
commit
d0bfdda97f
3 changed files with 12 additions and 22 deletions
|
@ -35,6 +35,8 @@ use gst::prelude::*;
|
||||||
|
|
||||||
#[cfg_attr(feature = "v1_10", macro_use)]
|
#[cfg_attr(feature = "v1_10", macro_use)]
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
|
#[cfg(feature = "v1_10")]
|
||||||
|
use glib::subclass::prelude::*;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::error::Error as StdError;
|
use std::error::Error as StdError;
|
||||||
|
@ -68,19 +70,10 @@ struct ErrorMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "v1_10")]
|
#[cfg(feature = "v1_10")]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, GBoxed)]
|
||||||
|
#[gboxed(type_name = "ErrorValue")]
|
||||||
struct ErrorValue(Arc<Mutex<Option<Error>>>);
|
struct ErrorValue(Arc<Mutex<Option<Error>>>);
|
||||||
|
|
||||||
#[cfg(feature = "v1_10")]
|
|
||||||
impl glib::subclass::boxed::BoxedType for ErrorValue {
|
|
||||||
const NAME: &'static str = "ErrorValue";
|
|
||||||
|
|
||||||
glib_boxed_type!();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "v1_10")]
|
|
||||||
glib_boxed_derive_traits!(ErrorValue);
|
|
||||||
|
|
||||||
fn example_main() -> Result<(), Error> {
|
fn example_main() -> Result<(), Error> {
|
||||||
gst::init()?;
|
gst::init()?;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ use gst_pbutils::prelude::*;
|
||||||
|
|
||||||
#[cfg_attr(feature = "v1_10", macro_use)]
|
#[cfg_attr(feature = "v1_10", macro_use)]
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
|
#[cfg(feature = "v1_10")]
|
||||||
|
use glib::subclass::prelude::*;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::error::Error as StdError;
|
use std::error::Error as StdError;
|
||||||
|
@ -54,19 +56,10 @@ struct ErrorMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "v1_10")]
|
#[cfg(feature = "v1_10")]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, GBoxed)]
|
||||||
|
#[gboxed(type_name = "ErrorValue")]
|
||||||
struct ErrorValue(Arc<Mutex<Option<Error>>>);
|
struct ErrorValue(Arc<Mutex<Option<Error>>>);
|
||||||
|
|
||||||
#[cfg(feature = "v1_10")]
|
|
||||||
impl glib::subclass::boxed::BoxedType for ErrorValue {
|
|
||||||
const NAME: &'static str = "ErrorValue";
|
|
||||||
|
|
||||||
glib_boxed_type!();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "v1_10")]
|
|
||||||
glib_boxed_derive_traits!(ErrorValue);
|
|
||||||
|
|
||||||
fn configure_encodebin(encodebin: &gst::Element) -> Result<(), Error> {
|
fn configure_encodebin(encodebin: &gst::Element) -> Result<(), Error> {
|
||||||
// To tell the encodebin what we want it to produce, we create an EncodingProfile
|
// To tell the encodebin what we want it to produce, we create an EncodingProfile
|
||||||
// https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/GstEncodingProfile.html
|
// https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/GstEncodingProfile.html
|
||||||
|
|
|
@ -55,6 +55,8 @@ where
|
||||||
let mut value = Value::uninitialized();
|
let mut value = Value::uninitialized();
|
||||||
let res =
|
let res =
|
||||||
gst_sys::gst_iterator_next(self.to_glib_none_mut().0, value.to_glib_none_mut().0);
|
gst_sys::gst_iterator_next(self.to_glib_none_mut().0, value.to_glib_none_mut().0);
|
||||||
|
|
||||||
|
#[allow(clippy::wildcard_in_or_patterns)]
|
||||||
match res {
|
match res {
|
||||||
gst_sys::GST_ITERATOR_OK => match value.get::<T>().expect("Iterator::next") {
|
gst_sys::GST_ITERATOR_OK => match value.get::<T>().expect("Iterator::next") {
|
||||||
Some(value) => Ok(Some(value)),
|
Some(value) => Ok(Some(value)),
|
||||||
|
@ -131,6 +133,7 @@ where
|
||||||
func_ptr,
|
func_ptr,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[allow(clippy::wildcard_in_or_patterns)]
|
||||||
match res {
|
match res {
|
||||||
gst_sys::GST_ITERATOR_OK | gst_sys::GST_ITERATOR_DONE => Ok(()),
|
gst_sys::GST_ITERATOR_OK | gst_sys::GST_ITERATOR_DONE => Ok(()),
|
||||||
gst_sys::GST_ITERATOR_RESYNC => Err(IteratorError::Resync),
|
gst_sys::GST_ITERATOR_RESYNC => Err(IteratorError::Resync),
|
||||||
|
@ -161,6 +164,7 @@ where
|
||||||
func_ptr,
|
func_ptr,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[allow(clippy::wildcard_in_or_patterns)]
|
||||||
match res {
|
match res {
|
||||||
gst_sys::GST_ITERATOR_OK | gst_sys::GST_ITERATOR_DONE => Ok(accum.unwrap()),
|
gst_sys::GST_ITERATOR_OK | gst_sys::GST_ITERATOR_DONE => Ok(accum.unwrap()),
|
||||||
gst_sys::GST_ITERATOR_RESYNC => Err(IteratorError::Resync),
|
gst_sys::GST_ITERATOR_RESYNC => Err(IteratorError::Resync),
|
||||||
|
|
Loading…
Reference in a new issue