mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-27 05:51:01 +00:00
Use new boxed type support from the GLib bindings
This commit is contained in:
parent
ab59e88809
commit
40426a2cf6
8 changed files with 33 additions and 38 deletions
|
@ -9,7 +9,7 @@ glib-sys = { git = "https://github.com/gtk-rs/sys" }
|
|||
gobject-sys = { git = "https://github.com/gtk-rs/sys" }
|
||||
gio-sys = { git = "https://github.com/gtk-rs/sys" }
|
||||
gstreamer-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys" }
|
||||
glib = { git = "https://github.com/gtk-rs/glib" }
|
||||
glib = { git = "https://github.com/gtk-rs/glib", features = ["subclassing"] }
|
||||
gio = { git = "https://github.com/gtk-rs/gio" }
|
||||
gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
gstreamer-check = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
|
||||
|
|
|
@ -222,11 +222,8 @@ impl AppSrc {
|
|||
let s = gst::Structure::new(
|
||||
"ts-io-context",
|
||||
&[
|
||||
("io-context", &glib::AnySendValue::new(io_context.clone())),
|
||||
(
|
||||
"pending-future-id",
|
||||
&glib::AnySendValue::new(*pending_future_id),
|
||||
),
|
||||
("io-context", &io_context),
|
||||
("pending-future-id", &*pending_future_id),
|
||||
],
|
||||
);
|
||||
Some(gst::Event::new_custom_downstream_sticky(s).build())
|
||||
|
|
|
@ -30,6 +30,7 @@ use tokio::reactor;
|
|||
use tokio_current_thread;
|
||||
use tokio_timer::timer;
|
||||
|
||||
use glib;
|
||||
use gst;
|
||||
|
||||
lazy_static! {
|
||||
|
@ -165,6 +166,14 @@ impl Drop for IOContextShutdown {
|
|||
#[derive(Clone)]
|
||||
pub struct IOContext(Arc<IOContextInner>);
|
||||
|
||||
impl glib::subclass::boxed::BoxedType for IOContext {
|
||||
const NAME: &'static str = "TsIOContext";
|
||||
|
||||
glib_boxed_type!();
|
||||
}
|
||||
|
||||
glib_boxed_derive_traits!(IOContext);
|
||||
|
||||
struct IOContextInner {
|
||||
name: String,
|
||||
runtime_handle: Mutex<tokio_current_thread::Handle>,
|
||||
|
@ -286,3 +295,11 @@ pub type PendingFuturesFuture<E> =
|
|||
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Debug)]
|
||||
pub struct PendingFutureId(u64);
|
||||
|
||||
impl glib::subclass::boxed::BoxedType for PendingFutureId {
|
||||
const NAME: &'static str = "TsPendingFutureId";
|
||||
|
||||
glib_boxed_type!();
|
||||
}
|
||||
|
||||
glib_boxed_derive_traits!(PendingFutureId);
|
||||
|
|
|
@ -23,6 +23,7 @@ extern crate gobject_sys as gobject_ffi;
|
|||
extern crate gstreamer_sys as gst_ffi;
|
||||
|
||||
extern crate gio;
|
||||
#[macro_use]
|
||||
extern crate glib;
|
||||
extern crate gobject_subclass;
|
||||
#[macro_use]
|
||||
|
|
|
@ -590,12 +590,8 @@ impl ProxySink {
|
|||
let s = e.get_structure().unwrap();
|
||||
if s.get_name() == "ts-io-context" {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
let io_context = s.get::<&glib::AnySendValue>("io-context").unwrap();
|
||||
let io_context = io_context.downcast_ref::<IOContext>().unwrap();
|
||||
let pending_future_id =
|
||||
s.get::<&glib::AnySendValue>("pending-future-id").unwrap();
|
||||
let pending_future_id =
|
||||
pending_future_id.downcast_ref::<PendingFutureId>().unwrap();
|
||||
let io_context = s.get::<&IOContext>("io-context").unwrap();
|
||||
let pending_future_id = s.get::<&PendingFutureId>("pending-future-id").unwrap();
|
||||
|
||||
gst_debug!(
|
||||
self.cat,
|
||||
|
@ -836,11 +832,8 @@ impl ProxySrc {
|
|||
let s = gst::Structure::new(
|
||||
"ts-io-context",
|
||||
&[
|
||||
("io-context", &glib::AnySendValue::new(io_context.clone())),
|
||||
(
|
||||
"pending-future-id",
|
||||
&glib::AnySendValue::new(*pending_future_id),
|
||||
),
|
||||
("io-context", &io_context),
|
||||
("pending-future-id", &*pending_future_id),
|
||||
],
|
||||
);
|
||||
Some(gst::Event::new_custom_downstream_sticky(s).build())
|
||||
|
|
|
@ -242,11 +242,8 @@ impl Queue {
|
|||
let s = gst::Structure::new(
|
||||
"ts-io-context",
|
||||
&[
|
||||
("io-context", &glib::AnySendValue::new(io_context.clone())),
|
||||
(
|
||||
"pending-future-id",
|
||||
&glib::AnySendValue::new(*pending_future_id),
|
||||
),
|
||||
("io-context", &io_context),
|
||||
("pending-future-id", &*pending_future_id),
|
||||
],
|
||||
);
|
||||
Some(gst::Event::new_custom_downstream_sticky(s).build())
|
||||
|
@ -472,12 +469,8 @@ impl Queue {
|
|||
let s = e.get_structure().unwrap();
|
||||
if s.get_name() == "ts-io-context" {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
let io_context = s.get::<&glib::AnySendValue>("io-context").unwrap();
|
||||
let io_context = io_context.downcast_ref::<IOContext>().unwrap();
|
||||
let pending_future_id =
|
||||
s.get::<&glib::AnySendValue>("pending-future-id").unwrap();
|
||||
let pending_future_id =
|
||||
pending_future_id.downcast_ref::<PendingFutureId>().unwrap();
|
||||
let io_context = s.get::<&IOContext>("io-context").unwrap();
|
||||
let pending_future_id = s.get::<&PendingFutureId>("pending-future-id").unwrap();
|
||||
|
||||
gst_debug!(
|
||||
self.cat,
|
||||
|
|
|
@ -319,11 +319,8 @@ impl TcpClientSrc {
|
|||
let s = gst::Structure::new(
|
||||
"ts-io-context",
|
||||
&[
|
||||
("io-context", &glib::AnySendValue::new(io_context.clone())),
|
||||
(
|
||||
"pending-future-id",
|
||||
&glib::AnySendValue::new(*pending_future_id),
|
||||
),
|
||||
("io-context", &io_context),
|
||||
("pending-future-id", &*pending_future_id),
|
||||
],
|
||||
);
|
||||
Some(gst::Event::new_custom_downstream_sticky(s).build())
|
||||
|
|
|
@ -400,11 +400,8 @@ impl UdpSrc {
|
|||
let s = gst::Structure::new(
|
||||
"ts-io-context",
|
||||
&[
|
||||
("io-context", &glib::AnySendValue::new(io_context.clone())),
|
||||
(
|
||||
"pending-future-id",
|
||||
&glib::AnySendValue::new(*pending_future_id),
|
||||
),
|
||||
("io-context", &io_context),
|
||||
("pending-future-id", &*pending_future_id),
|
||||
],
|
||||
);
|
||||
Some(gst::Event::new_custom_downstream_sticky(s).build())
|
||||
|
|
Loading…
Reference in a new issue