mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-28 20:41:31 +00:00
Implement FormattedValue on any candidate type
The trait FormattedValue was only implemented on types which could implement the full range of values for a Format. In order to declare a function which could take both the intrinsic type of any Format (e.g. `ClockTime`) as well the full range of values (e.g. `Option<ClockTime>`), the argument was declared: ```rust impl Into<GenericFormattedValue>, ``` This commit implements `FormattedValue` for any type representing a format. E.g.: both `ClockTime` and `Option<ClockTime>` will now implement `FormattedValue`. The trait `FormattedValueFullRange` is implemented on types which can be built from any raw value. These changes are intended to help for the implementation of a means to enforce format conformity at compilation time for functions with multiple formatted value arguments. The following signatures were found to be incorrect and are fixed: - `message::StepDone`: forced the type for `amount` and `duration` to be of the same type, when `duration` is expected to be of the `Time` format. - `query::Convert::set`: the two arguments were forced to the same type, so potentialy the same format, unless a `GenericFormattedValue` was used. See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1059
This commit is contained in:
parent
fbceaab941
commit
fe319af598
16 changed files with 326 additions and 360 deletions
|
@ -176,13 +176,11 @@ impl AudioInfo {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_audio_info_convert")]
|
||||
pub fn convert<V: Into<gst::GenericFormattedValue>, U: gst::SpecificFormattedValue>(
|
||||
pub fn convert<U: gst::SpecificFormattedValueFullRange>(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
) -> Option<U> {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
if from_glib(ffi::gst_audio_info_convert(
|
||||
|
@ -199,14 +197,12 @@ impl AudioInfo {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn convert_generic<V: Into<gst::GenericFormattedValue>>(
|
||||
pub fn convert_generic(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
dest_fmt: gst::Format,
|
||||
) -> Option<gst::GenericFormattedValue> {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
if from_glib(ffi::gst_audio_info_convert(
|
||||
|
|
|
@ -23,21 +23,19 @@ unsafe impl Sync for AudioClippingMeta {}
|
|||
|
||||
impl AudioClippingMeta {
|
||||
#[doc(alias = "gst_buffer_add_audio_clipping_meta")]
|
||||
pub fn add<V: Into<gst::GenericFormattedValue>>(
|
||||
pub fn add<V: gst::FormattedValue>(
|
||||
buffer: &mut gst::BufferRef,
|
||||
start: V,
|
||||
end: V,
|
||||
) -> gst::MetaRefMut<Self, gst::meta::Standalone> {
|
||||
skip_assert_initialized!();
|
||||
let start = start.into();
|
||||
let end = end.into();
|
||||
assert_eq!(start.format(), end.format());
|
||||
unsafe {
|
||||
let meta = ffi::gst_buffer_add_audio_clipping_meta(
|
||||
buffer.as_mut_ptr(),
|
||||
start.format().into_glib(),
|
||||
start.value() as u64,
|
||||
end.value() as u64,
|
||||
start.into_raw_value() as u64,
|
||||
end.into_raw_value() as u64,
|
||||
);
|
||||
|
||||
Self::from_mut_ptr(buffer, meta)
|
||||
|
|
|
@ -55,7 +55,7 @@ pub trait AggregatorExtManual: 'static {
|
|||
#[doc(alias = "gst_aggregator_update_segment")]
|
||||
fn update_segment<F: gst::FormattedValueIntrinsic>(&self, segment: &gst::FormattedSegment<F>);
|
||||
|
||||
fn set_position<V: FormattedValue>(&self, position: V);
|
||||
fn set_position(&self, position: impl FormattedValue);
|
||||
|
||||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
||||
|
@ -167,7 +167,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_position<V: FormattedValue>(&self, position: V) {
|
||||
fn set_position(&self, position: impl FormattedValue) {
|
||||
unsafe {
|
||||
let ptr: *mut ffi::GstAggregator = self.as_ref().to_glib_none().0;
|
||||
let ptr = &mut *ptr;
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::BaseParse;
|
|||
use crate::BaseParseFrame;
|
||||
use glib::prelude::*;
|
||||
use glib::translate::*;
|
||||
use gst::FormattedValue;
|
||||
use std::mem;
|
||||
|
||||
pub trait BaseParseExtManual: 'static {
|
||||
|
@ -14,18 +13,18 @@ pub trait BaseParseExtManual: 'static {
|
|||
fn src_pad(&self) -> &gst::Pad;
|
||||
|
||||
#[doc(alias = "gst_base_parse_set_duration")]
|
||||
fn set_duration<V: Into<gst::GenericFormattedValue>>(&self, duration: V, interval: u32);
|
||||
fn set_duration(&self, duration: impl gst::FormattedValue, interval: u32);
|
||||
#[doc(alias = "gst_base_parse_set_frame_rate")]
|
||||
fn set_frame_rate(&self, fps: gst::Fraction, lead_in: u32, lead_out: u32);
|
||||
|
||||
#[doc(alias = "gst_base_parse_convert_default")]
|
||||
fn convert_default<V: Into<gst::GenericFormattedValue>, U: gst::SpecificFormattedValue>(
|
||||
fn convert_default<U: gst::SpecificFormattedValueFullRange>(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
) -> Option<U>;
|
||||
fn convert_default_generic<V: Into<gst::GenericFormattedValue>>(
|
||||
fn convert_default_generic(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
dest_format: gst::Format,
|
||||
) -> Option<gst::GenericFormattedValue>;
|
||||
|
||||
|
@ -52,13 +51,12 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_duration<V: Into<gst::GenericFormattedValue>>(&self, duration: V, interval: u32) {
|
||||
let duration = duration.into();
|
||||
fn set_duration(&self, duration: impl gst::FormattedValue, interval: u32) {
|
||||
unsafe {
|
||||
ffi::gst_base_parse_set_duration(
|
||||
self.as_ref().to_glib_none().0,
|
||||
duration.format().into_glib(),
|
||||
duration.value(),
|
||||
duration.into_raw_value(),
|
||||
interval as i32,
|
||||
);
|
||||
}
|
||||
|
@ -77,11 +75,10 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn convert_default<V: Into<gst::GenericFormattedValue>, U: gst::SpecificFormattedValue>(
|
||||
fn convert_default<U: gst::SpecificFormattedValueFullRange>(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
) -> Option<U> {
|
||||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_base_parse_convert_default(
|
||||
|
@ -99,12 +96,11 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn convert_default_generic<V: Into<gst::GenericFormattedValue>>(
|
||||
fn convert_default_generic(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
dest_format: gst::Format,
|
||||
) -> Option<gst::GenericFormattedValue> {
|
||||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_base_parse_convert_default(
|
||||
|
|
|
@ -36,10 +36,10 @@ pub trait BaseParseImpl: BaseParseImplExt + ElementImpl {
|
|||
self.parent_handle_frame(element, frame)
|
||||
}
|
||||
|
||||
fn convert<V: Into<gst::GenericFormattedValue>>(
|
||||
fn convert(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
dest_format: gst::Format,
|
||||
) -> Option<gst::GenericFormattedValue> {
|
||||
self.parent_convert(element, src_val, dest_format)
|
||||
|
@ -63,10 +63,10 @@ pub trait BaseParseImplExt: ObjectSubclass {
|
|||
frame: BaseParseFrame,
|
||||
) -> Result<(gst::FlowSuccess, u32), gst::FlowError>;
|
||||
|
||||
fn parent_convert<V: Into<gst::GenericFormattedValue>>(
|
||||
fn parent_convert(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
dest_format: gst::Format,
|
||||
) -> Option<gst::GenericFormattedValue>;
|
||||
}
|
||||
|
@ -159,16 +159,15 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_convert<V: Into<gst::GenericFormattedValue>>(
|
||||
fn parent_convert(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
dest_format: gst::Format,
|
||||
) -> Option<gst::GenericFormattedValue> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass;
|
||||
let src_val = src_val.into();
|
||||
let res = (*parent_class).convert.map(|f| {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
|
||||
|
|
|
@ -730,13 +730,11 @@ impl VideoInfo {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_video_info_convert")]
|
||||
pub fn convert<V: Into<gst::GenericFormattedValue>, U: gst::SpecificFormattedValue>(
|
||||
pub fn convert<U: gst::SpecificFormattedValueFullRange>(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
) -> Option<U> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
if from_glib(ffi::gst_video_info_convert(
|
||||
|
@ -753,14 +751,12 @@ impl VideoInfo {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn convert_generic<V: Into<gst::GenericFormattedValue>>(
|
||||
pub fn convert_generic(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl gst::FormattedValue,
|
||||
dest_fmt: gst::Format,
|
||||
) -> Option<gst::GenericFormattedValue> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
if from_glib(ffi::gst_video_info_convert(
|
||||
|
|
|
@ -8,16 +8,13 @@ use crate::prelude::*;
|
|||
use crate::ClockTime;
|
||||
use crate::ElementFlags;
|
||||
use crate::Event;
|
||||
use crate::Format;
|
||||
use crate::FormattedValue;
|
||||
use crate::GenericFormattedValue;
|
||||
use crate::Pad;
|
||||
use crate::PadTemplate;
|
||||
use crate::Plugin;
|
||||
use crate::QueryRef;
|
||||
use crate::Rank;
|
||||
use crate::SpecificFormattedValue;
|
||||
use crate::State;
|
||||
use crate::{Format, FormattedValue, GenericFormattedValue, SpecificFormattedValueFullRange};
|
||||
|
||||
use glib::translate::*;
|
||||
|
||||
|
@ -208,13 +205,13 @@ pub trait ElementExtManual: 'static {
|
|||
fn remove_property_notify_watch(&self, watch_id: NotifyWatchId);
|
||||
|
||||
#[doc(alias = "gst_element_query_convert")]
|
||||
fn query_convert<V: Into<GenericFormattedValue>, U: SpecificFormattedValue>(
|
||||
fn query_convert<U: SpecificFormattedValueFullRange>(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
) -> Option<U>;
|
||||
fn query_convert_generic<V: Into<GenericFormattedValue>>(
|
||||
fn query_convert_generic(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
dest_format: Format,
|
||||
) -> Option<GenericFormattedValue>;
|
||||
|
||||
|
@ -229,7 +226,7 @@ pub trait ElementExtManual: 'static {
|
|||
fn query_position_generic(&self, format: Format) -> Option<GenericFormattedValue>;
|
||||
|
||||
#[doc(alias = "gst_element_seek")]
|
||||
fn seek<V: Into<GenericFormattedValue>>(
|
||||
fn seek<V: FormattedValue>(
|
||||
&self,
|
||||
rate: f64,
|
||||
flags: crate::SeekFlags,
|
||||
|
@ -239,10 +236,10 @@ pub trait ElementExtManual: 'static {
|
|||
stop: V,
|
||||
) -> Result<(), glib::error::BoolError>;
|
||||
#[doc(alias = "gst_element_seek_simple")]
|
||||
fn seek_simple<V: Into<GenericFormattedValue>>(
|
||||
fn seek_simple(
|
||||
&self,
|
||||
seek_flags: crate::SeekFlags,
|
||||
seek_pos: V,
|
||||
seek_pos: impl FormattedValue,
|
||||
) -> Result<(), glib::error::BoolError>;
|
||||
|
||||
#[doc(alias = "gst_element_call_async")]
|
||||
|
@ -553,11 +550,10 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn query_convert<V: Into<GenericFormattedValue>, U: SpecificFormattedValue>(
|
||||
fn query_convert<U: SpecificFormattedValueFullRange>(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
) -> Option<U> {
|
||||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_element_query_convert(
|
||||
|
@ -575,18 +571,17 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn query_convert_generic<V: Into<GenericFormattedValue>>(
|
||||
fn query_convert_generic(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
dest_format: Format,
|
||||
) -> Option<GenericFormattedValue> {
|
||||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_element_query_convert(
|
||||
self.as_ref().to_glib_none().0,
|
||||
src_val.format().into_glib(),
|
||||
src_val.value(),
|
||||
src_val.into_raw_value(),
|
||||
dest_format.into_glib(),
|
||||
dest_val.as_mut_ptr(),
|
||||
));
|
||||
|
@ -606,7 +601,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
|||
let mut duration = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_element_query_duration(
|
||||
self.as_ref().to_glib_none().0,
|
||||
T::FormattedValueType::default_format().into_glib(),
|
||||
T::default_format().into_glib(),
|
||||
duration.as_mut_ptr(),
|
||||
));
|
||||
if ret {
|
||||
|
@ -638,7 +633,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
|||
let mut cur = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_element_query_position(
|
||||
self.as_ref().to_glib_none().0,
|
||||
T::FormattedValueType::default_format().into_glib(),
|
||||
T::default_format().into_glib(),
|
||||
cur.as_mut_ptr(),
|
||||
));
|
||||
if ret {
|
||||
|
@ -665,7 +660,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn seek<V: Into<GenericFormattedValue>>(
|
||||
fn seek<V: FormattedValue>(
|
||||
&self,
|
||||
rate: f64,
|
||||
flags: crate::SeekFlags,
|
||||
|
@ -674,9 +669,6 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
|||
stop_type: crate::SeekType,
|
||||
stop: V,
|
||||
) -> Result<(), glib::error::BoolError> {
|
||||
let start = start.into();
|
||||
let stop = stop.into();
|
||||
|
||||
assert_eq!(stop.format(), start.format());
|
||||
|
||||
unsafe {
|
||||
|
@ -687,28 +679,27 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
|||
start.format().into_glib(),
|
||||
flags.into_glib(),
|
||||
start_type.into_glib(),
|
||||
start.value(),
|
||||
start.into_raw_value(),
|
||||
stop_type.into_glib(),
|
||||
stop.value(),
|
||||
stop.into_raw_value(),
|
||||
),
|
||||
"Failed to seek",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn seek_simple<V: Into<GenericFormattedValue>>(
|
||||
fn seek_simple(
|
||||
&self,
|
||||
seek_flags: crate::SeekFlags,
|
||||
seek_pos: V,
|
||||
seek_pos: impl FormattedValue,
|
||||
) -> Result<(), glib::error::BoolError> {
|
||||
let seek_pos = seek_pos.into();
|
||||
unsafe {
|
||||
glib::result_from_gboolean!(
|
||||
ffi::gst_element_seek_simple(
|
||||
self.as_ref().to_glib_none().0,
|
||||
seek_pos.format().into_glib(),
|
||||
seek_flags.into_glib(),
|
||||
seek_pos.value(),
|
||||
seek_pos.into_raw_value(),
|
||||
),
|
||||
"Failed to seek",
|
||||
)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use crate::structure::*;
|
||||
use crate::ClockTime;
|
||||
use crate::GenericFormattedValue;
|
||||
use crate::{FormattedValue, GenericFormattedValue};
|
||||
|
||||
use std::borrow::Borrow;
|
||||
use std::cmp;
|
||||
|
@ -642,22 +642,20 @@ declare_concrete_event!(@sticky Buffersize, T);
|
|||
impl Buffersize<Event> {
|
||||
#[doc(alias = "gst_event_new_buffer_size")]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new<V: Into<GenericFormattedValue>>(minsize: V, maxsize: V, r#async: bool) -> Event {
|
||||
pub fn new<V: FormattedValue>(minsize: V, maxsize: V, r#async: bool) -> Event {
|
||||
skip_assert_initialized!();
|
||||
Self::builder(minsize, maxsize, r#async).build()
|
||||
}
|
||||
|
||||
pub fn builder<'a, V: Into<GenericFormattedValue>>(
|
||||
pub fn builder<'a, V: FormattedValue>(
|
||||
minsize: V,
|
||||
maxsize: V,
|
||||
r#async: bool,
|
||||
) -> BuffersizeBuilder<'a> {
|
||||
assert_initialized_main_thread!();
|
||||
let minsize = minsize.into();
|
||||
let maxsize = maxsize.into();
|
||||
assert_eq!(minsize.format(), maxsize.format());
|
||||
|
||||
BuffersizeBuilder::new(minsize, maxsize, r#async)
|
||||
BuffersizeBuilder::new(minsize.into(), maxsize.into(), r#async)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -858,15 +856,14 @@ declare_concrete_event!(SegmentDone, T);
|
|||
impl SegmentDone<Event> {
|
||||
#[doc(alias = "gst_event_new_segment_done")]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new<V: Into<GenericFormattedValue>>(position: V) -> Event {
|
||||
pub fn new(position: impl FormattedValue) -> Event {
|
||||
skip_assert_initialized!();
|
||||
Self::builder(position).build()
|
||||
}
|
||||
|
||||
pub fn builder<'a, V: Into<GenericFormattedValue>>(position: V) -> SegmentDoneBuilder<'a> {
|
||||
pub fn builder<'a>(position: impl FormattedValue) -> SegmentDoneBuilder<'a> {
|
||||
assert_initialized_main_thread!();
|
||||
let position = position.into();
|
||||
SegmentDoneBuilder::new(position)
|
||||
SegmentDoneBuilder::new(position.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1030,7 +1027,7 @@ declare_concrete_event!(Seek, T);
|
|||
impl Seek<Event> {
|
||||
#[doc(alias = "gst_event_new_seek")]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new<V: Into<GenericFormattedValue>>(
|
||||
pub fn new<V: FormattedValue>(
|
||||
rate: f64,
|
||||
flags: crate::SeekFlags,
|
||||
start_type: crate::SeekType,
|
||||
|
@ -1042,7 +1039,7 @@ impl Seek<Event> {
|
|||
Self::builder(rate, flags, start_type, start, stop_type, stop).build()
|
||||
}
|
||||
|
||||
pub fn builder<'a, V: Into<GenericFormattedValue>>(
|
||||
pub fn builder<'a, V: FormattedValue>(
|
||||
rate: f64,
|
||||
flags: crate::SeekFlags,
|
||||
start_type: crate::SeekType,
|
||||
|
@ -1051,11 +1048,16 @@ impl Seek<Event> {
|
|||
stop: V,
|
||||
) -> SeekBuilder<'a> {
|
||||
assert_initialized_main_thread!();
|
||||
let start = start.into();
|
||||
let stop = stop.into();
|
||||
assert_eq!(start.format(), stop.format());
|
||||
|
||||
SeekBuilder::new(rate, flags, start_type, start, stop_type, stop)
|
||||
SeekBuilder::new(
|
||||
rate,
|
||||
flags,
|
||||
start_type,
|
||||
start.into(),
|
||||
stop_type,
|
||||
stop.into(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1168,18 +1170,13 @@ declare_concrete_event!(Step, T);
|
|||
impl Step<Event> {
|
||||
#[doc(alias = "gst_event_new_step")]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new<V: Into<GenericFormattedValue>>(
|
||||
amount: V,
|
||||
rate: f64,
|
||||
flush: bool,
|
||||
intermediate: bool,
|
||||
) -> Event {
|
||||
pub fn new(amount: impl FormattedValue, rate: f64, flush: bool, intermediate: bool) -> Event {
|
||||
skip_assert_initialized!();
|
||||
Self::builder(amount.into(), rate, flush, intermediate).build()
|
||||
Self::builder(amount, rate, flush, intermediate).build()
|
||||
}
|
||||
|
||||
pub fn builder<'a, V: Into<GenericFormattedValue>>(
|
||||
amount: V,
|
||||
pub fn builder<'a>(
|
||||
amount: impl FormattedValue,
|
||||
rate: f64,
|
||||
flush: bool,
|
||||
intermediate: bool,
|
||||
|
|
|
@ -77,15 +77,31 @@ impl fmt::Display for GenericFormattedValue {
|
|||
pub struct TryFromGenericFormattedValueError(());
|
||||
|
||||
pub trait FormattedValue: Copy + Clone + Sized + Into<GenericFormattedValue> + 'static {
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Type which allows building a `FormattedValue` of this format from any raw value.
|
||||
type FullRange: FormattedValueFullRange + From<Self>;
|
||||
|
||||
#[doc(alias = "get_default_format")]
|
||||
fn default_format() -> Format;
|
||||
|
||||
#[doc(alias = "get_format")]
|
||||
fn format(&self) -> Format;
|
||||
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Self;
|
||||
unsafe fn into_raw_value(self) -> i64;
|
||||
}
|
||||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// A [`FormattedValue`] which can be built from any raw value.
|
||||
///
|
||||
/// # Examples:
|
||||
///
|
||||
/// - `GenericFormattedValue` is the `FormattedValueFullRange` type for `GenericFormattedValue`.
|
||||
/// - `Undefined` is the `FormattedValueFullRange` type for `Undefined`.
|
||||
/// - `Option<Percent>` is the `FormattedValueFullRange` type for `Percent`.
|
||||
pub trait FormattedValueFullRange: FormattedValue + TryFrom<GenericFormattedValue> {
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Self;
|
||||
}
|
||||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// A trait implemented on the intrinsic type of a `FormattedValue`.
|
||||
///
|
||||
|
@ -94,11 +110,11 @@ pub trait FormattedValue: Copy + Clone + Sized + Into<GenericFormattedValue> + '
|
|||
/// - `GenericFormattedValue` is the intrinsic type for `GenericFormattedValue`.
|
||||
/// - `Undefined` is the intrinsic type for `Undefined`.
|
||||
/// - `Bytes` is the intrinsic type for `Option<Bytes>`.
|
||||
pub trait FormattedValueIntrinsic: Copy + Clone + Sized + 'static {
|
||||
type FormattedValueType: FormattedValue;
|
||||
}
|
||||
pub trait FormattedValueIntrinsic: FormattedValue {}
|
||||
|
||||
pub trait SpecificFormattedValue: FormattedValue + TryFrom<GenericFormattedValue> {}
|
||||
pub trait SpecificFormattedValue: FormattedValue {}
|
||||
|
||||
pub trait SpecificFormattedValueFullRange: FormattedValueFullRange {}
|
||||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// A trait implemented on the intrinsic type of a `SpecificFormattedValue`.
|
||||
|
@ -110,6 +126,8 @@ pub trait SpecificFormattedValue: FormattedValue + TryFrom<GenericFormattedValue
|
|||
pub trait SpecificFormattedValueIntrinsic: TryFromGlib<i64> + FormattedValueIntrinsic {}
|
||||
|
||||
impl FormattedValue for GenericFormattedValue {
|
||||
type FullRange = GenericFormattedValue;
|
||||
|
||||
fn default_format() -> Format {
|
||||
Format::Undefined
|
||||
}
|
||||
|
@ -118,15 +136,17 @@ impl FormattedValue for GenericFormattedValue {
|
|||
self.format()
|
||||
}
|
||||
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Self {
|
||||
GenericFormattedValue::new(format, value)
|
||||
}
|
||||
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
self.value()
|
||||
}
|
||||
}
|
||||
|
||||
impl FormattedValueFullRange for GenericFormattedValue {
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Self {
|
||||
GenericFormattedValue::new(format, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl GenericFormattedValue {
|
||||
pub fn new(format: Format, value: i64) -> Self {
|
||||
skip_assert_initialized!();
|
||||
|
@ -136,7 +156,9 @@ impl GenericFormattedValue {
|
|||
Format::Bytes => Self::Bytes(unsafe { FromGlib::from_glib(value as u64) }),
|
||||
Format::Time => Self::Time(unsafe { FromGlib::from_glib(value as u64) }),
|
||||
Format::Buffers => Self::Buffers(unsafe { FromGlib::from_glib(value as u64) }),
|
||||
Format::Percent => Self::Percent(unsafe { FormattedValue::from_raw(format, value) }),
|
||||
Format::Percent => {
|
||||
Self::Percent(unsafe { FormattedValueFullRange::from_raw(format, value) })
|
||||
}
|
||||
Format::__Unknown(_) => Self::Other(format, value),
|
||||
}
|
||||
}
|
||||
|
@ -170,9 +192,7 @@ impl GenericFormattedValue {
|
|||
}
|
||||
}
|
||||
|
||||
impl FormattedValueIntrinsic for GenericFormattedValue {
|
||||
type FormattedValueType = GenericFormattedValue;
|
||||
}
|
||||
impl FormattedValueIntrinsic for GenericFormattedValue {}
|
||||
|
||||
impl_common_ops_for_newtype_uint!(Default, u64);
|
||||
impl_format_value_traits!(Default, Default, Default, u64);
|
||||
|
@ -192,6 +212,8 @@ option_glib_newtype_from_to!(Buffers, Buffers::OFFSET_NONE);
|
|||
option_glib_newtype_display!(Buffers, "buffers");
|
||||
|
||||
impl FormattedValue for Undefined {
|
||||
type FullRange = Undefined;
|
||||
|
||||
fn default_format() -> Format {
|
||||
Format::Undefined
|
||||
}
|
||||
|
@ -200,14 +222,16 @@ impl FormattedValue for Undefined {
|
|||
Format::Undefined
|
||||
}
|
||||
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl FormattedValueFullRange for Undefined {
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Self {
|
||||
debug_assert_eq!(format, Format::Undefined);
|
||||
Undefined(value)
|
||||
}
|
||||
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Undefined> for GenericFormattedValue {
|
||||
|
@ -230,13 +254,7 @@ impl TryFrom<GenericFormattedValue> for Undefined {
|
|||
}
|
||||
}
|
||||
|
||||
impl FormattedValueIntrinsic for Undefined {
|
||||
type FormattedValueType = Undefined;
|
||||
}
|
||||
|
||||
impl SpecificFormattedValue for Undefined {}
|
||||
|
||||
impl SpecificFormattedValueIntrinsic for Undefined {}
|
||||
impl FormattedValueIntrinsic for Undefined {}
|
||||
|
||||
impl TryFromGlib<i64> for Undefined {
|
||||
type Error = std::convert::Infallible;
|
||||
|
@ -298,6 +316,8 @@ impl_common_ops_for_newtype_uint!(Percent, u32);
|
|||
option_glib_newtype_display!(Percent, "%");
|
||||
|
||||
impl FormattedValue for Option<Percent> {
|
||||
type FullRange = Option<Percent>;
|
||||
|
||||
fn default_format() -> Format {
|
||||
Format::Percent
|
||||
}
|
||||
|
@ -306,14 +326,16 @@ impl FormattedValue for Option<Percent> {
|
|||
Format::Percent
|
||||
}
|
||||
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
self.map_or(-1, |v| v.0 as i64)
|
||||
}
|
||||
}
|
||||
|
||||
impl FormattedValueFullRange for Option<Percent> {
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Self {
|
||||
debug_assert_eq!(format, Format::Percent);
|
||||
Percent::try_from_glib(value as i64).ok()
|
||||
}
|
||||
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
self.map_or(-1, |v| v.0 as i64)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Option<Percent>> for GenericFormattedValue {
|
||||
|
@ -329,6 +351,23 @@ impl From<Percent> for GenericFormattedValue {
|
|||
GenericFormattedValue::Percent(Some(v))
|
||||
}
|
||||
}
|
||||
|
||||
impl FormattedValue for Percent {
|
||||
type FullRange = Option<Percent>;
|
||||
|
||||
fn default_format() -> Format {
|
||||
Format::Percent
|
||||
}
|
||||
|
||||
fn format(&self) -> Format {
|
||||
Format::Percent
|
||||
}
|
||||
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
self.0 as i64
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<u64> for Percent {
|
||||
type Error = GlibNoneError;
|
||||
|
||||
|
@ -366,12 +405,9 @@ impl TryFrom<GenericFormattedValue> for Option<Percent> {
|
|||
}
|
||||
}
|
||||
|
||||
impl FormattedValueIntrinsic for Percent {
|
||||
type FormattedValueType = Option<Percent>;
|
||||
}
|
||||
|
||||
impl FormattedValueIntrinsic for Percent {}
|
||||
impl SpecificFormattedValue for Option<Percent> {}
|
||||
|
||||
impl SpecificFormattedValueFullRange for Option<Percent> {}
|
||||
impl SpecificFormattedValueIntrinsic for Percent {}
|
||||
|
||||
impl ops::Deref for Percent {
|
||||
|
|
|
@ -226,8 +226,8 @@ mod typefind_factory;
|
|||
|
||||
pub mod format;
|
||||
pub use crate::format::{
|
||||
FormattedValue, FormattedValueIntrinsic, GenericFormattedValue, SpecificFormattedValue,
|
||||
SpecificFormattedValueIntrinsic,
|
||||
FormattedValue, FormattedValueFullRange, FormattedValueIntrinsic, GenericFormattedValue,
|
||||
SpecificFormattedValue, SpecificFormattedValueFullRange, SpecificFormattedValueIntrinsic,
|
||||
};
|
||||
#[cfg(feature = "ser_de")]
|
||||
mod format_serde;
|
||||
|
@ -344,8 +344,8 @@ pub mod prelude {
|
|||
pub use muldiv::MulDiv;
|
||||
|
||||
pub use crate::format::{
|
||||
FormattedValue, FormattedValueIntrinsic, SpecificFormattedValue,
|
||||
SpecificFormattedValueIntrinsic,
|
||||
FormattedValue, FormattedValueFullRange, FormattedValueIntrinsic, SpecificFormattedValue,
|
||||
SpecificFormattedValueFullRange, SpecificFormattedValueIntrinsic,
|
||||
};
|
||||
pub use crate::utils::Displayable;
|
||||
|
||||
|
|
|
@ -375,6 +375,8 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
macro_rules! impl_format_value_traits(
|
||||
($name:ident, $format:ident, $format_value:ident, $inner_type:ty) => {
|
||||
impl FormattedValue for Option<$name> {
|
||||
type FullRange = Option<$name>;
|
||||
|
||||
fn default_format() -> Format {
|
||||
Format::$format
|
||||
}
|
||||
|
@ -383,14 +385,16 @@ macro_rules! impl_format_value_traits(
|
|||
Format::$format
|
||||
}
|
||||
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
IntoGlib::into_glib(self) as i64
|
||||
}
|
||||
}
|
||||
|
||||
impl FormattedValueFullRange for Option<$name> {
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Option<$name> {
|
||||
debug_assert_eq!(format, Format::$format);
|
||||
FromGlib::from_glib(value as u64)
|
||||
}
|
||||
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
IntoGlib::into_glib(self) as i64
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Option<$name>> for GenericFormattedValue {
|
||||
|
@ -406,11 +410,28 @@ macro_rules! impl_format_value_traits(
|
|||
Self::$format_value(Some(v))
|
||||
}
|
||||
}
|
||||
impl FormattedValue for $name {
|
||||
type FullRange = Option<$name>;
|
||||
|
||||
impl FormattedValueIntrinsic for $name {
|
||||
type FormattedValueType = Option<$name>;
|
||||
fn default_format() -> Format {
|
||||
Format::$format
|
||||
}
|
||||
|
||||
fn format(&self) -> Format {
|
||||
Format::$format
|
||||
}
|
||||
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
IntoGlib::into_glib(self) as i64
|
||||
}
|
||||
}
|
||||
|
||||
impl SpecificFormattedValue for Option<$name> {}
|
||||
impl SpecificFormattedValueFullRange for Option<$name> {}
|
||||
impl SpecificFormattedValue for $name {}
|
||||
impl FormattedValueIntrinsic for $name {}
|
||||
impl SpecificFormattedValueIntrinsic for $name {}
|
||||
|
||||
impl TryFrom<GenericFormattedValue> for Option<$name> {
|
||||
type Error = TryFromGenericFormattedValueError;
|
||||
|
||||
|
@ -442,9 +463,6 @@ macro_rules! impl_format_value_traits(
|
|||
}
|
||||
}
|
||||
|
||||
impl SpecificFormattedValue for Option<$name> {}
|
||||
impl SpecificFormattedValueIntrinsic for $name {}
|
||||
|
||||
impl ops::Deref for $name {
|
||||
type Target = $inner_type;
|
||||
|
||||
|
|
|
@ -673,32 +673,24 @@ declare_concrete_message!(StepDone, T);
|
|||
impl StepDone {
|
||||
#[doc(alias = "gst_message_new_step_done")]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new<V: Into<GenericFormattedValue>>(
|
||||
amount: V,
|
||||
pub fn new(
|
||||
amount: impl FormattedValue,
|
||||
rate: f64,
|
||||
flush: bool,
|
||||
intermediate: bool,
|
||||
duration: V,
|
||||
duration: impl Into<Option<crate::ClockTime>>,
|
||||
eos: bool,
|
||||
) -> Message {
|
||||
skip_assert_initialized!();
|
||||
Self::builder(
|
||||
amount.into(),
|
||||
rate,
|
||||
flush,
|
||||
intermediate,
|
||||
duration.into(),
|
||||
eos,
|
||||
)
|
||||
.build()
|
||||
Self::builder(amount, rate, flush, intermediate, duration, eos).build()
|
||||
}
|
||||
|
||||
pub fn builder<'a, V: Into<GenericFormattedValue>>(
|
||||
amount: V,
|
||||
pub fn builder<'a>(
|
||||
amount: impl FormattedValue,
|
||||
rate: f64,
|
||||
flush: bool,
|
||||
intermediate: bool,
|
||||
duration: V,
|
||||
duration: impl Into<Option<crate::ClockTime>>,
|
||||
eos: bool,
|
||||
) -> StepDoneBuilder<'a> {
|
||||
assert_initialized_main_thread!();
|
||||
|
@ -720,7 +712,7 @@ impl StepDone {
|
|||
f64,
|
||||
bool,
|
||||
bool,
|
||||
GenericFormattedValue,
|
||||
Option<crate::ClockTime>,
|
||||
bool,
|
||||
) {
|
||||
unsafe {
|
||||
|
@ -751,10 +743,7 @@ impl StepDone {
|
|||
rate.assume_init(),
|
||||
from_glib(flush.assume_init()),
|
||||
from_glib(intermediate.assume_init()),
|
||||
GenericFormattedValue::new(
|
||||
from_glib(format.assume_init()),
|
||||
duration.assume_init() as i64,
|
||||
),
|
||||
from_glib(duration.assume_init()),
|
||||
from_glib(eos.assume_init()),
|
||||
)
|
||||
}
|
||||
|
@ -970,15 +959,14 @@ declare_concrete_message!(SegmentStart, T);
|
|||
impl SegmentStart {
|
||||
#[doc(alias = "gst_message_new_segment_start")]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new<V: Into<GenericFormattedValue>>(position: V) -> Message {
|
||||
pub fn new(position: impl FormattedValue) -> Message {
|
||||
skip_assert_initialized!();
|
||||
Self::builder(position).build()
|
||||
}
|
||||
|
||||
pub fn builder<'a, V: Into<GenericFormattedValue>>(position: V) -> SegmentStartBuilder<'a> {
|
||||
pub fn builder<'a>(position: impl FormattedValue) -> SegmentStartBuilder<'a> {
|
||||
assert_initialized_main_thread!();
|
||||
let position = position.into();
|
||||
SegmentStartBuilder::new(position)
|
||||
SegmentStartBuilder::new(position.into())
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_message_parse_segment_start")]
|
||||
|
@ -1002,15 +990,14 @@ declare_concrete_message!(SegmentDone, T);
|
|||
impl SegmentDone {
|
||||
#[doc(alias = "gst_message_new_segment_done")]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new<V: Into<GenericFormattedValue>>(position: V) -> Message {
|
||||
pub fn new(position: impl FormattedValue) -> Message {
|
||||
skip_assert_initialized!();
|
||||
Self::builder(position).build()
|
||||
}
|
||||
|
||||
pub fn builder<'a, V: Into<GenericFormattedValue>>(position: V) -> SegmentDoneBuilder<'a> {
|
||||
pub fn builder<'a>(position: impl FormattedValue) -> SegmentDoneBuilder<'a> {
|
||||
assert_initialized_main_thread!();
|
||||
let position = position.into();
|
||||
SegmentDoneBuilder::new(position)
|
||||
SegmentDoneBuilder::new(position.into())
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_message_parse_segment_done")]
|
||||
|
@ -1133,20 +1120,20 @@ declare_concrete_message!(StepStart, T);
|
|||
impl StepStart {
|
||||
#[doc(alias = "gst_message_new_step_start")]
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new<V: Into<GenericFormattedValue>>(
|
||||
pub fn new(
|
||||
active: bool,
|
||||
amount: V,
|
||||
amount: impl FormattedValue,
|
||||
rate: f64,
|
||||
flush: bool,
|
||||
intermediate: bool,
|
||||
) -> Message {
|
||||
skip_assert_initialized!();
|
||||
Self::builder(active, amount.into(), rate, flush, intermediate).build()
|
||||
Self::builder(active, amount, rate, flush, intermediate).build()
|
||||
}
|
||||
|
||||
pub fn builder<'a, V: Into<GenericFormattedValue>>(
|
||||
pub fn builder<'a>(
|
||||
active: bool,
|
||||
amount: V,
|
||||
amount: impl FormattedValue,
|
||||
rate: f64,
|
||||
flush: bool,
|
||||
intermediate: bool,
|
||||
|
@ -2168,7 +2155,7 @@ pub struct StepDoneBuilder<'a> {
|
|||
rate: f64,
|
||||
flush: bool,
|
||||
intermediate: bool,
|
||||
duration: GenericFormattedValue,
|
||||
duration: Option<crate::ClockTime>,
|
||||
eos: bool,
|
||||
}
|
||||
|
||||
|
@ -2178,7 +2165,7 @@ impl<'a> StepDoneBuilder<'a> {
|
|||
rate: f64,
|
||||
flush: bool,
|
||||
intermediate: bool,
|
||||
duration: GenericFormattedValue,
|
||||
duration: Option<crate::ClockTime>,
|
||||
eos: bool,
|
||||
) -> Self {
|
||||
skip_assert_initialized!();
|
||||
|
@ -2201,7 +2188,7 @@ impl<'a> StepDoneBuilder<'a> {
|
|||
s.rate,
|
||||
s.flush.into_glib(),
|
||||
s.intermediate.into_glib(),
|
||||
s.duration.value() as u64,
|
||||
s.duration.into_raw_value() as u64,
|
||||
s.eos.into_glib(),
|
||||
));
|
||||
}
|
||||
|
@ -2613,12 +2600,10 @@ impl<'a> QosBuilder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn stats<V: Into<GenericFormattedValue>>(self, processed: V, dropped: V) -> Self {
|
||||
let processed = processed.into();
|
||||
let dropped = dropped.into();
|
||||
pub fn stats<V: FormattedValue>(self, processed: V, dropped: V) -> Self {
|
||||
assert_eq!(processed.format(), dropped.format());
|
||||
Self {
|
||||
stats: Some((processed, dropped)),
|
||||
stats: Some((processed.into(), dropped.into())),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,6 @@ use crate::Event;
|
|||
use crate::FlowError;
|
||||
use crate::FlowReturn;
|
||||
use crate::FlowSuccess;
|
||||
use crate::Format;
|
||||
use crate::FormattedValue;
|
||||
use crate::GenericFormattedValue;
|
||||
use crate::LoggableError;
|
||||
use crate::Pad;
|
||||
use crate::PadFlags;
|
||||
|
@ -17,7 +14,10 @@ use crate::PadProbeType;
|
|||
use crate::Query;
|
||||
use crate::QueryRef;
|
||||
use crate::StaticPadTemplate;
|
||||
use crate::{SpecificFormattedValue, SpecificFormattedValueIntrinsic};
|
||||
use crate::{
|
||||
Format, FormattedValue, GenericFormattedValue, SpecificFormattedValueFullRange,
|
||||
SpecificFormattedValueIntrinsic,
|
||||
};
|
||||
|
||||
use std::mem;
|
||||
use std::num::NonZeroU64;
|
||||
|
@ -272,14 +272,14 @@ pub trait PadExtManual: 'static {
|
|||
fn start_task<F: FnMut() + Send + 'static>(&self, func: F) -> Result<(), glib::BoolError>;
|
||||
|
||||
#[doc(alias = "gst_pad_peer_query_convert")]
|
||||
fn peer_query_convert<V: Into<GenericFormattedValue>, U: SpecificFormattedValue>(
|
||||
fn peer_query_convert<U: SpecificFormattedValueFullRange>(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
) -> Option<U>;
|
||||
#[doc(alias = "gst_pad_peer_query_convert")]
|
||||
fn peer_query_convert_generic<V: Into<GenericFormattedValue>>(
|
||||
fn peer_query_convert_generic(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
dest_format: Format,
|
||||
) -> Option<GenericFormattedValue>;
|
||||
|
||||
|
@ -294,14 +294,14 @@ pub trait PadExtManual: 'static {
|
|||
fn peer_query_position_generic(&self, format: Format) -> Option<GenericFormattedValue>;
|
||||
|
||||
#[doc(alias = "gst_pad_query_convert")]
|
||||
fn query_convert<V: Into<GenericFormattedValue>, U: SpecificFormattedValue>(
|
||||
fn query_convert<U: SpecificFormattedValueFullRange>(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
) -> Option<U>;
|
||||
#[doc(alias = "gst_pad_query_convert")]
|
||||
fn query_convert_generic<V: Into<GenericFormattedValue>>(
|
||||
fn query_convert_generic(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
dest_format: Format,
|
||||
) -> Option<GenericFormattedValue>;
|
||||
|
||||
|
@ -781,11 +781,10 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn peer_query_convert<V: Into<GenericFormattedValue>, U: SpecificFormattedValue>(
|
||||
fn peer_query_convert<U: SpecificFormattedValueFullRange>(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
) -> Option<U> {
|
||||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_pad_peer_query_convert(
|
||||
|
@ -803,12 +802,11 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn peer_query_convert_generic<V: Into<GenericFormattedValue>>(
|
||||
fn peer_query_convert_generic(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
dest_format: Format,
|
||||
) -> Option<GenericFormattedValue> {
|
||||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_pad_peer_query_convert(
|
||||
|
@ -834,7 +832,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
let mut duration = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_pad_peer_query_duration(
|
||||
self.as_ref().to_glib_none().0,
|
||||
T::FormattedValueType::default_format().into_glib(),
|
||||
T::default_format().into_glib(),
|
||||
duration.as_mut_ptr(),
|
||||
));
|
||||
if ret {
|
||||
|
@ -866,7 +864,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
let mut cur = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_pad_peer_query_position(
|
||||
self.as_ref().to_glib_none().0,
|
||||
T::FormattedValueType::default_format().into_glib(),
|
||||
T::default_format().into_glib(),
|
||||
cur.as_mut_ptr(),
|
||||
));
|
||||
if ret {
|
||||
|
@ -893,12 +891,10 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn query_convert<V: Into<GenericFormattedValue>, U: SpecificFormattedValue>(
|
||||
fn query_convert<U: SpecificFormattedValueFullRange>(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
) -> Option<U> {
|
||||
let src_val = src_val.into();
|
||||
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_pad_query_convert(
|
||||
|
@ -916,19 +912,17 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn query_convert_generic<V: Into<GenericFormattedValue>>(
|
||||
fn query_convert_generic(
|
||||
&self,
|
||||
src_val: V,
|
||||
src_val: impl FormattedValue,
|
||||
dest_format: Format,
|
||||
) -> Option<GenericFormattedValue> {
|
||||
let src_val = src_val.into();
|
||||
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_pad_query_convert(
|
||||
self.as_ref().to_glib_none().0,
|
||||
src_val.format().into_glib(),
|
||||
src_val.value(),
|
||||
src_val.into_raw_value(),
|
||||
dest_format.into_glib(),
|
||||
dest_val.as_mut_ptr(),
|
||||
));
|
||||
|
@ -948,7 +942,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
let mut duration = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_pad_query_duration(
|
||||
self.as_ref().to_glib_none().0,
|
||||
T::FormattedValueType::default_format().into_glib(),
|
||||
T::default_format().into_glib(),
|
||||
duration.as_mut_ptr(),
|
||||
));
|
||||
if ret {
|
||||
|
@ -980,7 +974,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
let mut cur = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(ffi::gst_pad_query_position(
|
||||
self.as_ref().to_glib_none().0,
|
||||
T::FormattedValueType::default_format().into_glib(),
|
||||
T::default_format().into_glib(),
|
||||
cur.as_mut_ptr(),
|
||||
));
|
||||
if ret {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use crate::structure::*;
|
||||
use crate::GenericFormattedValue;
|
||||
use crate::{FormattedValue, GenericFormattedValue};
|
||||
|
||||
use std::borrow::{Borrow, BorrowMut};
|
||||
use std::ffi::CStr;
|
||||
|
@ -319,11 +319,14 @@ impl Position {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_query_set_position")]
|
||||
pub fn set<V: Into<GenericFormattedValue>>(&mut self, pos: V) {
|
||||
let pos = pos.into();
|
||||
pub fn set(&mut self, pos: impl FormattedValue) {
|
||||
assert_eq!(pos.format(), self.format());
|
||||
unsafe {
|
||||
ffi::gst_query_set_position(self.as_mut_ptr(), pos.format().into_glib(), pos.value());
|
||||
ffi::gst_query_set_position(
|
||||
self.as_mut_ptr(),
|
||||
pos.format().into_glib(),
|
||||
pos.into_raw_value(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -364,11 +367,14 @@ impl Duration {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_query_set_duration")]
|
||||
pub fn set<V: Into<GenericFormattedValue>>(&mut self, dur: V) {
|
||||
let dur = dur.into();
|
||||
pub fn set(&mut self, dur: impl FormattedValue) {
|
||||
assert_eq!(dur.format(), self.format());
|
||||
unsafe {
|
||||
ffi::gst_query_set_duration(self.as_mut_ptr(), dur.format().into_glib(), dur.value());
|
||||
ffi::gst_query_set_duration(
|
||||
self.as_mut_ptr(),
|
||||
dur.format().into_glib(),
|
||||
dur.into_raw_value(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -482,10 +488,7 @@ impl Seeking {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_query_set_seeking")]
|
||||
pub fn set<V: Into<GenericFormattedValue>>(&mut self, seekable: bool, start: V, end: V) {
|
||||
let start = start.into();
|
||||
let end = end.into();
|
||||
|
||||
pub fn set<V: FormattedValue>(&mut self, seekable: bool, start: V, end: V) {
|
||||
assert_eq!(self.format(), start.format());
|
||||
assert_eq!(start.format(), end.format());
|
||||
|
||||
|
@ -494,8 +497,8 @@ impl Seeking {
|
|||
self.as_mut_ptr(),
|
||||
start.format().into_glib(),
|
||||
seekable.into_glib(),
|
||||
start.value(),
|
||||
end.value(),
|
||||
start.into_raw_value(),
|
||||
end.into_raw_value(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -553,10 +556,7 @@ impl Segment {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_query_set_segment")]
|
||||
pub fn set<V: Into<GenericFormattedValue>>(&mut self, rate: f64, start: V, stop: V) {
|
||||
let start = start.into();
|
||||
let stop = stop.into();
|
||||
|
||||
pub fn set<V: FormattedValue>(&mut self, rate: f64, start: V, stop: V) {
|
||||
assert_eq!(start.format(), stop.format());
|
||||
|
||||
unsafe {
|
||||
|
@ -564,8 +564,8 @@ impl Segment {
|
|||
self.as_mut_ptr(),
|
||||
rate,
|
||||
start.format().into_glib(),
|
||||
start.value(),
|
||||
stop.value(),
|
||||
start.into_raw_value(),
|
||||
stop.into_raw_value(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -574,13 +574,12 @@ impl Segment {
|
|||
declare_concrete_query!(Convert, T);
|
||||
impl Convert<Query> {
|
||||
#[doc(alias = "gst_query_new_convert")]
|
||||
pub fn new<V: Into<GenericFormattedValue>>(value: V, dest_fmt: crate::Format) -> Self {
|
||||
pub fn new(value: impl FormattedValue, dest_fmt: crate::Format) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
let value = value.into();
|
||||
unsafe {
|
||||
Self(from_glib_full(ffi::gst_query_new_convert(
|
||||
value.format().into_glib(),
|
||||
value.value(),
|
||||
value.into_raw_value(),
|
||||
dest_fmt.into_glib(),
|
||||
)))
|
||||
}
|
||||
|
@ -633,17 +632,14 @@ impl Convert {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_query_set_convert")]
|
||||
pub fn set<V: Into<GenericFormattedValue>>(&mut self, src: V, dest: V) {
|
||||
let src = src.into();
|
||||
let dest = dest.into();
|
||||
|
||||
pub fn set(&mut self, src: impl FormattedValue, dest: impl FormattedValue) {
|
||||
unsafe {
|
||||
ffi::gst_query_set_convert(
|
||||
self.as_mut_ptr(),
|
||||
src.format().into_glib(),
|
||||
src.value(),
|
||||
src.into_raw_value(),
|
||||
dest.format().into_glib(),
|
||||
dest.value(),
|
||||
dest.into_raw_value(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -840,15 +836,7 @@ impl Buffering {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_query_set_buffering_range")]
|
||||
pub fn set_range<V: Into<GenericFormattedValue>>(
|
||||
&mut self,
|
||||
start: V,
|
||||
stop: V,
|
||||
estimated_total: i64,
|
||||
) {
|
||||
let start = start.into();
|
||||
let stop = stop.into();
|
||||
|
||||
pub fn set_range<V: FormattedValue>(&mut self, start: V, stop: V, estimated_total: i64) {
|
||||
assert_eq!(self.format(), start.format());
|
||||
assert_eq!(start.format(), stop.format());
|
||||
|
||||
|
@ -856,8 +844,8 @@ impl Buffering {
|
|||
ffi::gst_query_set_buffering_range(
|
||||
self.as_mut_ptr(),
|
||||
start.format().into_glib(),
|
||||
start.value(),
|
||||
stop.value(),
|
||||
start.into_raw_value(),
|
||||
stop.into_raw_value(),
|
||||
estimated_total,
|
||||
);
|
||||
}
|
||||
|
@ -884,19 +872,18 @@ impl Buffering {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_query_add_buffering_range")]
|
||||
pub fn add_buffering_ranges<V: Into<GenericFormattedValue> + Copy>(
|
||||
&mut self,
|
||||
ranges: &[(V, V)],
|
||||
) {
|
||||
pub fn add_buffering_ranges<V: FormattedValue + Copy>(&mut self, ranges: &[(V, V)]) {
|
||||
unsafe {
|
||||
let fmt = self.format();
|
||||
|
||||
for &(start, stop) in ranges {
|
||||
let start = start.into();
|
||||
let stop = stop.into();
|
||||
assert_eq!(start.format(), fmt);
|
||||
assert_eq!(stop.format(), fmt);
|
||||
ffi::gst_query_add_buffering_range(self.as_mut_ptr(), start.value(), stop.value());
|
||||
ffi::gst_query_add_buffering_range(
|
||||
self.as_mut_ptr(),
|
||||
start.into_raw_value(),
|
||||
stop.into_raw_value(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::Format;
|
|||
use crate::GenericFormattedValue;
|
||||
use crate::SeekFlags;
|
||||
use crate::SeekType;
|
||||
use crate::{FormattedValue, FormattedValueIntrinsic};
|
||||
use crate::{FormattedValue, FormattedValueFullRange, FormattedValueIntrinsic};
|
||||
use glib::translate::*;
|
||||
use glib::StaticType;
|
||||
use std::fmt;
|
||||
|
@ -34,9 +34,7 @@ impl Segment {
|
|||
}
|
||||
|
||||
pub fn downcast<T: FormattedValueIntrinsic>(self) -> Result<FormattedSegment<T>, Self> {
|
||||
if T::FormattedValueType::default_format() == Format::Undefined
|
||||
|| T::FormattedValueType::default_format() == self.format()
|
||||
{
|
||||
if T::default_format() == Format::Undefined || T::default_format() == self.format() {
|
||||
Ok(FormattedSegment(self.0, PhantomData))
|
||||
} else {
|
||||
Err(self)
|
||||
|
@ -44,9 +42,7 @@ impl Segment {
|
|||
}
|
||||
|
||||
pub fn downcast_ref<T: FormattedValueIntrinsic>(&self) -> Option<&FormattedSegment<T>> {
|
||||
if T::FormattedValueType::default_format() == Format::Undefined
|
||||
|| T::FormattedValueType::default_format() == self.format()
|
||||
{
|
||||
if T::default_format() == Format::Undefined || T::default_format() == self.format() {
|
||||
Some(unsafe {
|
||||
&*(self as *const FormattedSegment<GenericFormattedValue>
|
||||
as *const FormattedSegment<T>)
|
||||
|
@ -57,9 +53,7 @@ impl Segment {
|
|||
}
|
||||
|
||||
pub fn downcast_mut<T: FormattedValueIntrinsic>(&mut self) -> Option<&mut FormattedSegment<T>> {
|
||||
if T::FormattedValueType::default_format() == Format::Undefined
|
||||
|| T::FormattedValueType::default_format() == self.format()
|
||||
{
|
||||
if T::default_format() == Format::Undefined || T::default_format() == self.format() {
|
||||
Some(unsafe {
|
||||
&mut *(self as *mut FormattedSegment<GenericFormattedValue>
|
||||
as *mut FormattedSegment<T>)
|
||||
|
@ -75,10 +69,7 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
assert_initialized_main_thread!();
|
||||
let segment = unsafe {
|
||||
let mut segment = mem::MaybeUninit::zeroed();
|
||||
ffi::gst_segment_init(
|
||||
segment.as_mut_ptr(),
|
||||
T::FormattedValueType::default_format().into_glib(),
|
||||
);
|
||||
ffi::gst_segment_init(segment.as_mut_ptr(), T::default_format().into_glib());
|
||||
segment.assume_init()
|
||||
};
|
||||
FormattedSegment(segment, PhantomData)
|
||||
|
@ -96,23 +87,20 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
|
||||
pub fn reset(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_segment_init(
|
||||
&mut self.0,
|
||||
T::FormattedValueType::default_format().into_glib(),
|
||||
);
|
||||
ffi::gst_segment_init(&mut self.0, T::default_format().into_glib());
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_segment_clip")]
|
||||
pub fn clip<V: Into<T::FormattedValueType>>(
|
||||
pub fn clip<V: Into<T::FullRange>>(
|
||||
&self,
|
||||
start: V,
|
||||
stop: V,
|
||||
) -> Option<(T::FormattedValueType, T::FormattedValueType)> {
|
||||
) -> Option<(T::FullRange, T::FullRange)> {
|
||||
let start = start.into();
|
||||
let stop = stop.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), start.format());
|
||||
assert_eq!(self.format(), stop.format());
|
||||
}
|
||||
|
@ -130,8 +118,8 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
));
|
||||
if ret {
|
||||
Some((
|
||||
T::FormattedValueType::from_raw(self.format(), clip_start.assume_init() as i64),
|
||||
T::FormattedValueType::from_raw(self.format(), clip_stop.assume_init() as i64),
|
||||
T::FullRange::from_raw(self.format(), clip_start.assume_init() as i64),
|
||||
T::FullRange::from_raw(self.format(), clip_stop.assume_init() as i64),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
|
@ -141,7 +129,7 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[doc(alias = "gst_segment_do_seek")]
|
||||
pub fn do_seek<V: Into<T::FormattedValueType>>(
|
||||
pub fn do_seek<V: Into<T::FullRange>>(
|
||||
&mut self,
|
||||
rate: f64,
|
||||
flags: SeekFlags,
|
||||
|
@ -154,7 +142,7 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
let start = start.into();
|
||||
let stop = stop.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), start.format());
|
||||
assert_eq!(self.format(), stop.format());
|
||||
}
|
||||
|
@ -195,18 +183,18 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_segment_position_from_running_time")]
|
||||
pub fn position_from_running_time<V: Into<T::FormattedValueType>>(
|
||||
pub fn position_from_running_time<V: Into<T::FullRange>>(
|
||||
&self,
|
||||
running_time: V,
|
||||
) -> T::FormattedValueType {
|
||||
) -> T::FullRange {
|
||||
let running_time = running_time.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), running_time.format());
|
||||
}
|
||||
|
||||
unsafe {
|
||||
T::FormattedValueType::from_raw(
|
||||
T::FullRange::from_raw(
|
||||
self.format(),
|
||||
ffi::gst_segment_position_from_running_time(
|
||||
&self.0,
|
||||
|
@ -218,13 +206,13 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_segment_position_from_running_time_full")]
|
||||
pub fn position_from_running_time_full<V: Into<T::FormattedValueType>>(
|
||||
pub fn position_from_running_time_full<V: Into<T::FullRange>>(
|
||||
&self,
|
||||
running_time: V,
|
||||
) -> (i32, T::FormattedValueType) {
|
||||
) -> (i32, T::FullRange) {
|
||||
let running_time = running_time.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), running_time.format());
|
||||
}
|
||||
|
||||
|
@ -238,24 +226,21 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
);
|
||||
(
|
||||
ret,
|
||||
T::FormattedValueType::from_raw(self.format(), position.assume_init() as i64),
|
||||
T::FullRange::from_raw(self.format(), position.assume_init() as i64),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_segment_position_from_stream_time")]
|
||||
pub fn position_from_stream_time<V: Into<T::FormattedValueType>>(
|
||||
&self,
|
||||
stream_time: V,
|
||||
) -> T::FormattedValueType {
|
||||
pub fn position_from_stream_time<V: Into<T::FullRange>>(&self, stream_time: V) -> T::FullRange {
|
||||
let stream_time = stream_time.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), stream_time.format());
|
||||
}
|
||||
|
||||
unsafe {
|
||||
T::FormattedValueType::from_raw(
|
||||
T::FullRange::from_raw(
|
||||
self.format(),
|
||||
ffi::gst_segment_position_from_stream_time(
|
||||
&self.0,
|
||||
|
@ -267,13 +252,13 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_segment_position_from_stream_time_full")]
|
||||
pub fn position_from_stream_time_full<V: Into<T::FormattedValueType>>(
|
||||
pub fn position_from_stream_time_full<V: Into<T::FullRange>>(
|
||||
&self,
|
||||
stream_time: V,
|
||||
) -> (i32, T::FormattedValueType) {
|
||||
) -> (i32, T::FullRange) {
|
||||
let stream_time = stream_time.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), stream_time.format());
|
||||
}
|
||||
|
||||
|
@ -287,19 +272,19 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
);
|
||||
(
|
||||
ret,
|
||||
T::FormattedValueType::from_raw(self.format(), position.assume_init() as i64),
|
||||
T::FullRange::from_raw(self.format(), position.assume_init() as i64),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_segment_set_running_time")]
|
||||
pub fn set_running_time<V: Into<T::FormattedValueType>>(
|
||||
pub fn set_running_time<V: Into<T::FullRange>>(
|
||||
&mut self,
|
||||
running_time: V,
|
||||
) -> Result<(), glib::BoolError> {
|
||||
let running_time = running_time.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), running_time.format());
|
||||
}
|
||||
|
||||
|
@ -316,18 +301,15 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_segment_to_running_time")]
|
||||
pub fn to_running_time<V: Into<T::FormattedValueType>>(
|
||||
&self,
|
||||
position: V,
|
||||
) -> T::FormattedValueType {
|
||||
pub fn to_running_time<V: Into<T::FullRange>>(&self, position: V) -> T::FullRange {
|
||||
let position = position.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), position.format());
|
||||
}
|
||||
|
||||
unsafe {
|
||||
T::FormattedValueType::from_raw(
|
||||
T::FullRange::from_raw(
|
||||
self.format(),
|
||||
ffi::gst_segment_to_running_time(
|
||||
&self.0,
|
||||
|
@ -339,13 +321,10 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_segment_to_running_time_full")]
|
||||
pub fn to_running_time_full<V: Into<T::FormattedValueType>>(
|
||||
&self,
|
||||
position: V,
|
||||
) -> (i32, T::FormattedValueType) {
|
||||
pub fn to_running_time_full<V: Into<T::FullRange>>(&self, position: V) -> (i32, T::FullRange) {
|
||||
let position = position.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), position.format());
|
||||
}
|
||||
|
||||
|
@ -359,24 +338,21 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
);
|
||||
(
|
||||
ret,
|
||||
T::FormattedValueType::from_raw(self.format(), running_time.assume_init() as i64),
|
||||
T::FullRange::from_raw(self.format(), running_time.assume_init() as i64),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_segment_to_stream_time")]
|
||||
pub fn to_stream_time<V: Into<T::FormattedValueType>>(
|
||||
&self,
|
||||
position: V,
|
||||
) -> T::FormattedValueType {
|
||||
pub fn to_stream_time<V: Into<T::FullRange>>(&self, position: V) -> T::FullRange {
|
||||
let position = position.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), position.format());
|
||||
}
|
||||
|
||||
unsafe {
|
||||
T::FormattedValueType::from_raw(
|
||||
T::FullRange::from_raw(
|
||||
self.format(),
|
||||
ffi::gst_segment_to_stream_time(
|
||||
&self.0,
|
||||
|
@ -388,13 +364,10 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_segment_to_stream_time_full")]
|
||||
pub fn to_stream_time_full<V: Into<T::FormattedValueType>>(
|
||||
&self,
|
||||
position: V,
|
||||
) -> (i32, T::FormattedValueType) {
|
||||
pub fn to_stream_time_full<V: Into<T::FullRange>>(&self, position: V) -> (i32, T::FullRange) {
|
||||
let position = position.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), position.format());
|
||||
}
|
||||
|
||||
|
@ -408,7 +381,7 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
);
|
||||
(
|
||||
ret,
|
||||
T::FormattedValueType::from_raw(self.format(), stream_time.assume_init() as i64),
|
||||
T::FullRange::from_raw(self.format(), stream_time.assume_init() as i64),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -450,14 +423,14 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_base")]
|
||||
pub fn base(&self) -> T::FormattedValueType {
|
||||
unsafe { T::FormattedValueType::from_raw(self.format(), self.0.base as i64) }
|
||||
pub fn base(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.0.base as i64) }
|
||||
}
|
||||
|
||||
pub fn set_base<V: Into<T::FormattedValueType>>(&mut self, base: V) {
|
||||
pub fn set_base<V: Into<T::FullRange>>(&mut self, base: V) {
|
||||
let base = base.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), base.format());
|
||||
}
|
||||
|
||||
|
@ -465,14 +438,14 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_offset")]
|
||||
pub fn offset(&self) -> T::FormattedValueType {
|
||||
unsafe { T::FormattedValueType::from_raw(self.format(), self.0.offset as i64) }
|
||||
pub fn offset(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.0.offset as i64) }
|
||||
}
|
||||
|
||||
pub fn set_offset<V: Into<T::FormattedValueType>>(&mut self, offset: V) {
|
||||
pub fn set_offset<V: Into<T::FullRange>>(&mut self, offset: V) {
|
||||
let offset = offset.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), offset.format());
|
||||
}
|
||||
|
||||
|
@ -480,14 +453,14 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_start")]
|
||||
pub fn start(&self) -> T::FormattedValueType {
|
||||
unsafe { T::FormattedValueType::from_raw(self.format(), self.0.start as i64) }
|
||||
pub fn start(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.0.start as i64) }
|
||||
}
|
||||
|
||||
pub fn set_start<V: Into<T::FormattedValueType>>(&mut self, start: V) {
|
||||
pub fn set_start<V: Into<T::FullRange>>(&mut self, start: V) {
|
||||
let start = start.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), start.format());
|
||||
}
|
||||
|
||||
|
@ -495,14 +468,14 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_stop")]
|
||||
pub fn stop(&self) -> T::FormattedValueType {
|
||||
unsafe { T::FormattedValueType::from_raw(self.format(), self.0.stop as i64) }
|
||||
pub fn stop(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.0.stop as i64) }
|
||||
}
|
||||
|
||||
pub fn set_stop<V: Into<T::FormattedValueType>>(&mut self, stop: V) {
|
||||
pub fn set_stop<V: Into<T::FullRange>>(&mut self, stop: V) {
|
||||
let stop = stop.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), stop.format());
|
||||
}
|
||||
|
||||
|
@ -510,14 +483,14 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_time")]
|
||||
pub fn time(&self) -> T::FormattedValueType {
|
||||
unsafe { T::FormattedValueType::from_raw(self.format(), self.0.time as i64) }
|
||||
pub fn time(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.0.time as i64) }
|
||||
}
|
||||
|
||||
pub fn set_time<V: Into<T::FormattedValueType>>(&mut self, time: V) {
|
||||
pub fn set_time<V: Into<T::FullRange>>(&mut self, time: V) {
|
||||
let time = time.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), time.format());
|
||||
}
|
||||
|
||||
|
@ -525,14 +498,14 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_position")]
|
||||
pub fn position(&self) -> T::FormattedValueType {
|
||||
unsafe { T::FormattedValueType::from_raw(self.format(), self.0.position as i64) }
|
||||
pub fn position(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.0.position as i64) }
|
||||
}
|
||||
|
||||
pub fn set_position<V: Into<T::FormattedValueType>>(&mut self, position: V) {
|
||||
pub fn set_position<V: Into<T::FullRange>>(&mut self, position: V) {
|
||||
let position = position.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), position.format());
|
||||
}
|
||||
|
||||
|
@ -540,14 +513,14 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_duration")]
|
||||
pub fn duration(&self) -> T::FormattedValueType {
|
||||
unsafe { T::FormattedValueType::from_raw(self.format(), self.0.duration as i64) }
|
||||
pub fn duration(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.0.duration as i64) }
|
||||
}
|
||||
|
||||
pub fn set_duration<V: Into<T::FormattedValueType>>(&mut self, duration: V) {
|
||||
pub fn set_duration<V: Into<T::FullRange>>(&mut self, duration: V) {
|
||||
let duration = duration.into();
|
||||
|
||||
if T::FormattedValueType::default_format() == Format::Undefined {
|
||||
if T::default_format() == Format::Undefined {
|
||||
assert_eq!(self.format(), duration.format());
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ impl<'de, T: SpecificFormattedValueIntrinsic> Deserialize<'de> for FormattedSegm
|
|||
de::Error::custom(format!(
|
||||
"failed to convert segment with format {:?} to {:?}",
|
||||
segment.format(),
|
||||
T::FormattedValueType::default_format(),
|
||||
T::default_format(),
|
||||
))
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue