Commit 6cef32a4 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵 Committed by Sebastian Dröge

Change various mini object references to references to the refcounted object

Fixes #204
parent e6f65a50
......@@ -641,7 +641,7 @@ fn main_loop(mut app: App) -> Result<glutin::WindowedContext<glutin::PossiblyCur
// get the last frame in channel
if let Some(sample) = receiver.try_iter().last() {
let buffer = sample.get_buffer().unwrap();
let buffer = sample.get_buffer_owned().unwrap();
let info = sample
.get_caps()
.and_then(|caps| gst_video::VideoInfo::from_caps(caps))
......@@ -660,9 +660,7 @@ fn main_loop(mut app: App) -> Result<glutin::WindowedContext<glutin::PossiblyCur
sync_meta.set_sync_point(gst_gl_context.as_ref().unwrap());
}
if let Ok(frame) =
gst_video::VideoFrame::from_buffer_readable_gl(buffer.to_owned(), &info)
{
if let Ok(frame) = gst_video::VideoFrame::from_buffer_readable_gl(buffer, &info) {
curr_frame = Some(frame);
}
}
......
......@@ -105,7 +105,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati
aggregator: &Aggregator,
templ: &gst::PadTemplate,
req_name: Option<&str>,
caps: Option<&gst::CapsRef>,
caps: Option<&gst::Caps>,
) -> Option<AggregatorPad> {
self.parent_create_new_pad(aggregator, templ, req_name, caps)
}
......@@ -113,7 +113,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati
fn update_src_caps(
&self,
aggregator: &Aggregator,
caps: &gst::CapsRef,
caps: &gst::Caps,
) -> Result<gst::Caps, gst::FlowError> {
self.parent_update_src_caps(aggregator, caps)
}
......@@ -125,7 +125,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati
fn negotiated_src_caps(
&self,
aggregator: &Aggregator,
caps: &gst::CapsRef,
caps: &gst::Caps,
) -> Result<(), gst::LoggableError> {
self.parent_negotiated_src_caps(aggregator, caps)
}
......@@ -189,13 +189,13 @@ pub trait AggregatorImplExt {
aggregator: &Aggregator,
templ: &gst::PadTemplate,
req_name: Option<&str>,
caps: Option<&gst::CapsRef>,
caps: Option<&gst::Caps>,
) -> Option<AggregatorPad>;
fn parent_update_src_caps(
&self,
aggregator: &Aggregator,
caps: &gst::CapsRef,
caps: &gst::Caps,
) -> Result<gst::Caps, gst::FlowError>;
fn parent_fixate_src_caps(&self, aggregator: &Aggregator, caps: gst::Caps) -> gst::Caps;
......@@ -203,7 +203,7 @@ pub trait AggregatorImplExt {
fn parent_negotiated_src_caps(
&self,
aggregator: &Aggregator,
caps: &gst::CapsRef,
caps: &gst::Caps,
) -> Result<(), gst::LoggableError>;
}
......@@ -426,7 +426,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
aggregator: &Aggregator,
templ: &gst::PadTemplate,
req_name: Option<&str>,
caps: Option<&gst::CapsRef>,
caps: Option<&gst::Caps>,
) -> Option<AggregatorPad> {
unsafe {
let data = self.get_type_data();
......@@ -439,7 +439,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
aggregator.to_glib_none().0,
templ.to_glib_none().0,
req_name.to_glib_none().0,
caps.map(|c| c.as_ptr()).unwrap_or(ptr::null()),
caps.to_glib_none().0,
))
}
}
......@@ -447,7 +447,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
fn parent_update_src_caps(
&self,
aggregator: &Aggregator,
caps: &gst::CapsRef,
caps: &gst::Caps,
) -> Result<gst::Caps, gst::FlowError> {
unsafe {
let data = self.get_type_data();
......@@ -483,7 +483,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
fn parent_negotiated_src_caps(
&self,
aggregator: &Aggregator,
caps: &gst::CapsRef,
caps: &gst::Caps,
) -> Result<(), gst::LoggableError> {
unsafe {
let data = self.get_type_data();
......@@ -493,7 +493,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
.negotiated_src_caps
.map(|f| {
gst_result_from_gboolean!(
f(aggregator.to_glib_none().0, caps.as_mut_ptr()),
f(aggregator.to_glib_none().0, caps.to_glib_none().0),
gst::CAT_RUST,
"Parent function `negotiated_src_caps` failed"
)
......@@ -822,11 +822,7 @@ where
&wrap,
&from_glib_borrow(templ),
req_name,
if caps.is_null() {
None
} else {
Some(gst::CapsRef::from_ptr(caps))
},
Option::<gst::Caps>::from_glib_borrow(caps).as_ref(),
)
})
.to_glib_full()
......@@ -849,7 +845,7 @@ where
*res = ptr::null_mut();
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
match imp.update_src_caps(&wrap, gst::CapsRef::from_ptr(caps)) {
match imp.update_src_caps(&wrap, &from_glib_borrow(caps)) {
Ok(res_caps) => {
*res = res_caps.into_ptr();
gst::FlowReturn::Ok
......@@ -893,7 +889,7 @@ where
let wrap: Aggregator = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.negotiated_src_caps(&wrap, gst::CapsRef::from_ptr(caps)) {
match imp.negotiated_src_caps(&wrap, &from_glib_borrow(caps)) {
Ok(()) => true,
Err(err) => {
err.log_with_object(&wrap);
......
......@@ -34,7 +34,7 @@ pub trait AggregatorPadImpl: AggregatorPadImplExt + PadImpl + Send + Sync + 'sta
&self,
aggregator_pad: &AggregatorPad,
aggregator: &Aggregator,
buffer: &gst::BufferRef,
buffer: &gst::Buffer,
) -> bool {
self.parent_skip_buffer(aggregator_pad, aggregator, buffer)
}
......@@ -51,7 +51,7 @@ pub trait AggregatorPadImplExt {
&self,
aggregator_pad: &AggregatorPad,
aggregator: &Aggregator,
buffer: &gst::BufferRef,
buffer: &gst::Buffer,
) -> bool;
}
......@@ -82,7 +82,7 @@ impl<T: AggregatorPadImpl + ObjectImpl> AggregatorPadImplExt for T {
&self,
aggregator_pad: &AggregatorPad,
aggregator: &Aggregator,
buffer: &gst::BufferRef,
buffer: &gst::Buffer,
) -> bool {
unsafe {
let data = self.get_type_data();
......@@ -94,7 +94,7 @@ impl<T: AggregatorPadImpl + ObjectImpl> AggregatorPadImplExt for T {
from_glib(f(
aggregator_pad.to_glib_none().0,
aggregator.to_glib_none().0,
buffer.as_mut_ptr(),
buffer.to_glib_none().0,
))
})
.unwrap_or(false)
......@@ -144,7 +144,7 @@ where
imp.skip_buffer(
&wrap,
&from_glib_borrow(aggregator),
gst::BufferRef::from_ptr(buffer),
&from_glib_borrow(buffer),
)
.to_glib()
}
This diff is collapsed.
......@@ -70,7 +70,7 @@ pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl + Send + Sync + 'static {
self.parent_event(element, event)
}
fn get_caps(&self, element: &BaseSrc, filter: Option<&gst::CapsRef>) -> Option<gst::Caps> {
fn get_caps(&self, element: &BaseSrc, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
self.parent_get_caps(element, filter)
}
......@@ -78,7 +78,7 @@ pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl + Send + Sync + 'static {
self.parent_negotiate(element)
}
fn set_caps(&self, element: &BaseSrc, caps: &gst::CapsRef) -> Result<(), gst::LoggableError> {
fn set_caps(&self, element: &BaseSrc, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
self.parent_set_caps(element, caps)
}
......@@ -125,18 +125,14 @@ pub trait BaseSrcImplExt {
fn parent_event(&self, element: &BaseSrc, event: &gst::Event) -> bool;
fn parent_get_caps(
&self,
element: &BaseSrc,
filter: Option<&gst::CapsRef>,
) -> Option<gst::Caps>;
fn parent_get_caps(&self, element: &BaseSrc, filter: Option<&gst::Caps>) -> Option<gst::Caps>;
fn parent_negotiate(&self, element: &BaseSrc) -> Result<(), gst::LoggableError>;
fn parent_set_caps(
&self,
element: &BaseSrc,
caps: &gst::CapsRef,
caps: &gst::Caps,
) -> Result<(), gst::LoggableError>;
fn parent_fixate(&self, element: &BaseSrc, caps: gst::Caps) -> gst::Caps;
......@@ -308,24 +304,15 @@ impl<T: BaseSrcImpl + ObjectImpl> BaseSrcImplExt for T {
}
}
fn parent_get_caps(
&self,
element: &BaseSrc,
filter: Option<&gst::CapsRef>,
) -> Option<gst::Caps> {
fn parent_get_caps(&self, element: &BaseSrc, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
unsafe {
let data = self.get_type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
let filter_ptr = if let Some(filter) = filter {
filter.as_mut_ptr()
} else {
ptr::null_mut()
};
(*parent_class)
.get_caps
.map(|f| from_glib_full(f(element.to_glib_none().0, filter_ptr)))
.map(|f| from_glib_full(f(element.to_glib_none().0, filter.to_glib_none().0)))
.unwrap_or(None)
}
}
......@@ -351,7 +338,7 @@ impl<T: BaseSrcImpl + ObjectImpl> BaseSrcImplExt for T {
fn parent_set_caps(
&self,
element: &BaseSrc,
caps: &gst::CapsRef,
caps: &gst::Caps,
) -> Result<(), gst::LoggableError> {
unsafe {
let data = self.get_type_data();
......@@ -361,7 +348,7 @@ impl<T: BaseSrcImpl + ObjectImpl> BaseSrcImplExt for T {
.set_caps
.map(|f| {
gst_result_from_gboolean!(
f(element.to_glib_none().0, caps.as_mut_ptr()),
f(element.to_glib_none().0, caps.to_glib_none().0),
gst::CAT_RUST,
"Parent function `set_caps` failed"
)
......@@ -666,14 +653,10 @@ where
let instance = &*(ptr as *mut T::Instance);
let imp = instance.get_impl();
let wrap: BaseSrc = from_glib_borrow(ptr);
let filter = if filter.is_null() {
None
} else {
Some(gst::CapsRef::from_ptr(filter))
};
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
imp.get_caps(&wrap, filter)
imp.get_caps(&wrap, filter.as_ref())
})
.map(|caps| caps.into_ptr())
.unwrap_or(ptr::null_mut())
......@@ -715,10 +698,10 @@ where
let instance = &*(ptr as *mut T::Instance);
let imp = instance.get_impl();
let wrap: BaseSrc = from_glib_borrow(ptr);
let caps = gst::CapsRef::from_ptr(caps);
let caps = from_glib_borrow(caps);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.set_caps(&wrap, caps) {
match imp.set_caps(&wrap, &caps) {
Ok(()) => true,
Err(err) => {
err.log_with_object(&wrap);
......
......@@ -114,7 +114,7 @@ pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl + Send + Sync +
fn transform_ip_passthrough(
&self,
element: &BaseTransform,
buf: &gst::BufferRef,
buf: &gst::Buffer,
) -> Result<gst::FlowSuccess, gst::FlowError> {
self.parent_transform_ip_passthrough(element, buf)
}
......@@ -193,7 +193,7 @@ pub trait BaseTransformImplExt {
fn parent_transform_ip_passthrough(
&self,
element: &BaseTransform,
buf: &gst::BufferRef,
buf: &gst::Buffer,
) -> Result<gst::FlowSuccess, gst::FlowError>;
}
......@@ -503,7 +503,7 @@ impl<T: BaseTransformImpl + ObjectImpl> BaseTransformImplExt for T {
}
});
gst::FlowReturn::from_glib(f(element.to_glib_none().0, &mut buf.as_mut_ptr()))
gst::FlowReturn::from_glib(f(element.to_glib_none().0, buf.as_mut_ptr() as *mut _))
.into_result()
}
}
......@@ -511,7 +511,7 @@ impl<T: BaseTransformImpl + ObjectImpl> BaseTransformImplExt for T {
fn parent_transform_ip_passthrough(
&self,
element: &BaseTransform,
buf: &gst::BufferRef,
buf: &gst::Buffer,
) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
let data = self.get_type_data();
......@@ -531,8 +531,9 @@ impl<T: BaseTransformImpl + ObjectImpl> BaseTransformImplExt for T {
}
});
gst::FlowReturn::from_glib(f(element.to_glib_none().0, &mut buf.as_mut_ptr()))
.into_result()
// FIXME: Wrong signature in FFI
let buf: *mut gst_sys::GstBuffer = buf.to_glib_none().0;
gst::FlowReturn::from_glib(f(element.to_glib_none().0, buf as *mut _)).into_result()
}
}
}
......@@ -920,7 +921,7 @@ where
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
if from_glib(gst_base_sys::gst_base_transform_is_passthrough(ptr)) {
imp.transform_ip_passthrough(&wrap, gst::BufferRef::from_ptr(buf))
imp.transform_ip_passthrough(&wrap, &from_glib_borrow(buf))
.into()
} else {
imp.transform_ip(&wrap, gst::BufferRef::from_mut_ptr(buf))
......
......@@ -9,7 +9,7 @@
use std::fmt;
use glib;
use glib::translate::{from_glib, ToGlib};
use glib::translate::{from_glib, from_glib_none, ToGlib};
use gst;
use gst::prelude::*;
use gst_sys;
......@@ -154,6 +154,10 @@ impl VideoOverlayCompositionMeta {
unsafe { ::VideoOverlayCompositionRef::from_ptr(self.0.overlay) }
}
pub fn get_overlay_owned(&self) -> ::VideoOverlayComposition {
unsafe { from_glib_none(self.get_overlay().as_ptr()) }
}
pub fn set_overlay(&mut self, overlay: &::VideoOverlayComposition) {
#![allow(clippy::cast_ptr_alignment)]
unsafe {
......
......@@ -13,7 +13,7 @@ use gst::miniobject::*;
use gst_video_sys;
use glib;
use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib};
use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr};
gst_define_mini_object_wrapper!(
VideoOverlayRectangle,
......@@ -35,7 +35,7 @@ impl fmt::Debug for VideoOverlayRectangleRef {
impl VideoOverlayRectangle {
pub fn new_raw(
buffer: &gst::BufferRef,
buffer: &gst::Buffer,
render_x: i32,
render_y: i32,
render_width: u32,
......@@ -45,7 +45,7 @@ impl VideoOverlayRectangle {
assert!(buffer.get_meta::<::VideoMeta>().is_some());
unsafe {
from_glib_full(gst_video_sys::gst_video_overlay_rectangle_new_raw(
buffer.as_mut_ptr(),
buffer.to_glib_none().0,
render_x,
render_y,
render_width,
......
......@@ -7,7 +7,7 @@
// except according to those terms.
use glib;
use glib::translate::from_glib_full;
use glib::translate::{from_glib_full, from_glib_none};
use gst_sys;
use std::fmt;
......@@ -65,6 +65,13 @@ impl BufferListRef {
}
}
pub fn get_owned(&self, idx: u32) -> Option<Buffer> {
unsafe {
let ptr = gst_sys::gst_buffer_list_get(self.as_mut_ptr(), idx);
from_glib_none(ptr)
}
}
#[cfg(any(feature = "v1_14", feature = "dox"))]
pub fn get_writable(&mut self, idx: u32) -> Option<&mut BufferRef> {
unsafe {
......@@ -93,6 +100,10 @@ impl BufferListRef {
pub fn iter(&self) -> Iter {
Iter::new(self)
}
pub fn iter_owned(&self) -> IterOwned {
IterOwned::new(self)
}
}
impl Default for BufferList {
......@@ -119,58 +130,70 @@ impl fmt::Debug for BufferListRef {
}
}
#[derive(Debug)]
pub struct Iter<'a> {
list: &'a BufferListRef,
idx: u32,
size: u32,
}
impl<'a> Iter<'a> {
fn new(list: &'a BufferListRef) -> Iter<'a> {
skip_assert_initialized!();
Iter {
list,
idx: 0,
size: list.len() as u32,
macro_rules! define_iter(
($name:ident, $styp:ty, $get_item:expr) => {
#[derive(Debug)]
pub struct $name<'a> {
list: &'a BufferListRef,
idx: u32,
size: u32,
}
impl<'a> $name<'a> {
fn new(list: &'a BufferListRef) -> $name<'a> {
skip_assert_initialized!();
$name {
list,
idx: 0,
size: list.len() as u32,
}
}
}
}
impl<'a> Iterator for Iter<'a> {
type Item = &'a BufferRef;
fn next(&mut self) -> Option<Self::Item> {
if self.idx >= self.size {
return None;
}
impl<'a> Iterator for $name<'a> {
type Item = $styp;
let item = self.list.get(self.idx);
self.idx += 1;
fn next(&mut self) -> Option<Self::Item> {
if self.idx >= self.size {
return None;
}
item
}
let item = $get_item(self.list, self.idx)?;
self.idx += 1;
fn size_hint(&self) -> (usize, Option<usize>) {
if self.idx == self.size {
return (0, Some(0));
Some(item)
}
let remaining = (self.size - self.idx) as usize;
fn size_hint(&self) -> (usize, Option<usize>) {
if self.idx == self.size {
return (0, Some(0));
}
let remaining = (self.size - self.idx) as usize;
(remaining, Some(remaining))
(remaining, Some(remaining))
}
}
}
impl<'a> DoubleEndedIterator for Iter<'a> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.idx == self.size {
return None;
impl<'a> DoubleEndedIterator for $name<'a> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.idx == self.size {
return None;
}
self.size -= 1;
$get_item(self.list, self.size)
}
}
self.size -= 1;
self.list.get(self.size)
impl<'a> ExactSizeIterator for $name<'a> {}
}
}
);
define_iter!(Iter, &'a BufferRef, |list: &'a BufferListRef, idx| {
list.get(idx)
});
impl<'a> ExactSizeIterator for Iter<'a> {}
define_iter!(IterOwned, Buffer, |list: &BufferListRef, idx| {
list.get_owned(idx)
});
......@@ -19,7 +19,7 @@ use std::ops::Deref;
use std::ptr;
use glib;
use glib::translate::{from_glib, from_glib_full, FromGlib, ToGlib, ToGlibPtr};
use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlib, ToGlib, ToGlibPtr};
use glib::value::ToSendValue;
#[cfg(any(feature = "v1_10", feature = "dox"))]
......@@ -571,6 +571,10 @@ impl<'a> Caps<'a> {
::CapsRef::from_ptr(caps)
}
}
pub fn get_caps_owned(&self) -> ::Caps {
unsafe { from_glib_none(self.get_caps().as_ptr()) }
}
}
declare_concrete_event!(Segment);
......@@ -608,6 +612,10 @@ impl<'a> Tag<'a> {
::TagListRef::from_ptr(tags)
}
}
pub fn get_tag_owned(&self) -> ::TagList {
unsafe { from_glib_none(self.get_tag().as_ptr()) }
}
}
declare_concrete_event!(BufferSize);
......@@ -674,6 +682,13 @@ impl<'a> Toc<'a> {
(::TocRef::from_ptr(toc), from_glib(updated))
}
}
pub fn get_toc_owned(&self) -> (::Toc, bool) {
unsafe {
let (toc, updated) = self.get_toc();
(from_glib_none(toc.as_ptr()), updated)
}
}
}
declare_concrete_event!(Protection);
......@@ -702,6 +717,13 @@ impl<'a> Protection<'a> {
)
}
}
pub fn get_owned(&self) -> (&'a str, ::Buffer, Option<&'a str>) {
unsafe {
let (system_id, buffer, origin) = self.get();
(system_id, from_glib_none(buffer.as_ptr()), origin)
}
}
}
declare_concrete_event!(SegmentDone);
......
......@@ -11,10 +11,11 @@ use std::marker::PhantomData;
use std::ops;
use miniobject::MiniObject;
use Buffer;
use BufferRef;
use glib;
use glib::translate::{from_glib, FromGlib};
use glib::translate::{from_glib, from_glib_none, FromGlib, ToGlibPtr};
use glib_sys;
use gst_sys;
......@@ -227,14 +228,11 @@ impl fmt::Debug for Meta {
pub struct ParentBufferMeta(gst_sys::GstParentBufferMeta);
impl ParentBufferMeta {
pub fn add<'a>(
buffer: &'a mut BufferRef,
parent: &BufferRef,
) -> MetaRefMut<'a, Self, Standalone> {
pub fn add<'a>(buffer: &'a mut BufferRef, parent: &Buffer) -> MetaRefMut<'a, Self, Standalone> {
unsafe {
let meta = gst_sys::gst_buffer_add_parent_buffer_meta(
buffer.as_mut_ptr(),
parent.as_mut_ptr(),
parent.to_glib_none().0,
);
Self::from_mut_ptr(buffer, meta)
......@@ -244,6 +242,10 @@ impl ParentBufferMeta {
pub fn get_parent(&self) -> &BufferRef {
unsafe { BufferRef::from_ptr(self.0.buffer) }
}
pub fn get_parent_owned(&self) -> Buffer {
unsafe { from_glib_none(self.0.buffer) }
}
}
unsafe impl MetaAPI for ParentBufferMeta {
......@@ -273,7 +275,7 @@ mod tests {
let mut buffer = ::Buffer::new();
let parent = ::Buffer::new();
{
let meta = ParentBufferMeta::add(buffer.get_mut().unwrap(), &*parent);
let meta = ParentBufferMeta::add(buffer.get_mut().unwrap(), &parent);
unsafe {
assert_eq!(meta.get_parent().as_ptr(), parent.as_ptr());
}
......
......@@ -914,6 +914,13 @@ impl<T: AsPtr> Allocation<T> {
}
}
pub fn get_owned(&self) -> (::Caps, bool) {
unsafe {
let (caps, need_pool) = self.get();
(from_glib_none(caps.as_ptr()), need_pool)
}
}
pub fn get_allocation_pools(&self) -> Vec<(Option<::BufferPool>, u32, u32, u32)> {
unsafe {
let n = gst_sys::gst_query_get_n_allocation_pools(self.0.as_ptr());
......@@ -1141,6 +1148,10 @@ impl<T: AsPtr> AcceptCaps<T> {
}
}
pub fn get_caps_owned(&self) -> ::Caps {
unsafe { from_glib_none(self.get_caps().as_ptr()) }
}
pub fn get_result(&self) -> bool {
unsafe {
let mut accepted = mem::uninitialized();
......@@ -1172,6 +1183,10 @@ impl<T: AsPtr> Caps<T> {
}
}
pub fn get_filter_owned(&self) -> Option<::Caps> {
unsafe { self.get_filter().map(|caps| from_glib_none(caps.as_ptr())) }
}
pub fn get_result(&self) -> Option<&::CapsRef> {
unsafe {
let mut caps = ptr::null_mut();
......@@ -1183,6 +1198,10 @@ impl<T: AsPtr> Caps<T> {
}
}
}
pub fn get_result_owned(&self) -> Option<::Caps> {
unsafe { self.get_result().map(|caps| from_glib_none(caps.as_ptr())) }
}
}
impl<T: AsMutPtr> Caps<T> {
......@@ -1209,6 +1228,13 @@ impl<T: AsPtr> Context<T> {
}
}
pub fn get_context_owned(&self) -> Option<::Context> {
unsafe {
self.get_context()
.map(|context| from_glib_none(context.as_ptr()))
}
}
pub fn get_context_type(&self) -> &str {
unsafe {
let mut context_type = ptr::null();
......
......@@ -15,8 +15,11 @@ use glib;
use glib::translate::{from_glib_full, from_glib_none, mut_override, ToGlibPtr};
use miniobject::*;
use Buffer;
use BufferList;