2017-07-24 08:51:14 +00:00
|
|
|
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
use Pad;
|
|
|
|
use PadProbeType;
|
|
|
|
use PadProbeReturn;
|
2017-07-25 12:08:42 +00:00
|
|
|
use Buffer;
|
2017-07-28 18:18:08 +00:00
|
|
|
use BufferList;
|
2017-11-11 10:21:55 +00:00
|
|
|
use Format;
|
2017-12-09 16:20:21 +00:00
|
|
|
use GenericFormattedValue;
|
|
|
|
use FormattedValue;
|
|
|
|
use SpecificFormattedValue;
|
2017-07-25 12:21:03 +00:00
|
|
|
use FlowReturn;
|
2017-07-29 15:09:14 +00:00
|
|
|
use Query;
|
2017-07-29 13:04:34 +00:00
|
|
|
use QueryRef;
|
2017-07-30 14:11:47 +00:00
|
|
|
use Event;
|
2017-10-15 08:08:56 +00:00
|
|
|
use StaticPadTemplate;
|
2017-07-28 18:18:08 +00:00
|
|
|
use miniobject::MiniObject;
|
2017-07-24 08:51:14 +00:00
|
|
|
|
|
|
|
use std::mem::transmute;
|
2017-07-25 12:21:03 +00:00
|
|
|
use std::ptr;
|
2017-09-16 22:45:21 +00:00
|
|
|
use std::mem;
|
2017-09-17 21:32:29 +00:00
|
|
|
use std::cell::RefCell;
|
2017-07-24 08:51:14 +00:00
|
|
|
|
2017-09-17 22:53:02 +00:00
|
|
|
use glib;
|
2017-07-25 12:08:42 +00:00
|
|
|
use glib::{IsA, StaticType};
|
2017-10-17 09:06:51 +00:00
|
|
|
use glib::translate::{from_glib, from_glib_borrow, from_glib_full, from_glib_none, mut_override,
|
2017-10-15 08:08:56 +00:00
|
|
|
FromGlib, ToGlib, ToGlibPtr};
|
2017-07-24 08:51:14 +00:00
|
|
|
use glib::source::CallbackGuard;
|
2017-08-03 08:09:39 +00:00
|
|
|
use glib_ffi;
|
2017-07-24 08:51:14 +00:00
|
|
|
use glib_ffi::gpointer;
|
2017-07-29 13:04:34 +00:00
|
|
|
use glib::Object;
|
2017-07-24 08:51:14 +00:00
|
|
|
|
|
|
|
use libc;
|
|
|
|
|
|
|
|
use ffi;
|
|
|
|
|
2017-10-15 08:08:56 +00:00
|
|
|
impl Pad {
|
2017-11-21 14:14:39 +00:00
|
|
|
pub fn new_from_static_template<'a, P: Into<Option<&'a str>>>(
|
|
|
|
templ: &StaticPadTemplate,
|
|
|
|
name: P,
|
|
|
|
) -> Pad {
|
2017-10-15 08:08:56 +00:00
|
|
|
assert_initialized_main_thread!();
|
2017-11-21 14:14:39 +00:00
|
|
|
let name = name.into();
|
2017-10-15 08:08:56 +00:00
|
|
|
unsafe {
|
2017-10-17 09:06:51 +00:00
|
|
|
from_glib_none(ffi::gst_pad_new_from_static_template(
|
|
|
|
mut_override(templ.to_glib_none().0),
|
|
|
|
name.to_glib_none().0,
|
|
|
|
))
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-08 21:45:45 +00:00
|
|
|
#[derive(Debug, Default, PartialEq, Eq)]
|
2017-07-24 08:51:14 +00:00
|
|
|
pub struct PadProbeId(libc::c_ulong);
|
2017-07-24 22:17:50 +00:00
|
|
|
pub const PAD_PROBE_ID_INVALID: PadProbeId = PadProbeId(0);
|
|
|
|
|
|
|
|
impl ToGlib for PadProbeId {
|
|
|
|
type GlibType = libc::c_ulong;
|
|
|
|
|
|
|
|
fn to_glib(&self) -> libc::c_ulong {
|
|
|
|
self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FromGlib<libc::c_ulong> for PadProbeId {
|
|
|
|
fn from_glib(val: libc::c_ulong) -> PadProbeId {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-24 22:17:50 +00:00
|
|
|
PadProbeId(val)
|
|
|
|
}
|
|
|
|
}
|
2017-07-24 08:51:14 +00:00
|
|
|
|
2017-07-29 15:09:14 +00:00
|
|
|
pub struct PadProbeInfo<'a> {
|
2017-07-24 08:51:14 +00:00
|
|
|
pub mask: PadProbeType,
|
|
|
|
pub id: PadProbeId,
|
|
|
|
pub offset: u64,
|
|
|
|
pub size: u32,
|
2017-07-29 15:09:14 +00:00
|
|
|
pub data: Option<PadProbeData<'a>>,
|
2017-07-24 08:51:14 +00:00
|
|
|
}
|
|
|
|
|
2017-07-29 15:09:14 +00:00
|
|
|
pub enum PadProbeData<'a> {
|
2017-07-25 12:08:42 +00:00
|
|
|
Buffer(Buffer),
|
2017-07-28 18:18:08 +00:00
|
|
|
BufferList(BufferList),
|
2017-07-29 15:09:14 +00:00
|
|
|
Query(&'a mut QueryRef),
|
2017-07-30 14:11:47 +00:00
|
|
|
Event(Event),
|
2017-07-24 08:51:14 +00:00
|
|
|
Unknown,
|
|
|
|
}
|
|
|
|
|
2017-08-03 08:09:39 +00:00
|
|
|
pub struct StreamLock(Pad);
|
|
|
|
impl Drop for StreamLock {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
unsafe {
|
|
|
|
let pad: *mut ffi::GstPad = self.0.to_glib_none().0;
|
|
|
|
glib_ffi::g_rec_mutex_unlock(&mut (*pad).stream_rec_lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-24 08:51:14 +00:00
|
|
|
pub trait PadExtManual {
|
|
|
|
fn add_probe<F>(&self, mask: PadProbeType, func: F) -> PadProbeId
|
|
|
|
where
|
2017-08-01 14:28:36 +00:00
|
|
|
F: Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static;
|
2017-07-24 08:51:14 +00:00
|
|
|
fn remove_probe(&self, id: PadProbeId);
|
2017-07-25 12:21:03 +00:00
|
|
|
|
|
|
|
fn chain(&self, buffer: Buffer) -> FlowReturn;
|
|
|
|
fn push(&self, buffer: Buffer) -> FlowReturn;
|
|
|
|
|
2017-08-14 19:21:11 +00:00
|
|
|
fn chain_list(&self, list: BufferList) -> FlowReturn;
|
|
|
|
fn push_list(&self, list: BufferList) -> FlowReturn;
|
|
|
|
|
2017-07-25 12:21:03 +00:00
|
|
|
fn pull_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowReturn>;
|
|
|
|
fn get_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowReturn>;
|
2017-07-29 13:04:34 +00:00
|
|
|
|
|
|
|
fn peer_query(&self, query: &mut QueryRef) -> bool;
|
|
|
|
fn query(&self, query: &mut QueryRef) -> bool;
|
2017-07-31 11:16:42 +00:00
|
|
|
fn query_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(
|
|
|
|
&self,
|
|
|
|
parent: Q,
|
|
|
|
query: &mut QueryRef,
|
|
|
|
) -> bool;
|
2017-07-29 13:04:34 +00:00
|
|
|
fn proxy_query_caps(&self, query: &mut QueryRef) -> bool;
|
|
|
|
fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool;
|
2017-08-01 12:58:50 +00:00
|
|
|
|
2017-08-01 14:28:36 +00:00
|
|
|
fn event_default<'a, P: IsA<::Object> + 'a, Q: Into<Option<&'a P>>>(
|
|
|
|
&self,
|
|
|
|
parent: Q,
|
|
|
|
event: Event,
|
|
|
|
) -> bool;
|
2017-08-01 12:58:50 +00:00
|
|
|
fn push_event(&self, event: Event) -> bool;
|
|
|
|
fn send_event(&self, event: Event) -> bool;
|
2017-08-03 08:09:39 +00:00
|
|
|
|
2017-09-17 21:24:36 +00:00
|
|
|
fn iterate_internal_links(&self) -> ::Iterator<Pad>;
|
|
|
|
fn iterate_internal_links_default<'a, P: IsA<::Object> + 'a, Q: Into<Option<&'a P>>>(
|
|
|
|
&self,
|
|
|
|
parent: Q,
|
|
|
|
) -> ::Iterator<Pad>;
|
|
|
|
|
2017-08-03 08:09:39 +00:00
|
|
|
fn stream_lock(&self) -> StreamLock;
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_activate_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>) -> bool + Send + Sync + 'static;
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_activatemode_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, ::PadMode, bool) -> bool + Send + Sync + 'static;
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_chain_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, ::Buffer) -> ::FlowReturn + Send + Sync + 'static;
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_chain_list_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, ::BufferList) -> ::FlowReturn + Send + Sync + 'static;
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_event_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, ::Event) -> bool + Send + Sync + 'static;
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_event_full_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, ::Event) -> ::FlowReturn + Send + Sync + 'static;
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_getrange_function<F>(&self, func: F)
|
|
|
|
where
|
2017-12-01 17:02:53 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, u64, u32) -> Result<::Buffer, ::FlowReturn>
|
2017-09-16 22:45:21 +00:00
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static;
|
|
|
|
|
|
|
|
fn set_iterate_internal_links_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>) -> ::Iterator<Pad> + Send + Sync + 'static;
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_link_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, &Pad) -> ::PadLinkReturn + Send + Sync + 'static;
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_query_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, &mut ::QueryRef) -> bool + Send + Sync + 'static;
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_unlink_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>) + Send + Sync + 'static;
|
2017-09-17 21:32:29 +00:00
|
|
|
|
2017-09-17 22:53:02 +00:00
|
|
|
fn start_task<F: FnMut() + Send + 'static>(&self, func: F) -> Result<(), glib::BoolError>;
|
2017-11-11 10:21:55 +00:00
|
|
|
|
2017-12-09 16:20:21 +00:00
|
|
|
fn peer_query_convert<V: Into<GenericFormattedValue>, U: SpecificFormattedValue>(
|
|
|
|
&self,
|
|
|
|
src_val: V,
|
|
|
|
) -> Option<U>;
|
|
|
|
fn peer_query_convert_generic<V: Into<GenericFormattedValue>>(
|
2017-11-11 10:21:55 +00:00
|
|
|
&self,
|
|
|
|
src_val: V,
|
|
|
|
dest_format: Format,
|
2017-12-09 16:20:21 +00:00
|
|
|
) -> Option<GenericFormattedValue>;
|
|
|
|
|
|
|
|
fn peer_query_duration<T: SpecificFormattedValue>(&self) -> Option<T>;
|
|
|
|
fn peer_query_duration_generic(&self, format: Format) -> Option<GenericFormattedValue>;
|
|
|
|
|
|
|
|
fn peer_query_position<T: SpecificFormattedValue>(&self) -> Option<T>;
|
|
|
|
fn peer_query_position_generic(&self, format: Format) -> Option<GenericFormattedValue>;
|
|
|
|
|
|
|
|
fn query_convert<V: Into<GenericFormattedValue>, U: SpecificFormattedValue>(
|
|
|
|
&self,
|
|
|
|
src_val: V,
|
|
|
|
) -> Option<U>;
|
|
|
|
fn query_convert_generic<V: Into<GenericFormattedValue>>(
|
2017-11-11 10:21:55 +00:00
|
|
|
&self,
|
|
|
|
src_val: V,
|
|
|
|
dest_format: Format,
|
2017-12-09 16:20:21 +00:00
|
|
|
) -> Option<GenericFormattedValue>;
|
|
|
|
|
|
|
|
fn query_duration<T: SpecificFormattedValue>(&self) -> Option<T>;
|
|
|
|
fn query_duration_generic(&self, format: Format) -> Option<GenericFormattedValue>;
|
|
|
|
|
|
|
|
fn query_position<T: SpecificFormattedValue>(&self) -> Option<T>;
|
|
|
|
fn query_position_generic(&self, format: Format) -> Option<GenericFormattedValue>;
|
2017-07-24 08:51:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<O: IsA<Pad>> PadExtManual for O {
|
|
|
|
fn add_probe<F>(&self, mask: PadProbeType, func: F) -> PadProbeId
|
|
|
|
where
|
2017-08-01 14:28:36 +00:00
|
|
|
F: Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static,
|
2017-07-24 08:51:14 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
2017-09-16 22:45:21 +00:00
|
|
|
let func_box: Box<
|
|
|
|
Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static,
|
|
|
|
> = Box::new(func);
|
2017-07-24 08:51:14 +00:00
|
|
|
let id = ffi::gst_pad_add_probe(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
mask.to_glib(),
|
|
|
|
Some(trampoline_pad_probe),
|
2017-09-16 22:45:21 +00:00
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
2017-07-24 08:51:14 +00:00
|
|
|
);
|
|
|
|
|
2017-07-24 22:17:50 +00:00
|
|
|
from_glib(id)
|
2017-07-24 08:51:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn remove_probe(&self, id: PadProbeId) {
|
|
|
|
unsafe {
|
2017-07-24 22:17:50 +00:00
|
|
|
ffi::gst_pad_remove_probe(self.to_glib_none().0, id.to_glib());
|
2017-07-24 08:51:14 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-25 12:21:03 +00:00
|
|
|
|
|
|
|
fn chain(&self, buffer: Buffer) -> FlowReturn {
|
|
|
|
unsafe { from_glib(ffi::gst_pad_chain(self.to_glib_none().0, buffer.into_ptr())) }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn push(&self, buffer: Buffer) -> FlowReturn {
|
|
|
|
unsafe { from_glib(ffi::gst_pad_push(self.to_glib_none().0, buffer.into_ptr())) }
|
|
|
|
}
|
|
|
|
|
2017-08-14 19:21:11 +00:00
|
|
|
fn chain_list(&self, list: BufferList) -> FlowReturn {
|
2017-09-10 11:55:29 +00:00
|
|
|
unsafe {
|
|
|
|
from_glib(ffi::gst_pad_chain_list(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
list.into_ptr(),
|
|
|
|
))
|
|
|
|
}
|
2017-08-14 19:21:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn push_list(&self, list: BufferList) -> FlowReturn {
|
2017-09-10 11:55:29 +00:00
|
|
|
unsafe {
|
|
|
|
from_glib(ffi::gst_pad_push_list(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
list.into_ptr(),
|
|
|
|
))
|
|
|
|
}
|
2017-08-14 19:21:11 +00:00
|
|
|
}
|
|
|
|
|
2017-07-25 12:21:03 +00:00
|
|
|
fn get_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowReturn> {
|
|
|
|
unsafe {
|
|
|
|
let mut buffer = ptr::null_mut();
|
|
|
|
let ret = from_glib(ffi::gst_pad_get_range(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
offset,
|
|
|
|
size,
|
|
|
|
&mut buffer,
|
|
|
|
));
|
|
|
|
if ret == FlowReturn::Ok {
|
|
|
|
Ok(from_glib_full(buffer))
|
|
|
|
} else {
|
|
|
|
Err(ret)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn pull_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowReturn> {
|
|
|
|
unsafe {
|
|
|
|
let mut buffer = ptr::null_mut();
|
|
|
|
let ret = from_glib(ffi::gst_pad_pull_range(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
offset,
|
|
|
|
size,
|
|
|
|
&mut buffer,
|
|
|
|
));
|
|
|
|
if ret == FlowReturn::Ok {
|
|
|
|
Ok(from_glib_full(buffer))
|
|
|
|
} else {
|
|
|
|
Err(ret)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-29 13:04:34 +00:00
|
|
|
|
|
|
|
fn query(&self, query: &mut QueryRef) -> bool {
|
|
|
|
unsafe {
|
2017-07-31 11:16:42 +00:00
|
|
|
from_glib(ffi::gst_pad_query(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
query.as_mut_ptr(),
|
|
|
|
))
|
2017-07-29 13:04:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn peer_query(&self, query: &mut QueryRef) -> bool {
|
|
|
|
unsafe {
|
2017-07-31 11:16:42 +00:00
|
|
|
from_glib(ffi::gst_pad_peer_query(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
query.as_mut_ptr(),
|
|
|
|
))
|
2017-07-29 13:04:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-31 11:16:42 +00:00
|
|
|
fn query_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(
|
|
|
|
&self,
|
|
|
|
parent: Q,
|
|
|
|
query: &mut QueryRef,
|
|
|
|
) -> bool {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-29 13:04:34 +00:00
|
|
|
let parent = parent.into();
|
|
|
|
let parent = parent.to_glib_none();
|
|
|
|
unsafe {
|
2017-07-31 11:16:42 +00:00
|
|
|
from_glib(ffi::gst_pad_query_default(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
parent.0 as *mut _,
|
|
|
|
query.as_mut_ptr(),
|
|
|
|
))
|
2017-07-29 13:04:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool {
|
|
|
|
unsafe {
|
2017-07-31 11:16:42 +00:00
|
|
|
from_glib(ffi::gst_pad_proxy_query_accept_caps(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
query.as_mut_ptr(),
|
|
|
|
))
|
2017-07-29 13:04:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn proxy_query_caps(&self, query: &mut QueryRef) -> bool {
|
|
|
|
unsafe {
|
2017-07-31 11:16:42 +00:00
|
|
|
from_glib(ffi::gst_pad_proxy_query_accept_caps(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
query.as_mut_ptr(),
|
|
|
|
))
|
2017-07-29 13:04:34 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-01 12:58:50 +00:00
|
|
|
|
2017-08-01 14:28:36 +00:00
|
|
|
fn event_default<'a, P: IsA<::Object> + 'a, Q: Into<Option<&'a P>>>(
|
|
|
|
&self,
|
|
|
|
parent: Q,
|
|
|
|
event: Event,
|
|
|
|
) -> bool {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-08-01 12:58:50 +00:00
|
|
|
let parent = parent.into();
|
|
|
|
let parent = parent.to_glib_none();
|
|
|
|
unsafe {
|
2017-08-01 14:28:36 +00:00
|
|
|
from_glib(ffi::gst_pad_event_default(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
parent.0,
|
|
|
|
event.into_ptr(),
|
|
|
|
))
|
2017-08-01 12:58:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn push_event(&self, event: Event) -> bool {
|
|
|
|
unsafe {
|
2017-08-01 14:28:36 +00:00
|
|
|
from_glib(ffi::gst_pad_push_event(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
event.into_ptr(),
|
|
|
|
))
|
2017-08-01 12:58:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn send_event(&self, event: Event) -> bool {
|
|
|
|
unsafe {
|
2017-08-01 14:28:36 +00:00
|
|
|
from_glib(ffi::gst_pad_send_event(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
event.into_ptr(),
|
|
|
|
))
|
2017-08-01 12:58:50 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-03 08:09:39 +00:00
|
|
|
|
2017-09-17 21:24:36 +00:00
|
|
|
fn iterate_internal_links(&self) -> ::Iterator<Pad> {
|
|
|
|
unsafe { from_glib_full(ffi::gst_pad_iterate_internal_links(self.to_glib_none().0)) }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn iterate_internal_links_default<'a, P: IsA<::Object> + 'a, Q: Into<Option<&'a P>>>(
|
|
|
|
&self,
|
|
|
|
parent: Q,
|
|
|
|
) -> ::Iterator<Pad> {
|
|
|
|
let parent = parent.into();
|
|
|
|
let parent = parent.to_glib_none();
|
|
|
|
unsafe {
|
|
|
|
from_glib_full(ffi::gst_pad_iterate_internal_links_default(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
parent.0,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 08:09:39 +00:00
|
|
|
fn stream_lock(&self) -> StreamLock {
|
|
|
|
unsafe {
|
|
|
|
let pad = self.to_glib_none().0;
|
|
|
|
glib_ffi::g_rec_mutex_lock(&mut (*pad).stream_rec_lock);
|
|
|
|
StreamLock(from_glib_none(pad))
|
|
|
|
}
|
|
|
|
}
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
fn set_activate_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>) -> bool + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
2017-09-17 22:45:39 +00:00
|
|
|
let func_box: Box<
|
|
|
|
Fn(&Pad, &Option<::Object>) -> bool + Send + Sync + 'static,
|
|
|
|
> = Box::new(func);
|
2017-09-16 22:45:21 +00:00
|
|
|
ffi::gst_pad_set_activate_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_activate_function),
|
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_activatemode_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, ::PadMode, bool) -> bool + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let func_box: Box<
|
2017-09-17 22:45:39 +00:00
|
|
|
Fn(&Pad, &Option<::Object>, ::PadMode, bool) -> bool + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
> = Box::new(func);
|
|
|
|
ffi::gst_pad_set_activatemode_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_activatemode_function),
|
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_chain_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, ::Buffer) -> ::FlowReturn + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let func_box: Box<
|
2017-09-17 22:45:39 +00:00
|
|
|
Fn(&Pad, &Option<::Object>, ::Buffer) -> ::FlowReturn + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
> = Box::new(func);
|
|
|
|
ffi::gst_pad_set_chain_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_chain_function),
|
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_chain_list_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, ::BufferList) -> ::FlowReturn + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let func_box: Box<
|
2017-09-17 22:45:39 +00:00
|
|
|
Fn(&Pad, &Option<::Object>, ::BufferList) -> ::FlowReturn + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
> = Box::new(func);
|
|
|
|
ffi::gst_pad_set_chain_list_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_chain_list_function),
|
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_event_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, ::Event) -> bool + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let func_box: Box<
|
2017-09-17 22:45:39 +00:00
|
|
|
Fn(&Pad, &Option<::Object>, ::Event) -> bool + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
> = Box::new(func);
|
|
|
|
ffi::gst_pad_set_event_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_event_function),
|
2017-09-18 17:44:01 +00:00
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
2017-09-16 22:45:21 +00:00
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_event_full_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, ::Event) -> ::FlowReturn + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let func_box: Box<
|
2017-09-17 22:45:39 +00:00
|
|
|
Fn(&Pad, &Option<::Object>, ::Event) -> ::FlowReturn + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
> = Box::new(func);
|
|
|
|
ffi::gst_pad_set_event_full_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_event_full_function),
|
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_getrange_function<F>(&self, func: F)
|
|
|
|
where
|
2017-12-01 17:02:53 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, u64, u32) -> Result<::Buffer, ::FlowReturn>
|
2017-09-16 22:45:21 +00:00
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
|
|
|
|
let func_box: Box<
|
2017-12-01 17:02:53 +00:00
|
|
|
Fn(&Pad, &Option<::Object>, u64, u32) -> Result<::Buffer, ::FlowReturn>
|
2017-09-16 22:45:21 +00:00
|
|
|
+ Send
|
|
|
|
+ Sync
|
|
|
|
+ 'static,
|
|
|
|
> = Box::new(func);
|
|
|
|
ffi::gst_pad_set_getrange_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_getrange_function),
|
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_iterate_internal_links_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>) -> ::Iterator<Pad> + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let func_box: Box<
|
2017-09-17 22:45:39 +00:00
|
|
|
Fn(&Pad, &Option<::Object>) -> ::Iterator<Pad> + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
> = Box::new(func);
|
|
|
|
ffi::gst_pad_set_iterate_internal_links_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_iterate_internal_links_function),
|
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_link_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, &Pad) -> ::PadLinkReturn + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let func_box: Box<
|
2017-09-17 22:45:39 +00:00
|
|
|
Fn(&Pad, &Option<::Object>, &Pad) -> ::PadLinkReturn + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
> = Box::new(func);
|
|
|
|
ffi::gst_pad_set_link_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_link_function),
|
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_query_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>, &mut ::QueryRef) -> bool + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
|
|
|
let func_box: Box<
|
2017-09-17 22:45:39 +00:00
|
|
|
Fn(&Pad, &Option<::Object>, &mut ::QueryRef) -> bool + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
> = Box::new(func);
|
|
|
|
ffi::gst_pad_set_query_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_query_function),
|
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_unlink_function<F>(&self, func: F)
|
|
|
|
where
|
2017-09-17 22:45:39 +00:00
|
|
|
F: Fn(&Pad, &Option<::Object>) + Send + Sync + 'static,
|
2017-09-16 22:45:21 +00:00
|
|
|
{
|
|
|
|
unsafe {
|
2017-09-17 22:45:39 +00:00
|
|
|
let func_box: Box<Fn(&Pad, &Option<::Object>) + Send + Sync + 'static> = Box::new(func);
|
2017-09-16 22:45:21 +00:00
|
|
|
ffi::gst_pad_set_unlink_function_full(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_unlink_function),
|
|
|
|
Box::into_raw(Box::new(func_box)) as gpointer,
|
|
|
|
Some(destroy_closure),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-09-17 21:32:29 +00:00
|
|
|
|
2017-09-17 22:53:02 +00:00
|
|
|
fn start_task<F: FnMut() + Send + 'static>(&self, func: F) -> Result<(), glib::BoolError> {
|
2017-09-17 21:32:29 +00:00
|
|
|
unsafe {
|
2017-09-17 22:53:02 +00:00
|
|
|
glib::error::BoolError::from_glib(
|
|
|
|
ffi::gst_pad_start_task(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
Some(trampoline_pad_task),
|
|
|
|
into_raw_pad_task(func),
|
|
|
|
Some(destroy_closure_pad_task),
|
|
|
|
),
|
|
|
|
"Failed to start pad task",
|
|
|
|
)
|
2017-09-17 21:32:29 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-11 10:21:55 +00:00
|
|
|
|
2017-12-09 16:20:21 +00:00
|
|
|
fn peer_query_convert<V: Into<GenericFormattedValue>, U: SpecificFormattedValue>(
|
|
|
|
&self,
|
|
|
|
src_val: V,
|
|
|
|
) -> Option<U> {
|
|
|
|
let src_val = src_val.into();
|
|
|
|
unsafe {
|
|
|
|
let mut dest_val = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_peer_query_convert(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
src_val.get_format().to_glib(),
|
|
|
|
src_val.to_glib(),
|
|
|
|
U::get_default_format().to_glib(),
|
|
|
|
&mut dest_val,
|
|
|
|
));
|
|
|
|
if ret {
|
|
|
|
Some(U::from_glib(U::get_default_format(), dest_val))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn peer_query_convert_generic<V: Into<GenericFormattedValue>>(
|
2017-11-11 10:21:55 +00:00
|
|
|
&self,
|
|
|
|
src_val: V,
|
|
|
|
dest_format: Format,
|
2017-12-09 16:20:21 +00:00
|
|
|
) -> Option<GenericFormattedValue> {
|
2017-11-11 10:21:55 +00:00
|
|
|
let src_val = src_val.into();
|
|
|
|
unsafe {
|
|
|
|
let mut dest_val = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_peer_query_convert(
|
|
|
|
self.to_glib_none().0,
|
2017-12-09 16:20:21 +00:00
|
|
|
src_val.get_format().to_glib(),
|
|
|
|
src_val.to_glib(),
|
2017-11-11 10:21:55 +00:00
|
|
|
dest_format.to_glib(),
|
|
|
|
&mut dest_val,
|
|
|
|
));
|
|
|
|
if ret {
|
2017-12-09 16:20:21 +00:00
|
|
|
Some(GenericFormattedValue::new(dest_format, dest_val))
|
2017-11-11 10:21:55 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-09 16:20:21 +00:00
|
|
|
fn peer_query_duration<T: SpecificFormattedValue>(&self) -> Option<T> {
|
|
|
|
unsafe {
|
|
|
|
let mut duration = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_peer_query_duration(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
T::get_default_format().to_glib(),
|
|
|
|
&mut duration,
|
|
|
|
));
|
|
|
|
if ret {
|
|
|
|
Some(T::from_glib(T::get_default_format(), duration))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn peer_query_duration_generic(&self, format: Format) -> Option<GenericFormattedValue> {
|
2017-11-11 10:21:55 +00:00
|
|
|
unsafe {
|
|
|
|
let mut duration = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_peer_query_duration(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
format.to_glib(),
|
|
|
|
&mut duration,
|
|
|
|
));
|
|
|
|
if ret {
|
2017-12-09 16:20:21 +00:00
|
|
|
Some(GenericFormattedValue::new(format, duration))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn peer_query_position<T: SpecificFormattedValue>(&self) -> Option<T> {
|
|
|
|
unsafe {
|
|
|
|
let mut cur = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_peer_query_position(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
T::get_default_format().to_glib(),
|
|
|
|
&mut cur,
|
|
|
|
));
|
|
|
|
if ret {
|
|
|
|
Some(T::from_glib(T::get_default_format(), cur))
|
2017-11-11 10:21:55 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-09 16:20:21 +00:00
|
|
|
fn peer_query_position_generic(&self, format: Format) -> Option<GenericFormattedValue> {
|
2017-11-11 10:21:55 +00:00
|
|
|
unsafe {
|
|
|
|
let mut cur = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_peer_query_position(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
format.to_glib(),
|
|
|
|
&mut cur,
|
|
|
|
));
|
|
|
|
if ret {
|
2017-12-09 16:20:21 +00:00
|
|
|
Some(GenericFormattedValue::new(format, cur))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn query_convert<V: Into<GenericFormattedValue>, U: SpecificFormattedValue>(
|
|
|
|
&self,
|
|
|
|
src_val: V,
|
|
|
|
) -> Option<U> {
|
|
|
|
let src_val = src_val.into();
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
let mut dest_val = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_query_convert(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
src_val.get_format().to_glib(),
|
|
|
|
src_val.to_glib(),
|
|
|
|
U::get_default_format().to_glib(),
|
|
|
|
&mut dest_val,
|
|
|
|
));
|
|
|
|
if ret {
|
|
|
|
Some(U::from_glib(U::get_default_format(), dest_val))
|
2017-11-11 10:21:55 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-09 16:20:21 +00:00
|
|
|
fn query_convert_generic<V: Into<GenericFormattedValue>>(
|
2017-11-11 10:21:55 +00:00
|
|
|
&self,
|
|
|
|
src_val: V,
|
|
|
|
dest_format: Format,
|
2017-12-09 16:20:21 +00:00
|
|
|
) -> Option<GenericFormattedValue> {
|
2017-11-11 10:21:55 +00:00
|
|
|
let src_val = src_val.into();
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
let mut dest_val = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_query_convert(
|
|
|
|
self.to_glib_none().0,
|
2017-12-09 16:20:21 +00:00
|
|
|
src_val.get_format().to_glib(),
|
|
|
|
src_val.get_value(),
|
2017-11-11 10:21:55 +00:00
|
|
|
dest_format.to_glib(),
|
|
|
|
&mut dest_val,
|
|
|
|
));
|
|
|
|
if ret {
|
2017-12-09 16:20:21 +00:00
|
|
|
Some(GenericFormattedValue::new(dest_format, dest_val))
|
2017-11-11 10:21:55 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-09 16:20:21 +00:00
|
|
|
fn query_duration<T: SpecificFormattedValue>(&self) -> Option<T> {
|
|
|
|
unsafe {
|
|
|
|
let mut duration = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_query_duration(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
T::get_default_format().to_glib(),
|
|
|
|
&mut duration,
|
|
|
|
));
|
|
|
|
if ret {
|
|
|
|
Some(T::from_glib(T::get_default_format(), duration))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn query_duration_generic(&self, format: Format) -> Option<GenericFormattedValue> {
|
2017-11-11 10:21:55 +00:00
|
|
|
unsafe {
|
|
|
|
let mut duration = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_query_duration(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
format.to_glib(),
|
|
|
|
&mut duration,
|
|
|
|
));
|
|
|
|
if ret {
|
2017-12-09 16:20:21 +00:00
|
|
|
Some(GenericFormattedValue::new(format, duration))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn query_position<T: SpecificFormattedValue>(&self) -> Option<T> {
|
|
|
|
unsafe {
|
|
|
|
let mut cur = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_query_position(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
T::get_default_format().to_glib(),
|
|
|
|
&mut cur,
|
|
|
|
));
|
|
|
|
if ret {
|
|
|
|
Some(T::from_glib(T::get_default_format(), cur))
|
2017-11-11 10:21:55 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-09 16:20:21 +00:00
|
|
|
fn query_position_generic(&self, format: Format) -> Option<GenericFormattedValue> {
|
2017-11-11 10:21:55 +00:00
|
|
|
unsafe {
|
|
|
|
let mut cur = mem::uninitialized();
|
|
|
|
let ret = from_glib(ffi::gst_pad_query_position(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
format.to_glib(),
|
|
|
|
&mut cur,
|
|
|
|
));
|
|
|
|
if ret {
|
2017-12-09 16:20:21 +00:00
|
|
|
Some(GenericFormattedValue::new(format, cur))
|
2017-11-11 10:21:55 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-24 08:51:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_pad_probe(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
info: *mut ffi::GstPadProbeInfo,
|
|
|
|
func: gpointer,
|
|
|
|
) -> ffi::GstPadProbeReturn {
|
|
|
|
let _guard = CallbackGuard::new();
|
2017-09-10 11:54:43 +00:00
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-08-02 16:40:31 +00:00
|
|
|
let func: &&(Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static) =
|
2017-08-01 14:28:36 +00:00
|
|
|
transmute(func);
|
2017-07-25 12:08:42 +00:00
|
|
|
let mut data_type = None;
|
2017-07-24 08:51:14 +00:00
|
|
|
|
|
|
|
let mut probe_info = PadProbeInfo {
|
|
|
|
mask: from_glib((*info).type_),
|
|
|
|
id: PadProbeId((*info).id),
|
|
|
|
offset: (*info).offset,
|
|
|
|
size: (*info).size,
|
|
|
|
data: if (*info).data.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
2017-07-25 12:08:42 +00:00
|
|
|
let data = (*info).data as *const ffi::GstMiniObject;
|
|
|
|
if (*data).type_ == Buffer::static_type().to_glib() {
|
|
|
|
data_type = Some(Buffer::static_type());
|
|
|
|
Some(PadProbeData::Buffer(
|
2017-07-29 12:52:46 +00:00
|
|
|
from_glib_none(data as *const ffi::GstBuffer),
|
2017-07-25 12:08:42 +00:00
|
|
|
))
|
2017-07-28 18:18:08 +00:00
|
|
|
} else if (*data).type_ == BufferList::static_type().to_glib() {
|
|
|
|
data_type = Some(BufferList::static_type());
|
|
|
|
Some(PadProbeData::BufferList(
|
2017-07-29 12:52:46 +00:00
|
|
|
from_glib_none(data as *const ffi::GstBufferList),
|
2017-07-28 18:18:08 +00:00
|
|
|
))
|
2017-07-29 15:09:14 +00:00
|
|
|
} else if (*data).type_ == Query::static_type().to_glib() {
|
|
|
|
data_type = Some(Query::static_type());
|
|
|
|
Some(PadProbeData::Query(
|
|
|
|
QueryRef::from_mut_ptr(data as *mut ffi::GstQuery),
|
|
|
|
))
|
2017-07-30 14:11:47 +00:00
|
|
|
} else if (*data).type_ == Event::static_type().to_glib() {
|
|
|
|
data_type = Some(Event::static_type());
|
|
|
|
Some(PadProbeData::Event(
|
|
|
|
from_glib_none(data as *const ffi::GstEvent),
|
|
|
|
))
|
2017-07-25 12:08:42 +00:00
|
|
|
} else {
|
|
|
|
Some(PadProbeData::Unknown)
|
|
|
|
}
|
2017-07-24 08:51:14 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2017-09-09 13:01:32 +00:00
|
|
|
let ret = func(&from_glib_borrow(pad), &mut probe_info).to_glib();
|
2017-07-24 08:51:14 +00:00
|
|
|
|
2017-07-25 12:08:42 +00:00
|
|
|
match probe_info.data {
|
|
|
|
Some(PadProbeData::Buffer(buffer)) => {
|
|
|
|
assert_eq!(data_type, Some(Buffer::static_type()));
|
2017-07-28 18:18:08 +00:00
|
|
|
if (*info).data != buffer.as_mut_ptr() as *mut _ {
|
|
|
|
ffi::gst_mini_object_unref((*info).data as *mut _);
|
|
|
|
(*info).data = buffer.into_ptr() as *mut libc::c_void;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Some(PadProbeData::BufferList(bufferlist)) => {
|
|
|
|
assert_eq!(data_type, Some(BufferList::static_type()));
|
|
|
|
if (*info).data != bufferlist.as_mut_ptr() as *mut _ {
|
|
|
|
ffi::gst_mini_object_unref((*info).data as *mut _);
|
|
|
|
(*info).data = bufferlist.into_ptr() as *mut libc::c_void;
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:11:47 +00:00
|
|
|
Some(PadProbeData::Event(event)) => {
|
|
|
|
assert_eq!(data_type, Some(Event::static_type()));
|
|
|
|
if (*info).data != event.as_mut_ptr() as *mut _ {
|
|
|
|
ffi::gst_mini_object_unref((*info).data as *mut _);
|
|
|
|
(*info).data = event.into_ptr() as *mut libc::c_void;
|
|
|
|
}
|
|
|
|
}
|
2017-07-28 18:18:08 +00:00
|
|
|
None => {
|
2017-07-29 15:09:14 +00:00
|
|
|
assert_ne!(data_type, Some(Query::static_type()));
|
2017-07-28 18:18:08 +00:00
|
|
|
if !(*info).data.is_null() {
|
|
|
|
ffi::gst_mini_object_unref((*info).data as *mut _);
|
|
|
|
(*info).data = ptr::null_mut();
|
|
|
|
}
|
2017-07-25 12:08:42 +00:00
|
|
|
}
|
|
|
|
_ => (),
|
|
|
|
}
|
2017-07-24 08:51:14 +00:00
|
|
|
|
|
|
|
ret
|
|
|
|
}
|
|
|
|
|
2017-09-16 22:45:21 +00:00
|
|
|
unsafe extern "C" fn trampoline_activate_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
) -> glib_ffi::gboolean {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-09-18 14:26:42 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>) -> bool + Send + Sync + 'static) =
|
|
|
|
transmute((*pad).activatedata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
func(&from_glib_borrow(pad), &from_glib_borrow(parent)).to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_activatemode_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
mode: ffi::GstPadMode,
|
|
|
|
active: glib_ffi::gboolean,
|
|
|
|
) -> glib_ffi::gboolean {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-09-17 22:45:39 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>, ::PadMode, bool) -> bool
|
|
|
|
+ Send
|
|
|
|
+ Sync
|
2017-09-18 14:26:42 +00:00
|
|
|
+ 'static) = transmute((*pad).activatemodedata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
func(
|
|
|
|
&from_glib_borrow(pad),
|
|
|
|
&from_glib_borrow(parent),
|
|
|
|
from_glib(mode),
|
|
|
|
from_glib(active),
|
|
|
|
).to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_chain_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
buffer: *mut ffi::GstBuffer,
|
|
|
|
) -> ffi::GstFlowReturn {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-09-17 22:45:39 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>, ::Buffer) -> ::FlowReturn
|
|
|
|
+ Send
|
|
|
|
+ Sync
|
2017-09-18 14:26:42 +00:00
|
|
|
+ 'static) = transmute((*pad).chaindata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
func(
|
|
|
|
&from_glib_borrow(pad),
|
|
|
|
&from_glib_borrow(parent),
|
|
|
|
from_glib_full(buffer),
|
|
|
|
).to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_chain_list_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
list: *mut ffi::GstBufferList,
|
|
|
|
) -> ffi::GstFlowReturn {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-09-17 22:45:39 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>, ::BufferList) -> ::FlowReturn
|
|
|
|
+ Send
|
|
|
|
+ Sync
|
2017-09-18 14:26:42 +00:00
|
|
|
+ 'static) = transmute((*pad).chainlistdata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
func(
|
|
|
|
&from_glib_borrow(pad),
|
|
|
|
&from_glib_borrow(parent),
|
|
|
|
from_glib_full(list),
|
|
|
|
).to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_event_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
event: *mut ffi::GstEvent,
|
|
|
|
) -> glib_ffi::gboolean {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-09-17 22:45:39 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>, ::Event) -> bool + Send + Sync + 'static) =
|
2017-09-18 14:26:42 +00:00
|
|
|
transmute((*pad).eventdata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
func(
|
|
|
|
&from_glib_borrow(pad),
|
|
|
|
&from_glib_borrow(parent),
|
|
|
|
from_glib_full(event),
|
|
|
|
).to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_event_full_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
event: *mut ffi::GstEvent,
|
|
|
|
) -> ffi::GstFlowReturn {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-09-17 22:45:39 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>, ::Event) -> ::FlowReturn
|
|
|
|
+ Send
|
|
|
|
+ Sync
|
2017-09-18 14:26:42 +00:00
|
|
|
+ 'static) = transmute((*pad).eventdata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
func(
|
|
|
|
&from_glib_borrow(pad),
|
|
|
|
&from_glib_borrow(parent),
|
|
|
|
from_glib_full(event),
|
|
|
|
).to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_getrange_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
offset: u64,
|
|
|
|
length: u32,
|
|
|
|
buffer: *mut *mut ffi::GstBuffer,
|
|
|
|
) -> ffi::GstFlowReturn {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-12-01 17:02:53 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>, u64, u32) -> Result<::Buffer, ::FlowReturn>
|
2017-09-16 22:45:21 +00:00
|
|
|
+ Send
|
|
|
|
+ Sync
|
2017-09-18 14:26:42 +00:00
|
|
|
+ 'static) = transmute((*pad).getrangedata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
match func(
|
|
|
|
&from_glib_borrow(pad),
|
|
|
|
&from_glib_borrow(parent),
|
|
|
|
offset,
|
|
|
|
length,
|
|
|
|
) {
|
|
|
|
Ok(new_buffer) => {
|
|
|
|
*buffer = new_buffer.into_ptr();
|
|
|
|
::FlowReturn::Ok.to_glib()
|
|
|
|
}
|
|
|
|
Err(ret) => ret.to_glib(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_iterate_internal_links_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
) -> *mut ffi::GstIterator {
|
2017-07-24 08:51:14 +00:00
|
|
|
let _guard = CallbackGuard::new();
|
2017-09-16 22:45:21 +00:00
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-09-17 22:45:39 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>) -> ::Iterator<Pad> + Send + Sync + 'static) =
|
2017-09-18 14:26:42 +00:00
|
|
|
transmute((*pad).iterintlinkdata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
// Steal the iterator and return it
|
|
|
|
let ret = func(&from_glib_borrow(pad), &from_glib_borrow(parent));
|
|
|
|
let ptr = ret.to_glib_none().0;
|
|
|
|
mem::forget(ret);
|
|
|
|
|
|
|
|
ptr as *mut _
|
2017-07-24 08:51:14 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 22:45:21 +00:00
|
|
|
unsafe extern "C" fn trampoline_link_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
peer: *mut ffi::GstPad,
|
|
|
|
) -> ffi::GstPadLinkReturn {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-09-17 22:45:39 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>, &::Pad) -> ::PadLinkReturn
|
|
|
|
+ Send
|
|
|
|
+ Sync
|
2017-09-18 14:26:42 +00:00
|
|
|
+ 'static) = transmute((*pad).linkdata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
func(
|
|
|
|
&from_glib_borrow(pad),
|
|
|
|
&from_glib_borrow(parent),
|
|
|
|
&from_glib_borrow(peer),
|
|
|
|
).to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_query_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
query: *mut ffi::GstQuery,
|
|
|
|
) -> glib_ffi::gboolean {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-09-17 22:45:39 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>, &mut ::QueryRef) -> bool
|
|
|
|
+ Send
|
|
|
|
+ Sync
|
2017-09-18 14:26:42 +00:00
|
|
|
+ 'static) = transmute((*pad).querydata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
func(
|
|
|
|
&from_glib_borrow(pad),
|
|
|
|
&from_glib_borrow(parent),
|
|
|
|
::QueryRef::from_mut_ptr(query),
|
|
|
|
).to_glib()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_unlink_function(
|
|
|
|
pad: *mut ffi::GstPad,
|
|
|
|
parent: *mut ffi::GstObject,
|
|
|
|
) {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
2017-09-18 14:26:42 +00:00
|
|
|
let func: &&(Fn(&Pad, &Option<::Object>) + Send + Sync + 'static) =
|
|
|
|
transmute((*pad).unlinkdata);
|
2017-09-16 22:45:21 +00:00
|
|
|
|
|
|
|
func(&from_glib_borrow(pad), &from_glib_borrow(parent))
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn destroy_closure(ptr: gpointer) {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
Box::<Box<Fn()>>::from_raw(ptr as *mut _);
|
2017-07-24 08:51:14 +00:00
|
|
|
}
|
2017-09-17 21:32:29 +00:00
|
|
|
|
|
|
|
unsafe extern "C" fn trampoline_pad_task(func: gpointer) {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
|
|
|
let func: &RefCell<Box<FnMut() + Send + 'static>> = transmute(func);
|
|
|
|
(&mut *func.borrow_mut())()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn destroy_closure_pad_task(ptr: gpointer) {
|
|
|
|
let _guard = CallbackGuard::new();
|
|
|
|
Box::<RefCell<Box<FnMut() + Send + 'static>>>::from_raw(ptr as *mut _);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn into_raw_pad_task<F: FnMut() + Send + 'static>(func: F) -> gpointer {
|
|
|
|
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
|
|
|
|
let func: Box<RefCell<Box<FnMut() + Send + 'static>>> = Box::new(RefCell::new(Box::new(func)));
|
|
|
|
Box::into_raw(func) as gpointer
|
|
|
|
}
|
2017-09-17 22:45:39 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
use prelude::*;
|
|
|
|
use std::sync::{Arc, Mutex};
|
2017-09-17 22:53:02 +00:00
|
|
|
use std::sync::mpsc::channel;
|
2017-09-17 22:45:39 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_event_chain_functions() {
|
|
|
|
::init().unwrap();
|
|
|
|
|
|
|
|
let pad = ::Pad::new("sink", ::PadDirection::Sink);
|
|
|
|
|
|
|
|
let events = Arc::new(Mutex::new(Vec::new()));
|
|
|
|
let events_clone = events.clone();
|
|
|
|
pad.set_event_function(move |_, _, event| {
|
|
|
|
let mut events = events_clone.lock().unwrap();
|
|
|
|
events.push(event);
|
|
|
|
|
|
|
|
true
|
|
|
|
});
|
|
|
|
|
|
|
|
let buffers = Arc::new(Mutex::new(Vec::new()));
|
|
|
|
let buffers_clone = buffers.clone();
|
|
|
|
pad.set_chain_function(move |_, _, buffer| {
|
|
|
|
let mut buffers = buffers_clone.lock().unwrap();
|
|
|
|
buffers.push(buffer);
|
|
|
|
|
|
|
|
::FlowReturn::Ok
|
|
|
|
});
|
|
|
|
|
|
|
|
pad.set_active(true).unwrap();
|
|
|
|
|
|
|
|
assert!(pad.send_event(::Event::new_stream_start("test").build()));
|
2017-12-09 16:20:21 +00:00
|
|
|
let segment = ::FormattedSegment::<::ClockTime>::new();
|
|
|
|
assert!(pad.send_event(
|
|
|
|
::Event::new_segment(segment.as_ref()).build()
|
|
|
|
));
|
2017-09-17 22:45:39 +00:00
|
|
|
|
|
|
|
assert_eq!(pad.chain(::Buffer::new()), ::FlowReturn::Ok);
|
|
|
|
|
|
|
|
let events = events.lock().unwrap();
|
|
|
|
let buffers = buffers.lock().unwrap();
|
|
|
|
assert_eq!(events.len(), 2);
|
|
|
|
assert_eq!(buffers.len(), 1);
|
|
|
|
|
|
|
|
match events[0].view() {
|
|
|
|
::EventView::StreamStart(..) => (),
|
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
|
|
|
|
match events[1].view() {
|
|
|
|
::EventView::Segment(..) => (),
|
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|
2017-09-17 22:53:02 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_task() {
|
|
|
|
::init().unwrap();
|
|
|
|
|
|
|
|
let pad = ::Pad::new("sink", ::PadDirection::Sink);
|
|
|
|
let (sender, receiver) = channel();
|
|
|
|
|
|
|
|
let mut i = 0;
|
|
|
|
let pad_clone = pad.clone();
|
|
|
|
pad.start_task(move || {
|
|
|
|
i += 1;
|
|
|
|
if i == 3 {
|
|
|
|
sender.send(i).unwrap();
|
|
|
|
pad_clone.pause_task().unwrap();
|
|
|
|
}
|
|
|
|
}).unwrap();
|
|
|
|
|
|
|
|
assert_eq!(receiver.recv().unwrap(), 3);
|
|
|
|
}
|
2017-09-17 22:45:39 +00:00
|
|
|
}
|