Update manual code for glib API changes

This commit is contained in:
Sebastian Dröge 2019-01-16 13:32:58 +02:00
parent 6da0a9d169
commit 931c485150
46 changed files with 343 additions and 303 deletions

View file

@ -24,7 +24,7 @@ extern crate gstreamer_video as gst_video;
use gst_video::prelude::*;
extern crate glib;
use glib::translate::ToGlibPtr;
use glib::object::ObjectType;
extern crate gio;
use gio::prelude::*;
@ -133,7 +133,7 @@ fn create_ui(app: &gtk::Application) {
// our video region from the window system, and then we will
// pass this unique identifier to the overlay provided by our
// sink - so the sink can then arrange the overlay.
let xid = gdk_x11_window_get_xid(gdk_window.to_glib_none().0);
let xid = gdk_x11_window_get_xid(gdk_window.as_ptr() as *mut _);
video_overlay.set_window_handle(xid as usize);
}
} else {
@ -156,7 +156,7 @@ fn create_ui(app: &gtk::Application) {
// our video region from the windowing system, and then we will
// pass this unique identifier to the overlay provided by our
// sink - so the sink can then arrange the overlay.
let window = gdk_quartz_window_get_nsview(gdk_window.to_glib_none().0);
let window = gdk_quartz_window_get_nsview(gdk_window.as_ptr() as *mut _);
video_overlay.set_window_handle(window as usize);
}
} else {

View file

@ -29,8 +29,6 @@ use std::sync::{Arc, Mutex};
extern crate failure;
use failure::Error;
use glib::GString;
#[macro_use]
extern crate failure_derive;
@ -191,7 +189,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
// Update the text layout. This function is only updating pango's internal state.
// So e.g. that after a 90 degree rotation it knows that what was previously going
// to end up as a 200x100 rectangle would now be 100x200.
pangocairo::functions::update_layout(&cr, &layout);
pangocairo::functions::update_layout(&cr, &**layout);
let (width, _height) = layout.get_size();
// Using width and height of the text, we can properly possition it within
// our canvas.
@ -201,7 +199,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
);
// After telling the layout object where to draw itself, we actually tell
// it to draw itself into our cairo context.
pangocairo::functions::show_layout(&cr, &layout);
pangocairo::functions::show_layout(&cr, &**layout);
// Here we go one step up in our stack of transformations, removing any
// changes we did to them since the last call to cr.save();

View file

@ -7,6 +7,7 @@
// except according to those terms.
use ffi;
use glib::object::ObjectType;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
@ -190,7 +191,7 @@ impl AppSink {
>,
> = Box_::new(Box_::new(f));
connect_raw(
self.to_glib_none().0,
self.as_ptr() as *mut _,
b"new-sample\0".as_ptr() as *const _,
transmute(new_sample_trampoline as usize),
Box_::into_raw(f) as *mut _,
@ -214,7 +215,7 @@ impl AppSink {
>,
> = Box_::new(Box_::new(f));
connect_raw(
self.to_glib_none().0,
self.as_ptr() as *mut _,
b"new-preroll\0".as_ptr() as *const _,
transmute(new_preroll_trampoline as usize),
Box_::into_raw(f) as *mut _,

View file

@ -22,7 +22,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(ffi::gst_aggregator_finish_buffer(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
buffer.into_ptr(),
))
};

View file

@ -7,8 +7,8 @@
// except according to those terms.
use ffi;
use glib::object::{IsA, IsClassFor};
use glib::translate::*;
use glib::{IsA, IsClassFor};
use gst;
use gst_ffi;
use AggregatorPad;
@ -22,8 +22,7 @@ pub trait AggregatorPadExtManual: 'static {
impl<O: IsA<AggregatorPad>> AggregatorPadExtManual for O {
fn get_segment(&self) -> gst::Segment {
unsafe {
let stash = self.to_glib_none();
let ptr: &ffi::GstAggregatorPad = &*stash.0;
let ptr: &ffi::GstAggregatorPad = &*(self.as_ptr() as *const _);
::utils::MutexGuard::lock(&ptr.parent.object.lock);
from_glib_none(&ptr.segment as *const gst_ffi::GstSegment)
}

View file

@ -7,8 +7,8 @@
// except according to those terms.
use ffi;
use glib::object::{IsA, IsClassFor};
use glib::translate::*;
use glib::{IsA, IsClassFor};
use gst;
use std::mem;
use std::ops;
@ -28,8 +28,7 @@ pub trait BaseSinkExtManual: 'static {
impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
fn get_segment(&self) -> gst::Segment {
unsafe {
let stash = self.to_glib_none();
let sink: &ffi::GstBaseSink = &*stash.0;
let sink: &ffi::GstBaseSink = &*(self.as_ptr() as *const _);
::utils::MutexGuard::lock(&sink.element.object.lock);
from_glib_none(&sink.segment as *const _)
}
@ -42,7 +41,7 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
unsafe {
let mut jitter = mem::uninitialized();
let ret: gst::FlowReturn = from_glib(ffi::gst_base_sink_wait(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
time.to_glib(),
&mut jitter,
));
@ -51,8 +50,11 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
}
fn wait_preroll(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn =
unsafe { from_glib(ffi::gst_base_sink_wait_preroll(self.to_glib_none().0)) };
let ret: gst::FlowReturn = unsafe {
from_glib(ffi::gst_base_sink_wait_preroll(
self.as_ref().to_glib_none().0,
))
};
ret.into_result()
}
}

View file

@ -7,8 +7,8 @@
// except according to those terms.
use ffi;
use glib::object::{IsA, IsClassFor};
use glib::translate::*;
use glib::{IsA, IsClassFor};
use gst;
use std::ops;
use BaseSrc;
@ -26,8 +26,7 @@ pub trait BaseSrcExtManual: 'static {
impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
fn get_segment(&self) -> gst::Segment {
unsafe {
let stash = self.to_glib_none();
let src: &ffi::GstBaseSrc = &*stash.0;
let src: &ffi::GstBaseSrc = &*(self.as_ptr() as *const _);
::utils::MutexGuard::lock(&src.element.object.lock);
from_glib_none(&src.segment as *const _)
}
@ -36,19 +35,22 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
fn start_complete(&self, ret: Result<gst::FlowSuccess, gst::FlowError>) {
let ret: gst::FlowReturn = ret.into();
unsafe {
ffi::gst_base_src_start_complete(self.to_glib_none().0, ret.to_glib());
ffi::gst_base_src_start_complete(self.as_ref().to_glib_none().0, ret.to_glib());
}
}
fn start_wait(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn =
unsafe { from_glib(ffi::gst_base_src_start_wait(self.to_glib_none().0)) };
unsafe { from_glib(ffi::gst_base_src_start_wait(self.as_ref().to_glib_none().0)) };
ret.into_result()
}
fn wait_playing(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn =
unsafe { from_glib(ffi::gst_base_src_wait_playing(self.to_glib_none().0)) };
let ret: gst::FlowReturn = unsafe {
from_glib(ffi::gst_base_src_wait_playing(
self.as_ref().to_glib_none().0,
))
};
ret.into_result()
}
}

View file

@ -7,8 +7,8 @@
// except according to those terms.
use ffi;
use glib::object::{IsA, IsClassFor};
use glib::translate::*;
use glib::{IsA, IsClassFor};
use gst;
use std::ops;
use BaseTransform;
@ -20,8 +20,7 @@ pub trait BaseTransformExtManual: 'static {
impl<O: IsA<BaseTransform>> BaseTransformExtManual for O {
fn get_segment(&self) -> gst::Segment {
unsafe {
let stash = self.to_glib_none();
let trans: &ffi::GstBaseTransform = &*stash.0;
let trans: &ffi::GstBaseTransform = &*(self.as_ptr() as *const _);
::utils::MutexGuard::lock(&trans.element.object.lock);
from_glib_none(&trans.segment as *const _)
}

View file

@ -35,7 +35,7 @@ impl FlowCombiner {
pub fn add_pad<P: IsA<gst::Pad>>(&self, pad: &P) {
unsafe {
ffi::gst_flow_combiner_add_pad(self.to_glib_none().0, pad.to_glib_none().0);
ffi::gst_flow_combiner_add_pad(self.to_glib_none().0, pad.as_ref().to_glib_none().0);
}
}
@ -47,7 +47,7 @@ impl FlowCombiner {
pub fn remove_pad<P: IsA<gst::Pad>>(&self, pad: &P) {
unsafe {
ffi::gst_flow_combiner_remove_pad(self.to_glib_none().0, pad.to_glib_none().0);
ffi::gst_flow_combiner_remove_pad(self.to_glib_none().0, pad.as_ref().to_glib_none().0);
}
}
@ -80,7 +80,7 @@ impl FlowCombiner {
let ret: gst::FlowReturn = unsafe {
from_glib(ffi::gst_flow_combiner_update_pad_flow(
self.to_glib_none().0,
pad.to_glib_none().0,
pad.as_ref().to_glib_none().0,
fret.to_glib(),
))
};

View file

@ -23,13 +23,12 @@ pub fn type_find_helper_for_data<
) -> (Option<gst::Caps>, gst::TypeFindProbability) {
assert_initialized_main_thread!();
let obj = obj.into();
let obj = obj.to_glib_none();
unsafe {
let mut prob = mem::uninitialized();
let data = data.as_ref();
let (ptr, len) = (data.as_ptr(), data.len());
let ret = from_glib_full(ffi::gst_type_find_helper_for_data(
obj.0,
obj.map(|p| p.as_ref()).to_glib_none().0,
mut_override(ptr),
len,
&mut prob,

View file

@ -62,7 +62,7 @@ impl Harness {
unsafe {
ffi::gst_harness_add_element_full(
self.0.as_ptr(),
element.to_glib_none().0,
element.as_ref().to_glib_none().0,
hsrc.to_glib_none().0 as *mut _,
element_sinkpad_name.0,
hsink.to_glib_none().0 as *mut _,
@ -73,13 +73,16 @@ impl Harness {
pub fn add_element_sink_pad<P: IsA<gst::Pad>>(&mut self, sinkpad: &P) {
unsafe {
ffi::gst_harness_add_element_sink_pad(self.0.as_ptr(), sinkpad.to_glib_none().0);
ffi::gst_harness_add_element_sink_pad(
self.0.as_ptr(),
sinkpad.as_ref().to_glib_none().0,
);
}
}
pub fn add_element_src_pad<P: IsA<gst::Pad>>(&mut self, srcpad: &P) {
unsafe {
ffi::gst_harness_add_element_src_pad(self.0.as_ptr(), srcpad.to_glib_none().0);
ffi::gst_harness_add_element_src_pad(self.0.as_ptr(), srcpad.as_ref().to_glib_none().0);
}
}
@ -563,7 +566,7 @@ impl Harness {
let element_srcpad_name = element_srcpad_name.to_glib_none();
unsafe {
Self::from_glib_full(ffi::gst_harness_new_full(
element.to_glib_none().0,
element.as_ref().to_glib_none().0,
hsrc.to_glib_none().0 as *mut _,
element_sinkpad_name.0,
hsink.to_glib_none().0 as *mut _,
@ -595,7 +598,7 @@ impl Harness {
let element_srcpad_name = element_srcpad_name.to_glib_none();
unsafe {
Self::from_glib_full(ffi::gst_harness_new_with_element(
element.to_glib_none().0,
element.as_ref().to_glib_none().0,
element_sinkpad_name.0,
element_srcpad_name.0,
))

View file

@ -22,7 +22,7 @@ impl<O: IsA<TimelineElement>> TimelineElementExtManual for O {
fn get_child_property(&self, name: &str) -> Option<glib::Value> {
unsafe {
let found: bool = from_glib(ffi::ges_timeline_element_lookup_child(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
ptr::null_mut(),
ptr::null_mut(),
@ -33,7 +33,7 @@ impl<O: IsA<TimelineElement>> TimelineElementExtManual for O {
let mut value = glib::Value::uninitialized();
ffi::ges_timeline_element_get_child_property(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none_mut().0,
);
@ -44,7 +44,7 @@ impl<O: IsA<TimelineElement>> TimelineElementExtManual for O {
fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError> {
unsafe {
let found: bool = from_glib(ffi::ges_timeline_element_lookup_child(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
ptr::null_mut(),
ptr::null_mut(),
@ -55,7 +55,7 @@ impl<O: IsA<TimelineElement>> TimelineElementExtManual for O {
let value = value.to_value();
ffi::ges_timeline_element_set_child_property(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none().0,
);

View file

@ -35,7 +35,7 @@ impl ContextGLExt for ContextRef {
fn set_gl_display<T: IsA<GLDisplay>>(&self, display: &T) {
unsafe {
ffi::gst_context_set_gl_display(self.as_mut_ptr(), display.to_glib_none().0);
ffi::gst_context_set_gl_display(self.as_mut_ptr(), display.as_ref().to_glib_none().0);
}
}
}

View file

@ -23,45 +23,18 @@ impl GLContext {
available_apis: GLAPI,
) -> Option<GLContext> {
from_glib_full(ffi::gst_gl_context_new_wrapped(
display.to_glib_none().0,
display.as_ref().to_glib_none().0,
handle,
context_type.to_glib(),
available_apis.to_glib(),
))
}
}
pub trait GLContextExtManual: 'static {
fn get_gl_context(&self) -> uintptr_t;
fn get_proc_address(&self, name: &str) -> uintptr_t;
fn get_current_gl_context(context_type: GLPlatform) -> uintptr_t;
fn get_proc_address_with_platform(
context_type: GLPlatform,
gl_api: GLAPI,
name: &str,
) -> uintptr_t;
}
impl<O: IsA<GLContext>> GLContextExtManual for O {
fn get_gl_context(&self) -> uintptr_t {
unsafe { ffi::gst_gl_context_get_gl_context(self.to_glib_none().0) as uintptr_t }
}
fn get_proc_address(&self, name: &str) -> uintptr_t {
unsafe {
ffi::gst_gl_context_get_proc_address(self.to_glib_none().0, name.to_glib_none().0)
as uintptr_t
}
}
fn get_current_gl_context(context_type: GLPlatform) -> uintptr_t {
pub fn get_current_gl_context(context_type: GLPlatform) -> uintptr_t {
unsafe { ffi::gst_gl_context_get_current_gl_context(context_type.to_glib()) as uintptr_t }
}
fn get_proc_address_with_platform(
pub fn get_proc_address_with_platform(
context_type: GLPlatform,
gl_api: GLAPI,
name: &str,
@ -75,3 +48,24 @@ impl<O: IsA<GLContext>> GLContextExtManual for O {
}
}
}
pub trait GLContextExtManual: 'static {
fn get_gl_context(&self) -> uintptr_t;
fn get_proc_address(&self, name: &str) -> uintptr_t;
}
impl<O: IsA<GLContext>> GLContextExtManual for O {
fn get_gl_context(&self) -> uintptr_t {
unsafe { ffi::gst_gl_context_get_gl_context(self.as_ref().to_glib_none().0) as uintptr_t }
}
fn get_proc_address(&self, name: &str) -> uintptr_t {
unsafe {
ffi::gst_gl_context_get_proc_address(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
) as uintptr_t
}
}
}

View file

@ -9,7 +9,7 @@
use ffi;
use NetClientClock;
use glib::object::Downcast;
use glib::object::Cast;
use glib::translate::*;
use gst;
@ -32,7 +32,7 @@ impl NetClientClock {
remote_port,
base_time.to_glib(),
))
.downcast_unchecked()
.unsafe_cast()
}
} else {
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
@ -43,7 +43,7 @@ impl NetClientClock {
remote_port,
base_time.to_glib(),
))
.downcast_unchecked()
.unsafe_cast()
}
}
}

View file

@ -27,7 +27,7 @@ impl NetTimeProvider {
if (major, minor) > (1, 12) {
unsafe {
from_glib_full(ffi::gst_net_time_provider_new(
clock.to_glib_none().0,
clock.as_ref().to_glib_none().0,
address.0,
port,
))
@ -36,7 +36,7 @@ impl NetTimeProvider {
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
unsafe {
from_glib_none(ffi::gst_net_time_provider_new(
clock.to_glib_none().0,
clock.as_ref().to_glib_none().0,
address.0,
port,
))

View file

@ -9,7 +9,7 @@
use ffi;
use NtpClock;
use glib::object::Downcast;
use glib::object::Cast;
use glib::translate::*;
use gst;
@ -32,7 +32,7 @@ impl NtpClock {
remote_port,
base_time.to_glib(),
))
.downcast_unchecked()
.unsafe_cast()
}
} else {
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
@ -43,7 +43,7 @@ impl NtpClock {
remote_port,
base_time.to_glib(),
))
.downcast_unchecked()
.unsafe_cast()
}
}
}

View file

@ -9,7 +9,7 @@
use ffi;
use PtpClock;
use glib::object::Downcast;
use glib::object::Cast;
use glib::translate::*;
use gst;
@ -21,14 +21,12 @@ impl PtpClock {
let (major, minor, _, _) = gst::version();
if (major, minor) > (1, 12) {
unsafe {
gst::Clock::from_glib_full(ffi::gst_ptp_clock_new(name.0, domain))
.downcast_unchecked()
gst::Clock::from_glib_full(ffi::gst_ptp_clock_new(name.0, domain)).unsafe_cast()
}
} else {
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
unsafe {
gst::Clock::from_glib_none(ffi::gst_ptp_clock_new(name.0, domain))
.downcast_unchecked()
gst::Clock::from_glib_none(ffi::gst_ptp_clock_new(name.0, domain)).unsafe_cast()
}
}
}

View file

@ -11,8 +11,8 @@ use gst;
use auto::Discoverer;
use glib::object::Downcast;
use glib::signal::connect;
use glib::object::{Cast, ObjectType};
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::IsA;
@ -29,7 +29,7 @@ impl Discoverer {
pub fn set_property_timeout(&self, timeout: gst::ClockTime) {
unsafe {
gobject_ffi::g_object_set_property(
self.to_glib_none().0,
self.as_ptr() as *mut _,
"timeout".to_glib_none().0,
Value::from(&timeout).to_glib_none().0,
);
@ -40,7 +40,7 @@ impl Discoverer {
let mut value = Value::from(&0u64);
unsafe {
gobject_ffi::g_object_get_property(
self.to_glib_none().0,
self.as_ptr() as *mut _,
"timeout".to_glib_none().0,
value.to_glib_none_mut().0,
);
@ -54,9 +54,9 @@ impl Discoverer {
) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(
self.to_glib_none().0,
"notify::timeout",
connect_raw(
self.as_ptr() as *mut _,
b"notify::timeout\0".as_ptr() as *const _,
transmute(notify_timeout_trampoline::<Self> as usize),
Box_::into_raw(f) as *mut _,
)
@ -73,5 +73,5 @@ unsafe extern "C" fn notify_timeout_trampoline<P>(
{
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&Discoverer::from_glib_borrow(this).downcast_unchecked())
f(&Discoverer::from_glib_borrow(this).unsafe_cast())
}

View file

@ -43,11 +43,11 @@ trait EncodingProfileBuilderCommon {
fn set_restriction<'a, P: Into<Option<&'a gst::Caps>>>(&self, restriction: P);
}
impl<O: IsA<EncodingProfile> + IsA<glib::object::Object>> EncodingProfileBuilderCommon for O {
impl<O: IsA<EncodingProfile>> EncodingProfileBuilderCommon for O {
fn set_allow_dynamic_output(&self, allow_dynamic_output: bool) {
unsafe {
ffi::gst_encoding_profile_set_allow_dynamic_output(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
allow_dynamic_output.to_glib(),
);
}
@ -57,19 +57,28 @@ impl<O: IsA<EncodingProfile> + IsA<glib::object::Object>> EncodingProfileBuilder
let description = description.into();
let description = description.to_glib_none();
unsafe {
ffi::gst_encoding_profile_set_description(self.to_glib_none().0, description.0);
ffi::gst_encoding_profile_set_description(
self.as_ref().to_glib_none().0,
description.0,
);
}
}
fn set_enabled(&self, enabled: bool) {
unsafe {
ffi::gst_encoding_profile_set_enabled(self.to_glib_none().0, enabled.to_glib());
ffi::gst_encoding_profile_set_enabled(
self.as_ref().to_glib_none().0,
enabled.to_glib(),
);
}
}
fn set_format(&self, format: &gst::Caps) {
unsafe {
ffi::gst_encoding_profile_set_format(self.to_glib_none().0, format.to_glib_none().0);
ffi::gst_encoding_profile_set_format(
self.as_ref().to_glib_none().0,
format.to_glib_none().0,
);
}
}
@ -77,13 +86,13 @@ impl<O: IsA<EncodingProfile> + IsA<glib::object::Object>> EncodingProfileBuilder
let name = name.into();
let name = name.to_glib_none();
unsafe {
ffi::gst_encoding_profile_set_name(self.to_glib_none().0, name.0);
ffi::gst_encoding_profile_set_name(self.as_ref().to_glib_none().0, name.0);
}
}
fn set_presence(&self, presence: u32) {
unsafe {
ffi::gst_encoding_profile_set_presence(self.to_glib_none().0, presence);
ffi::gst_encoding_profile_set_presence(self.as_ref().to_glib_none().0, presence);
}
}
@ -91,7 +100,7 @@ impl<O: IsA<EncodingProfile> + IsA<glib::object::Object>> EncodingProfileBuilder
let preset = preset.into();
let preset = preset.to_glib_none();
unsafe {
ffi::gst_encoding_profile_set_preset(self.to_glib_none().0, preset.0);
ffi::gst_encoding_profile_set_preset(self.as_ref().to_glib_none().0, preset.0);
}
}
@ -99,7 +108,10 @@ impl<O: IsA<EncodingProfile> + IsA<glib::object::Object>> EncodingProfileBuilder
let preset_name = preset_name.into();
let preset_name = preset_name.to_glib_none();
unsafe {
ffi::gst_encoding_profile_set_preset_name(self.to_glib_none().0, preset_name.0);
ffi::gst_encoding_profile_set_preset_name(
self.as_ref().to_glib_none().0,
preset_name.0,
);
}
}
@ -111,7 +123,7 @@ impl<O: IsA<EncodingProfile> + IsA<glib::object::Object>> EncodingProfileBuilder
None => gst_ffi::gst_caps_new_any(),
};
ffi::gst_encoding_profile_set_restriction(self.to_glib_none().0, restriction);
ffi::gst_encoding_profile_set_restriction(self.as_ref().to_glib_none().0, restriction);
}
}
}
@ -216,7 +228,7 @@ impl EncodingContainerProfile {
glib_result_from_gboolean!(
ffi::gst_encoding_container_profile_add_profile(
self.to_glib_none().0,
profile.to_glib_full(),
profile.as_ref().to_glib_full(),
),
"Failed to add profile",
)
@ -463,9 +475,7 @@ impl<'a> EncodingContainerProfileBuilder<'a> {
}
pub fn add_profile<P: IsA<EncodingProfile>>(mut self, profile: &P) -> Self {
unsafe {
self.profiles.push(from_glib_none(profile.to_glib_none().0));
}
self.profiles.push(profile.as_ref().clone());
self
}
}
@ -574,9 +584,8 @@ mod tests {
);
assert_eq!(video_profile.is_enabled(), ENABLED);
let video_profile: EncodingVideoProfile = glib::object::Downcast::downcast(video_profile)
.ok()
.unwrap();
let video_profile: EncodingVideoProfile =
glib::object::Cast::downcast(video_profile).ok().unwrap();
assert_eq!(video_profile.get_variableframerate(), VARIABLE_FRAMERATE);
assert_eq!(video_profile.get_pass(), PASS);
}
@ -632,7 +641,7 @@ mod tests {
assert_eq!(profile.is_enabled(), ENABLED);
let container_profile: EncodingContainerProfile =
glib::object::Downcast::downcast(profile).ok().unwrap();
glib::object::Cast::downcast(profile).ok().unwrap();
assert!(container_profile.contains_profile(&video_profile));
assert!(container_profile.contains_profile(&audio_profile));

View file

@ -8,7 +8,8 @@
use ffi;
use glib;
use glib::signal::connect;
use glib::object::ObjectType;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib_ffi;
@ -58,9 +59,9 @@ impl Player {
unsafe {
let f: Box_<Box_<Fn(&Player, gst::ClockTime) + Send + 'static>> =
Box_::new(Box_::new(f));
connect(
self.to_glib_none().0,
"duration-changed",
connect_raw(
self.as_ptr() as *mut _,
b"duration-changed\0".as_ptr() as *const _,
transmute(duration_changed_trampoline as usize),
Box_::into_raw(f) as *mut _,
)
@ -74,9 +75,9 @@ impl Player {
unsafe {
let f: Box_<Box_<Fn(&Player, gst::ClockTime) + Send + 'static>> =
Box_::new(Box_::new(f));
connect(
self.to_glib_none().0,
"position-updated",
connect_raw(
self.as_ptr() as *mut _,
b"position-updated\0".as_ptr() as *const _,
transmute(position_updated_trampoline as usize),
Box_::into_raw(f) as *mut _,
)
@ -90,9 +91,9 @@ impl Player {
unsafe {
let f: Box_<Box_<Fn(&Player, gst::ClockTime) + Send + 'static>> =
Box_::new(Box_::new(f));
connect(
self.to_glib_none().0,
"seek-done",
connect_raw(
self.as_ptr() as *mut _,
b"seek-done\0".as_ptr() as *const _,
transmute(seek_done_trampoline as usize),
Box_::into_raw(f) as *mut _,
)

View file

@ -33,7 +33,7 @@ impl PlayerVideoOverlayVideoRenderer {
from_glib_full(ffi::gst_player_video_overlay_video_renderer_new_with_sink(
window_handle as *mut _,
video_sink.to_glib_none().0,
video_sink.as_ref().to_glib_none().0,
) as *mut _)
}
@ -43,7 +43,7 @@ impl PlayerVideoOverlayVideoRenderer {
unsafe {
from_glib_full(ffi::gst_player_video_overlay_video_renderer_new_with_sink(
ptr::null_mut(),
video_sink.to_glib_none().0,
video_sink.as_ref().to_glib_none().0,
) as *mut _)
}
}

View file

@ -27,7 +27,7 @@ impl<O: IsA<RTSPAddressPool>> RTSPAddressPoolExtManual for O {
unsafe {
let mut address = ptr::null_mut();
let ret = from_glib(ffi::gst_rtsp_address_pool_reserve_address(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
ip_address.to_glib_none().0,
port,
n_ports,

View file

@ -12,7 +12,10 @@ impl<O: IsA<RTSPAuth>> RTSPAuthExtManual for O {
fn set_default_token<'a, P: Into<Option<&'a mut RTSPToken>>>(&self, token: P) {
let mut token = token.into();
unsafe {
ffi::gst_rtsp_auth_set_default_token(self.to_glib_none().0, token.to_glib_none_mut().0);
ffi::gst_rtsp_auth_set_default_token(
self.as_ref().to_glib_none().0,
token.to_glib_none_mut().0,
);
}
}
}

View file

@ -12,11 +12,10 @@ pub trait RTSPClientExtManual: 'static {
impl<O: IsA<RTSPClient>> RTSPClientExtManual for O {
fn attach<'a, P: Into<Option<&'a glib::MainContext>>>(&self, context: P) -> SourceId {
let context = context.into();
let context = context.to_glib_none();
unsafe {
from_glib(ffi::gst_rtsp_client_attach(
self.to_glib_none().0,
context.0,
self.as_ref().to_glib_none().0,
context.to_glib_none().0,
))
}
}

View file

@ -10,6 +10,8 @@ use RTSPMediaFactory;
#[cfg(any(feature = "v1_14", feature = "dox"))]
use ffi;
#[cfg(any(feature = "v1_14", feature = "dox"))]
use glib::translate::*;
use glib::IsA;
#[cfg(any(feature = "v1_14", feature = "dox"))]
use gst;
@ -24,7 +26,7 @@ impl<O: IsA<RTSPMediaFactory>> RTSPMediaFactoryExtManual for O {
fn add_role_from_structure(&self, structure: &gst::StructureRef) {
unsafe {
ffi::gst_rtsp_media_factory_add_role_from_structure(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
structure.as_mut_ptr(),
);
}

View file

@ -12,11 +12,10 @@ pub trait RTSPServerExtManual: 'static {
impl<O: IsA<RTSPServer>> RTSPServerExtManual for O {
fn attach<'a, P: Into<Option<&'a glib::MainContext>>>(&self, context: P) -> SourceId {
let context = context.into();
let context = context.to_glib_none();
unsafe {
from_glib(ffi::gst_rtsp_server_attach(
self.to_glib_none().0,
context.0,
self.as_ref().to_glib_none().0,
context.to_glib_none().0,
))
}
}

View file

@ -54,7 +54,7 @@ impl<O: IsA<RTSPSessionPool>> RTSPSessionPoolExtManual for O {
{
skip_assert_initialized!();
unsafe {
let source = ffi::gst_rtsp_session_pool_create_watch(self.to_glib_none().0);
let source = ffi::gst_rtsp_session_pool_create_watch(self.as_ref().to_glib_none().0);
let trampoline = trampoline_watch as gpointer;
glib_ffi::g_source_set_callback(
source,

View file

@ -14,7 +14,7 @@ impl<O: IsA<RTSPStream>> RTSPStreamExtManual for O {
fn recv_rtcp(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(ffi::gst_rtsp_stream_recv_rtcp(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
buffer.to_glib_full(),
))
};
@ -24,7 +24,7 @@ impl<O: IsA<RTSPStream>> RTSPStreamExtManual for O {
fn recv_rtp(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(ffi::gst_rtsp_stream_recv_rtp(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
buffer.to_glib_full(),
))
};

View file

@ -20,7 +20,7 @@ impl<O: IsA<RTSPStreamTransport>> RTSPStreamTransportExtManual for O {
) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(ffi::gst_rtsp_stream_transport_recv_data(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
channel,
buffer.to_glib_full(),
))

View file

@ -22,11 +22,11 @@ pub trait VideoOverlayExtManual: 'static {
impl<O: IsA<VideoOverlay>> VideoOverlayExtManual for O {
unsafe fn set_window_handle(&self, handle: uintptr_t) {
ffi::gst_video_overlay_set_window_handle(self.to_glib_none().0, handle)
ffi::gst_video_overlay_set_window_handle(self.as_ref().to_glib_none().0, handle)
}
unsafe fn got_window_handle(&self, handle: uintptr_t) {
ffi::gst_video_overlay_got_window_handle(self.to_glib_none().0, handle)
ffi::gst_video_overlay_got_window_handle(self.as_ref().to_glib_none().0, handle)
}
}

View file

@ -10,8 +10,9 @@ use Bin;
use Element;
use glib;
use glib::object::{IsA, IsClassFor};
use glib::translate::{from_glib, from_glib_full, FromGlibPtrContainer, ToGlib, ToGlibPtr};
use glib::{GString, IsA, IsClassFor};
use glib::GString;
use ffi;
@ -43,8 +44,10 @@ impl<O: IsA<Bin>> GstBinExtManual for O {
fn add_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
for e in elements {
unsafe {
let ret: bool =
from_glib(ffi::gst_bin_add(self.to_glib_none().0, e.to_glib_none().0));
let ret: bool = from_glib(ffi::gst_bin_add(
self.as_ref().to_glib_none().0,
e.as_ref().to_glib_none().0,
));
if !ret {
return Err(glib_bool_error!("Failed to add elements"));
}
@ -58,8 +61,8 @@ impl<O: IsA<Bin>> GstBinExtManual for O {
for e in elements {
unsafe {
let ret: bool = from_glib(ffi::gst_bin_remove(
self.to_glib_none().0,
e.to_glib_none().0,
self.as_ref().to_glib_none().0,
e.as_ref().to_glib_none().0,
));
if !ret {
return Err(glib_bool_error!("Failed to add elements"));
@ -73,36 +76,39 @@ impl<O: IsA<Bin>> GstBinExtManual for O {
fn iterate_all_by_interface(&self, iface: glib::types::Type) -> ::Iterator<Element> {
unsafe {
from_glib_full(ffi::gst_bin_iterate_all_by_interface(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
iface.to_glib(),
))
}
}
fn iterate_elements(&self) -> ::Iterator<Element> {
unsafe { from_glib_full(ffi::gst_bin_iterate_elements(self.to_glib_none().0)) }
unsafe {
from_glib_full(ffi::gst_bin_iterate_elements(
self.as_ref().to_glib_none().0,
))
}
}
fn iterate_recurse(&self) -> ::Iterator<Element> {
unsafe { from_glib_full(ffi::gst_bin_iterate_recurse(self.to_glib_none().0)) }
unsafe { from_glib_full(ffi::gst_bin_iterate_recurse(self.as_ref().to_glib_none().0)) }
}
fn iterate_sinks(&self) -> ::Iterator<Element> {
unsafe { from_glib_full(ffi::gst_bin_iterate_sinks(self.to_glib_none().0)) }
unsafe { from_glib_full(ffi::gst_bin_iterate_sinks(self.as_ref().to_glib_none().0)) }
}
fn iterate_sorted(&self) -> ::Iterator<Element> {
unsafe { from_glib_full(ffi::gst_bin_iterate_sorted(self.to_glib_none().0)) }
unsafe { from_glib_full(ffi::gst_bin_iterate_sorted(self.as_ref().to_glib_none().0)) }
}
fn iterate_sources(&self) -> ::Iterator<Element> {
unsafe { from_glib_full(ffi::gst_bin_iterate_sources(self.to_glib_none().0)) }
unsafe { from_glib_full(ffi::gst_bin_iterate_sources(self.as_ref().to_glib_none().0)) }
}
fn get_children(&self) -> Vec<Element> {
unsafe {
let stash = self.to_glib_none();
let bin: &ffi::GstBin = &*stash.0;
let bin: &ffi::GstBin = &*(self.as_ptr() as *const _);
::utils::MutexGuard::lock(&bin.element.object.lock);
FromGlibPtrContainer::from_glib_none(bin.children)
}

View file

@ -241,7 +241,7 @@ pub trait BufferPoolExtManual: 'static {
impl<O: IsA<BufferPool>> BufferPoolExtManual for O {
fn get_config(&self) -> BufferPoolConfig {
unsafe {
let ptr = ffi::gst_buffer_pool_get_config(self.to_glib_none().0);
let ptr = ffi::gst_buffer_pool_get_config(self.as_ref().to_glib_none().0);
BufferPoolConfig(from_glib_full(ptr))
}
}
@ -249,7 +249,10 @@ impl<O: IsA<BufferPool>> BufferPoolExtManual for O {
fn set_config(&self, config: BufferPoolConfig) -> Result<(), glib::error::BoolError> {
unsafe {
glib_result_from_gboolean!(
ffi::gst_buffer_pool_set_config(self.to_glib_none().0, config.0.into_ptr()),
ffi::gst_buffer_pool_set_config(
self.as_ref().to_glib_none().0,
config.0.into_ptr()
),
"Failed to set config",
)
}
@ -257,7 +260,7 @@ impl<O: IsA<BufferPool>> BufferPoolExtManual for O {
fn is_flushing(&self) -> bool {
unsafe {
let stash = self.to_glib_none();
let stash = self.as_ref().to_glib_none();
let ptr: *mut ffi::GstBufferPool = stash.0;
from_glib((*ptr).flushing)
@ -277,7 +280,7 @@ impl<O: IsA<BufferPool>> BufferPoolExtManual for O {
unsafe {
let mut buffer = ptr::null_mut();
let ret: ::FlowReturn = from_glib(ffi::gst_buffer_pool_acquire_buffer(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
&mut buffer,
params_ptr,
));
@ -288,7 +291,7 @@ impl<O: IsA<BufferPool>> BufferPoolExtManual for O {
fn release_buffer(&self, buffer: ::Buffer) {
unsafe {
ffi::gst_buffer_pool_release_buffer(self.to_glib_none().0, buffer.into_ptr());
ffi::gst_buffer_pool_release_buffer(self.as_ref().to_glib_none().0, buffer.into_ptr());
}
}
}

View file

@ -22,7 +22,7 @@ impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {
fn get_child_property(&self, name: &str) -> Option<glib::Value> {
unsafe {
let found: bool = from_glib(ffi::gst_child_proxy_lookup(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
ptr::null_mut(),
ptr::null_mut(),
@ -33,7 +33,7 @@ impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {
let mut value = glib::Value::uninitialized();
ffi::gst_child_proxy_get_property(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none_mut().0,
);
@ -44,7 +44,7 @@ impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {
fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError> {
unsafe {
let found: bool = from_glib(ffi::gst_child_proxy_lookup(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
ptr::null_mut(),
ptr::null_mut(),
@ -55,7 +55,7 @@ impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {
let value = value.to_value();
ffi::gst_child_proxy_set_property(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none().0,
);

View file

@ -186,7 +186,7 @@ impl<O: IsA<Clock>> ClockExtManual for O {
fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> Option<ClockId> {
unsafe {
from_glib_full(ffi::gst_clock_new_periodic_id(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
start_time.to_glib(),
interval.to_glib(),
))
@ -202,7 +202,7 @@ impl<O: IsA<Clock>> ClockExtManual for O {
skip_assert_initialized!();
unsafe {
let res: bool = from_glib(ffi::gst_clock_periodic_id_reinit(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
id.to_glib_none().0,
start_time.to_glib(),
interval.to_glib(),
@ -218,7 +218,7 @@ impl<O: IsA<Clock>> ClockExtManual for O {
fn new_single_shot_id(&self, time: ClockTime) -> Option<ClockId> {
unsafe {
from_glib_full(ffi::gst_clock_new_single_shot_id(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
time.to_glib(),
))
}
@ -227,7 +227,7 @@ impl<O: IsA<Clock>> ClockExtManual for O {
fn single_shot_id_reinit(&self, id: &ClockId, time: ClockTime) -> Result<(), glib::BoolError> {
unsafe {
let res: bool = from_glib(ffi::gst_clock_single_shot_id_reinit(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
id.to_glib_none().0,
time.to_glib(),
));

View file

@ -8,8 +8,8 @@
use DeviceProvider;
use glib::object::IsA;
use glib::translate::ToGlibPtr;
use glib::IsA;
use std::ffi::CStr;
@ -23,7 +23,7 @@ pub trait DeviceProviderExtManual: 'static {
impl<O: IsA<DeviceProvider>> DeviceProviderExtManual for O {
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str> {
unsafe {
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class
let klass = (*(self.as_ptr() as *mut gobject_ffi::GTypeInstance)).g_class
as *mut ffi::GstDeviceProviderClass;
let ptr = ffi::gst_device_provider_class_get_metadata(klass, key.to_glib_none().0);

View file

@ -10,13 +10,13 @@ use Element;
use glib;
#[cfg(any(feature = "v1_10", feature = "dox"))]
use glib::object::Downcast;
use glib::object::Cast;
use glib::object::{IsA, IsClassFor};
#[cfg(any(feature = "v1_10", feature = "dox"))]
use glib::translate::FromGlibPtrBorrow;
use glib::translate::{
from_glib, from_glib_full, from_glib_none, FromGlib, FromGlibPtrContainer, ToGlib, ToGlibPtr,
};
use glib::{IsA, IsClassFor};
use miniobject::MiniObject;
use ClockTime;
use Event;
@ -50,8 +50,8 @@ impl Element {
for (e1, e2) in elements.iter().zip(elements.iter().skip(1)) {
unsafe {
let ret: bool = from_glib(ffi::gst_element_link(
e1.to_glib_none().0,
e2.to_glib_none().0,
e1.as_ref().to_glib_none().0,
e2.as_ref().to_glib_none().0,
));
if !ret {
return Err(glib_bool_error!("Failed to link elements"));
@ -66,7 +66,7 @@ impl Element {
skip_assert_initialized!();
for (e1, e2) in elements.iter().zip(elements.iter().skip(1)) {
unsafe {
ffi::gst_element_unlink(e1.to_glib_none().0, e2.to_glib_none().0);
ffi::gst_element_unlink(e1.as_ref().to_glib_none().0, e2.as_ref().to_glib_none().0);
}
}
}
@ -216,7 +216,7 @@ pub trait ElementExtManual: 'static {
impl<O: IsA<Element>> ElementExtManual for O {
fn get_element_class(&self) -> &ElementClass {
unsafe {
let klass = (*(self.to_glib_none().0 as *mut gobject_ffi::GTypeInstance)).g_class
let klass = (*(self.as_ptr() as *mut gobject_ffi::GTypeInstance)).g_class
as *const ElementClass;
&*klass
}
@ -228,7 +228,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
) -> Result<StateChangeSuccess, StateChangeError> {
let ret: StateChangeReturn = unsafe {
from_glib(ffi::gst_element_change_state(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
transition.to_glib(),
))
};
@ -241,7 +241,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
) -> Result<StateChangeSuccess, StateChangeError> {
let ret: StateChangeReturn = unsafe {
from_glib(ffi::gst_element_continue_state(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
ret.to_glib(),
))
};
@ -256,7 +256,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
let mut state = mem::uninitialized();
let mut pending = mem::uninitialized();
let ret: StateChangeReturn = from_glib(ffi::gst_element_get_state(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
&mut state,
&mut pending,
timeout.to_glib(),
@ -268,7 +268,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
fn set_state(&self, state: State) -> Result<StateChangeSuccess, StateChangeError> {
let ret: StateChangeReturn = unsafe {
from_glib(ffi::gst_element_set_state(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
state.to_glib(),
))
};
@ -278,7 +278,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
fn query(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_element_query(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
query.as_mut_ptr(),
))
}
@ -287,7 +287,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
fn send_event(&self, event: Event) -> bool {
unsafe {
from_glib(ffi::gst_element_send_event(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
event.into_ptr(),
))
}
@ -323,7 +323,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
};
ffi::gst_element_message_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
type_,
T::domain().to_glib(),
code.code(),
@ -356,7 +356,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
};
ffi::gst_element_message_full_with_details(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
type_,
T::domain().to_glib(),
code.code(),
@ -383,7 +383,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
unsafe {
ffi::gst_element_message_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
ffi::GST_MESSAGE_ERROR,
error_domain.to_glib(),
error_code,
@ -397,21 +397,32 @@ impl<O: IsA<Element>> ElementExtManual for O {
}
fn iterate_pads(&self) -> ::Iterator<Pad> {
unsafe { from_glib_full(ffi::gst_element_iterate_pads(self.to_glib_none().0)) }
unsafe {
from_glib_full(ffi::gst_element_iterate_pads(
self.as_ref().to_glib_none().0,
))
}
}
fn iterate_sink_pads(&self) -> ::Iterator<Pad> {
unsafe { from_glib_full(ffi::gst_element_iterate_sink_pads(self.to_glib_none().0)) }
unsafe {
from_glib_full(ffi::gst_element_iterate_sink_pads(
self.as_ref().to_glib_none().0,
))
}
}
fn iterate_src_pads(&self) -> ::Iterator<Pad> {
unsafe { from_glib_full(ffi::gst_element_iterate_src_pads(self.to_glib_none().0)) }
unsafe {
from_glib_full(ffi::gst_element_iterate_src_pads(
self.as_ref().to_glib_none().0,
))
}
}
fn get_pads(&self) -> Vec<Pad> {
unsafe {
let stash = self.to_glib_none();
let elt: &ffi::GstElement = &*stash.0;
let elt: &ffi::GstElement = &*(self.as_ptr() as *const _);
::utils::MutexGuard::lock(&elt.object.lock);
FromGlibPtrContainer::from_glib_none(elt.pads)
}
@ -419,8 +430,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
fn get_sink_pads(&self) -> Vec<Pad> {
unsafe {
let stash = self.to_glib_none();
let elt: &ffi::GstElement = &*stash.0;
let elt: &ffi::GstElement = &*(self.as_ptr() as *const _);
::utils::MutexGuard::lock(&elt.object.lock);
FromGlibPtrContainer::from_glib_none(elt.sinkpads)
}
@ -428,8 +438,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
fn get_src_pads(&self) -> Vec<Pad> {
unsafe {
let stash = self.to_glib_none();
let elt: &ffi::GstElement = &*stash.0;
let elt: &ffi::GstElement = &*(self.as_ptr() as *const _);
::utils::MutexGuard::lock(&elt.object.lock);
FromGlibPtrContainer::from_glib_none(elt.srcpads)
}
@ -445,7 +454,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
let property_name = property_name.to_glib_none();
unsafe {
from_glib(ffi::gst_element_add_property_deep_notify_watch(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
property_name.0,
include_value.to_glib(),
))
@ -462,7 +471,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
let property_name = property_name.to_glib_none();
unsafe {
from_glib(ffi::gst_element_add_property_notify_watch(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
property_name.0,
include_value.to_glib(),
))
@ -472,7 +481,10 @@ impl<O: IsA<Element>> ElementExtManual for O {
#[cfg(any(feature = "v1_10", feature = "dox"))]
fn remove_property_notify_watch(&self, watch_id: NotifyWatchId) {
unsafe {
ffi::gst_element_remove_property_notify_watch(self.to_glib_none().0, watch_id.0);
ffi::gst_element_remove_property_notify_watch(
self.as_ref().to_glib_none().0,
watch_id.0,
);
}
}
@ -484,7 +496,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
unsafe {
let mut dest_val = mem::uninitialized();
let ret = from_glib(ffi::gst_element_query_convert(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
src_val.get_format().to_glib(),
src_val.to_raw_value(),
U::get_default_format().to_glib(),
@ -507,7 +519,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
unsafe {
let mut dest_val = mem::uninitialized();
let ret = from_glib(ffi::gst_element_query_convert(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
src_val.get_format().to_glib(),
src_val.get_value(),
dest_format.to_glib(),
@ -525,7 +537,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
unsafe {
let mut duration = mem::uninitialized();
let ret = from_glib(ffi::gst_element_query_duration(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
T::get_default_format().to_glib(),
&mut duration,
));
@ -541,7 +553,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
unsafe {
let mut duration = mem::uninitialized();
let ret = from_glib(ffi::gst_element_query_duration(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
format.to_glib(),
&mut duration,
));
@ -557,7 +569,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
unsafe {
let mut cur = mem::uninitialized();
let ret = from_glib(ffi::gst_element_query_position(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
T::get_default_format().to_glib(),
&mut cur,
));
@ -573,7 +585,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
unsafe {
let mut cur = mem::uninitialized();
let ret = from_glib(ffi::gst_element_query_position(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
format.to_glib(),
&mut cur,
));
@ -602,7 +614,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
unsafe {
glib_result_from_gboolean!(
ffi::gst_element_seek(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
rate,
start.get_format().to_glib(),
flags.to_glib(),
@ -625,7 +637,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
unsafe {
glib_result_from_gboolean!(
ffi::gst_element_seek_simple(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
seek_pos.get_format().to_glib(),
seek_flags.to_glib(),
seek_pos.get_value(),
@ -649,7 +661,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
let user_data: &mut Option<Box<F>> = &mut *(user_data as *mut _);
let callback = user_data.take().unwrap();
callback(&Element::from_glib_borrow(element).downcast_unchecked());
callback(&Element::from_glib_borrow(element).unsafe_cast());
}
unsafe extern "C" fn free_user_data<O: IsA<Element>, F: FnOnce(&O) + Send + 'static>(
@ -662,7 +674,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
let free_user_data = free_user_data::<Self, F>;
unsafe {
ffi::gst_element_call_async(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline),
Box::into_raw(user_data) as *mut _,
Some(free_user_data),

View file

@ -7,7 +7,7 @@
// except according to those terms.
use ffi;
use glib::object::Downcast;
use glib::object::Cast;
use glib::object::{IsA, IsClassFor};
use glib::translate::*;
use GhostPad;
@ -24,8 +24,11 @@ impl GhostPad {
let name = name.into();
let name = name.to_glib_none();
unsafe {
Option::<Pad>::from_glib_none(ffi::gst_ghost_pad_new(name.0, target.to_glib_none().0))
.map(|o| Downcast::downcast_unchecked(o))
Option::<Pad>::from_glib_none(ffi::gst_ghost_pad_new(
name.0,
target.as_ref().to_glib_none().0,
))
.map(|o| Cast::unsafe_cast(o))
}
}
@ -40,10 +43,10 @@ impl GhostPad {
unsafe {
Option::<Pad>::from_glib_none(ffi::gst_ghost_pad_new_from_template(
name.0,
target.to_glib_none().0,
target.as_ref().to_glib_none().0,
templ.to_glib_none().0,
))
.map(|o| Downcast::downcast_unchecked(o))
.map(|o| Cast::unsafe_cast(o))
}
}
@ -60,11 +63,10 @@ impl GhostPad {
) -> bool {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_ghost_pad_activate_mode_default(
pad.to_glib_none().0 as *mut ffi::GstPad,
parent.0,
parent.map(|p| p.as_ref()).to_glib_none().0,
mode.to_glib(),
active.to_glib(),
))
@ -84,11 +86,10 @@ impl GhostPad {
) -> bool {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_ghost_pad_internal_activate_mode_default(
pad.to_glib_none().0 as *mut ffi::GstPad,
parent.0,
parent.map(|p| p.as_ref()).to_glib_none().0,
mode.to_glib(),
active.to_glib(),
))

View file

@ -12,7 +12,7 @@ impl<O: IsA<glib::Object>> GObjectExtManualGst for O {
fn set_property_from_str(&self, name: &str, value: &str) {
unsafe {
ffi::gst_util_set_object_arg(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none().0,
);

View file

@ -7,7 +7,7 @@
// except according to those terms.
use glib;
use glib::object::{Downcast, ObjectExt};
use glib::object::{Cast, ObjectExt};
use glib::signal::SignalHandlerId;
use glib::translate::{from_glib_borrow, from_glib_none, ToGlibPtr};
use glib::IsA;
@ -44,10 +44,10 @@ impl<O: IsA<::Object>> GstObjectExtManual for O {
};
let obj: glib::Object =
unsafe { from_glib_borrow(self.to_glib_none().0 as *mut gobject_ffi::GObject) };
unsafe { from_glib_borrow(self.as_ptr() as *mut gobject_ffi::GObject) };
obj.connect(signal_name.as_str(), false, move |values| {
let obj: O = unsafe { values[0].get::<::Object>().unwrap().downcast_unchecked() };
let obj: O = unsafe { values[0].get::<::Object>().unwrap().unsafe_cast() };
let prop_obj: ::Object = values[1].get().unwrap();
let pspec = unsafe {

View file

@ -35,12 +35,12 @@ use std::ops;
use std::ptr;
use glib;
use glib::object::{IsA, IsClassFor};
use glib::translate::{
from_glib, from_glib_borrow, from_glib_full, from_glib_none, mut_override, FromGlib, ToGlib,
ToGlibPtr,
};
use glib::Object;
use glib::{IsA, IsClassFor, StaticType};
use glib::StaticType;
use glib_ffi;
use glib_ffi::gpointer;
@ -127,7 +127,7 @@ pub trait PadExtManual: 'static {
fn peer_query(&self, query: &mut QueryRef) -> bool;
fn query(&self, query: &mut QueryRef) -> bool;
fn query_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(
fn query_default<'a, P: IsA<::Object> + 'a, Q: Into<Option<&'a P>>>(
&self,
parent: Q,
query: &mut QueryRef,
@ -273,7 +273,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static,
> = Box::new(func);
let id = ffi::gst_pad_add_probe(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
mask.to_glib(),
Some(trampoline_pad_probe),
Box::into_raw(Box::new(func_box)) as gpointer,
@ -290,28 +290,34 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn remove_probe(&self, id: PadProbeId) {
unsafe {
ffi::gst_pad_remove_probe(self.to_glib_none().0, id.to_glib());
ffi::gst_pad_remove_probe(self.as_ref().to_glib_none().0, id.to_glib());
}
}
fn chain(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> {
unsafe {
FlowReturn::from_glib(ffi::gst_pad_chain(self.to_glib_none().0, buffer.into_ptr()))
.into_result()
FlowReturn::from_glib(ffi::gst_pad_chain(
self.as_ref().to_glib_none().0,
buffer.into_ptr(),
))
.into_result()
}
}
fn push(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> {
unsafe {
FlowReturn::from_glib(ffi::gst_pad_push(self.to_glib_none().0, buffer.into_ptr()))
.into_result()
FlowReturn::from_glib(ffi::gst_pad_push(
self.as_ref().to_glib_none().0,
buffer.into_ptr(),
))
.into_result()
}
}
fn chain_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> {
unsafe {
FlowReturn::from_glib(ffi::gst_pad_chain_list(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
list.into_ptr(),
))
.into_result()
@ -321,7 +327,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn push_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> {
unsafe {
FlowReturn::from_glib(ffi::gst_pad_push_list(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
list.into_ptr(),
))
.into_result()
@ -332,7 +338,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut buffer = ptr::null_mut();
let ret: FlowReturn = from_glib(ffi::gst_pad_get_range(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
offset,
size,
&mut buffer,
@ -345,7 +351,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut buffer = ptr::null_mut();
let ret: FlowReturn = from_glib(ffi::gst_pad_pull_range(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
offset,
size,
&mut buffer,
@ -357,7 +363,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn query(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_pad_query(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
query.as_mut_ptr(),
))
}
@ -366,24 +372,23 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn peer_query(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_pad_peer_query(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
query.as_mut_ptr(),
))
}
}
fn query_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(
fn query_default<'a, P: IsA<::Object> + 'a, Q: Into<Option<&'a P>>>(
&self,
parent: Q,
query: &mut QueryRef,
) -> bool {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_pad_query_default(
self.to_glib_none().0,
parent.0 as *mut _,
self.as_ref().to_glib_none().0,
parent.map(|p| p.as_ref()).to_glib_none().0,
query.as_mut_ptr(),
))
}
@ -392,7 +397,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_pad_proxy_query_accept_caps(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
query.as_mut_ptr(),
))
}
@ -401,7 +406,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn proxy_query_caps(&self, query: &mut QueryRef) -> bool {
unsafe {
from_glib(ffi::gst_pad_proxy_query_accept_caps(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
query.as_mut_ptr(),
))
}
@ -414,11 +419,10 @@ impl<O: IsA<Pad>> PadExtManual for O {
) -> bool {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_pad_event_default(
self.to_glib_none().0,
parent.0,
self.as_ref().to_glib_none().0,
parent.map(|p| p.as_ref()).to_glib_none().0,
event.into_ptr(),
))
}
@ -427,7 +431,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn push_event(&self, event: Event) -> bool {
unsafe {
from_glib(ffi::gst_pad_push_event(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
event.into_ptr(),
))
}
@ -436,20 +440,27 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn send_event(&self, event: Event) -> bool {
unsafe {
from_glib(ffi::gst_pad_send_event(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
event.into_ptr(),
))
}
}
fn get_last_flow_return(&self) -> Result<FlowSuccess, FlowError> {
let ret: FlowReturn =
unsafe { from_glib(ffi::gst_pad_get_last_flow_return(self.to_glib_none().0)) };
let ret: FlowReturn = unsafe {
from_glib(ffi::gst_pad_get_last_flow_return(
self.as_ref().to_glib_none().0,
))
};
ret.into_result()
}
fn iterate_internal_links(&self) -> ::Iterator<Pad> {
unsafe { from_glib_full(ffi::gst_pad_iterate_internal_links(self.to_glib_none().0)) }
unsafe {
from_glib_full(ffi::gst_pad_iterate_internal_links(
self.as_ref().to_glib_none().0,
))
}
}
fn iterate_internal_links_default<'a, P: IsA<::Object> + 'a, Q: Into<Option<&'a P>>>(
@ -457,11 +468,10 @@ impl<O: IsA<Pad>> PadExtManual for O {
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,
self.as_ref().to_glib_none().0,
parent.map(|p| p.as_ref()).to_glib_none().0,
))
}
}
@ -469,8 +479,8 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn link<P: IsA<Pad>>(&self, sinkpad: &P) -> Result<PadLinkSuccess, PadLinkError> {
let ret: PadLinkReturn = unsafe {
from_glib(ffi::gst_pad_link(
self.to_glib_none().0,
sinkpad.to_glib_none().0,
self.as_ref().to_glib_none().0,
sinkpad.as_ref().to_glib_none().0,
))
};
ret.into_result()
@ -483,8 +493,8 @@ impl<O: IsA<Pad>> PadExtManual for O {
) -> Result<PadLinkSuccess, PadLinkError> {
let ret: PadLinkReturn = unsafe {
from_glib(ffi::gst_pad_link_full(
self.to_glib_none().0,
sinkpad.to_glib_none().0,
self.as_ref().to_glib_none().0,
sinkpad.as_ref().to_glib_none().0,
flags.to_glib(),
))
};
@ -493,9 +503,9 @@ impl<O: IsA<Pad>> PadExtManual for O {
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))
let ptr: &mut ffi::GstPad = &mut *(self.as_ptr() as *mut _);
glib_ffi::g_rec_mutex_lock(&mut ptr.stream_rec_lock);
StreamLock(from_glib_none(ptr as *mut ffi::GstPad))
}
}
@ -508,7 +518,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
let func_box: Box<Fn(&Pad, &Option<::Object>) -> bool + Send + Sync + 'static> =
Box::new(func);
ffi::gst_pad_set_activate_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_activate_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -526,7 +536,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
Fn(&Pad, &Option<::Object>, ::PadMode, bool) -> bool + Send + Sync + 'static,
> = Box::new(func);
ffi::gst_pad_set_activatemode_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_activatemode_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -549,7 +559,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
+ 'static,
> = Box::new(func);
ffi::gst_pad_set_chain_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_chain_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -572,7 +582,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
+ 'static,
> = Box::new(func);
ffi::gst_pad_set_chain_list_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_chain_list_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -589,7 +599,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
Fn(&Pad, &Option<::Object>, ::Event) -> bool + Send + Sync + 'static,
> = Box::new(func);
ffi::gst_pad_set_event_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_event_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -612,7 +622,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
+ 'static,
> = Box::new(func);
ffi::gst_pad_set_event_full_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_event_full_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -636,7 +646,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
+ 'static,
> = Box::new(func);
ffi::gst_pad_set_getrange_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_getrange_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -653,7 +663,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
Fn(&Pad, &Option<::Object>) -> ::Iterator<Pad> + Send + Sync + 'static,
> = Box::new(func);
ffi::gst_pad_set_iterate_internal_links_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_iterate_internal_links_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -676,7 +686,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
+ 'static,
> = Box::new(func);
ffi::gst_pad_set_link_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_link_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -693,7 +703,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
Fn(&Pad, &Option<::Object>, &mut ::QueryRef) -> bool + Send + Sync + 'static,
> = Box::new(func);
ffi::gst_pad_set_query_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_query_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -708,7 +718,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let func_box: Box<Fn(&Pad, &Option<::Object>) + Send + Sync + 'static> = Box::new(func);
ffi::gst_pad_set_unlink_function_full(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_unlink_function),
Box::into_raw(Box::new(func_box)) as gpointer,
Some(destroy_closure),
@ -720,7 +730,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
glib_result_from_gboolean!(
ffi::gst_pad_start_task(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
Some(trampoline_pad_task),
into_raw_pad_task(func),
Some(destroy_closure_pad_task),
@ -738,7 +748,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut dest_val = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_peer_query_convert(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
src_val.get_format().to_glib(),
src_val.to_raw_value(),
U::get_default_format().to_glib(),
@ -761,7 +771,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut dest_val = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_peer_query_convert(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
src_val.get_format().to_glib(),
src_val.to_raw_value(),
dest_format.to_glib(),
@ -779,7 +789,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut duration = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_peer_query_duration(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
T::get_default_format().to_glib(),
&mut duration,
));
@ -795,7 +805,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut duration = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_peer_query_duration(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
format.to_glib(),
&mut duration,
));
@ -811,7 +821,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut cur = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_peer_query_position(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
T::get_default_format().to_glib(),
&mut cur,
));
@ -827,7 +837,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut cur = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_peer_query_position(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
format.to_glib(),
&mut cur,
));
@ -848,7 +858,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut dest_val = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_query_convert(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
src_val.get_format().to_glib(),
src_val.to_raw_value(),
U::get_default_format().to_glib(),
@ -872,7 +882,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut dest_val = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_query_convert(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
src_val.get_format().to_glib(),
src_val.get_value(),
dest_format.to_glib(),
@ -890,7 +900,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut duration = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_query_duration(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
T::get_default_format().to_glib(),
&mut duration,
));
@ -906,7 +916,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut duration = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_query_duration(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
format.to_glib(),
&mut duration,
));
@ -922,7 +932,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut cur = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_query_position(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
T::get_default_format().to_glib(),
&mut cur,
));
@ -938,7 +948,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe {
let mut cur = mem::uninitialized();
let ret = from_glib(ffi::gst_pad_query_position(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
format.to_glib(),
&mut cur,
));
@ -952,8 +962,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn get_mode(&self) -> ::PadMode {
unsafe {
let stash = self.to_glib_none();
let ptr: &ffi::GstPad = &*stash.0;
let ptr: &ffi::GstPad = &*(self.as_ptr() as *const _);
from_glib(ptr.mode)
}
}
@ -998,14 +1007,18 @@ impl<O: IsA<Pad>> PadExtManual for O {
as *const &mut (FnMut(Event) -> Result<Option<Event>, Option<Event>>)
as glib_ffi::gpointer;
ffi::gst_pad_sticky_events_foreach(self.to_glib_none().0, Some(trampoline), func_ptr);
ffi::gst_pad_sticky_events_foreach(
self.as_ref().to_glib_none().0,
Some(trampoline),
func_ptr,
);
}
}
fn store_sticky_event(&self, event: &Event) -> Result<FlowSuccess, FlowError> {
let ret: FlowReturn = unsafe {
from_glib(ffi::gst_pad_store_sticky_event(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
event.to_glib_none().0,
))
};

View file

@ -16,8 +16,8 @@ use Object;
use Pad;
use ProxyPad;
use glib::object::IsA;
use glib::translate::{from_glib, from_glib_full, ToGlibPtr};
use glib::IsA;
use ffi;
@ -29,11 +29,10 @@ impl ProxyPad {
) -> Result<FlowSuccess, FlowError> {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
let ret: FlowReturn = unsafe {
from_glib(ffi::gst_proxy_pad_chain_default(
pad.to_glib_none().0 as *mut ffi::GstPad,
parent.0,
pad.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
buffer.into_ptr(),
))
};
@ -47,11 +46,10 @@ impl ProxyPad {
) -> Result<FlowSuccess, FlowError> {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
let ret: FlowReturn = unsafe {
from_glib(ffi::gst_proxy_pad_chain_list_default(
pad.to_glib_none().0 as *mut ffi::GstPad,
parent.0,
pad.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
list.into_ptr(),
))
};
@ -68,8 +66,8 @@ impl ProxyPad {
unsafe {
let mut buffer = ptr::null_mut();
let ret: FlowReturn = from_glib(ffi::gst_proxy_pad_getrange_default(
pad.to_glib_none().0 as *mut ffi::GstPad,
parent.to_glib_none().0,
pad.as_ptr() as *mut ffi::GstPad,
parent.as_ref().to_glib_none().0,
offset,
size,
&mut buffer,
@ -89,11 +87,10 @@ impl ProxyPad {
) -> Option<::Iterator<Pad>> {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib_full(ffi::gst_proxy_pad_iterate_internal_links_default(
pad.to_glib_none().0 as *mut ffi::GstPad,
parent.0,
pad.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0,
))
}
}

View file

@ -152,7 +152,7 @@ where
) -> R {
unsafe {
assert!(element.get_type().is_a(&T::get_type()));
let ptr: *mut ffi::GstElement = element.to_glib_none().0;
let ptr: *mut ffi::GstElement = element.as_ptr() as *mut _;
let instance = &*(ptr as *mut T::Instance);
let imp = instance.get_impl();

View file

@ -39,7 +39,7 @@ use std::sync::atomic::AtomicBool;
#[repr(C)]
pub struct ElementInstanceStruct<T: ObjectSubclass> {
parent: <T::ParentType as glib::wrapper::Wrapper>::GlibType,
parent: <T::ParentType as glib::object::ObjectType>::GlibType,
panicked: AtomicBool,
}

View file

@ -29,7 +29,7 @@ impl<O: IsA<TagSetter>> TagSetterExtManual for O {
let v = value.to_send_value();
ffi::gst_tag_setter_add_tag_value(
self.to_glib_none().0,
self.as_ref().to_glib_none().0,
mode.to_glib(),
T::tag_name().to_glib_none().0,
v.to_glib_none().0,

View file

@ -4,7 +4,7 @@ mod tutorial5 {
use std::process;
extern crate glib;
use self::glib::translate::*;
use self::glib::object::ObjectType;
use self::glib::*;
extern crate gdk;
@ -223,7 +223,7 @@ mod tutorial5 {
}
unsafe {
let xid = gdk_x11_window_get_xid(gdk_window.to_glib_none().0);
let xid = gdk_x11_window_get_xid(gdk_window.as_ptr() as *mut _);
video_overlay.set_window_handle(xid as usize);
}
} else {
@ -239,7 +239,7 @@ mod tutorial5 {
}
unsafe {
let window = gdk_quartz_window_get_nsview(gdk_window.to_glib_none().0);
let window = gdk_quartz_window_get_nsview(gdk_window.as_ptr() as *mut _);
video_overlay.set_window_handle(window as usize);
}
} else {