forked from mirrors/gstreamer-rs
gstreamer: Allow borrowing Segment
s from Value
s without copying
This commit is contained in:
parent
c9d07219c8
commit
20ac231146
3 changed files with 19 additions and 2 deletions
|
@ -245,7 +245,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
|
||||||
let f: &F = &*(f as *const F);
|
let f: &F = &*(f as *const F);
|
||||||
f(
|
f(
|
||||||
Aggregator::from_glib_borrow(this).unsafe_cast_ref(),
|
Aggregator::from_glib_borrow(this).unsafe_cast_ref(),
|
||||||
&gst::Segment::from_glib_borrow(segment),
|
gst::Segment::from_ptr(segment),
|
||||||
from_glib(pts),
|
from_glib(pts),
|
||||||
from_glib(dts),
|
from_glib(dts),
|
||||||
from_glib(duration),
|
from_glib(duration),
|
||||||
|
|
|
@ -173,7 +173,7 @@ impl SampleRef {
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(&*(ptr as *const crate::Segment))
|
Some(crate::Segment::from_ptr(ptr))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,11 @@ pub type Segment = FormattedSegment<GenericFormattedValue>;
|
||||||
pub struct FormattedSegment<T: FormattedValueIntrinsic>(ffi::GstSegment, PhantomData<T>);
|
pub struct FormattedSegment<T: FormattedValueIntrinsic>(ffi::GstSegment, PhantomData<T>);
|
||||||
|
|
||||||
impl Segment {
|
impl Segment {
|
||||||
|
pub unsafe fn from_ptr<'a>(ptr: *const ffi::GstSegment) -> &'a Segment {
|
||||||
|
assert!(!ptr.is_null());
|
||||||
|
&*(ptr as *const Self)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn reset_with_format(&mut self, format: Format) {
|
pub fn reset_with_format(&mut self, format: Format) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_segment_init(self.to_glib_none_mut().0, format.into_glib());
|
ffi::gst_segment_init(self.to_glib_none_mut().0, format.into_glib());
|
||||||
|
@ -649,6 +654,18 @@ unsafe impl<'a> glib::value::FromValue<'a> for Segment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
unsafe impl<'a> glib::value::FromValue<'a> for &'a Segment {
|
||||||
|
type Checker = glib::value::GenericValueTypeOrNoneChecker<Self>;
|
||||||
|
|
||||||
|
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||||
|
skip_assert_initialized!();
|
||||||
|
Segment::from_ptr(
|
||||||
|
glib::gobject_ffi::g_value_get_boxed(value.to_glib_none().0) as *const ffi::GstSegment
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
impl<T: FormattedValueIntrinsic> glib::value::ToValue for FormattedSegment<T> {
|
impl<T: FormattedValueIntrinsic> glib::value::ToValue for FormattedSegment<T> {
|
||||||
fn to_value(&self) -> glib::Value {
|
fn to_value(&self) -> glib::Value {
|
||||||
|
|
Loading…
Reference in a new issue