Commit 40426a2c authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Use new boxed type support from the GLib bindings

parent ab59e888
......@@ -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())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment