Commit 931c4851 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Update manual code for glib API changes

parent 6da0a9d1
......@@ -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 {
......
......@@ -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();
......
......@@ -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 _,
......
......@@ -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(),
))
};
......
......@@ -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)
}
......
......@@ -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()
}
}
......
......@@ -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()
}
}
......
......@@ -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 _)
}
......
......@@ -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(),
))
};
......
......@@ -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,
......
......@@ -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,
))
......
......@@ -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,
);
......
......@@ -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);
}
}
}
......@@ -23,53 +23,47 @@ 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 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 }
}
pub fn get_proc_address_with_platform(
context_type: GLPlatform,
gl_api: GLAPI,
name: &str,
) -> uintptr_t {
unsafe {
ffi::gst_gl_context_get_proc_address_with_platform(
context_type.to_glib(),
gl_api.to_glib(),
name.to_glib_none().0,
) as uintptr_t
}
}
}
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 }
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.to_glib_none().0, name.to_glib_none().0)
as uintptr_t
}
}
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(
context_type: GLPlatform,
gl_api: GLAPI,
name: &str,
) -> uintptr_t {
unsafe {
ffi::gst_gl_context_get_proc_address_with_platform(
context_type.to_glib(),
gl_api.to_glib(),
ffi::gst_gl_context_get_proc_address(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
) as uintptr_t
}
......
......@@ -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()
}
}
}
......
......@@ -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,
))
......
......@@ -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()
}
}
}
......
......@@ -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()
}
}
}
......
......@@ -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())
}
......@@ -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 {