message/query/event: Implement views in a more consistent way

Co-authored-by: Jan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>
This commit is contained in:
Sebastian Dröge 2022-01-18 11:57:22 +02:00
parent 65c833bc80
commit 5e2249d368
14 changed files with 762 additions and 836 deletions

View file

@ -87,7 +87,7 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
fn propose_allocation( fn propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_propose_allocation(element, query) self.parent_propose_allocation(element, query)
} }
@ -95,7 +95,7 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
fn decide_allocation( fn decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_decide_allocation(element, query) self.parent_decide_allocation(element, query)
} }
@ -151,13 +151,13 @@ pub trait AudioDecoderImplExt: ObjectSubclass {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
} }
@ -468,7 +468,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -492,7 +492,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -821,7 +821,7 @@ unsafe extern "C" fn audio_decoder_propose_allocation<T: AudioDecoderImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr); let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };
@ -845,7 +845,7 @@ unsafe extern "C" fn audio_decoder_decide_allocation<T: AudioDecoderImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr); let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };

View file

@ -79,7 +79,7 @@ pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl {
fn propose_allocation( fn propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_propose_allocation(element, query) self.parent_propose_allocation(element, query)
} }
@ -87,7 +87,7 @@ pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl {
fn decide_allocation( fn decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_decide_allocation(element, query) self.parent_decide_allocation(element, query)
} }
@ -137,13 +137,13 @@ pub trait AudioEncoderImplExt: ObjectSubclass {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
} }
@ -418,7 +418,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -442,7 +442,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -741,7 +741,7 @@ unsafe extern "C" fn audio_encoder_propose_allocation<T: AudioEncoderImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr); let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };
@ -765,7 +765,7 @@ unsafe extern "C" fn audio_encoder_decide_allocation<T: AudioEncoderImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr); let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };

View file

@ -153,8 +153,8 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl {
&self, &self,
element: &Self::Type, element: &Self::Type,
pad: &AggregatorPad, pad: &AggregatorPad,
decide_query: Option<gst::query::Allocation<&gst::QueryRef>>, decide_query: Option<&gst::query::Allocation>,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_propose_allocation(element, pad, decide_query, query) self.parent_propose_allocation(element, pad, decide_query, query)
} }
@ -162,7 +162,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl {
fn decide_allocation( fn decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_decide_allocation(element, query) self.parent_decide_allocation(element, query)
} }
@ -289,14 +289,14 @@ pub trait AggregatorImplExt: ObjectSubclass {
&self, &self,
element: &Self::Type, element: &Self::Type,
pad: &AggregatorPad, pad: &AggregatorPad,
decide_query: Option<gst::query::Allocation<&gst::QueryRef>>, decide_query: Option<&gst::query::Allocation>,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
@ -692,8 +692,8 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
&self, &self,
element: &Self::Type, element: &Self::Type,
pad: &AggregatorPad, pad: &AggregatorPad,
decide_query: Option<gst::query::Allocation<&gst::QueryRef>>, decide_query: Option<&gst::query::Allocation>,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -722,7 +722,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -1178,7 +1178,7 @@ unsafe extern "C" fn aggregator_propose_allocation<T: AggregatorImpl>(
} }
}; };
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };
@ -1207,7 +1207,7 @@ unsafe extern "C" fn aggregator_decide_allocation<T: AggregatorImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr); let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };

View file

@ -81,7 +81,7 @@ pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl {
fn propose_allocation( fn propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_propose_allocation(element, query) self.parent_propose_allocation(element, query)
} }
@ -137,7 +137,7 @@ pub trait BaseSinkImplExt: ObjectSubclass {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
} }
@ -403,7 +403,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -671,7 +671,7 @@ unsafe extern "C" fn base_sink_propose_allocation<T: BaseSinkImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr); let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };

View file

@ -111,7 +111,7 @@ pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl {
fn decide_allocation( fn decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_decide_allocation(element, query) self.parent_decide_allocation(element, query)
} }
@ -180,7 +180,7 @@ pub trait BaseSrcImplExt: ObjectSubclass {
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
} }
@ -587,7 +587,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -1020,7 +1020,7 @@ unsafe extern "C" fn base_src_decide_allocation<T: BaseSrcImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr); let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };

View file

@ -138,8 +138,8 @@ pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl {
fn propose_allocation( fn propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
decide_query: Option<gst::query::Allocation<&gst::QueryRef>>, decide_query: Option<&gst::query::Allocation>,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_propose_allocation(element, decide_query, query) self.parent_propose_allocation(element, decide_query, query)
} }
@ -147,7 +147,7 @@ pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl {
fn decide_allocation( fn decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_decide_allocation(element, query) self.parent_decide_allocation(element, query)
} }
@ -277,14 +277,14 @@ pub trait BaseTransformImplExt: ObjectSubclass {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
decide_query: Option<gst::query::Allocation<&gst::QueryRef>>, decide_query: Option<&gst::query::Allocation>,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
fn parent_copy_metadata( fn parent_copy_metadata(
@ -717,8 +717,8 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
decide_query: Option<gst::query::Allocation<&gst::QueryRef>>, decide_query: Option<&gst::query::Allocation>,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -746,7 +746,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -1329,7 +1329,7 @@ unsafe extern "C" fn base_transform_propose_allocation<T: BaseTransformImpl>(
} }
}; };
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };
@ -1353,7 +1353,7 @@ unsafe extern "C" fn base_transform_decide_allocation<T: BaseTransformImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr); let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };

View file

@ -7,7 +7,7 @@ use std::ptr;
#[doc(alias = "gst_gl_handle_context_query")] #[doc(alias = "gst_gl_handle_context_query")]
pub fn gl_handle_context_query( pub fn gl_handle_context_query(
element: &impl IsA<gst::Element>, element: &impl IsA<gst::Element>,
query: gst::query::Context<&mut gst::QueryRef>, query: &mut gst::query::Context,
display: Option<&impl IsA<GLDisplay>>, display: Option<&impl IsA<GLDisplay>>,
context: Option<&impl IsA<GLContext>>, context: Option<&impl IsA<GLContext>>,
other_context: Option<&impl IsA<GLContext>>, other_context: Option<&impl IsA<GLContext>>,

View file

@ -91,7 +91,7 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl {
fn propose_allocation( fn propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_propose_allocation(element, query) self.parent_propose_allocation(element, query)
} }
@ -99,7 +99,7 @@ pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl {
fn decide_allocation( fn decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_decide_allocation(element, query) self.parent_decide_allocation(element, query)
} }
@ -166,13 +166,13 @@ pub trait VideoDecoderImplExt: ObjectSubclass {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
#[cfg(any(feature = "v1_20", feature = "dox"))] #[cfg(any(feature = "v1_20", feature = "dox"))]
@ -494,7 +494,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -518,7 +518,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -869,7 +869,7 @@ unsafe extern "C" fn video_decoder_propose_allocation<T: VideoDecoderImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr); let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };
@ -893,7 +893,7 @@ unsafe extern "C" fn video_decoder_decide_allocation<T: VideoDecoderImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr); let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };

View file

@ -77,7 +77,7 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl {
fn propose_allocation( fn propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_propose_allocation(element, query) self.parent_propose_allocation(element, query)
} }
@ -85,7 +85,7 @@ pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl {
fn decide_allocation( fn decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
self.parent_decide_allocation(element, query) self.parent_decide_allocation(element, query)
} }
@ -131,13 +131,13 @@ pub trait VideoEncoderImplExt: ObjectSubclass {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError>; ) -> Result<(), gst::LoggableError>;
} }
@ -410,7 +410,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
fn parent_propose_allocation( fn parent_propose_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -434,7 +434,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
fn parent_decide_allocation( fn parent_decide_allocation(
&self, &self,
element: &Self::Type, element: &Self::Type,
query: gst::query::Allocation<&mut gst::QueryRef>, query: &mut gst::query::Allocation,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
@ -721,7 +721,7 @@ unsafe extern "C" fn video_encoder_propose_allocation<T: VideoEncoderImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr); let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };
@ -745,7 +745,7 @@ unsafe extern "C" fn video_encoder_decide_allocation<T: VideoEncoderImpl>(
let imp = instance.imp(); let imp = instance.imp();
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr); let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
gst::QueryView::Allocation(allocation) => allocation, gst::QueryViewMut::Allocation(allocation) => allocation,
_ => unreachable!(), _ => unreachable!(),
}; };

View file

@ -4,6 +4,7 @@ use crate::structure::*;
use crate::ClockTime; use crate::ClockTime;
use crate::GenericFormattedValue; use crate::GenericFormattedValue;
use std::borrow::Borrow;
use std::cmp; use std::cmp;
use std::ffi::CStr; use std::ffi::CStr;
use std::fmt; use std::fmt;
@ -12,9 +13,7 @@ use std::num::NonZeroU32;
use std::ops::Deref; use std::ops::Deref;
use std::ptr; use std::ptr;
use glib::translate::{ use glib::translate::*;
from_glib, from_glib_full, from_glib_none, try_from_glib, IntoGlib, ToGlibPtr,
};
use glib::value::ToSendValue; use glib::value::ToSendValue;
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
@ -221,55 +220,49 @@ impl EventRef {
self.structure().map_or(false, |s| s.has_name(name)) self.structure().map_or(false, |s| s.has_name(name))
} }
pub fn view(&self) -> EventView<&EventRef> { pub fn view(&self) -> EventView {
let type_ = unsafe { (*self.as_ptr()).type_ }; unsafe {
let type_ = (*self.as_ptr()).type_;
match type_ { match type_ {
ffi::GST_EVENT_FLUSH_START => EventView::FlushStart(FlushStart(self)), ffi::GST_EVENT_FLUSH_START => FlushStart::view(self),
ffi::GST_EVENT_FLUSH_STOP => EventView::FlushStop(FlushStop(self)), ffi::GST_EVENT_FLUSH_STOP => FlushStop::view(self),
ffi::GST_EVENT_STREAM_START => EventView::StreamStart(StreamStart(self)), ffi::GST_EVENT_STREAM_START => StreamStart::view(self),
ffi::GST_EVENT_CAPS => EventView::Caps(Caps(self)), ffi::GST_EVENT_CAPS => Caps::view(self),
ffi::GST_EVENT_SEGMENT => EventView::Segment(Segment(self)), ffi::GST_EVENT_SEGMENT => Segment::view(self),
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
ffi::GST_EVENT_STREAM_COLLECTION => EventView::StreamCollection(StreamCollection(self)), ffi::GST_EVENT_STREAM_COLLECTION => StreamCollection::view(self),
ffi::GST_EVENT_TAG => EventView::Tag(Tag(self)), ffi::GST_EVENT_TAG => Tag::view(self),
ffi::GST_EVENT_BUFFERSIZE => EventView::Buffersize(Buffersize(self)), ffi::GST_EVENT_BUFFERSIZE => Buffersize::view(self),
ffi::GST_EVENT_SINK_MESSAGE => EventView::SinkMessage(SinkMessage(self)), ffi::GST_EVENT_SINK_MESSAGE => SinkMessage::view(self),
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
ffi::GST_EVENT_STREAM_GROUP_DONE => EventView::StreamGroupDone(StreamGroupDone(self)), ffi::GST_EVENT_STREAM_GROUP_DONE => StreamGroupDone::view(self),
ffi::GST_EVENT_EOS => EventView::Eos(Eos(self)), ffi::GST_EVENT_EOS => Eos::view(self),
ffi::GST_EVENT_TOC => EventView::Toc(Toc(self)), ffi::GST_EVENT_TOC => Toc::view(self),
ffi::GST_EVENT_PROTECTION => EventView::Protection(Protection(self)), ffi::GST_EVENT_PROTECTION => Protection::view(self),
ffi::GST_EVENT_SEGMENT_DONE => EventView::SegmentDone(SegmentDone(self)), ffi::GST_EVENT_SEGMENT_DONE => SegmentDone::view(self),
ffi::GST_EVENT_GAP => EventView::Gap(Gap(self)), ffi::GST_EVENT_GAP => Gap::view(self),
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
ffi::GST_EVENT_INSTANT_RATE_CHANGE => { ffi::GST_EVENT_INSTANT_RATE_CHANGE => InstantRateChange::view(self),
EventView::InstantRateChange(InstantRateChange(self)) ffi::GST_EVENT_QOS => Qos::view(self),
ffi::GST_EVENT_SEEK => Seek::view(self),
ffi::GST_EVENT_NAVIGATION => Navigation::view(self),
ffi::GST_EVENT_LATENCY => Latency::view(self),
ffi::GST_EVENT_STEP => Step::view(self),
ffi::GST_EVENT_RECONFIGURE => Reconfigure::view(self),
ffi::GST_EVENT_TOC_SELECT => TocSelect::view(self),
#[cfg(any(feature = "v1_10", feature = "dox"))]
ffi::GST_EVENT_SELECT_STREAMS => SelectStreams::view(self),
#[cfg(any(feature = "v1_18", feature = "dox"))]
ffi::GST_EVENT_INSTANT_RATE_SYNC_TIME => InstantRateSyncTime::view(self),
ffi::GST_EVENT_CUSTOM_UPSTREAM => CustomUpstream::view(self),
ffi::GST_EVENT_CUSTOM_DOWNSTREAM => CustomDownstream::view(self),
ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB => CustomDownstreamOob::view(self),
ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY => CustomDownstreamSticky::view(self),
ffi::GST_EVENT_CUSTOM_BOTH => CustomBoth::view(self),
ffi::GST_EVENT_CUSTOM_BOTH_OOB => CustomBothOob::view(self),
_ => Other::view(self),
} }
ffi::GST_EVENT_QOS => EventView::Qos(Qos(self)),
ffi::GST_EVENT_SEEK => EventView::Seek(Seek(self)),
ffi::GST_EVENT_NAVIGATION => EventView::Navigation(Navigation(self)),
ffi::GST_EVENT_LATENCY => EventView::Latency(Latency(self)),
ffi::GST_EVENT_STEP => EventView::Step(Step(self)),
ffi::GST_EVENT_RECONFIGURE => EventView::Reconfigure(Reconfigure(self)),
ffi::GST_EVENT_TOC_SELECT => EventView::TocSelect(TocSelect(self)),
#[cfg(any(feature = "v1_10", feature = "dox"))]
ffi::GST_EVENT_SELECT_STREAMS => EventView::SelectStreams(SelectStreams(self)),
#[cfg(any(feature = "v1_18", feature = "dox"))]
ffi::GST_EVENT_INSTANT_RATE_SYNC_TIME => {
EventView::InstantRateSyncTime(InstantRateSyncTime(self))
}
ffi::GST_EVENT_CUSTOM_UPSTREAM => EventView::CustomUpstream(CustomUpstream(self)),
ffi::GST_EVENT_CUSTOM_DOWNSTREAM => EventView::CustomDownstream(CustomDownstream(self)),
ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB => {
EventView::CustomDownstreamOob(CustomDownstreamOob(self))
}
ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY => {
EventView::CustomDownstreamSticky(CustomDownstreamSticky(self))
}
ffi::GST_EVENT_CUSTOM_BOTH => EventView::CustomBoth(CustomBoth(self)),
ffi::GST_EVENT_CUSTOM_BOTH_OOB => EventView::CustomBothOob(CustomBothOob(self)),
_ => EventView::Other(Other(self)),
} }
} }
} }
@ -291,116 +284,122 @@ impl fmt::Debug for EventRef {
} }
} }
pub unsafe trait AsPtr { pub trait StickyEventType: ToOwned {
unsafe fn as_ptr(&self) -> *mut ffi::GstEvent;
}
unsafe impl AsPtr for Event {
unsafe fn as_ptr(&self) -> *mut ffi::GstEvent {
EventRef::as_ptr(self) as *mut ffi::GstEvent
}
}
unsafe impl<'a> AsPtr for &'a EventRef {
unsafe fn as_ptr(&self) -> *mut ffi::GstEvent {
EventRef::as_ptr(self) as *mut ffi::GstEvent
}
}
pub trait StickyEventType {
const TYPE: EventType; const TYPE: EventType;
unsafe fn from_event(event: Event) -> Self; unsafe fn from_event(event: Event) -> Self::Owned;
} }
#[derive(Debug)] #[derive(Debug)]
#[non_exhaustive] #[non_exhaustive]
pub enum EventView<T> { pub enum EventView<'a> {
FlushStart(FlushStart<T>), FlushStart(&'a FlushStart),
FlushStop(FlushStop<T>), FlushStop(&'a FlushStop),
StreamStart(StreamStart<T>), StreamStart(&'a StreamStart),
Caps(Caps<T>), Caps(&'a Caps),
Segment(Segment<T>), Segment(&'a Segment),
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
StreamCollection(StreamCollection<T>), StreamCollection(&'a StreamCollection),
Tag(Tag<T>), Tag(&'a Tag),
Buffersize(Buffersize<T>), Buffersize(&'a Buffersize),
SinkMessage(SinkMessage<T>), SinkMessage(&'a SinkMessage),
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
StreamGroupDone(StreamGroupDone<T>), StreamGroupDone(&'a StreamGroupDone),
Eos(Eos<T>), Eos(&'a Eos),
Toc(Toc<T>), Toc(&'a Toc),
Protection(Protection<T>), Protection(&'a Protection),
SegmentDone(SegmentDone<T>), SegmentDone(&'a SegmentDone),
Gap(Gap<T>), Gap(&'a Gap),
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
InstantRateChange(InstantRateChange<T>), InstantRateChange(&'a InstantRateChange),
Qos(Qos<T>), Qos(&'a Qos),
Seek(Seek<T>), Seek(&'a Seek),
Navigation(Navigation<T>), Navigation(&'a Navigation),
Latency(Latency<T>), Latency(&'a Latency),
Step(Step<T>), Step(&'a Step),
Reconfigure(Reconfigure<T>), Reconfigure(&'a Reconfigure),
TocSelect(TocSelect<T>), TocSelect(&'a TocSelect),
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
SelectStreams(SelectStreams<T>), SelectStreams(&'a SelectStreams),
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
InstantRateSyncTime(InstantRateSyncTime<T>), InstantRateSyncTime(&'a InstantRateSyncTime),
CustomUpstream(CustomUpstream<T>), CustomUpstream(&'a CustomUpstream),
CustomDownstream(CustomDownstream<T>), CustomDownstream(&'a CustomDownstream),
CustomDownstreamOob(CustomDownstreamOob<T>), CustomDownstreamOob(&'a CustomDownstreamOob),
CustomDownstreamSticky(CustomDownstreamSticky<T>), CustomDownstreamSticky(&'a CustomDownstreamSticky),
CustomBoth(CustomBoth<T>), CustomBoth(&'a CustomBoth),
CustomBothOob(CustomBothOob<T>), CustomBothOob(&'a CustomBothOob),
Other(Other<T>), Other(&'a Other),
} }
macro_rules! declare_concrete_event { macro_rules! declare_concrete_event {
(@sticky $name:ident, $param:ident) => { (@sticky $name:ident, $param:ident) => {
declare_concrete_event!($name, $param); declare_concrete_event!($name, $param);
impl StickyEventType for $name<Event> { impl StickyEventType for $name {
const TYPE: EventType = EventType::$name; const TYPE: EventType = EventType::$name;
unsafe fn from_event(event: Event) -> Self { unsafe fn from_event(event: Event) -> Self::Owned {
Self(event) $name::<Event>(event)
} }
} }
}; };
($name:ident, $param:ident) => { ($name:ident, $param:ident) => {
#[derive(Debug)] #[derive(Debug)]
pub struct $name<$param>($param); #[repr(transparent)]
pub struct $name<$param = EventRef>($param);
impl<'a> $name<&'a EventRef> { impl $name {
pub fn event(&self) -> &EventRef { pub fn event(&self) -> &EventRef {
self.0 unsafe { &*(self as *const Self as *const EventRef) }
}
unsafe fn view(event: &EventRef) -> EventView<'_> {
let event = &*(event as *const EventRef as *const Self);
EventView::$name(event)
} }
} }
impl<'a> Deref for $name<&'a EventRef> { impl Deref for $name {
type Target = EventRef; type Target = EventRef;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
self.0 self.event()
} }
} }
impl Deref for $name<Event> { impl ToOwned for $name {
type Target = EventRef; type Owned = $name<Event>;
fn deref(&self) -> &Self::Target { fn to_owned(&self) -> Self::Owned {
&self.0 $name::<Event>(self.copy())
} }
} }
impl $name<Event> { impl $name<Event> {
pub fn get_mut(&mut self) -> Option<&mut EventRef> { pub fn get_mut(&mut self) -> Option<&mut $name> {
self.0.get_mut() self.0
.get_mut()
.map(|event| unsafe { &mut *(event as *mut EventRef as *mut $name) })
}
}
impl Deref for $name<Event> {
type Target = $name;
fn deref(&self) -> &Self::Target {
unsafe { &*(self.0.as_ptr() as *const Self::Target) }
}
}
impl Borrow<$name> for $name<Event> {
fn borrow(&self) -> &$name {
&*self
} }
} }
@ -443,14 +442,14 @@ impl FlushStop<Event> {
} }
} }
impl<T: AsPtr> FlushStop<T> { impl FlushStop {
#[doc(alias = "get_reset_time")] #[doc(alias = "get_reset_time")]
#[doc(alias = "gst_event_parse_flush_stop")] #[doc(alias = "gst_event_parse_flush_stop")]
pub fn resets_time(&self) -> bool { pub fn resets_time(&self) -> bool {
unsafe { unsafe {
let mut reset_time = mem::MaybeUninit::uninit(); let mut reset_time = mem::MaybeUninit::uninit();
ffi::gst_event_parse_flush_stop(self.0.as_ptr(), reset_time.as_mut_ptr()); ffi::gst_event_parse_flush_stop(self.as_mut_ptr(), reset_time.as_mut_ptr());
from_glib(reset_time.assume_init()) from_glib(reset_time.assume_init())
} }
@ -470,40 +469,27 @@ impl StreamStart<Event> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
StreamStartBuilder::new(stream_id) StreamStartBuilder::new(stream_id)
} }
}
impl StreamStart {
#[doc(alias = "get_stream_id")] #[doc(alias = "get_stream_id")]
#[doc(alias = "gst_event_parse_stream_start")] #[doc(alias = "gst_event_parse_stream_start")]
pub fn stream_id(&self) -> &str { pub fn stream_id(&self) -> &str {
unsafe { unsafe {
let mut stream_id = ptr::null(); let mut stream_id = ptr::null();
ffi::gst_event_parse_stream_start(AsPtr::as_ptr(&self.0), &mut stream_id); ffi::gst_event_parse_stream_start(self.as_mut_ptr(), &mut stream_id);
CStr::from_ptr(stream_id).to_str().unwrap() CStr::from_ptr(stream_id).to_str().unwrap()
} }
} }
}
impl<'a> StreamStart<&'a EventRef> {
#[doc(alias = "get_stream_id")]
#[doc(alias = "gst_event_parse_stream_start")]
pub fn stream_id(&self) -> &'a str {
unsafe {
let mut stream_id = ptr::null();
ffi::gst_event_parse_stream_start(AsPtr::as_ptr(&self.0), &mut stream_id);
CStr::from_ptr(stream_id).to_str().unwrap()
}
}
}
impl<T: AsPtr> StreamStart<T> {
#[doc(alias = "get_stream_flags")] #[doc(alias = "get_stream_flags")]
#[doc(alias = "gst_event_parse_stream_flags")] #[doc(alias = "gst_event_parse_stream_flags")]
pub fn stream_flags(&self) -> crate::StreamFlags { pub fn stream_flags(&self) -> crate::StreamFlags {
unsafe { unsafe {
let mut stream_flags = mem::MaybeUninit::uninit(); let mut stream_flags = mem::MaybeUninit::uninit();
ffi::gst_event_parse_stream_flags(self.0.as_ptr(), stream_flags.as_mut_ptr()); ffi::gst_event_parse_stream_flags(self.as_mut_ptr(), stream_flags.as_mut_ptr());
from_glib(stream_flags.assume_init()) from_glib(stream_flags.assume_init())
} }
@ -515,7 +501,7 @@ impl<T: AsPtr> StreamStart<T> {
unsafe { unsafe {
let mut group_id = mem::MaybeUninit::uninit(); let mut group_id = mem::MaybeUninit::uninit();
ffi::gst_event_parse_group_id(self.0.as_ptr(), group_id.as_mut_ptr()); ffi::gst_event_parse_group_id(self.as_mut_ptr(), group_id.as_mut_ptr());
let group_id = group_id.assume_init(); let group_id = group_id.assume_init();
if group_id == 0 { if group_id == 0 {
@ -533,7 +519,7 @@ impl<T: AsPtr> StreamStart<T> {
pub fn stream(&self) -> Option<crate::Stream> { pub fn stream(&self) -> Option<crate::Stream> {
unsafe { unsafe {
let mut stream = ptr::null_mut(); let mut stream = ptr::null_mut();
ffi::gst_event_parse_stream(self.0.as_ptr(), &mut stream); ffi::gst_event_parse_stream(self.as_mut_ptr(), &mut stream);
from_glib_full(stream) from_glib_full(stream)
} }
} }
@ -552,33 +538,16 @@ impl Caps<Event> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
CapsBuilder::new(caps) CapsBuilder::new(caps)
} }
}
impl Caps {
#[doc(alias = "get_caps")] #[doc(alias = "get_caps")]
#[doc(alias = "gst_event_parse_caps")] #[doc(alias = "gst_event_parse_caps")]
pub fn caps(&self) -> &crate::CapsRef { pub fn caps(&self) -> &crate::CapsRef {
unsafe { unsafe {
let mut caps = ptr::null_mut(); let mut caps = ptr::null_mut();
ffi::gst_event_parse_caps(AsPtr::as_ptr(&self.0), &mut caps); ffi::gst_event_parse_caps(self.as_mut_ptr(), &mut caps);
crate::CapsRef::from_ptr(caps)
}
}
#[doc(alias = "get_caps_owned")]
#[doc(alias = "gst_event_parse_caps")]
pub fn caps_owned(&self) -> crate::Caps {
unsafe { from_glib_none(self.caps().as_ptr()) }
}
}
impl<'a> Caps<&'a EventRef> {
#[doc(alias = "get_caps")]
#[doc(alias = "gst_event_parse_caps")]
pub fn caps(&self) -> &'a crate::CapsRef {
unsafe {
let mut caps = ptr::null_mut();
ffi::gst_event_parse_caps(AsPtr::as_ptr(&self.0), &mut caps);
crate::CapsRef::from_ptr(caps) crate::CapsRef::from_ptr(caps)
} }
} }
@ -605,27 +574,16 @@ impl Segment<Event> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
SegmentBuilder::new(segment.as_ref()) SegmentBuilder::new(segment.as_ref())
} }
}
impl Segment {
#[doc(alias = "get_segment")] #[doc(alias = "get_segment")]
#[doc(alias = "gst_event_parse_segment")] #[doc(alias = "gst_event_parse_segment")]
pub fn segment(&self) -> &crate::Segment { pub fn segment(&self) -> &crate::Segment {
unsafe { unsafe {
let mut segment = ptr::null(); let mut segment = ptr::null();
ffi::gst_event_parse_segment(AsPtr::as_ptr(&self.0), &mut segment); ffi::gst_event_parse_segment(self.as_mut_ptr(), &mut segment);
&*(segment as *mut ffi::GstSegment as *mut crate::Segment)
}
}
}
impl<'a> Segment<&'a EventRef> {
#[doc(alias = "get_segment")]
#[doc(alias = "gst_event_parse_segment")]
pub fn segment(&self) -> &'a crate::Segment {
unsafe {
let mut segment = ptr::null();
ffi::gst_event_parse_segment(AsPtr::as_ptr(&self.0), &mut segment);
&*(segment as *mut ffi::GstSegment as *mut crate::Segment) &*(segment as *mut ffi::GstSegment as *mut crate::Segment)
} }
} }
@ -656,7 +614,7 @@ impl StreamCollection<Event> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
impl<T: AsPtr> StreamCollection<T> { impl StreamCollection {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
#[doc(alias = "get_stream_collection")] #[doc(alias = "get_stream_collection")]
@ -665,7 +623,7 @@ impl<T: AsPtr> StreamCollection<T> {
unsafe { unsafe {
let mut stream_collection = ptr::null_mut(); let mut stream_collection = ptr::null_mut();
ffi::gst_event_parse_stream_collection(self.0.as_ptr(), &mut stream_collection); ffi::gst_event_parse_stream_collection(self.as_mut_ptr(), &mut stream_collection);
from_glib_full(stream_collection) from_glib_full(stream_collection)
} }
} }
@ -684,33 +642,16 @@ impl Tag<Event> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
TagBuilder::new(tags) TagBuilder::new(tags)
} }
}
impl Tag {
#[doc(alias = "get_tag")] #[doc(alias = "get_tag")]
#[doc(alias = "gst_event_parse_tag")] #[doc(alias = "gst_event_parse_tag")]
pub fn tag(&self) -> &crate::TagListRef { pub fn tag(&self) -> &crate::TagListRef {
unsafe { unsafe {
let mut tags = ptr::null_mut(); let mut tags = ptr::null_mut();
ffi::gst_event_parse_tag(AsPtr::as_ptr(&self.0), &mut tags); ffi::gst_event_parse_tag(self.as_mut_ptr(), &mut tags);
crate::TagListRef::from_ptr(tags)
}
}
#[doc(alias = "get_tag_owned")]
#[doc(alias = "gst_event_parse_tag")]
pub fn tag_owned(&self) -> crate::TagList {
unsafe { from_glib_none(self.tag().as_ptr()) }
}
}
impl<'a> Tag<&'a EventRef> {
#[doc(alias = "get_tag")]
#[doc(alias = "gst_event_parse_tag")]
pub fn tag(&self) -> &'a crate::TagListRef {
unsafe {
let mut tags = ptr::null_mut();
ffi::gst_event_parse_tag(AsPtr::as_ptr(&self.0), &mut tags);
crate::TagListRef::from_ptr(tags) crate::TagListRef::from_ptr(tags)
} }
} }
@ -745,7 +686,7 @@ impl Buffersize<Event> {
} }
} }
impl<T: AsPtr> Buffersize<T> { impl Buffersize {
#[doc(alias = "gst_event_parse_buffer_size")] #[doc(alias = "gst_event_parse_buffer_size")]
pub fn get(&self) -> (GenericFormattedValue, GenericFormattedValue, bool) { pub fn get(&self) -> (GenericFormattedValue, GenericFormattedValue, bool) {
unsafe { unsafe {
@ -755,7 +696,7 @@ impl<T: AsPtr> Buffersize<T> {
let mut async_ = mem::MaybeUninit::uninit(); let mut async_ = mem::MaybeUninit::uninit();
ffi::gst_event_parse_buffer_size( ffi::gst_event_parse_buffer_size(
self.0.as_ptr(), self.as_mut_ptr(),
fmt.as_mut_ptr(), fmt.as_mut_ptr(),
minsize.as_mut_ptr(), minsize.as_mut_ptr(),
maxsize.as_mut_ptr(), maxsize.as_mut_ptr(),
@ -785,14 +726,14 @@ impl SinkMessage<Event> {
} }
} }
impl<T: AsPtr> SinkMessage<T> { impl SinkMessage {
#[doc(alias = "get_message")] #[doc(alias = "get_message")]
#[doc(alias = "gst_event_parse_sink_message")] #[doc(alias = "gst_event_parse_sink_message")]
pub fn message(&self) -> crate::Message { pub fn message(&self) -> crate::Message {
unsafe { unsafe {
let mut msg = ptr::null_mut(); let mut msg = ptr::null_mut();
ffi::gst_event_parse_sink_message(self.0.as_ptr(), &mut msg); ffi::gst_event_parse_sink_message(self.as_mut_ptr(), &mut msg);
from_glib_full(msg) from_glib_full(msg)
} }
} }
@ -823,7 +764,7 @@ impl StreamGroupDone<Event> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
impl<T: AsPtr> StreamGroupDone<T> { impl StreamGroupDone {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
#[doc(alias = "get_group_id")] #[doc(alias = "get_group_id")]
@ -832,7 +773,7 @@ impl<T: AsPtr> StreamGroupDone<T> {
unsafe { unsafe {
let mut group_id = mem::MaybeUninit::uninit(); let mut group_id = mem::MaybeUninit::uninit();
ffi::gst_event_parse_stream_group_done(self.0.as_ptr(), group_id.as_mut_ptr()); ffi::gst_event_parse_stream_group_done(self.as_mut_ptr(), group_id.as_mut_ptr());
let group_id = group_id.assume_init(); let group_id = group_id.assume_init();
assert_ne!(group_id, 0); assert_ne!(group_id, 0);
@ -873,7 +814,7 @@ impl Toc<Event> {
} }
} }
impl<T: AsPtr> Toc<T> { impl Toc {
#[doc(alias = "get_toc")] #[doc(alias = "get_toc")]
#[doc(alias = "gst_event_parse_toc")] #[doc(alias = "gst_event_parse_toc")]
pub fn toc(&self) -> (&crate::TocRef, bool) { pub fn toc(&self) -> (&crate::TocRef, bool) {
@ -881,7 +822,7 @@ impl<T: AsPtr> Toc<T> {
let mut toc = ptr::null_mut(); let mut toc = ptr::null_mut();
let mut updated = mem::MaybeUninit::uninit(); let mut updated = mem::MaybeUninit::uninit();
ffi::gst_event_parse_toc(self.0.as_ptr(), &mut toc, updated.as_mut_ptr()); ffi::gst_event_parse_toc(self.as_mut_ptr(), &mut toc, updated.as_mut_ptr());
( (
crate::TocRef::from_ptr(toc), crate::TocRef::from_ptr(toc),
from_glib(updated.assume_init()), from_glib(updated.assume_init()),
@ -914,7 +855,7 @@ impl Protection<Event> {
} }
} }
impl<T: AsPtr> Protection<T> { impl Protection {
#[doc(alias = "gst_event_parse_protection")] #[doc(alias = "gst_event_parse_protection")]
pub fn get(&self) -> (&str, &crate::BufferRef, Option<&str>) { pub fn get(&self) -> (&str, &crate::BufferRef, Option<&str>) {
unsafe { unsafe {
@ -923,7 +864,7 @@ impl<T: AsPtr> Protection<T> {
let mut origin = ptr::null(); let mut origin = ptr::null();
ffi::gst_event_parse_protection( ffi::gst_event_parse_protection(
self.0.as_ptr(), self.as_mut_ptr(),
&mut system_id, &mut system_id,
&mut buffer, &mut buffer,
&mut origin, &mut origin,
@ -966,7 +907,7 @@ impl SegmentDone<Event> {
} }
} }
impl<T: AsPtr> SegmentDone<T> { impl SegmentDone {
#[doc(alias = "gst_event_parse_segment_done")] #[doc(alias = "gst_event_parse_segment_done")]
pub fn get(&self) -> GenericFormattedValue { pub fn get(&self) -> GenericFormattedValue {
unsafe { unsafe {
@ -974,7 +915,7 @@ impl<T: AsPtr> SegmentDone<T> {
let mut position = mem::MaybeUninit::uninit(); let mut position = mem::MaybeUninit::uninit();
ffi::gst_event_parse_segment_done( ffi::gst_event_parse_segment_done(
self.0.as_ptr(), self.as_mut_ptr(),
fmt.as_mut_ptr(), fmt.as_mut_ptr(),
position.as_mut_ptr(), position.as_mut_ptr(),
); );
@ -999,7 +940,7 @@ impl Gap<Event> {
} }
} }
impl<T: AsPtr> Gap<T> { impl Gap {
#[doc(alias = "gst_event_parse_gap")] #[doc(alias = "gst_event_parse_gap")]
pub fn get(&self) -> (ClockTime, Option<ClockTime>) { pub fn get(&self) -> (ClockTime, Option<ClockTime>) {
unsafe { unsafe {
@ -1007,7 +948,7 @@ impl<T: AsPtr> Gap<T> {
let mut duration = mem::MaybeUninit::uninit(); let mut duration = mem::MaybeUninit::uninit();
ffi::gst_event_parse_gap( ffi::gst_event_parse_gap(
self.0.as_ptr(), self.as_mut_ptr(),
timestamp.as_mut_ptr(), timestamp.as_mut_ptr(),
duration.as_mut_ptr(), duration.as_mut_ptr(),
); );
@ -1025,7 +966,7 @@ impl<T: AsPtr> Gap<T> {
pub fn gap_flags(&self) -> crate::GapFlags { pub fn gap_flags(&self) -> crate::GapFlags {
unsafe { unsafe {
let mut flags = mem::MaybeUninit::uninit(); let mut flags = mem::MaybeUninit::uninit();
ffi::gst_event_parse_gap_flags(self.0.as_ptr(), flags.as_mut_ptr()); ffi::gst_event_parse_gap_flags(self.as_mut_ptr(), flags.as_mut_ptr());
from_glib(flags.assume_init()) from_glib(flags.assume_init())
} }
} }
@ -1055,7 +996,7 @@ impl InstantRateChange<Event> {
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
impl<T: AsPtr> InstantRateChange<T> { impl InstantRateChange {
#[doc(alias = "gst_event_parse_instant_rate_change")] #[doc(alias = "gst_event_parse_instant_rate_change")]
pub fn get(&self) -> (f64, crate::SegmentFlags) { pub fn get(&self) -> (f64, crate::SegmentFlags) {
unsafe { unsafe {
@ -1063,7 +1004,7 @@ impl<T: AsPtr> InstantRateChange<T> {
let mut new_flags = mem::MaybeUninit::uninit(); let mut new_flags = mem::MaybeUninit::uninit();
ffi::gst_event_parse_instant_rate_change( ffi::gst_event_parse_instant_rate_change(
self.0.as_ptr(), self.as_mut_ptr(),
multiplier.as_mut_ptr(), multiplier.as_mut_ptr(),
new_flags.as_mut_ptr(), new_flags.as_mut_ptr(),
); );
@ -1095,7 +1036,7 @@ impl Qos<Event> {
} }
} }
impl<T: AsPtr> Qos<T> { impl Qos {
#[doc(alias = "gst_event_parse_qos")] #[doc(alias = "gst_event_parse_qos")]
pub fn get(&self) -> (crate::QOSType, f64, i64, Option<ClockTime>) { pub fn get(&self) -> (crate::QOSType, f64, i64, Option<ClockTime>) {
unsafe { unsafe {
@ -1105,7 +1046,7 @@ impl<T: AsPtr> Qos<T> {
let mut timestamp = mem::MaybeUninit::uninit(); let mut timestamp = mem::MaybeUninit::uninit();
ffi::gst_event_parse_qos( ffi::gst_event_parse_qos(
self.0.as_ptr(), self.as_mut_ptr(),
type_.as_mut_ptr(), type_.as_mut_ptr(),
proportion.as_mut_ptr(), proportion.as_mut_ptr(),
diff.as_mut_ptr(), diff.as_mut_ptr(),
@ -1155,7 +1096,7 @@ impl Seek<Event> {
} }
} }
impl<T: AsPtr> Seek<T> { impl Seek {
#[doc(alias = "gst_event_parse_seek")] #[doc(alias = "gst_event_parse_seek")]
pub fn get( pub fn get(
&self, &self,
@ -1177,7 +1118,7 @@ impl<T: AsPtr> Seek<T> {
let mut stop = mem::MaybeUninit::uninit(); let mut stop = mem::MaybeUninit::uninit();
ffi::gst_event_parse_seek( ffi::gst_event_parse_seek(
self.0.as_ptr(), self.as_mut_ptr(),
rate.as_mut_ptr(), rate.as_mut_ptr(),
fmt.as_mut_ptr(), fmt.as_mut_ptr(),
flags.as_mut_ptr(), flags.as_mut_ptr(),
@ -1207,7 +1148,7 @@ impl<T: AsPtr> Seek<T> {
let mut trickmode_interval = mem::MaybeUninit::uninit(); let mut trickmode_interval = mem::MaybeUninit::uninit();
ffi::gst_event_parse_seek_trickmode_interval( ffi::gst_event_parse_seek_trickmode_interval(
self.0.as_ptr(), self.as_mut_ptr(),
trickmode_interval.as_mut_ptr(), trickmode_interval.as_mut_ptr(),
); );
@ -1246,14 +1187,14 @@ impl Latency<Event> {
} }
} }
impl<T: AsPtr> Latency<T> { impl Latency {
#[doc(alias = "get_latency")] #[doc(alias = "get_latency")]
#[doc(alias = "gst_event_parse_latency")] #[doc(alias = "gst_event_parse_latency")]
pub fn latency(&self) -> ClockTime { pub fn latency(&self) -> ClockTime {
unsafe { unsafe {
let mut latency = mem::MaybeUninit::uninit(); let mut latency = mem::MaybeUninit::uninit();
ffi::gst_event_parse_latency(self.0.as_ptr(), latency.as_mut_ptr()); ffi::gst_event_parse_latency(self.as_mut_ptr(), latency.as_mut_ptr());
try_from_glib(latency.assume_init()).expect("undefined latency") try_from_glib(latency.assume_init()).expect("undefined latency")
} }
@ -1285,7 +1226,7 @@ impl Step<Event> {
} }
} }
impl<T: AsPtr> Step<T> { impl Step {
#[doc(alias = "gst_event_parse_step")] #[doc(alias = "gst_event_parse_step")]
pub fn get(&self) -> (GenericFormattedValue, f64, bool, bool) { pub fn get(&self) -> (GenericFormattedValue, f64, bool, bool) {
unsafe { unsafe {
@ -1296,7 +1237,7 @@ impl<T: AsPtr> Step<T> {
let mut intermediate = mem::MaybeUninit::uninit(); let mut intermediate = mem::MaybeUninit::uninit();
ffi::gst_event_parse_step( ffi::gst_event_parse_step(
self.0.as_ptr(), self.as_mut_ptr(),
fmt.as_mut_ptr(), fmt.as_mut_ptr(),
amount.as_mut_ptr(), amount.as_mut_ptr(),
rate.as_mut_ptr(), rate.as_mut_ptr(),
@ -1345,26 +1286,15 @@ impl TocSelect<Event> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
TocSelectBuilder::new(uid) TocSelectBuilder::new(uid)
} }
}
impl TocSelect {
#[doc(alias = "get_uid")] #[doc(alias = "get_uid")]
pub fn uid(&self) -> &str { pub fn uid(&self) -> &str {
unsafe { unsafe {
let mut uid = ptr::null_mut(); let mut uid = ptr::null_mut();
ffi::gst_event_parse_toc_select(AsPtr::as_ptr(&self.0), &mut uid); ffi::gst_event_parse_toc_select(self.as_mut_ptr(), &mut uid);
CStr::from_ptr(uid).to_str().unwrap()
}
}
}
impl<'a> TocSelect<&'a EventRef> {
#[doc(alias = "get_uid")]
pub fn uid(&self) -> &'a str {
unsafe {
let mut uid = ptr::null_mut();
ffi::gst_event_parse_toc_select(AsPtr::as_ptr(&self.0), &mut uid);
CStr::from_ptr(uid).to_str().unwrap() CStr::from_ptr(uid).to_str().unwrap()
} }
@ -1396,7 +1326,7 @@ impl SelectStreams<Event> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
impl<T: AsPtr> SelectStreams<T> { impl SelectStreams {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
#[doc(alias = "get_streams")] #[doc(alias = "get_streams")]
@ -1405,7 +1335,7 @@ impl<T: AsPtr> SelectStreams<T> {
unsafe { unsafe {
let mut streams = ptr::null_mut(); let mut streams = ptr::null_mut();
ffi::gst_event_parse_select_streams(self.0.as_ptr(), &mut streams); ffi::gst_event_parse_select_streams(self.as_mut_ptr(), &mut streams);
FromGlibPtrContainer::from_glib_full(streams) FromGlibPtrContainer::from_glib_full(streams)
} }
@ -1445,7 +1375,7 @@ impl InstantRateSyncTime<Event> {
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
impl<T: AsPtr> InstantRateSyncTime<T> { impl InstantRateSyncTime {
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
#[doc(alias = "parse_instant_rate_sync_time")] #[doc(alias = "parse_instant_rate_sync_time")]
@ -1457,7 +1387,7 @@ impl<T: AsPtr> InstantRateSyncTime<T> {
let mut upstream_running_time = mem::MaybeUninit::uninit(); let mut upstream_running_time = mem::MaybeUninit::uninit();
ffi::gst_event_parse_instant_rate_sync_time( ffi::gst_event_parse_instant_rate_sync_time(
self.0.as_ptr(), self.as_mut_ptr(),
rate_multiplier.as_mut_ptr(), rate_multiplier.as_mut_ptr(),
running_time.as_mut_ptr(), running_time.as_mut_ptr(),
upstream_running_time.as_mut_ptr(), upstream_running_time.as_mut_ptr(),
@ -2547,4 +2477,19 @@ mod tests {
let structure = flush_start_evt.structure().unwrap(); let structure = flush_start_evt.structure().unwrap();
assert_eq!(structure.get("test"), Ok(42u32)); assert_eq!(structure.get("test"), Ok(42u32));
} }
#[test]
fn test_view_lifetimes() {
crate::init().unwrap();
let caps = crate::Caps::builder("some/x-caps").build();
let event = crate::event::Caps::new(&caps);
let caps2 = match event.view() {
EventView::Caps(caps) => caps.caps(),
_ => unreachable!(),
};
assert_eq!(&*caps, caps2);
}
} }

View file

@ -115,7 +115,7 @@ pub use crate::bufferlist::{BufferList, BufferListRef};
mod bufferlist_serde; mod bufferlist_serde;
pub mod query; pub mod query;
pub use crate::query::{Query, QueryRef, QueryView}; pub use crate::query::{Query, QueryRef, QueryView, QueryViewMut};
pub mod event; pub mod event;
pub use crate::event::{Event, EventRef, EventView, GroupId, Seqnum}; pub use crate::event::{Event, EventRef, EventView, GroupId, Seqnum};
pub mod context; pub mod context;

View file

@ -9,6 +9,7 @@ use crate::Object;
use crate::Seqnum; use crate::Seqnum;
use crate::TagList; use crate::TagList;
use std::borrow::Borrow;
use std::ffi::CStr; use std::ffi::CStr;
use std::fmt; use std::fmt;
use std::mem; use std::mem;
@ -16,9 +17,7 @@ use std::num::NonZeroU32;
use std::ops::Deref; use std::ops::Deref;
use std::ptr; use std::ptr;
use glib::translate::{ use glib::translate::*;
from_glib, from_glib_full, from_glib_none, mut_override, try_from_glib, IntoGlib, ToGlibPtr,
};
mini_object_wrapper!(Message, MessageRef, ffi::GstMessage, || { mini_object_wrapper!(Message, MessageRef, ffi::GstMessage, || {
ffi::gst_message_get_type() ffi::gst_message_get_type()
@ -74,63 +73,58 @@ impl MessageRef {
} }
pub fn view(&self) -> MessageView { pub fn view(&self) -> MessageView {
let type_ = unsafe { (*self.as_ptr()).type_ }; unsafe {
let type_ = (*self.as_ptr()).type_;
match type_ { match type_ {
ffi::GST_MESSAGE_EOS => MessageView::Eos(Eos(self)), ffi::GST_MESSAGE_EOS => Eos::view(self),
ffi::GST_MESSAGE_ERROR => MessageView::Error(Error(self)), ffi::GST_MESSAGE_ERROR => Error::view(self),
ffi::GST_MESSAGE_WARNING => MessageView::Warning(Warning(self)), ffi::GST_MESSAGE_WARNING => Warning::view(self),
ffi::GST_MESSAGE_INFO => MessageView::Info(Info(self)), ffi::GST_MESSAGE_INFO => Info::view(self),
ffi::GST_MESSAGE_TAG => MessageView::Tag(Tag(self)), ffi::GST_MESSAGE_TAG => Tag::view(self),
ffi::GST_MESSAGE_BUFFERING => MessageView::Buffering(Buffering(self)), ffi::GST_MESSAGE_BUFFERING => Buffering::view(self),
ffi::GST_MESSAGE_STATE_CHANGED => MessageView::StateChanged(StateChanged(self)), ffi::GST_MESSAGE_STATE_CHANGED => StateChanged::view(self),
ffi::GST_MESSAGE_STATE_DIRTY => MessageView::StateDirty(StateDirty(self)), ffi::GST_MESSAGE_STATE_DIRTY => StateDirty::view(self),
ffi::GST_MESSAGE_STEP_DONE => MessageView::StepDone(StepDone(self)), ffi::GST_MESSAGE_STEP_DONE => StepDone::view(self),
ffi::GST_MESSAGE_CLOCK_PROVIDE => MessageView::ClockProvide(ClockProvide(self)), ffi::GST_MESSAGE_CLOCK_PROVIDE => ClockProvide::view(self),
ffi::GST_MESSAGE_CLOCK_LOST => MessageView::ClockLost(ClockLost(self)), ffi::GST_MESSAGE_CLOCK_LOST => ClockLost::view(self),
ffi::GST_MESSAGE_NEW_CLOCK => MessageView::NewClock(NewClock(self)), ffi::GST_MESSAGE_NEW_CLOCK => NewClock::view(self),
ffi::GST_MESSAGE_STRUCTURE_CHANGE => { ffi::GST_MESSAGE_STRUCTURE_CHANGE => StructureChange::view(self),
MessageView::StructureChange(StructureChange(self)) ffi::GST_MESSAGE_STREAM_STATUS => StreamStatus::view(self),
ffi::GST_MESSAGE_APPLICATION => Application::view(self),
ffi::GST_MESSAGE_ELEMENT => Element::view(self),
ffi::GST_MESSAGE_SEGMENT_START => SegmentStart::view(self),
ffi::GST_MESSAGE_SEGMENT_DONE => SegmentDone::view(self),
ffi::GST_MESSAGE_DURATION_CHANGED => DurationChanged::view(self),
ffi::GST_MESSAGE_LATENCY => Latency::view(self),
ffi::GST_MESSAGE_ASYNC_START => AsyncStart::view(self),
ffi::GST_MESSAGE_ASYNC_DONE => AsyncDone::view(self),
ffi::GST_MESSAGE_REQUEST_STATE => RequestState::view(self),
ffi::GST_MESSAGE_STEP_START => StepStart::view(self),
ffi::GST_MESSAGE_QOS => Qos::view(self),
ffi::GST_MESSAGE_PROGRESS => Progress::view(self),
ffi::GST_MESSAGE_TOC => Toc::view(self),
ffi::GST_MESSAGE_RESET_TIME => ResetTime::view(self),
ffi::GST_MESSAGE_STREAM_START => StreamStart::view(self),
ffi::GST_MESSAGE_NEED_CONTEXT => NeedContext::view(self),
ffi::GST_MESSAGE_HAVE_CONTEXT => HaveContext::view(self),
ffi::GST_MESSAGE_DEVICE_ADDED => DeviceAdded::view(self),
ffi::GST_MESSAGE_DEVICE_REMOVED => DeviceRemoved::view(self),
#[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
ffi::GST_MESSAGE_REDIRECT => Redirect::view(self),
#[cfg(any(feature = "v1_10", feature = "dox"))]
ffi::GST_MESSAGE_PROPERTY_NOTIFY => PropertyNotify::view(self),
#[cfg(any(feature = "v1_10", feature = "dox"))]
ffi::GST_MESSAGE_STREAM_COLLECTION => StreamCollection::view(self),
#[cfg(any(feature = "v1_10", feature = "dox"))]
ffi::GST_MESSAGE_STREAMS_SELECTED => StreamsSelected::view(self),
#[cfg(any(feature = "v1_16", feature = "dox"))]
ffi::GST_MESSAGE_DEVICE_CHANGED => DeviceChanged::view(self),
#[cfg(any(feature = "v1_18", feature = "dox"))]
ffi::GST_MESSAGE_INSTANT_RATE_REQUEST => InstantRateRequest::view(self),
_ => MessageView::Other,
} }
ffi::GST_MESSAGE_STREAM_STATUS => MessageView::StreamStatus(StreamStatus(self)),
ffi::GST_MESSAGE_APPLICATION => MessageView::Application(Application(self)),
ffi::GST_MESSAGE_ELEMENT => MessageView::Element(Element(self)),
ffi::GST_MESSAGE_SEGMENT_START => MessageView::SegmentStart(SegmentStart(self)),
ffi::GST_MESSAGE_SEGMENT_DONE => MessageView::SegmentDone(SegmentDone(self)),
ffi::GST_MESSAGE_DURATION_CHANGED => {
MessageView::DurationChanged(DurationChanged(self))
}
ffi::GST_MESSAGE_LATENCY => MessageView::Latency(Latency(self)),
ffi::GST_MESSAGE_ASYNC_START => MessageView::AsyncStart(AsyncStart(self)),
ffi::GST_MESSAGE_ASYNC_DONE => MessageView::AsyncDone(AsyncDone(self)),
ffi::GST_MESSAGE_REQUEST_STATE => MessageView::RequestState(RequestState(self)),
ffi::GST_MESSAGE_STEP_START => MessageView::StepStart(StepStart(self)),
ffi::GST_MESSAGE_QOS => MessageView::Qos(Qos(self)),
ffi::GST_MESSAGE_PROGRESS => MessageView::Progress(Progress(self)),
ffi::GST_MESSAGE_TOC => MessageView::Toc(Toc(self)),
ffi::GST_MESSAGE_RESET_TIME => MessageView::ResetTime(ResetTime(self)),
ffi::GST_MESSAGE_STREAM_START => MessageView::StreamStart(StreamStart(self)),
ffi::GST_MESSAGE_NEED_CONTEXT => MessageView::NeedContext(NeedContext(self)),
ffi::GST_MESSAGE_HAVE_CONTEXT => MessageView::HaveContext(HaveContext(self)),
ffi::GST_MESSAGE_DEVICE_ADDED => MessageView::DeviceAdded(DeviceAdded(self)),
ffi::GST_MESSAGE_DEVICE_REMOVED => MessageView::DeviceRemoved(DeviceRemoved(self)),
#[cfg(any(feature = "v1_10", feature = "dox"))]
ffi::GST_MESSAGE_PROPERTY_NOTIFY => MessageView::PropertyNotify(PropertyNotify(self)),
#[cfg(any(feature = "v1_10", feature = "dox"))]
ffi::GST_MESSAGE_STREAM_COLLECTION => {
MessageView::StreamCollection(StreamCollection(self))
}
#[cfg(any(feature = "v1_10", feature = "dox"))]
ffi::GST_MESSAGE_STREAMS_SELECTED => {
MessageView::StreamsSelected(StreamsSelected(self))
}
#[cfg(any(feature = "v1_16", feature = "dox"))]
ffi::GST_MESSAGE_DEVICE_CHANGED => MessageView::DeviceChanged(DeviceChanged(self)),
#[cfg(any(feature = "v1_18", feature = "dox"))]
ffi::GST_MESSAGE_INSTANT_RATE_REQUEST => {
MessageView::InstantRateRequest(InstantRateRequest(self))
}
_ => MessageView::Other,
} }
} }
@ -183,77 +177,128 @@ impl fmt::Debug for MessageRef {
#[derive(Debug)] #[derive(Debug)]
#[non_exhaustive] #[non_exhaustive]
pub enum MessageView<'a> { pub enum MessageView<'a> {
Eos(Eos<'a>), Eos(&'a Eos),
Error(Error<'a>), Error(&'a Error),
Warning(Warning<'a>), Warning(&'a Warning),
Info(Info<'a>), Info(&'a Info),
Tag(Tag<'a>), Tag(&'a Tag),
Buffering(Buffering<'a>), Buffering(&'a Buffering),
StateChanged(StateChanged<'a>), StateChanged(&'a StateChanged),
StateDirty(StateDirty<'a>), StateDirty(&'a StateDirty),
StepDone(StepDone<'a>), StepDone(&'a StepDone),
ClockProvide(ClockProvide<'a>), ClockProvide(&'a ClockProvide),
ClockLost(ClockLost<'a>), ClockLost(&'a ClockLost),
NewClock(NewClock<'a>), NewClock(&'a NewClock),
StructureChange(StructureChange<'a>), StructureChange(&'a StructureChange),
StreamStatus(StreamStatus<'a>), StreamStatus(&'a StreamStatus),
Application(Application<'a>), Application(&'a Application),
Element(Element<'a>), Element(&'a Element),
SegmentStart(SegmentStart<'a>), SegmentStart(&'a SegmentStart),
SegmentDone(SegmentDone<'a>), SegmentDone(&'a SegmentDone),
DurationChanged(DurationChanged<'a>), DurationChanged(&'a DurationChanged),
Latency(Latency<'a>), Latency(&'a Latency),
AsyncStart(AsyncStart<'a>), AsyncStart(&'a AsyncStart),
AsyncDone(AsyncDone<'a>), AsyncDone(&'a AsyncDone),
RequestState(RequestState<'a>), RequestState(&'a RequestState),
StepStart(StepStart<'a>), StepStart(&'a StepStart),
Qos(Qos<'a>), Qos(&'a Qos),
Progress(Progress<'a>), Progress(&'a Progress),
Toc(Toc<'a>), Toc(&'a Toc),
ResetTime(ResetTime<'a>), ResetTime(&'a ResetTime),
StreamStart(StreamStart<'a>), StreamStart(&'a StreamStart),
NeedContext(NeedContext<'a>), NeedContext(&'a NeedContext),
HaveContext(HaveContext<'a>), HaveContext(&'a HaveContext),
DeviceAdded(DeviceAdded<'a>), DeviceAdded(&'a DeviceAdded),
DeviceRemoved(DeviceRemoved<'a>), DeviceRemoved(&'a DeviceRemoved),
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
PropertyNotify(PropertyNotify<'a>), PropertyNotify(&'a PropertyNotify),
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
StreamCollection(StreamCollection<'a>), StreamCollection(&'a StreamCollection),
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
StreamsSelected(StreamsSelected<'a>), StreamsSelected(&'a StreamsSelected),
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
Redirect(Redirect<'a>), Redirect(&'a Redirect),
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
DeviceChanged(DeviceChanged<'a>), DeviceChanged(&'a DeviceChanged),
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
InstantRateRequest(InstantRateRequest<'a>), InstantRateRequest(&'a InstantRateRequest),
Other, Other,
} }
macro_rules! declare_concrete_message( macro_rules! declare_concrete_message(
($name:ident) => { ($name:ident, $param:ident) => {
#[derive(Debug)] #[derive(Debug)]
pub struct $name<'a>(&'a MessageRef); #[repr(transparent)]
pub struct $name<$param = MessageRef>($param);
impl<'a> Deref for $name<'a> { impl $name {
pub fn message(&self) -> &MessageRef {
unsafe { &*(self as *const Self as *const MessageRef) }
}
unsafe fn view(message: &MessageRef) -> MessageView<'_> {
let message = &*(message as *const MessageRef as *const Self);
MessageView::$name(message)
}
}
impl Deref for $name {
type Target = MessageRef; type Target = MessageRef;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
self.0 unsafe {
&*(self as *const Self as *const Self::Target)
}
}
}
impl ToOwned for $name {
type Owned = $name<Message>;
fn to_owned(&self) -> Self::Owned {
$name::<Message>(self.copy())
}
}
impl $name<Message> {
pub fn get_mut(&mut self) -> Option<&mut $name> {
self.0.get_mut().map(|message| unsafe {
&mut *(message as *mut MessageRef as *mut $name)
})
}
}
impl Deref for $name<Message> {
type Target = $name;
fn deref(&self) -> &Self::Target {
unsafe { &*(self.0.as_ptr() as *const Self::Target) }
}
}
impl Borrow<$name> for $name<Message> {
fn borrow(&self) -> &$name {
&*self
}
}
impl From<$name<Message>> for Message {
fn from(concrete: $name<Message>) -> Self {
skip_assert_initialized!();
concrete.0
} }
} }
} }
); );
declare_concrete_message!(Eos); declare_concrete_message!(Eos, T);
impl<'a> Eos<'a> { impl Eos {
#[doc(alias = "gst_message_new_eos")] #[doc(alias = "gst_message_new_eos")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new() -> Message { pub fn new() -> Message {
@ -261,14 +306,14 @@ impl<'a> Eos<'a> {
Self::builder().build() Self::builder().build()
} }
pub fn builder() -> EosBuilder<'a> { pub fn builder<'a>() -> EosBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
EosBuilder::new() EosBuilder::new()
} }
} }
declare_concrete_message!(Error); declare_concrete_message!(Error, T);
impl<'a> Error<'a> { impl Error {
#[doc(alias = "gst_message_new_error")] #[doc(alias = "gst_message_new_error")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new<T: MessageErrorDomain>(error: T, message: &str) -> Message { pub fn new<T: MessageErrorDomain>(error: T, message: &str) -> Message {
@ -324,8 +369,8 @@ impl<'a> Error<'a> {
} }
} }
declare_concrete_message!(Warning); declare_concrete_message!(Warning, T);
impl<'a> Warning<'a> { impl Warning {
#[doc(alias = "gst_message_new_warning")] #[doc(alias = "gst_message_new_warning")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new<T: MessageErrorDomain>(error: T, message: &str) -> Message { pub fn new<T: MessageErrorDomain>(error: T, message: &str) -> Message {
@ -381,8 +426,8 @@ impl<'a> Warning<'a> {
} }
} }
declare_concrete_message!(Info); declare_concrete_message!(Info, T);
impl<'a> Info<'a> { impl Info {
#[doc(alias = "gst_message_new_info")] #[doc(alias = "gst_message_new_info")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new<T: MessageErrorDomain>(error: T, message: &str) -> Message { pub fn new<T: MessageErrorDomain>(error: T, message: &str) -> Message {
@ -438,8 +483,8 @@ impl<'a> Info<'a> {
} }
} }
declare_concrete_message!(Tag); declare_concrete_message!(Tag, T);
impl<'a> Tag<'a> { impl Tag {
#[doc(alias = "gst_message_new_tag")] #[doc(alias = "gst_message_new_tag")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(tags: &TagList) -> Message { pub fn new(tags: &TagList) -> Message {
@ -463,8 +508,8 @@ impl<'a> Tag<'a> {
} }
} }
declare_concrete_message!(Buffering); declare_concrete_message!(Buffering, T);
impl<'a> Buffering<'a> { impl Buffering {
#[doc(alias = "gst_message_new_buffering")] #[doc(alias = "gst_message_new_buffering")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(percent: i32) -> Message { pub fn new(percent: i32) -> Message {
@ -472,7 +517,7 @@ impl<'a> Buffering<'a> {
Self::builder(percent).build() Self::builder(percent).build()
} }
pub fn builder(percent: i32) -> BufferingBuilder<'a> { pub fn builder<'a>(percent: i32) -> BufferingBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
BufferingBuilder::new(percent) BufferingBuilder::new(percent)
} }
@ -514,8 +559,8 @@ impl<'a> Buffering<'a> {
} }
} }
declare_concrete_message!(StateChanged); declare_concrete_message!(StateChanged, T);
impl<'a> StateChanged<'a> { impl StateChanged {
#[doc(alias = "gst_message_new_state_changed")] #[doc(alias = "gst_message_new_state_changed")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(old: crate::State, new: crate::State, pending: crate::State) -> Message { pub fn new(old: crate::State, new: crate::State, pending: crate::State) -> Message {
@ -523,7 +568,7 @@ impl<'a> StateChanged<'a> {
Self::builder(old, new, pending).build() Self::builder(old, new, pending).build()
} }
pub fn builder( pub fn builder<'a>(
old: crate::State, old: crate::State,
new: crate::State, new: crate::State,
pending: crate::State, pending: crate::State,
@ -584,8 +629,8 @@ impl<'a> StateChanged<'a> {
} }
} }
declare_concrete_message!(StateDirty); declare_concrete_message!(StateDirty, T);
impl<'a> StateDirty<'a> { impl StateDirty {
#[doc(alias = "gst_message_new_state_dirty")] #[doc(alias = "gst_message_new_state_dirty")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new() -> Message { pub fn new() -> Message {
@ -593,14 +638,14 @@ impl<'a> StateDirty<'a> {
Self::builder().build() Self::builder().build()
} }
pub fn builder() -> StateDirtyBuilder<'a> { pub fn builder<'a>() -> StateDirtyBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
StateDirtyBuilder::new() StateDirtyBuilder::new()
} }
} }
declare_concrete_message!(StepDone); declare_concrete_message!(StepDone, T);
impl<'a> StepDone<'a> { impl StepDone {
#[doc(alias = "gst_message_new_step_done")] #[doc(alias = "gst_message_new_step_done")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new<V: Into<GenericFormattedValue>>( pub fn new<V: Into<GenericFormattedValue>>(
@ -623,7 +668,7 @@ impl<'a> StepDone<'a> {
.build() .build()
} }
pub fn builder<V: Into<GenericFormattedValue>>( pub fn builder<'a, V: Into<GenericFormattedValue>>(
amount: V, amount: V,
rate: f64, rate: f64,
flush: bool, flush: bool,
@ -691,8 +736,8 @@ impl<'a> StepDone<'a> {
} }
} }
declare_concrete_message!(ClockProvide); declare_concrete_message!(ClockProvide, T);
impl<'a> ClockProvide<'a> { impl ClockProvide {
#[doc(alias = "gst_message_new_clock_provide")] #[doc(alias = "gst_message_new_clock_provide")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(clock: &crate::Clock, ready: bool) -> Message { pub fn new(clock: &crate::Clock, ready: bool) -> Message {
@ -734,8 +779,8 @@ impl<'a> ClockProvide<'a> {
} }
} }
declare_concrete_message!(ClockLost); declare_concrete_message!(ClockLost, T);
impl<'a> ClockLost<'a> { impl ClockLost {
#[doc(alias = "gst_message_new_clock_lost")] #[doc(alias = "gst_message_new_clock_lost")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(clock: &crate::Clock) -> Message { pub fn new(clock: &crate::Clock) -> Message {
@ -761,8 +806,8 @@ impl<'a> ClockLost<'a> {
} }
} }
declare_concrete_message!(NewClock); declare_concrete_message!(NewClock, T);
impl<'a> NewClock<'a> { impl NewClock {
#[doc(alias = "gst_message_new_new_clock")] #[doc(alias = "gst_message_new_new_clock")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(clock: &crate::Clock) -> Message { pub fn new(clock: &crate::Clock) -> Message {
@ -788,8 +833,8 @@ impl<'a> NewClock<'a> {
} }
} }
declare_concrete_message!(StructureChange); declare_concrete_message!(StructureChange, T);
impl<'a> StructureChange<'a> { impl StructureChange {
#[doc(alias = "gst_message_new_structure_change")] #[doc(alias = "gst_message_new_structure_change")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(type_: crate::StructureChangeType, owner: &crate::Element, busy: bool) -> Message { pub fn new(type_: crate::StructureChangeType, owner: &crate::Element, busy: bool) -> Message {
@ -829,8 +874,8 @@ impl<'a> StructureChange<'a> {
} }
} }
declare_concrete_message!(StreamStatus); declare_concrete_message!(StreamStatus, T);
impl<'a> StreamStatus<'a> { impl StreamStatus {
#[doc(alias = "gst_message_new_stream_status")] #[doc(alias = "gst_message_new_stream_status")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(type_: crate::StreamStatusType, owner: &crate::Element) -> Message { pub fn new(type_: crate::StreamStatusType, owner: &crate::Element) -> Message {
@ -866,8 +911,8 @@ impl<'a> StreamStatus<'a> {
} }
} }
declare_concrete_message!(Application); declare_concrete_message!(Application, T);
impl<'a> Application<'a> { impl Application {
#[doc(alias = "gst_message_new_application")] #[doc(alias = "gst_message_new_application")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(structure: crate::Structure) -> Message { pub fn new(structure: crate::Structure) -> Message {
@ -875,14 +920,14 @@ impl<'a> Application<'a> {
Self::builder(structure).build() Self::builder(structure).build()
} }
pub fn builder(structure: crate::Structure) -> ApplicationBuilder<'a> { pub fn builder<'a>(structure: crate::Structure) -> ApplicationBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
ApplicationBuilder::new(structure) ApplicationBuilder::new(structure)
} }
} }
declare_concrete_message!(Element); declare_concrete_message!(Element, T);
impl<'a> Element<'a> { impl Element {
#[doc(alias = "gst_message_new_element")] #[doc(alias = "gst_message_new_element")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(structure: crate::Structure) -> Message { pub fn new(structure: crate::Structure) -> Message {
@ -890,14 +935,14 @@ impl<'a> Element<'a> {
Self::builder(structure).build() Self::builder(structure).build()
} }
pub fn builder(structure: crate::Structure) -> ElementBuilder<'a> { pub fn builder<'a>(structure: crate::Structure) -> ElementBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
ElementBuilder::new(structure) ElementBuilder::new(structure)
} }
} }
declare_concrete_message!(SegmentStart); declare_concrete_message!(SegmentStart, T);
impl<'a> SegmentStart<'a> { impl SegmentStart {
#[doc(alias = "gst_message_new_segment_start")] #[doc(alias = "gst_message_new_segment_start")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new<V: Into<GenericFormattedValue>>(position: V) -> Message { pub fn new<V: Into<GenericFormattedValue>>(position: V) -> Message {
@ -905,7 +950,7 @@ impl<'a> SegmentStart<'a> {
Self::builder(position).build() Self::builder(position).build()
} }
pub fn builder<V: Into<GenericFormattedValue>>(position: V) -> SegmentStartBuilder<'a> { pub fn builder<'a, V: Into<GenericFormattedValue>>(position: V) -> SegmentStartBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
let position = position.into(); let position = position.into();
SegmentStartBuilder::new(position) SegmentStartBuilder::new(position)
@ -928,8 +973,8 @@ impl<'a> SegmentStart<'a> {
} }
} }
declare_concrete_message!(SegmentDone); declare_concrete_message!(SegmentDone, T);
impl<'a> SegmentDone<'a> { impl SegmentDone {
#[doc(alias = "gst_message_new_segment_done")] #[doc(alias = "gst_message_new_segment_done")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new<V: Into<GenericFormattedValue>>(position: V) -> Message { pub fn new<V: Into<GenericFormattedValue>>(position: V) -> Message {
@ -937,7 +982,7 @@ impl<'a> SegmentDone<'a> {
Self::builder(position).build() Self::builder(position).build()
} }
pub fn builder<V: Into<GenericFormattedValue>>(position: V) -> SegmentDoneBuilder<'a> { pub fn builder<'a, V: Into<GenericFormattedValue>>(position: V) -> SegmentDoneBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
let position = position.into(); let position = position.into();
SegmentDoneBuilder::new(position) SegmentDoneBuilder::new(position)
@ -960,8 +1005,8 @@ impl<'a> SegmentDone<'a> {
} }
} }
declare_concrete_message!(DurationChanged); declare_concrete_message!(DurationChanged, T);
impl<'a> DurationChanged<'a> { impl DurationChanged {
#[doc(alias = "gst_message_new_duration_changed")] #[doc(alias = "gst_message_new_duration_changed")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new() -> Message { pub fn new() -> Message {
@ -969,14 +1014,14 @@ impl<'a> DurationChanged<'a> {
Self::builder().build() Self::builder().build()
} }
pub fn builder() -> DurationChangedBuilder<'a> { pub fn builder<'a>() -> DurationChangedBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
DurationChangedBuilder::new() DurationChangedBuilder::new()
} }
} }
declare_concrete_message!(Latency); declare_concrete_message!(Latency, T);
impl<'a> Latency<'a> { impl Latency {
#[doc(alias = "gst_message_new_latency")] #[doc(alias = "gst_message_new_latency")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new() -> Message { pub fn new() -> Message {
@ -984,14 +1029,14 @@ impl<'a> Latency<'a> {
Self::builder().build() Self::builder().build()
} }
pub fn builder() -> LatencyBuilder<'a> { pub fn builder<'a>() -> LatencyBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
LatencyBuilder::new() LatencyBuilder::new()
} }
} }
declare_concrete_message!(AsyncStart); declare_concrete_message!(AsyncStart, T);
impl<'a> AsyncStart<'a> { impl AsyncStart {
#[doc(alias = "gst_message_new_async_start")] #[doc(alias = "gst_message_new_async_start")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new() -> Message { pub fn new() -> Message {
@ -999,14 +1044,14 @@ impl<'a> AsyncStart<'a> {
Self::builder().build() Self::builder().build()
} }
pub fn builder() -> AsyncStartBuilder<'a> { pub fn builder<'a>() -> AsyncStartBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
AsyncStartBuilder::new() AsyncStartBuilder::new()
} }
} }
declare_concrete_message!(AsyncDone); declare_concrete_message!(AsyncDone, T);
impl<'a> AsyncDone<'a> { impl AsyncDone {
#[doc(alias = "gst_message_new_async_done")] #[doc(alias = "gst_message_new_async_done")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(running_time: impl Into<Option<crate::ClockTime>>) -> Message { pub fn new(running_time: impl Into<Option<crate::ClockTime>>) -> Message {
@ -1014,7 +1059,7 @@ impl<'a> AsyncDone<'a> {
Self::builder().running_time(running_time).build() Self::builder().running_time(running_time).build()
} }
pub fn builder() -> AsyncDoneBuilder<'a> { pub fn builder<'a>() -> AsyncDoneBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
AsyncDoneBuilder::new() AsyncDoneBuilder::new()
} }
@ -1032,8 +1077,8 @@ impl<'a> AsyncDone<'a> {
} }
} }
declare_concrete_message!(RequestState); declare_concrete_message!(RequestState, T);
impl<'a> RequestState<'a> { impl RequestState {
#[doc(alias = "gst_message_new_request_state")] #[doc(alias = "gst_message_new_request_state")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(state: crate::State) -> Message { pub fn new(state: crate::State) -> Message {
@ -1041,7 +1086,7 @@ impl<'a> RequestState<'a> {
Self::builder(state).build() Self::builder(state).build()
} }
pub fn builder(state: crate::State) -> RequestStateBuilder<'a> { pub fn builder<'a>(state: crate::State) -> RequestStateBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
RequestStateBuilder::new(state) RequestStateBuilder::new(state)
} }
@ -1059,8 +1104,8 @@ impl<'a> RequestState<'a> {
} }
} }
declare_concrete_message!(StepStart); declare_concrete_message!(StepStart, T);
impl<'a> StepStart<'a> { impl StepStart {
#[doc(alias = "gst_message_new_step_start")] #[doc(alias = "gst_message_new_step_start")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new<V: Into<GenericFormattedValue>>( pub fn new<V: Into<GenericFormattedValue>>(
@ -1074,7 +1119,7 @@ impl<'a> StepStart<'a> {
Self::builder(active, amount.into(), rate, flush, intermediate).build() Self::builder(active, amount.into(), rate, flush, intermediate).build()
} }
pub fn builder<V: Into<GenericFormattedValue>>( pub fn builder<'a, V: Into<GenericFormattedValue>>(
active: bool, active: bool,
amount: V, amount: V,
rate: f64, rate: f64,
@ -1119,8 +1164,8 @@ impl<'a> StepStart<'a> {
} }
} }
declare_concrete_message!(Qos); declare_concrete_message!(Qos, T);
impl<'a> Qos<'a> { impl Qos {
#[doc(alias = "gst_message_new_qos")] #[doc(alias = "gst_message_new_qos")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new( pub fn new(
@ -1139,7 +1184,7 @@ impl<'a> Qos<'a> {
.build() .build()
} }
pub fn builder(live: bool) -> QosBuilder<'a> { pub fn builder<'a>(live: bool) -> QosBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
QosBuilder::new(live) QosBuilder::new(live)
} }
@ -1232,16 +1277,16 @@ impl<'a> Qos<'a> {
} }
} }
declare_concrete_message!(Progress); declare_concrete_message!(Progress, T);
impl<'a> Progress<'a> { impl Progress {
#[doc(alias = "gst_message_new_progress")] #[doc(alias = "gst_message_new_progress")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(type_: crate::ProgressType, code: &'a str, text: &'a str) -> Message { pub fn new(type_: crate::ProgressType, code: &str, text: &str) -> Message {
skip_assert_initialized!(); skip_assert_initialized!();
Self::builder(type_, code, text).build() Self::builder(type_, code, text).build()
} }
pub fn builder( pub fn builder<'a>(
type_: crate::ProgressType, type_: crate::ProgressType,
code: &'a str, code: &'a str,
text: &'a str, text: &'a str,
@ -1251,7 +1296,7 @@ impl<'a> Progress<'a> {
} }
#[doc(alias = "gst_message_parse_progress")] #[doc(alias = "gst_message_parse_progress")]
pub fn get(&self) -> (crate::ProgressType, &'a str, &'a str) { pub fn get(&self) -> (crate::ProgressType, &str, &str) {
unsafe { unsafe {
let mut type_ = mem::MaybeUninit::uninit(); let mut type_ = mem::MaybeUninit::uninit();
let mut code = ptr::null_mut(); let mut code = ptr::null_mut();
@ -1272,8 +1317,8 @@ impl<'a> Progress<'a> {
} }
} }
declare_concrete_message!(Toc); declare_concrete_message!(Toc, T);
impl<'a> Toc<'a> { impl Toc {
// FIXME could use false for updated as default // FIXME could use false for updated as default
// Even better: use an enum for updated so that it is more explicit than true / false // Even better: use an enum for updated so that it is more explicit than true / false
#[doc(alias = "gst_message_new_toc")] #[doc(alias = "gst_message_new_toc")]
@ -1300,8 +1345,8 @@ impl<'a> Toc<'a> {
} }
} }
declare_concrete_message!(ResetTime); declare_concrete_message!(ResetTime, T);
impl<'a> ResetTime<'a> { impl ResetTime {
#[doc(alias = "gst_message_new_reset_time")] #[doc(alias = "gst_message_new_reset_time")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(running_time: crate::ClockTime) -> Message { pub fn new(running_time: crate::ClockTime) -> Message {
@ -1309,7 +1354,7 @@ impl<'a> ResetTime<'a> {
Self::builder(running_time).build() Self::builder(running_time).build()
} }
pub fn builder(running_time: crate::ClockTime) -> ResetTimeBuilder<'a> { pub fn builder<'a>(running_time: crate::ClockTime) -> ResetTimeBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
ResetTimeBuilder::new(running_time) ResetTimeBuilder::new(running_time)
} }
@ -1327,8 +1372,8 @@ impl<'a> ResetTime<'a> {
} }
} }
declare_concrete_message!(StreamStart); declare_concrete_message!(StreamStart, T);
impl<'a> StreamStart<'a> { impl StreamStart {
#[doc(alias = "gst_message_new_stream_start")] #[doc(alias = "gst_message_new_stream_start")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new() -> Message { pub fn new() -> Message {
@ -1336,7 +1381,7 @@ impl<'a> StreamStart<'a> {
Self::builder().build() Self::builder().build()
} }
pub fn builder() -> StreamStartBuilder<'a> { pub fn builder<'a>() -> StreamStartBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
StreamStartBuilder::new() StreamStartBuilder::new()
} }
@ -1364,8 +1409,8 @@ impl<'a> StreamStart<'a> {
} }
} }
declare_concrete_message!(NeedContext); declare_concrete_message!(NeedContext, T);
impl<'a> NeedContext<'a> { impl NeedContext {
#[doc(alias = "gst_message_new_need_context")] #[doc(alias = "gst_message_new_need_context")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(context_type: &str) -> Message { pub fn new(context_type: &str) -> Message {
@ -1391,8 +1436,8 @@ impl<'a> NeedContext<'a> {
} }
} }
declare_concrete_message!(HaveContext); declare_concrete_message!(HaveContext, T);
impl<'a> HaveContext<'a> { impl HaveContext {
#[doc(alias = "gst_message_new_have_context")] #[doc(alias = "gst_message_new_have_context")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(context: crate::Context) -> Message { pub fn new(context: crate::Context) -> Message {
@ -1400,7 +1445,7 @@ impl<'a> HaveContext<'a> {
Self::builder(context).build() Self::builder(context).build()
} }
pub fn builder(context: crate::Context) -> HaveContextBuilder<'a> { pub fn builder<'a>(context: crate::Context) -> HaveContextBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
HaveContextBuilder::new(context) HaveContextBuilder::new(context)
} }
@ -1416,8 +1461,8 @@ impl<'a> HaveContext<'a> {
} }
} }
declare_concrete_message!(DeviceAdded); declare_concrete_message!(DeviceAdded, T);
impl<'a> DeviceAdded<'a> { impl DeviceAdded {
#[doc(alias = "gst_message_new_device_added")] #[doc(alias = "gst_message_new_device_added")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(device: &crate::Device) -> Message { pub fn new(device: &crate::Device) -> Message {
@ -1443,8 +1488,8 @@ impl<'a> DeviceAdded<'a> {
} }
} }
declare_concrete_message!(DeviceRemoved); declare_concrete_message!(DeviceRemoved, T);
impl<'a> DeviceRemoved<'a> { impl DeviceRemoved {
#[doc(alias = "gst_message_new_device_removed")] #[doc(alias = "gst_message_new_device_removed")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(device: &crate::Device) -> Message { pub fn new(device: &crate::Device) -> Message {
@ -1472,10 +1517,10 @@ impl<'a> DeviceRemoved<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
declare_concrete_message!(PropertyNotify); declare_concrete_message!(PropertyNotify, T);
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
impl<'a> PropertyNotify<'a> { impl PropertyNotify {
#[doc(alias = "gst_message_new_property_notify")] #[doc(alias = "gst_message_new_property_notify")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(property_name: &str) -> Message { pub fn new(property_name: &str) -> Message {
@ -1489,7 +1534,7 @@ impl<'a> PropertyNotify<'a> {
} }
#[doc(alias = "gst_message_parse_property_notify")] #[doc(alias = "gst_message_parse_property_notify")]
pub fn get(&self) -> (Object, &str, Option<&'a glib::Value>) { pub fn get(&self) -> (Object, &str, Option<&glib::Value>) {
unsafe { unsafe {
let mut object = ptr::null_mut(); let mut object = ptr::null_mut();
let mut property_name = ptr::null(); let mut property_name = ptr::null();
@ -1517,10 +1562,10 @@ impl<'a> PropertyNotify<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
declare_concrete_message!(StreamCollection); declare_concrete_message!(StreamCollection, T);
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
impl<'a> StreamCollection<'a> { impl StreamCollection {
#[doc(alias = "gst_message_new_stream_collection")] #[doc(alias = "gst_message_new_stream_collection")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(collection: &crate::StreamCollection) -> Message { pub fn new(collection: &crate::StreamCollection) -> Message {
@ -1548,10 +1593,10 @@ impl<'a> StreamCollection<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
declare_concrete_message!(StreamsSelected); declare_concrete_message!(StreamsSelected, T);
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
impl<'a> StreamsSelected<'a> { impl StreamsSelected {
#[doc(alias = "gst_message_new_streams_selected")] #[doc(alias = "gst_message_new_streams_selected")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(collection: &crate::StreamCollection) -> Message { pub fn new(collection: &crate::StreamCollection) -> Message {
@ -1597,10 +1642,10 @@ impl<'a> StreamsSelected<'a> {
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
declare_concrete_message!(Redirect); declare_concrete_message!(Redirect, T);
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
impl<'a> Redirect<'a> { impl Redirect {
#[doc(alias = "gst_message_new_redirect")] #[doc(alias = "gst_message_new_redirect")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(location: &str) -> Message { pub fn new(location: &str) -> Message {
@ -1653,18 +1698,18 @@ impl<'a> Redirect<'a> {
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
declare_concrete_message!(DeviceChanged); declare_concrete_message!(DeviceChanged, T);
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
impl<'a> DeviceChanged<'a> { impl DeviceChanged {
#[doc(alias = "gst_message_new_device_changed")] #[doc(alias = "gst_message_new_device_changed")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(device: &'a crate::Device, changed_device: &'a crate::Device) -> Message { pub fn new(device: &crate::Device, changed_device: &crate::Device) -> Message {
skip_assert_initialized!(); skip_assert_initialized!();
Self::builder(device, changed_device).build() Self::builder(device, changed_device).build()
} }
pub fn builder( pub fn builder<'a>(
device: &'a crate::Device, device: &'a crate::Device,
changed_device: &'a crate::Device, changed_device: &'a crate::Device,
) -> DeviceChangedBuilder<'a> { ) -> DeviceChangedBuilder<'a> {
@ -1692,10 +1737,10 @@ impl<'a> DeviceChanged<'a> {
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
declare_concrete_message!(InstantRateRequest); declare_concrete_message!(InstantRateRequest, T);
#[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
impl<'a> InstantRateRequest<'a> { impl InstantRateRequest {
#[doc(alias = "gst_message_new_instant_rate_request")] #[doc(alias = "gst_message_new_instant_rate_request")]
#[allow(clippy::new_ret_no_self)] #[allow(clippy::new_ret_no_self)]
pub fn new(rate_multiplier: f64) -> Message { pub fn new(rate_multiplier: f64) -> Message {
@ -1703,7 +1748,7 @@ impl<'a> InstantRateRequest<'a> {
Self::builder(rate_multiplier).build() Self::builder(rate_multiplier).build()
} }
pub fn builder(rate_multiplier: f64) -> InstantRateRequestBuilder<'a> { pub fn builder<'a>(rate_multiplier: f64) -> InstantRateRequestBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
InstantRateRequestBuilder::new(rate_multiplier) InstantRateRequestBuilder::new(rate_multiplier)
} }

View file

@ -324,7 +324,7 @@ pub trait PadExtManual: 'static {
#[doc(alias = "gst_pad_get_sticky_event")] #[doc(alias = "gst_pad_get_sticky_event")]
#[doc(alias = "get_sticky_event")] #[doc(alias = "get_sticky_event")]
fn sticky_event<T: crate::event::StickyEventType>(&self, idx: u32) -> Option<T>; fn sticky_event<T: crate::event::StickyEventType>(&self, idx: u32) -> Option<T::Owned>;
fn set_pad_flags(&self, flags: PadFlags); fn set_pad_flags(&self, flags: PadFlags);
@ -1059,7 +1059,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
} }
} }
fn sticky_event<T: crate::event::StickyEventType>(&self, idx: u32) -> Option<T> { fn sticky_event<T: crate::event::StickyEventType>(&self, idx: u32) -> Option<T::Owned> {
unsafe { unsafe {
let ptr = ffi::gst_pad_get_sticky_event( let ptr = ffi::gst_pad_get_sticky_event(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
@ -2169,6 +2169,32 @@ mod tests {
); );
} }
#[test]
fn test_sticky_events() {
crate::init().unwrap();
let pad = crate::Pad::builder(Some("sink"), crate::PadDirection::Sink).build();
pad.set_active(true).unwrap();
// Send some sticky events
assert!(pad.send_event(crate::event::StreamStart::new("test")));
let caps = crate::Caps::builder("some/x-caps").build();
assert!(pad.send_event(crate::event::Caps::new(&caps)));
let segment = crate::FormattedSegment::<crate::ClockTime>::new();
assert!(pad.send_event(crate::event::Segment::new(segment.as_ref())));
let stream_start = pad.sticky_event::<crate::event::StreamStart>(0).unwrap();
assert_eq!(stream_start.stream_id(), "test");
let caps2 = pad.sticky_event::<crate::event::Caps>(0).unwrap();
assert_eq!(&*caps, caps2.caps());
let segment = pad.sticky_event::<crate::event::Segment>(0).unwrap();
assert_eq!(segment.segment().format(), crate::Format::Time);
}
#[test] #[test]
fn test_sticky_events_foreach() { fn test_sticky_events_foreach() {
crate::init().unwrap(); crate::init().unwrap();

File diff suppressed because it is too large Load diff