2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use std::{borrow::Borrow, cmp, ffi::CStr, fmt, mem, num::NonZeroU32, ops::Deref, ptr};
|
2017-08-02 17:09:00 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use glib::{
|
|
|
|
translate::{FromGlibPtrContainer, *},
|
|
|
|
value::ToSendValue,
|
|
|
|
};
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use crate::{
|
2024-06-02 08:48:53 +00:00
|
|
|
ffi,
|
2023-01-03 18:58:25 +00:00
|
|
|
format::{
|
|
|
|
CompatibleFormattedValue, FormattedValue, FormattedValueIntrinsic, GenericFormattedValue,
|
|
|
|
},
|
|
|
|
structure::*,
|
|
|
|
ClockTime, EventType,
|
|
|
|
};
|
2017-11-29 16:55:56 +00:00
|
|
|
|
2020-01-24 15:46:18 +00:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
pub struct Seqnum(pub(crate) NonZeroU32);
|
2017-12-05 19:32:16 +00:00
|
|
|
|
2020-01-24 15:46:18 +00:00
|
|
|
impl Seqnum {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_util_seqnum_next")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2020-01-24 15:46:18 +00:00
|
|
|
pub fn next() -> Self {
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let v = ffi::gst_util_seqnum_next();
|
2020-01-24 15:46:18 +00:00
|
|
|
if v == 0 {
|
|
|
|
Seqnum::next()
|
|
|
|
} else {
|
|
|
|
Seqnum(NonZeroU32::new_unchecked(v))
|
|
|
|
}
|
|
|
|
}
|
2017-12-05 19:32:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-27 15:15:46 +00:00
|
|
|
impl IntoGlib for Seqnum {
|
2020-01-24 15:46:18 +00:00
|
|
|
type GlibType = u32;
|
2017-12-05 19:32:16 +00:00
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-27 15:15:46 +00:00
|
|
|
fn into_glib(self) -> u32 {
|
2020-01-24 15:46:18 +00:00
|
|
|
self.0.get()
|
2017-12-05 19:32:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-06 08:25:07 +00:00
|
|
|
impl cmp::PartialOrd for Seqnum {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2018-08-06 08:25:07 +00:00
|
|
|
fn partial_cmp(&self, other: &Seqnum) -> Option<cmp::Ordering> {
|
|
|
|
Some(self.cmp(other))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl cmp::Ord for Seqnum {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2018-08-06 08:25:07 +00:00
|
|
|
fn cmp(&self, other: &Seqnum) -> cmp::Ordering {
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let ret = ffi::gst_util_seqnum_compare(self.0.get(), other.0.get());
|
2019-12-22 07:59:23 +00:00
|
|
|
ret.cmp(&0)
|
2018-08-06 08:25:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-24 15:46:18 +00:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
pub struct GroupId(pub(crate) NonZeroU32);
|
2017-12-05 19:32:16 +00:00
|
|
|
|
2020-01-24 15:46:18 +00:00
|
|
|
impl GroupId {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_util_group_id_next")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2020-01-24 15:46:18 +00:00
|
|
|
pub fn next() -> Self {
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let v = ffi::gst_util_group_id_next();
|
2020-01-24 15:46:18 +00:00
|
|
|
if v == 0 {
|
|
|
|
GroupId::next()
|
|
|
|
} else {
|
|
|
|
GroupId(NonZeroU32::new_unchecked(v))
|
|
|
|
}
|
|
|
|
}
|
2017-12-05 19:32:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 16:55:56 +00:00
|
|
|
impl EventType {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_IS_UPSTREAM")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn is_upstream(self) -> bool {
|
2021-04-27 15:15:46 +00:00
|
|
|
(self.into_glib() as u32) & ffi::GST_EVENT_TYPE_UPSTREAM != 0
|
2017-11-29 16:55:56 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_IS_DOWNSTREAM")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn is_downstream(self) -> bool {
|
2021-04-27 15:15:46 +00:00
|
|
|
(self.into_glib() as u32) & ffi::GST_EVENT_TYPE_DOWNSTREAM != 0
|
2017-11-29 16:55:56 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_IS_SERIALIZED")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn is_serialized(self) -> bool {
|
2021-04-27 15:15:46 +00:00
|
|
|
(self.into_glib() as u32) & ffi::GST_EVENT_TYPE_SERIALIZED != 0
|
2017-11-29 16:55:56 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_IS_STICKY")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn is_sticky(self) -> bool {
|
2021-04-27 15:15:46 +00:00
|
|
|
(self.into_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY != 0
|
2017-11-29 16:55:56 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_IS_STICKY_MULTI")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn is_sticky_multi(self) -> bool {
|
2021-04-27 15:15:46 +00:00
|
|
|
(self.into_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY_MULTI != 0
|
2017-11-29 16:55:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialOrd for EventType {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
|
|
|
|
if !self.is_serialized() || !other.is_serialized() {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
2022-11-21 11:43:22 +00:00
|
|
|
// See gst_event_type_to_sticky_ordering() from 1.22
|
|
|
|
let fixup_event_ordering = |v| match v {
|
|
|
|
ffi::GST_EVENT_INSTANT_RATE_CHANGE => ffi::GST_EVENT_SEGMENT as u32 + 1,
|
|
|
|
_ => v as u32,
|
|
|
|
};
|
|
|
|
|
|
|
|
let v1 = fixup_event_ordering(self.into_glib());
|
|
|
|
let v2 = fixup_event_ordering(other.into_glib());
|
2017-11-29 16:55:56 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
let stream_start = ffi::GST_EVENT_STREAM_START as u32;
|
|
|
|
let segment = ffi::GST_EVENT_SEGMENT as u32;
|
|
|
|
let eos = ffi::GST_EVENT_EOS as u32;
|
2017-11-29 16:55:56 +00:00
|
|
|
|
|
|
|
// Strictly ordered range between stream_start and segment,
|
|
|
|
// and EOS is bigger than everything else
|
|
|
|
if v1 >= stream_start && v1 <= segment || v2 >= stream_start && v2 <= segment {
|
|
|
|
Some(v1.cmp(&v2))
|
|
|
|
// If one is EOS, the other is definitely less or equal
|
|
|
|
} else if v1 == eos || v2 == eos {
|
|
|
|
if v1 == v2 {
|
|
|
|
Some(cmp::Ordering::Equal)
|
|
|
|
} else if v1 == eos {
|
|
|
|
Some(cmp::Ordering::Greater)
|
|
|
|
} else {
|
|
|
|
Some(cmp::Ordering::Less)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-20 15:09:22 +00:00
|
|
|
mini_object_wrapper!(Event, EventRef, ffi::GstEvent, || {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_get_type()
|
2018-09-28 15:11:46 +00:00
|
|
|
});
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl EventRef {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_seqnum")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_get_seqnum")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn seqnum(&self) -> Seqnum {
|
2020-01-24 15:46:18 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let seqnum = ffi::gst_event_get_seqnum(self.as_mut_ptr());
|
2022-12-25 10:47:02 +00:00
|
|
|
debug_assert_ne!(seqnum, 0);
|
2020-01-24 15:46:18 +00:00
|
|
|
Seqnum(NonZeroU32::new_unchecked(seqnum))
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_running_time_offset")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_get_running_time_offset")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn running_time_offset(&self) -> i64 {
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { ffi::gst_event_get_running_time_offset(self.as_mut_ptr()) }
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_set_running_time_offset")]
|
2017-12-03 15:13:46 +00:00
|
|
|
pub fn set_running_time_offset(&mut self, offset: i64) {
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { ffi::gst_event_set_running_time_offset(self.as_mut_ptr(), offset) }
|
2017-12-03 15:13:46 +00:00
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_structure")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_get_structure")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn structure(&self) -> Option<&StructureRef> {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let structure = ffi::gst_event_get_structure(self.as_mut_ptr());
|
2017-12-01 09:21:20 +00:00
|
|
|
if structure.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(StructureRef::from_glib_borrow(structure))
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_writable_structure")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2020-11-19 20:10:13 +00:00
|
|
|
pub fn structure_mut(&mut self) -> &mut StructureRef {
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
StructureRef::from_glib_borrow_mut(ffi::gst_event_writable_structure(self.as_mut_ptr()))
|
2020-11-19 20:10:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_IS_UPSTREAM")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn is_upstream(&self) -> bool {
|
2021-04-11 19:39:50 +00:00
|
|
|
self.type_().is_upstream()
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_IS_DOWNSTREAM")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn is_downstream(&self) -> bool {
|
2021-04-11 19:39:50 +00:00
|
|
|
self.type_().is_downstream()
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_IS_SERIALIZED")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn is_serialized(&self) -> bool {
|
2021-04-11 19:39:50 +00:00
|
|
|
self.type_().is_serialized()
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_IS_STICKY")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn is_sticky(&self) -> bool {
|
2021-04-11 19:39:50 +00:00
|
|
|
self.type_().is_sticky()
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_IS_STICKY_MULTI")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn is_sticky_multi(&self) -> bool {
|
2021-04-11 19:39:50 +00:00
|
|
|
self.type_().is_sticky_multi()
|
2017-11-29 16:55:56 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_type")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_EVENT_TYPE")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn type_(&self) -> EventType {
|
2017-11-29 16:55:56 +00:00
|
|
|
unsafe { from_glib((*self.as_ptr()).type_) }
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-13 20:00:01 +00:00
|
|
|
#[doc(alias = "gst_event_has_name")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-12-13 20:00:01 +00:00
|
|
|
pub fn has_name(&self, name: &str) -> bool {
|
2024-06-19 08:04:25 +00:00
|
|
|
self.structure().is_some_and(|s| s.has_name(name))
|
2021-12-13 20:00:01 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
pub fn view(&self) -> EventView {
|
|
|
|
unsafe {
|
|
|
|
let type_ = (*self.as_ptr()).type_;
|
|
|
|
|
|
|
|
match type_ {
|
|
|
|
ffi::GST_EVENT_FLUSH_START => FlushStart::view(self),
|
|
|
|
ffi::GST_EVENT_FLUSH_STOP => FlushStop::view(self),
|
|
|
|
ffi::GST_EVENT_STREAM_START => StreamStart::view(self),
|
|
|
|
ffi::GST_EVENT_CAPS => Caps::view(self),
|
|
|
|
ffi::GST_EVENT_SEGMENT => Segment::view(self),
|
|
|
|
ffi::GST_EVENT_STREAM_COLLECTION => StreamCollection::view(self),
|
|
|
|
ffi::GST_EVENT_TAG => Tag::view(self),
|
|
|
|
ffi::GST_EVENT_BUFFERSIZE => Buffersize::view(self),
|
|
|
|
ffi::GST_EVENT_SINK_MESSAGE => SinkMessage::view(self),
|
|
|
|
ffi::GST_EVENT_STREAM_GROUP_DONE => StreamGroupDone::view(self),
|
|
|
|
ffi::GST_EVENT_EOS => Eos::view(self),
|
|
|
|
ffi::GST_EVENT_TOC => Toc::view(self),
|
|
|
|
ffi::GST_EVENT_PROTECTION => Protection::view(self),
|
|
|
|
ffi::GST_EVENT_SEGMENT_DONE => SegmentDone::view(self),
|
|
|
|
ffi::GST_EVENT_GAP => Gap::view(self),
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::GST_EVENT_INSTANT_RATE_CHANGE => InstantRateChange::view(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),
|
|
|
|
ffi::GST_EVENT_SELECT_STREAMS => SelectStreams::view(self),
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
2022-01-18 09:57:22 +00:00
|
|
|
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),
|
2017-09-10 11:54:43 +00:00
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:49:25 +00:00
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2020-06-29 21:12:46 +00:00
|
|
|
impl fmt::Debug for Event {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
EventRef::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:21:20 +00:00
|
|
|
impl fmt::Debug for EventRef {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
f.debug_struct("Event")
|
2022-08-11 14:02:02 +00:00
|
|
|
.field("ptr", &self.as_ptr())
|
2021-04-11 19:39:50 +00:00
|
|
|
.field("type", &self.type_().name())
|
|
|
|
.field("seqnum", &self.seqnum())
|
|
|
|
.field("structure", &self.structure())
|
2017-12-01 09:21:20 +00:00
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
pub trait StickyEventType: ToOwned {
|
2021-10-17 09:48:21 +00:00
|
|
|
const TYPE: EventType;
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
unsafe fn from_event(event: Event) -> Self::Owned;
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
|
|
|
|
2019-01-22 14:55:59 +00:00
|
|
|
#[derive(Debug)]
|
2021-10-17 09:50:14 +00:00
|
|
|
#[non_exhaustive]
|
2022-01-18 09:57:22 +00:00
|
|
|
pub enum EventView<'a> {
|
|
|
|
FlushStart(&'a FlushStart),
|
|
|
|
FlushStop(&'a FlushStop),
|
|
|
|
StreamStart(&'a StreamStart),
|
|
|
|
Caps(&'a Caps),
|
|
|
|
Segment(&'a Segment),
|
|
|
|
StreamCollection(&'a StreamCollection),
|
|
|
|
Tag(&'a Tag),
|
|
|
|
Buffersize(&'a Buffersize),
|
|
|
|
SinkMessage(&'a SinkMessage),
|
|
|
|
StreamGroupDone(&'a StreamGroupDone),
|
|
|
|
Eos(&'a Eos),
|
|
|
|
Toc(&'a Toc),
|
|
|
|
Protection(&'a Protection),
|
|
|
|
SegmentDone(&'a SegmentDone),
|
|
|
|
Gap(&'a Gap),
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2022-01-18 09:57:22 +00:00
|
|
|
InstantRateChange(&'a InstantRateChange),
|
|
|
|
Qos(&'a Qos),
|
|
|
|
Seek(&'a Seek),
|
|
|
|
Navigation(&'a Navigation),
|
|
|
|
Latency(&'a Latency),
|
|
|
|
Step(&'a Step),
|
|
|
|
Reconfigure(&'a Reconfigure),
|
|
|
|
TocSelect(&'a TocSelect),
|
|
|
|
SelectStreams(&'a SelectStreams),
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2022-01-18 09:57:22 +00:00
|
|
|
InstantRateSyncTime(&'a InstantRateSyncTime),
|
|
|
|
CustomUpstream(&'a CustomUpstream),
|
|
|
|
CustomDownstream(&'a CustomDownstream),
|
|
|
|
CustomDownstreamOob(&'a CustomDownstreamOob),
|
|
|
|
CustomDownstreamSticky(&'a CustomDownstreamSticky),
|
|
|
|
CustomBoth(&'a CustomBoth),
|
|
|
|
CustomBothOob(&'a CustomBothOob),
|
|
|
|
Other(&'a Other),
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
macro_rules! declare_concrete_event {
|
|
|
|
(@sticky $name:ident, $param:ident) => {
|
|
|
|
declare_concrete_event!($name, $param);
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl StickyEventType for $name {
|
2021-10-17 09:48:21 +00:00
|
|
|
const TYPE: EventType = EventType::$name;
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
unsafe fn from_event(event: Event) -> Self::Owned {
|
|
|
|
$name::<Event>(event)
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
($name:ident, $param:ident) => {
|
2022-01-18 09:57:22 +00:00
|
|
|
#[repr(transparent)]
|
|
|
|
pub struct $name<$param = EventRef>($param);
|
2021-10-17 09:48:21 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl $name {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn event(&self) -> &EventRef {
|
2022-01-18 09:57:22 +00:00
|
|
|
unsafe { &*(self as *const Self as *const EventRef) }
|
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
unsafe fn view(event: &EventRef) -> EventView<'_> {
|
|
|
|
let event = &*(event as *const EventRef as *const Self);
|
|
|
|
EventView::$name(event)
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Deref for $name {
|
2018-01-29 10:31:12 +00:00
|
|
|
type Target = EventRef;
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2018-01-29 10:31:12 +00:00
|
|
|
fn deref(&self) -> &Self::Target {
|
2022-01-18 09:57:22 +00:00
|
|
|
self.event()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ToOwned for $name {
|
|
|
|
type Owned = $name<Event>;
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
fn to_owned(&self) -> Self::Owned {
|
|
|
|
$name::<Event>(self.copy())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl $name<Event> {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
pub fn get_mut(&mut self) -> Option<&mut $name> {
|
2018-01-29 10:31:12 +00:00
|
|
|
self.0
|
2022-01-18 09:57:22 +00:00
|
|
|
.get_mut()
|
|
|
|
.map(|event| unsafe { &mut *(event as *mut EventRef as *mut $name) })
|
2018-01-29 10:31:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
impl Deref for $name<Event> {
|
2022-01-18 09:57:22 +00:00
|
|
|
type Target = $name;
|
2021-10-17 09:48:21 +00:00
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-10-17 09:48:21 +00:00
|
|
|
fn deref(&self) -> &Self::Target {
|
2022-01-18 09:57:22 +00:00
|
|
|
unsafe { &*(self.0.as_ptr() as *const Self::Target) }
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Borrow<$name> for $name<Event> {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
fn borrow(&self) -> &$name {
|
|
|
|
&*self
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<$name<Event>> for Event {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-10-17 09:48:21 +00:00
|
|
|
fn from(concrete: $name<Event>) -> Self {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
concrete.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
declare_concrete_event!(FlushStart, T);
|
|
|
|
impl FlushStart<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_flush_start")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new() -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder().build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>() -> FlushStartBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
FlushStartBuilder::new()
|
|
|
|
}
|
|
|
|
}
|
2018-01-29 10:31:12 +00:00
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for FlushStart {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("FlushStart")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for FlushStart<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
FlushStart::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(FlushStop, T);
|
|
|
|
impl FlushStop<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_flush_stop")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(reset_time: bool) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(reset_time).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(reset_time: bool) -> FlushStopBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
FlushStopBuilder::new(reset_time)
|
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl FlushStop {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_reset_time")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_flush_stop")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn resets_time(&self) -> bool {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut reset_time = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_flush_stop(self.as_mut_ptr(), reset_time.as_mut_ptr());
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(reset_time.assume_init())
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for FlushStop {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("FlushStop")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("resets-time", &self.resets_time())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for FlushStop<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
FlushStop::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky StreamStart, T);
|
|
|
|
impl StreamStart<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_stream_start")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(stream_id: &str) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(stream_id).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(stream_id: &str) -> StreamStartBuilder {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
StreamStartBuilder::new(stream_id)
|
|
|
|
}
|
2022-01-17 17:33:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl StreamStart {
|
2022-01-17 17:33:13 +00:00
|
|
|
#[doc(alias = "get_stream_id")]
|
|
|
|
#[doc(alias = "gst_event_parse_stream_start")]
|
2022-01-18 09:57:22 +00:00
|
|
|
pub fn stream_id(&self) -> &str {
|
2022-01-17 17:33:13 +00:00
|
|
|
unsafe {
|
|
|
|
let mut stream_id = ptr::null();
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_stream_start(self.as_mut_ptr(), &mut stream_id);
|
2017-12-16 15:30:50 +00:00
|
|
|
CStr::from_ptr(stream_id).to_str().unwrap()
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_stream_flags")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_parse_stream_flags")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn stream_flags(&self) -> crate::StreamFlags {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut stream_flags = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_stream_flags(self.as_mut_ptr(), stream_flags.as_mut_ptr());
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(stream_flags.assume_init())
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_group_id")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_parse_group_id")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn group_id(&self) -> Option<GroupId> {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut group_id = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_group_id(self.as_mut_ptr(), group_id.as_mut_ptr());
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2020-01-24 15:46:18 +00:00
|
|
|
let group_id = group_id.assume_init();
|
|
|
|
if group_id == 0 {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(GroupId(NonZeroU32::new_unchecked(group_id)))
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-17 10:32:33 +00:00
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_stream")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_parse_stream")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn stream(&self) -> Option<crate::Stream> {
|
2020-05-17 10:32:33 +00:00
|
|
|
unsafe {
|
|
|
|
let mut stream = ptr::null_mut();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_stream(self.as_mut_ptr(), &mut stream);
|
2020-05-17 10:32:33 +00:00
|
|
|
from_glib_full(stream)
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for StreamStart {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("StreamStart")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("stream-id", &self.stream_id())
|
|
|
|
.field("stream-flags", &self.stream_flags())
|
|
|
|
.field("group-id", &self.group_id())
|
|
|
|
.field("stream", &self.stream())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for StreamStart<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
StreamStart::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky Caps, T);
|
|
|
|
impl Caps<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_caps")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(caps: &crate::Caps) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(caps).build()
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn builder(caps: &crate::Caps) -> CapsBuilder {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CapsBuilder::new(caps)
|
|
|
|
}
|
2022-01-17 17:33:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Caps {
|
2022-01-17 17:33:13 +00:00
|
|
|
#[doc(alias = "get_caps")]
|
|
|
|
#[doc(alias = "gst_event_parse_caps")]
|
2022-01-18 09:57:22 +00:00
|
|
|
pub fn caps(&self) -> &crate::CapsRef {
|
2022-01-17 17:33:13 +00:00
|
|
|
unsafe {
|
|
|
|
let mut caps = ptr::null_mut();
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_caps(self.as_mut_ptr(), &mut caps);
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::CapsRef::from_ptr(caps)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-23 11:28:09 +00:00
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_caps_owned")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_caps")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn caps_owned(&self) -> crate::Caps {
|
|
|
|
unsafe { from_glib_none(self.caps().as_ptr()) }
|
2019-05-23 11:28:09 +00:00
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Caps {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("Caps")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("caps", &self.caps())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Caps<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Caps::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky Segment, T);
|
|
|
|
impl Segment<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_segment")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2022-10-09 16:37:45 +00:00
|
|
|
pub fn new<F: FormattedValueIntrinsic>(segment: &crate::FormattedSegment<F>) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(segment).build()
|
|
|
|
}
|
|
|
|
|
2022-10-09 16:37:45 +00:00
|
|
|
pub fn builder<F: FormattedValueIntrinsic>(
|
2020-11-21 13:46:48 +00:00
|
|
|
segment: &crate::FormattedSegment<F>,
|
|
|
|
) -> SegmentBuilder {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
SegmentBuilder::new(segment.as_ref())
|
|
|
|
}
|
2022-01-17 17:33:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Segment {
|
2022-01-17 17:33:13 +00:00
|
|
|
#[doc(alias = "get_segment")]
|
|
|
|
#[doc(alias = "gst_event_parse_segment")]
|
2022-01-18 09:57:22 +00:00
|
|
|
pub fn segment(&self) -> &crate::Segment {
|
2022-01-17 17:33:13 +00:00
|
|
|
unsafe {
|
|
|
|
let mut segment = ptr::null();
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_segment(self.as_mut_ptr(), &mut segment);
|
2020-11-21 13:46:48 +00:00
|
|
|
&*(segment as *mut ffi::GstSegment as *mut crate::Segment)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Segment {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("Segment")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("segment", &self.segment())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Segment<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Segment::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky StreamCollection, T);
|
|
|
|
impl StreamCollection<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_stream_collection")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(stream_collection: &crate::StreamCollection) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(stream_collection).build()
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn builder(stream_collection: &crate::StreamCollection) -> StreamCollectionBuilder {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
StreamCollectionBuilder::new(stream_collection)
|
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl StreamCollection {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_stream_collection")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_parse_stream_collection")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn stream_collection(&self) -> crate::StreamCollection {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
|
|
|
let mut stream_collection = ptr::null_mut();
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_stream_collection(self.as_mut_ptr(), &mut stream_collection);
|
2017-07-30 14:06:44 +00:00
|
|
|
from_glib_full(stream_collection)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for StreamCollection {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("StreamCollection")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("stream-collection", &self.stream_collection())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for StreamCollection<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
StreamCollection::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky Tag, T);
|
|
|
|
impl Tag<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_tag")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(tags: crate::TagList) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(tags).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(tags: crate::TagList) -> TagBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
TagBuilder::new(tags)
|
|
|
|
}
|
2022-01-17 17:33:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Tag {
|
2022-01-17 17:33:13 +00:00
|
|
|
#[doc(alias = "get_tag")]
|
|
|
|
#[doc(alias = "gst_event_parse_tag")]
|
2022-01-18 09:57:22 +00:00
|
|
|
pub fn tag(&self) -> &crate::TagListRef {
|
2022-01-17 17:33:13 +00:00
|
|
|
unsafe {
|
|
|
|
let mut tags = ptr::null_mut();
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_tag(self.as_mut_ptr(), &mut tags);
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::TagListRef::from_ptr(tags)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-23 11:28:09 +00:00
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_tag_owned")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_tag")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn tag_owned(&self) -> crate::TagList {
|
|
|
|
unsafe { from_glib_none(self.tag().as_ptr()) }
|
2019-05-23 11:28:09 +00:00
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Tag {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("Tag")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("tag", &self.tag())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Tag<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Tag::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky Buffersize, T);
|
|
|
|
impl Buffersize<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_buffer_size")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2022-07-05 11:13:50 +00:00
|
|
|
pub fn new<V: FormattedValue>(
|
|
|
|
minsize: V,
|
|
|
|
maxsize: impl CompatibleFormattedValue<V>,
|
|
|
|
r#async: bool,
|
|
|
|
) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
2020-11-21 13:46:48 +00:00
|
|
|
Self::builder(minsize, maxsize, r#async).build()
|
2020-06-23 15:52:51 +00:00
|
|
|
}
|
|
|
|
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn builder<'a, V: FormattedValue>(
|
2020-06-23 15:52:51 +00:00
|
|
|
minsize: V,
|
2022-07-05 11:13:50 +00:00
|
|
|
maxsize: impl CompatibleFormattedValue<V>,
|
2020-11-21 13:46:48 +00:00
|
|
|
r#async: bool,
|
2021-10-17 09:48:21 +00:00
|
|
|
) -> BuffersizeBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
2022-07-05 11:13:50 +00:00
|
|
|
let maxsize = maxsize.try_into_checked(minsize).unwrap();
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-07-03 16:04:06 +00:00
|
|
|
BuffersizeBuilder::new(minsize.into(), maxsize.into(), r#async)
|
2020-06-23 15:52:51 +00:00
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Buffersize {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_buffer_size")]
|
2017-12-09 16:20:21 +00:00
|
|
|
pub fn get(&self) -> (GenericFormattedValue, GenericFormattedValue, bool) {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut minsize = mem::MaybeUninit::uninit();
|
|
|
|
let mut maxsize = mem::MaybeUninit::uninit();
|
|
|
|
let mut async_ = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_parse_buffer_size(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
fmt.as_mut_ptr(),
|
|
|
|
minsize.as_mut_ptr(),
|
|
|
|
maxsize.as_mut_ptr(),
|
|
|
|
async_.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
);
|
2017-11-11 10:21:55 +00:00
|
|
|
(
|
2019-07-11 12:34:28 +00:00
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), minsize.assume_init()),
|
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), maxsize.assume_init()),
|
|
|
|
from_glib(async_.assume_init()),
|
2017-11-11 10:21:55 +00:00
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Buffersize {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
let (minsize, maxsize, async_) = self.get();
|
|
|
|
f.debug_struct("Buffersize")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("min-size", &minsize)
|
|
|
|
.field("max-size", &maxsize)
|
|
|
|
.field("async", &async_)
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Buffersize<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Buffersize::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky SinkMessage, T);
|
|
|
|
impl SinkMessage<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_sink_message")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn new(name: &str, msg: &crate::Message) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(name, msg).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(name: &'a str, msg: &'a crate::Message) -> SinkMessageBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
SinkMessageBuilder::new(name, msg)
|
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl SinkMessage {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_message")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_parse_sink_message")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn message(&self) -> crate::Message {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
|
|
|
let mut msg = ptr::null_mut();
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_sink_message(self.as_mut_ptr(), &mut msg);
|
2017-07-30 14:06:44 +00:00
|
|
|
from_glib_full(msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for SinkMessage {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("SinkMessage")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("message", &self.message())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for SinkMessage<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
SinkMessage::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky StreamGroupDone, T);
|
|
|
|
impl StreamGroupDone<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_stream_group_done")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(group_id: GroupId) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(group_id).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(group_id: GroupId) -> StreamGroupDoneBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
StreamGroupDoneBuilder::new(group_id)
|
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl StreamGroupDone {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_group_id")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_stream_group_done")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn group_id(&self) -> GroupId {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut group_id = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_stream_group_done(self.as_mut_ptr(), group_id.as_mut_ptr());
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2020-01-24 15:46:18 +00:00
|
|
|
let group_id = group_id.assume_init();
|
2022-12-25 10:47:02 +00:00
|
|
|
debug_assert_ne!(group_id, 0);
|
2020-01-24 15:46:18 +00:00
|
|
|
GroupId(NonZeroU32::new_unchecked(group_id))
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for StreamGroupDone {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("StreamGroupDone")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("group-id", &self.group_id())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for StreamGroupDone<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
StreamGroupDone::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky Eos, T);
|
|
|
|
impl Eos<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_eos")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new() -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder().build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>() -> EosBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
EosBuilder::new()
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Eos {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("Eos")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Eos<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Eos::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky Toc, T);
|
|
|
|
impl Toc<Event> {
|
2020-06-23 15:52:51 +00:00
|
|
|
// FIXME could use false for updated as default
|
|
|
|
// Even better: use an enum for updated so that it is more explicit than true / false
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_toc")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(toc: &crate::Toc, updated: bool) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(toc, updated).build()
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn builder(toc: &crate::Toc, updated: bool) -> TocBuilder {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
TocBuilder::new(toc, updated)
|
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Toc {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_toc")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_parse_toc")]
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn toc(&self) -> (&crate::TocRef, bool) {
|
2017-08-08 20:37:48 +00:00
|
|
|
unsafe {
|
|
|
|
let mut toc = ptr::null_mut();
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut updated = mem::MaybeUninit::uninit();
|
2017-08-08 20:37:48 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_toc(self.as_mut_ptr(), &mut toc, updated.as_mut_ptr());
|
2020-11-21 13:46:48 +00:00
|
|
|
(
|
|
|
|
crate::TocRef::from_ptr(toc),
|
|
|
|
from_glib(updated.assume_init()),
|
|
|
|
)
|
2017-08-08 20:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-23 11:28:09 +00:00
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_toc_owned")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_toc")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn toc_owned(&self) -> (crate::Toc, bool) {
|
2019-05-23 11:28:09 +00:00
|
|
|
unsafe {
|
2021-04-11 19:39:50 +00:00
|
|
|
let (toc, updated) = self.toc();
|
2019-05-23 11:28:09 +00:00
|
|
|
(from_glib_none(toc.as_ptr()), updated)
|
|
|
|
}
|
|
|
|
}
|
2017-08-08 20:37:48 +00:00
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Toc {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("Toc")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("toc", &self.toc())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Toc<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Toc::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky Protection, T);
|
|
|
|
impl Protection<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_protection")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn new(system_id: &str, data: &crate::Buffer) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(system_id, data).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(system_id: &'a str, data: &'a crate::Buffer) -> ProtectionBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
ProtectionBuilder::new(system_id, data)
|
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Protection {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_protection")]
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn get(&self) -> (&str, &crate::BufferRef, Option<&str>) {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
|
|
|
let mut system_id = ptr::null();
|
|
|
|
let mut buffer = ptr::null_mut();
|
|
|
|
let mut origin = ptr::null();
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_parse_protection(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
&mut system_id,
|
|
|
|
&mut buffer,
|
|
|
|
&mut origin,
|
|
|
|
);
|
|
|
|
|
|
|
|
(
|
|
|
|
CStr::from_ptr(system_id).to_str().unwrap(),
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::BufferRef::from_ptr(buffer),
|
2017-12-16 15:30:50 +00:00
|
|
|
if origin.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(CStr::from_ptr(origin).to_str().unwrap())
|
|
|
|
},
|
2017-07-31 11:16:42 +00:00
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-23 11:28:09 +00:00
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_protection")]
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn get_owned(&self) -> (&str, crate::Buffer, Option<&str>) {
|
2019-05-23 11:28:09 +00:00
|
|
|
unsafe {
|
|
|
|
let (system_id, buffer, origin) = self.get();
|
|
|
|
(system_id, from_glib_none(buffer.as_ptr()), origin)
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Protection {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
let (system_id, buffer, origin) = self.get();
|
|
|
|
f.debug_struct("Protection")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("system-id", &system_id)
|
|
|
|
.field("buffer", &buffer)
|
|
|
|
.field("origin", &origin)
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Protection<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Protection::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(SegmentDone, T);
|
|
|
|
impl SegmentDone<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_segment_done")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn new(position: impl FormattedValue) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(position).build()
|
|
|
|
}
|
|
|
|
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn builder<'a>(position: impl FormattedValue) -> SegmentDoneBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
2022-07-03 16:04:06 +00:00
|
|
|
SegmentDoneBuilder::new(position.into())
|
2020-06-23 15:52:51 +00:00
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl SegmentDone {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_segment_done")]
|
2017-12-09 16:20:21 +00:00
|
|
|
pub fn get(&self) -> GenericFormattedValue {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut position = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_parse_segment_done(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
fmt.as_mut_ptr(),
|
|
|
|
position.as_mut_ptr(),
|
|
|
|
);
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), position.assume_init())
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for SegmentDone {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("SegmentDone")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("segment", &self.get())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for SegmentDone<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
SegmentDone::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(Gap, T);
|
|
|
|
impl Gap<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_gap")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn new(timestamp: ClockTime, duration: impl Into<Option<ClockTime>>) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
2021-04-28 22:29:13 +00:00
|
|
|
Self::builder(timestamp).duration(duration).build()
|
2020-06-23 15:52:51 +00:00
|
|
|
}
|
|
|
|
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn builder<'a>(timestamp: ClockTime) -> GapBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
2021-04-28 22:29:13 +00:00
|
|
|
GapBuilder::new(timestamp)
|
2020-06-23 15:52:51 +00:00
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Gap {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_gap")]
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn get(&self) -> (ClockTime, Option<ClockTime>) {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut timestamp = mem::MaybeUninit::uninit();
|
|
|
|
let mut duration = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_parse_gap(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
timestamp.as_mut_ptr(),
|
|
|
|
duration.as_mut_ptr(),
|
|
|
|
);
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
(
|
2021-04-28 22:29:13 +00:00
|
|
|
try_from_glib(timestamp.assume_init()).expect("undefined timestamp"),
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(duration.assume_init()),
|
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-09 12:51:19 +00:00
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_20")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
|
2021-07-09 12:51:19 +00:00
|
|
|
#[doc(alias = "gst_event_parse_gap_flags")]
|
|
|
|
pub fn gap_flags(&self) -> crate::GapFlags {
|
|
|
|
unsafe {
|
|
|
|
let mut flags = mem::MaybeUninit::uninit();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_gap_flags(self.as_mut_ptr(), flags.as_mut_ptr());
|
2021-07-09 12:51:19 +00:00
|
|
|
from_glib(flags.assume_init())
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Gap {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
let (timestamp, duration) = self.get();
|
|
|
|
let mut f = f.debug_struct("Gap");
|
|
|
|
f.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("timestamp", ×tamp)
|
|
|
|
.field("duration", &duration);
|
|
|
|
#[cfg(feature = "v1_20")]
|
|
|
|
f.field("flags", &self.gap_flags());
|
|
|
|
f.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Gap<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Gap::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2021-10-17 11:27:44 +00:00
|
|
|
declare_concrete_event!(@sticky InstantRateChange, T);
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2021-10-17 11:27:44 +00:00
|
|
|
impl InstantRateChange<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_instant_rate_change")]
|
2021-10-17 11:27:44 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(multiplier: f64, new_flags: crate::SegmentFlags) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(multiplier, new_flags).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder<'a>(
|
|
|
|
multiplier: f64,
|
|
|
|
new_flags: crate::SegmentFlags,
|
|
|
|
) -> InstantRateChangeBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
InstantRateChangeBuilder::new(multiplier, new_flags)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2022-01-18 09:57:22 +00:00
|
|
|
impl InstantRateChange {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_instant_rate_change")]
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn get(&self) -> (f64, crate::SegmentFlags) {
|
|
|
|
unsafe {
|
|
|
|
let mut multiplier = mem::MaybeUninit::uninit();
|
|
|
|
let mut new_flags = mem::MaybeUninit::uninit();
|
|
|
|
|
|
|
|
ffi::gst_event_parse_instant_rate_change(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-10-17 11:27:44 +00:00
|
|
|
multiplier.as_mut_ptr(),
|
|
|
|
new_flags.as_mut_ptr(),
|
|
|
|
);
|
|
|
|
|
|
|
|
(multiplier.assume_init(), from_glib(new_flags.assume_init()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
impl std::fmt::Debug for InstantRateChange {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
let (multiplier, new_flags) = self.get();
|
|
|
|
f.debug_struct("InstantRateChange")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("multiplier", &multiplier)
|
|
|
|
.field("new-flags", &new_flags)
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
impl std::fmt::Debug for InstantRateChange<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
InstantRateChange::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(Qos, T);
|
|
|
|
impl Qos<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_qos")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(
|
|
|
|
type_: crate::QOSType,
|
|
|
|
proportion: f64,
|
|
|
|
diff: i64,
|
2021-10-17 11:27:44 +00:00
|
|
|
timestamp: impl Into<Option<ClockTime>>,
|
2020-11-21 13:46:48 +00:00
|
|
|
) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
2021-04-28 22:29:13 +00:00
|
|
|
Self::builder(type_, proportion, diff)
|
|
|
|
.timestamp(timestamp)
|
|
|
|
.build()
|
2020-06-23 15:52:51 +00:00
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(type_: crate::QOSType, proportion: f64, diff: i64) -> QosBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
2021-04-28 22:29:13 +00:00
|
|
|
QosBuilder::new(type_, proportion, diff)
|
2020-06-23 15:52:51 +00:00
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Qos {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_qos")]
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn get(&self) -> (crate::QOSType, f64, i64, Option<ClockTime>) {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut type_ = mem::MaybeUninit::uninit();
|
|
|
|
let mut proportion = mem::MaybeUninit::uninit();
|
|
|
|
let mut diff = mem::MaybeUninit::uninit();
|
|
|
|
let mut timestamp = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_parse_qos(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
type_.as_mut_ptr(),
|
|
|
|
proportion.as_mut_ptr(),
|
|
|
|
diff.as_mut_ptr(),
|
|
|
|
timestamp.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
);
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
(
|
|
|
|
from_glib(type_.assume_init()),
|
|
|
|
proportion.assume_init(),
|
|
|
|
diff.assume_init(),
|
|
|
|
from_glib(timestamp.assume_init()),
|
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Qos {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
let (type_, proportion, diff, timestamp) = self.get();
|
|
|
|
f.debug_struct("Qos")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("type", &type_)
|
|
|
|
.field("proportion", &proportion)
|
|
|
|
.field("diff", &diff)
|
|
|
|
.field("timestamp", ×tamp)
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Qos<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Qos::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(Seek, T);
|
|
|
|
impl Seek<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_seek")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn new<V: FormattedValue>(
|
2020-06-23 15:52:51 +00:00
|
|
|
rate: f64,
|
2020-11-21 13:46:48 +00:00
|
|
|
flags: crate::SeekFlags,
|
|
|
|
start_type: crate::SeekType,
|
2020-06-23 15:52:51 +00:00
|
|
|
start: V,
|
2020-11-21 13:46:48 +00:00
|
|
|
stop_type: crate::SeekType,
|
2022-07-05 11:13:50 +00:00
|
|
|
stop: impl CompatibleFormattedValue<V>,
|
2020-06-23 15:52:51 +00:00
|
|
|
) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(rate, flags, start_type, start, stop_type, stop).build()
|
|
|
|
}
|
|
|
|
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn builder<'a, V: FormattedValue>(
|
2020-06-23 15:52:51 +00:00
|
|
|
rate: f64,
|
2020-11-21 13:46:48 +00:00
|
|
|
flags: crate::SeekFlags,
|
|
|
|
start_type: crate::SeekType,
|
2020-06-23 15:52:51 +00:00
|
|
|
start: V,
|
2020-11-21 13:46:48 +00:00
|
|
|
stop_type: crate::SeekType,
|
2022-07-05 11:13:50 +00:00
|
|
|
stop: impl CompatibleFormattedValue<V>,
|
2020-06-23 15:52:51 +00:00
|
|
|
) -> SeekBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
2022-07-05 11:13:50 +00:00
|
|
|
let stop = stop.try_into_checked(start).unwrap();
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-07-03 16:04:06 +00:00
|
|
|
SeekBuilder::new(
|
|
|
|
rate,
|
|
|
|
flags,
|
|
|
|
start_type,
|
|
|
|
start.into(),
|
|
|
|
stop_type,
|
|
|
|
stop.into(),
|
|
|
|
)
|
2020-06-23 15:52:51 +00:00
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Seek {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_seek")]
|
2017-11-11 10:21:55 +00:00
|
|
|
pub fn get(
|
|
|
|
&self,
|
|
|
|
) -> (
|
|
|
|
f64,
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::SeekFlags,
|
|
|
|
crate::SeekType,
|
2017-12-09 16:20:21 +00:00
|
|
|
GenericFormattedValue,
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::SeekType,
|
2017-12-09 16:20:21 +00:00
|
|
|
GenericFormattedValue,
|
2017-11-11 10:21:55 +00:00
|
|
|
) {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut rate = mem::MaybeUninit::uninit();
|
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut flags = mem::MaybeUninit::uninit();
|
|
|
|
let mut start_type = mem::MaybeUninit::uninit();
|
|
|
|
let mut start = mem::MaybeUninit::uninit();
|
|
|
|
let mut stop_type = mem::MaybeUninit::uninit();
|
|
|
|
let mut stop = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_parse_seek(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
rate.as_mut_ptr(),
|
|
|
|
fmt.as_mut_ptr(),
|
|
|
|
flags.as_mut_ptr(),
|
|
|
|
start_type.as_mut_ptr(),
|
|
|
|
start.as_mut_ptr(),
|
|
|
|
stop_type.as_mut_ptr(),
|
|
|
|
stop.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
(
|
2019-07-11 12:34:28 +00:00
|
|
|
rate.assume_init(),
|
|
|
|
from_glib(flags.assume_init()),
|
|
|
|
from_glib(start_type.assume_init()),
|
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), start.assume_init()),
|
|
|
|
from_glib(stop_type.assume_init()),
|
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), stop.assume_init()),
|
2017-07-31 11:16:42 +00:00
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-23 16:53:10 +00:00
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_16")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_trickmode_interval")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_parse_seek_trickmode_interval")]
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn trickmode_interval(&self) -> Option<ClockTime> {
|
2019-04-23 16:53:10 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut trickmode_interval = mem::MaybeUninit::uninit();
|
2019-04-23 16:53:10 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_parse_seek_trickmode_interval(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
trickmode_interval.as_mut_ptr(),
|
2019-04-23 16:53:10 +00:00
|
|
|
);
|
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(trickmode_interval.assume_init())
|
2019-04-23 16:53:10 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Seek {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
let (rate, flags, start_type, start, stop_type, stop) = self.get();
|
|
|
|
f.debug_struct("Seek")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("rate", &rate)
|
|
|
|
.field("flags", &flags)
|
|
|
|
.field("start-type", &start_type)
|
|
|
|
.field("start", &start)
|
|
|
|
.field("stop-type", &stop_type)
|
|
|
|
.field("stop", &stop)
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Seek<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Seek::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(Navigation, T);
|
|
|
|
impl Navigation<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_navigation")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(structure: crate::Structure) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(structure: crate::Structure) -> NavigationBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
NavigationBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Navigation {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("Navigation")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Navigation<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Navigation::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(Latency, T);
|
|
|
|
impl Latency<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_latency")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn new(latency: ClockTime) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(latency).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn builder<'a>(latency: ClockTime) -> LatencyBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
LatencyBuilder::new(latency)
|
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Latency {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_latency")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_parse_latency")]
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn latency(&self) -> ClockTime {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut latency = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_latency(self.as_mut_ptr(), latency.as_mut_ptr());
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2021-04-28 22:29:13 +00:00
|
|
|
try_from_glib(latency.assume_init()).expect("undefined latency")
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Latency {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("Latency")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("latency", &self.latency())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Latency<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Latency::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(Step, T);
|
|
|
|
impl Step<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_step")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn new(amount: impl FormattedValue, rate: f64, flush: bool, intermediate: bool) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
2022-07-03 16:04:06 +00:00
|
|
|
Self::builder(amount, rate, flush, intermediate).build()
|
2020-06-23 15:52:51 +00:00
|
|
|
}
|
|
|
|
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn builder<'a>(
|
|
|
|
amount: impl FormattedValue,
|
2020-06-23 15:52:51 +00:00
|
|
|
rate: f64,
|
|
|
|
flush: bool,
|
|
|
|
intermediate: bool,
|
|
|
|
) -> StepBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
StepBuilder::new(amount.into(), rate, flush, intermediate)
|
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Step {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_parse_step")]
|
2017-12-09 16:20:21 +00:00
|
|
|
pub fn get(&self) -> (GenericFormattedValue, f64, bool, bool) {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut amount = mem::MaybeUninit::uninit();
|
|
|
|
let mut rate = mem::MaybeUninit::uninit();
|
|
|
|
let mut flush = mem::MaybeUninit::uninit();
|
|
|
|
let mut intermediate = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_parse_step(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
fmt.as_mut_ptr(),
|
|
|
|
amount.as_mut_ptr(),
|
|
|
|
rate.as_mut_ptr(),
|
|
|
|
flush.as_mut_ptr(),
|
|
|
|
intermediate.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
(
|
2019-07-11 12:34:28 +00:00
|
|
|
GenericFormattedValue::new(
|
|
|
|
from_glib(fmt.assume_init()),
|
|
|
|
amount.assume_init() as i64,
|
|
|
|
),
|
|
|
|
rate.assume_init(),
|
|
|
|
from_glib(flush.assume_init()),
|
|
|
|
from_glib(intermediate.assume_init()),
|
2017-07-31 11:16:42 +00:00
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Step {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
let (amount, rate, flush, intermediate) = self.get();
|
|
|
|
f.debug_struct("Step")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("amount", &amount)
|
|
|
|
.field("rate", &rate)
|
|
|
|
.field("flush", &flush)
|
|
|
|
.field("intermediate", &intermediate)
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Step<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Step::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(Reconfigure, T);
|
|
|
|
impl Reconfigure<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_reconfigure")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new() -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder().build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>() -> ReconfigureBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
ReconfigureBuilder::new()
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Reconfigure {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("Reconfigure")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Reconfigure<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Reconfigure::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(TocSelect, T);
|
|
|
|
impl TocSelect<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_toc_select")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(uid: &str) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(uid).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(uid: &str) -> TocSelectBuilder {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
TocSelectBuilder::new(uid)
|
|
|
|
}
|
2022-01-17 17:33:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl TocSelect {
|
2022-01-17 17:33:13 +00:00
|
|
|
#[doc(alias = "get_uid")]
|
2022-01-18 09:57:22 +00:00
|
|
|
pub fn uid(&self) -> &str {
|
2022-01-17 17:33:13 +00:00
|
|
|
unsafe {
|
|
|
|
let mut uid = ptr::null_mut();
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_toc_select(self.as_mut_ptr(), &mut uid);
|
2017-07-30 14:06:44 +00:00
|
|
|
|
|
|
|
CStr::from_ptr(uid).to_str().unwrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for TocSelect {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("TocSelect")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("uid", &self.uid())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for TocSelect<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
TocSelect::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(SelectStreams, T);
|
|
|
|
impl SelectStreams<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_select_streams")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn new(streams: &[&str]) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(streams).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(streams: &'a [&'a str]) -> SelectStreamsBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
SelectStreamsBuilder::new(streams)
|
|
|
|
}
|
2021-10-17 09:48:21 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl SelectStreams {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_streams")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_event_parse_select_streams")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn streams(&self) -> Vec<String> {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
|
|
|
let mut streams = ptr::null_mut();
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_event_parse_select_streams(self.as_mut_ptr(), &mut streams);
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2017-07-30 14:15:34 +00:00
|
|
|
FromGlibPtrContainer::from_glib_full(streams)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for SelectStreams {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("SelectStreams")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("streams", &self.streams())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for SelectStreams<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
SelectStreams::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2021-10-17 11:27:44 +00:00
|
|
|
declare_concrete_event!(InstantRateSyncTime, T);
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2021-10-17 11:27:44 +00:00
|
|
|
impl InstantRateSyncTime<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_instant_rate_sync_time")]
|
2021-10-17 11:27:44 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(
|
|
|
|
rate_multiplier: f64,
|
|
|
|
running_time: ClockTime,
|
|
|
|
upstream_running_time: ClockTime,
|
|
|
|
) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(rate_multiplier, running_time, upstream_running_time).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder<'a>(
|
|
|
|
rate_multiplier: f64,
|
|
|
|
running_time: ClockTime,
|
|
|
|
upstream_running_time: ClockTime,
|
|
|
|
) -> InstantRateSyncTimeBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
InstantRateSyncTimeBuilder::new(rate_multiplier, running_time, upstream_running_time)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2022-01-18 09:57:22 +00:00
|
|
|
impl InstantRateSyncTime {
|
2021-10-17 11:27:44 +00:00
|
|
|
#[doc(alias = "parse_instant_rate_sync_time")]
|
|
|
|
#[doc(alias = "gst_event_parse_instant_rate_sync_time")]
|
|
|
|
pub fn get(&self) -> (f64, ClockTime, ClockTime) {
|
|
|
|
unsafe {
|
|
|
|
let mut rate_multiplier = mem::MaybeUninit::uninit();
|
|
|
|
let mut running_time = mem::MaybeUninit::uninit();
|
|
|
|
let mut upstream_running_time = mem::MaybeUninit::uninit();
|
|
|
|
|
|
|
|
ffi::gst_event_parse_instant_rate_sync_time(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-10-17 11:27:44 +00:00
|
|
|
rate_multiplier.as_mut_ptr(),
|
|
|
|
running_time.as_mut_ptr(),
|
|
|
|
upstream_running_time.as_mut_ptr(),
|
|
|
|
);
|
|
|
|
|
|
|
|
(
|
|
|
|
rate_multiplier.assume_init(),
|
|
|
|
try_from_glib(running_time.assume_init()).expect("undefined timestamp"),
|
|
|
|
try_from_glib(upstream_running_time.assume_init()).expect("undefined timestamp"),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
impl std::fmt::Debug for InstantRateSyncTime {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
let (rate_multiplier, running_time, upstream_running_time) = self.get();
|
|
|
|
f.debug_struct("InstantRateSyncTime")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.field("rate-multiplier", &rate_multiplier)
|
|
|
|
.field("running-time", &running_time)
|
|
|
|
.field("upstream-running-time", &upstream_running_time)
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
impl std::fmt::Debug for InstantRateSyncTime<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
InstantRateSyncTime::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(CustomUpstream, T);
|
|
|
|
impl CustomUpstream<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_custom")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(structure: crate::Structure) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(structure: crate::Structure) -> CustomUpstreamBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomUpstreamBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for CustomUpstream {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("CustomUpstream")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for CustomUpstream<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
CustomUpstream::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(CustomDownstream, T);
|
|
|
|
impl CustomDownstream<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_custom")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(structure: crate::Structure) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(structure: crate::Structure) -> CustomDownstreamBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomDownstreamBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for CustomDownstream {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("CustomDownstream")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for CustomDownstream<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
CustomDownstream::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(CustomDownstreamOob, T);
|
|
|
|
impl CustomDownstreamOob<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_custom")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(structure: crate::Structure) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(structure: crate::Structure) -> CustomDownstreamOobBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomDownstreamOobBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for CustomDownstreamOob {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("CustomDownstreamOob")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for CustomDownstreamOob<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
CustomDownstreamOob::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(@sticky CustomDownstreamSticky, T);
|
|
|
|
impl CustomDownstreamSticky<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_custom")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(structure: crate::Structure) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(structure: crate::Structure) -> CustomDownstreamStickyBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomDownstreamStickyBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for CustomDownstreamSticky {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("CustomDownstreamSticky")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for CustomDownstreamSticky<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
CustomDownstreamSticky::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(CustomBoth, T);
|
|
|
|
impl CustomBoth<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_custom")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(structure: crate::Structure) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(structure: crate::Structure) -> CustomBothBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomBothBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for CustomBoth {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("CustomBoth")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for CustomBoth<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
CustomBoth::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(CustomBothOob, T);
|
|
|
|
impl CustomBothOob<Event> {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_new_custom")]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(structure: crate::Structure) -> Event {
|
2020-06-23 15:52:51 +00:00
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
pub fn builder<'a>(structure: crate::Structure) -> CustomBothOobBuilder<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomBothOobBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for CustomBothOob {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("CustomBothOob")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for CustomBothOob<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
CustomBothOob::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
declare_concrete_event!(Other, T);
|
|
|
|
|
2023-05-22 12:20:29 +00:00
|
|
|
impl std::fmt::Debug for Other {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
f.debug_struct("Other")
|
|
|
|
.field("seqnum", &self.event().seqnum())
|
|
|
|
.field("running-time-offset", &self.event().running_time_offset())
|
|
|
|
.field("structure", &self.event().structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-24 07:36:08 +00:00
|
|
|
impl std::fmt::Debug for Other<Event> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
Other::<EventRef>::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:58:25 +00:00
|
|
|
struct EventBuilder<'a> {
|
|
|
|
seqnum: Option<Seqnum>,
|
|
|
|
running_time_offset: Option<i64>,
|
2023-12-31 13:49:42 +00:00
|
|
|
other_fields: Vec<(&'a str, glib::SendValue)>,
|
2018-01-29 10:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> EventBuilder<'a> {
|
|
|
|
fn new() -> Self {
|
|
|
|
Self {
|
|
|
|
seqnum: None,
|
|
|
|
running_time_offset: None,
|
2018-02-22 10:18:37 +00:00
|
|
|
other_fields: Vec::new(),
|
2018-01-29 10:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn seqnum(self, seqnum: Seqnum) -> Self {
|
|
|
|
Self {
|
|
|
|
seqnum: Some(seqnum),
|
2018-02-22 10:18:37 +00:00
|
|
|
..self
|
2018-01-29 10:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn running_time_offset(self, running_time_offset: i64) -> Self {
|
|
|
|
Self {
|
|
|
|
running_time_offset: Some(running_time_offset),
|
2018-02-22 10:18:37 +00:00
|
|
|
..self
|
2018-01-29 10:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-31 13:49:42 +00:00
|
|
|
fn other_field(self, name: &'a str, value: impl ToSendValue) -> Self {
|
|
|
|
let mut other_fields = self.other_fields;
|
|
|
|
other_fields.push((name, value.to_send_value()));
|
|
|
|
|
2018-01-29 10:58:25 +00:00
|
|
|
Self {
|
2023-12-31 13:49:42 +00:00
|
|
|
other_fields,
|
2018-02-22 10:18:37 +00:00
|
|
|
..self
|
2018-01-29 10:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
2023-12-31 13:49:42 +00:00
|
|
|
|
|
|
|
fn other_fields(self, other_fields: &[(&'a str, &'a (dyn ToSendValue + Sync))]) -> Self {
|
|
|
|
let mut s = self;
|
|
|
|
|
|
|
|
for (name, value) in other_fields {
|
|
|
|
s = s.other_field(name, value.to_send_value());
|
|
|
|
}
|
|
|
|
|
|
|
|
s
|
|
|
|
}
|
2018-01-29 10:58:25 +00:00
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
macro_rules! event_builder_generic_impl {
|
|
|
|
($new_fn:expr) => {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_set_seqnum")]
|
2019-02-28 08:32:13 +00:00
|
|
|
#[allow(clippy::needless_update)]
|
2017-12-05 19:32:16 +00:00
|
|
|
pub fn seqnum(self, seqnum: Seqnum) -> Self {
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: self.builder.seqnum(seqnum),
|
2020-04-24 09:46:16 +00:00
|
|
|
..self
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
#[doc(alias = "gst_event_set_seqnum")]
|
|
|
|
#[allow(clippy::needless_update)]
|
|
|
|
pub fn seqnum_if(self, seqnum: Seqnum, predicate: bool) -> Self {
|
|
|
|
if predicate {
|
|
|
|
self.seqnum(seqnum)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-29 16:04:34 +00:00
|
|
|
#[doc(alias = "gst_event_set_seqnum")]
|
|
|
|
#[allow(clippy::needless_update)]
|
|
|
|
pub fn seqnum_if_some(self, seqnum: Option<Seqnum>) -> Self {
|
|
|
|
if let Some(seqnum) = seqnum {
|
|
|
|
self.seqnum(seqnum)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_event_set_running_time_offset")]
|
2019-02-28 08:32:13 +00:00
|
|
|
#[allow(clippy::needless_update)]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn running_time_offset(self, running_time_offset: i64) -> Self {
|
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: self.builder.running_time_offset(running_time_offset),
|
2020-04-24 09:46:16 +00:00
|
|
|
..self
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
#[doc(alias = "gst_event_set_running_time_offset")]
|
|
|
|
#[allow(clippy::needless_update)]
|
|
|
|
pub fn running_time_offset_if(self, running_time_offset: i64, predicate: bool) -> Self {
|
|
|
|
if predicate {
|
|
|
|
self.running_time_offset(running_time_offset)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-29 16:04:34 +00:00
|
|
|
#[doc(alias = "gst_event_set_running_time_offset")]
|
|
|
|
#[allow(clippy::needless_update)]
|
|
|
|
pub fn running_time_offset_if_some(self, running_time_offset: Option<i64>) -> Self {
|
|
|
|
if let Some(running_time_offset) = running_time_offset {
|
|
|
|
self.running_time_offset(running_time_offset)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
// rustdoc-stripper-ignore-next
|
|
|
|
/// Sets field `name` to the given value `value`.
|
|
|
|
///
|
|
|
|
/// Overrides any default or previously defined value for `name`.
|
2023-12-31 13:49:42 +00:00
|
|
|
#[allow(clippy::needless_update)]
|
|
|
|
pub fn other_field(self, name: &'a str, value: impl ToSendValue) -> Self {
|
|
|
|
Self {
|
|
|
|
builder: self.builder.other_field(name, value),
|
|
|
|
..self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
impl_builder_gvalue_extra_setters!(other_field);
|
2024-03-29 16:04:34 +00:00
|
|
|
|
2023-12-31 13:49:42 +00:00
|
|
|
#[deprecated = "use build.other_field() instead"]
|
2019-02-28 08:32:13 +00:00
|
|
|
#[allow(clippy::needless_update)]
|
2021-04-20 07:19:02 +00:00
|
|
|
pub fn other_fields(
|
|
|
|
self,
|
|
|
|
other_fields: &[(&'a str, &'a (dyn ToSendValue + Sync))],
|
|
|
|
) -> Self {
|
2017-09-13 19:38:19 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: self.builder.other_fields(other_fields),
|
2020-04-24 09:46:16 +00:00
|
|
|
..self
|
2017-09-13 19:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "Building the event without using it has no effect"]
|
2023-08-22 07:00:35 +00:00
|
|
|
#[allow(clippy::redundant_closure_call)]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn build(mut self) -> Event {
|
|
|
|
unsafe {
|
|
|
|
let event = $new_fn(&mut self);
|
2018-01-29 10:58:25 +00:00
|
|
|
if let Some(seqnum) = self.builder.seqnum {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_set_seqnum(event, seqnum.0.get());
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 10:58:25 +00:00
|
|
|
if let Some(running_time_offset) = self.builder.running_time_offset {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_set_running_time_offset(event, running_time_offset);
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 10:58:25 +00:00
|
|
|
if !self.builder.other_fields.is_empty() {
|
2020-11-21 13:46:48 +00:00
|
|
|
let s = StructureRef::from_glib_borrow_mut(ffi::gst_event_writable_structure(
|
|
|
|
event,
|
|
|
|
));
|
2017-09-13 19:38:19 +00:00
|
|
|
|
2018-01-29 10:58:25 +00:00
|
|
|
for (k, v) in self.builder.other_fields {
|
2023-12-31 13:49:42 +00:00
|
|
|
s.set_value(k, v);
|
2017-09-13 19:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
from_glib_full(event)
|
|
|
|
}
|
|
|
|
}
|
2020-04-24 09:46:16 +00:00
|
|
|
};
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct FlushStartBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> FlushStartBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new() -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|_| { ffi::gst_event_new_flush_start() });
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct FlushStopBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-31 11:16:42 +00:00
|
|
|
reset_time: bool,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> FlushStopBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(reset_time: bool) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
reset_time,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_flush_stop(s.reset_time.into_glib())
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub struct StreamStartBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
stream_id: &'a str,
|
2020-11-21 13:46:48 +00:00
|
|
|
flags: Option<crate::StreamFlags>,
|
2017-12-05 19:32:16 +00:00
|
|
|
group_id: Option<GroupId>,
|
2020-11-21 13:46:48 +00:00
|
|
|
stream: Option<crate::Stream>,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> StreamStartBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(stream_id: &'a str) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
stream_id,
|
2017-07-30 14:06:44 +00:00
|
|
|
flags: None,
|
|
|
|
group_id: None,
|
2020-05-17 10:32:33 +00:00
|
|
|
stream: None,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn flags(self, flags: crate::StreamFlags) -> Self {
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
|
|
|
flags: Some(flags),
|
2017-07-31 11:16:42 +00:00
|
|
|
..self
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
pub fn flags_if(self, flags: crate::StreamFlags, predicate: bool) -> Self {
|
|
|
|
if predicate {
|
|
|
|
self.flags(flags)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-29 16:04:34 +00:00
|
|
|
pub fn flags_if_some(self, flags: Option<crate::StreamFlags>) -> Self {
|
|
|
|
if let Some(flags) = flags {
|
|
|
|
self.flags(flags)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-05 19:32:16 +00:00
|
|
|
pub fn group_id(self, group_id: GroupId) -> Self {
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
|
|
|
group_id: Some(group_id),
|
2017-07-31 11:16:42 +00:00
|
|
|
..self
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
pub fn group_id_if(self, group_id: GroupId, predicate: bool) -> Self {
|
|
|
|
if predicate {
|
|
|
|
self.group_id(group_id)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-29 16:04:34 +00:00
|
|
|
pub fn group_id_if_some(self, group_id: Option<GroupId>) -> Self {
|
|
|
|
if let Some(group_id) = group_id {
|
|
|
|
self.group_id(group_id)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn stream(self, stream: crate::Stream) -> Self {
|
2020-05-17 10:32:33 +00:00
|
|
|
Self {
|
|
|
|
stream: Some(stream),
|
|
|
|
..self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
pub fn stream_if(self, stream: crate::Stream, predicate: bool) -> Self {
|
|
|
|
if predicate {
|
|
|
|
self.stream(stream)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-29 16:04:34 +00:00
|
|
|
pub fn stream_if_some(self, stream: Option<crate::Stream>) -> Self {
|
|
|
|
if let Some(stream) = stream {
|
|
|
|
self.stream(stream)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
2020-11-21 13:46:48 +00:00
|
|
|
let ev = ffi::gst_event_new_stream_start(s.stream_id.to_glib_none().0);
|
2017-07-30 14:06:44 +00:00
|
|
|
if let Some(flags) = s.flags {
|
2021-04-27 15:15:46 +00:00
|
|
|
ffi::gst_event_set_stream_flags(ev, flags.into_glib());
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
if let Some(group_id) = s.group_id {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_set_group_id(ev, group_id.0.get());
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-05-17 10:32:33 +00:00
|
|
|
|
2020-11-19 10:08:50 +00:00
|
|
|
if let Some(ref stream) = s.stream {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_set_stream(ev, stream.to_glib_none().0);
|
2020-05-17 10:32:33 +00:00
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
ev
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub struct CapsBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2020-11-21 13:46:48 +00:00
|
|
|
caps: &'a crate::Caps,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> CapsBuilder<'a> {
|
2020-11-21 13:46:48 +00:00
|
|
|
fn new(caps: &'a crate::Caps) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
caps,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| { ffi::gst_event_new_caps(s.caps.as_mut_ptr()) });
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub struct SegmentBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2020-11-21 13:46:48 +00:00
|
|
|
segment: &'a crate::Segment,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> SegmentBuilder<'a> {
|
2020-11-21 13:46:48 +00:00
|
|
|
fn new(segment: &'a crate::Segment) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
segment,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_segment(s.segment.to_glib_none().0)
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub struct StreamCollectionBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2020-11-21 13:46:48 +00:00
|
|
|
stream_collection: &'a crate::StreamCollection,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> StreamCollectionBuilder<'a> {
|
2020-11-21 13:46:48 +00:00
|
|
|
fn new(stream_collection: &'a crate::StreamCollection) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
stream_collection,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_stream_collection(s.stream_collection.to_glib_none().0)
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2021-10-17 11:27:44 +00:00
|
|
|
pub struct InstantRateSyncTimeBuilder<'a> {
|
|
|
|
builder: EventBuilder<'a>,
|
|
|
|
rate_multiplier: f64,
|
|
|
|
running_time: ClockTime,
|
|
|
|
upstream_running_time: ClockTime,
|
|
|
|
}
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2021-10-17 11:27:44 +00:00
|
|
|
impl<'a> InstantRateSyncTimeBuilder<'a> {
|
|
|
|
fn new(
|
|
|
|
rate_multiplier: f64,
|
|
|
|
running_time: ClockTime,
|
|
|
|
upstream_running_time: ClockTime,
|
|
|
|
) -> Self {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self {
|
|
|
|
builder: EventBuilder::new(),
|
|
|
|
rate_multiplier,
|
|
|
|
running_time,
|
|
|
|
upstream_running_time,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_instant_rate_sync_time(
|
|
|
|
s.rate_multiplier,
|
|
|
|
s.running_time.into_glib(),
|
|
|
|
s.upstream_running_time.into_glib(),
|
|
|
|
)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct TagBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2020-11-21 13:46:48 +00:00
|
|
|
tags: Option<crate::TagList>,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> TagBuilder<'a> {
|
2020-11-21 13:46:48 +00:00
|
|
|
fn new(tags: crate::TagList) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
tags: Some(tags),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &mut Self| {
|
|
|
|
let tags = s.tags.take().unwrap();
|
2022-05-06 19:41:15 +00:00
|
|
|
ffi::gst_event_new_tag(tags.into_glib_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2021-10-17 09:48:21 +00:00
|
|
|
pub struct BuffersizeBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-12-09 16:20:21 +00:00
|
|
|
minsize: GenericFormattedValue,
|
|
|
|
maxsize: GenericFormattedValue,
|
2020-11-21 13:46:48 +00:00
|
|
|
r#async: bool,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
impl<'a> BuffersizeBuilder<'a> {
|
2020-11-21 13:46:48 +00:00
|
|
|
fn new(minsize: GenericFormattedValue, maxsize: GenericFormattedValue, r#async: bool) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
minsize,
|
|
|
|
maxsize,
|
2020-11-21 13:46:48 +00:00
|
|
|
r#async,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_buffer_size(
|
|
|
|
s.minsize.format().into_glib(),
|
|
|
|
s.minsize.value(),
|
|
|
|
s.maxsize.value(),
|
|
|
|
s.r#async.into_glib(),
|
|
|
|
)
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub struct SinkMessageBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
name: &'a str,
|
2020-11-21 13:46:48 +00:00
|
|
|
msg: &'a crate::Message,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> SinkMessageBuilder<'a> {
|
2020-11-21 13:46:48 +00:00
|
|
|
fn new(name: &'a str, msg: &'a crate::Message) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
name,
|
|
|
|
msg,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_sink_message(s.name.to_glib_none().0, s.msg.as_mut_ptr())
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct StreamGroupDoneBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-12-05 19:32:16 +00:00
|
|
|
group_id: GroupId,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> StreamGroupDoneBuilder<'a> {
|
2017-12-05 19:32:16 +00:00
|
|
|
fn new(group_id: GroupId) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
group_id,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_stream_group_done(s.group_id.0.get())
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct EosBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> EosBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new() -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
event_builder_generic_impl!(|_| ffi::gst_event_new_eos());
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-08-08 20:37:48 +00:00
|
|
|
pub struct TocBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2020-11-21 13:46:48 +00:00
|
|
|
toc: &'a crate::Toc,
|
2017-07-30 14:06:44 +00:00
|
|
|
updated: bool,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-08-08 20:37:48 +00:00
|
|
|
impl<'a> TocBuilder<'a> {
|
2020-11-21 13:46:48 +00:00
|
|
|
fn new(toc: &'a crate::Toc, updated: bool) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
toc,
|
|
|
|
updated,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_toc(
|
2017-12-20 17:30:14 +00:00
|
|
|
s.toc.to_glib_none().0,
|
2021-04-27 15:15:46 +00:00
|
|
|
s.updated.into_glib()
|
2017-12-20 17:30:14 +00:00
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub struct ProtectionBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
system_id: &'a str,
|
2020-11-21 13:46:48 +00:00
|
|
|
data: &'a crate::Buffer,
|
2017-12-16 15:30:50 +00:00
|
|
|
origin: Option<&'a str>,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> ProtectionBuilder<'a> {
|
2020-11-21 13:46:48 +00:00
|
|
|
fn new(system_id: &'a str, data: &'a crate::Buffer) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
system_id,
|
|
|
|
data,
|
2017-12-16 15:30:50 +00:00
|
|
|
origin: None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn origin(self, origin: &'a str) -> Self {
|
|
|
|
Self {
|
|
|
|
origin: Some(origin),
|
|
|
|
..self
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
pub fn origin_if(self, origin: &'a str, predicate: bool) -> Self {
|
|
|
|
if predicate {
|
|
|
|
self.origin(origin)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-29 16:04:34 +00:00
|
|
|
pub fn origin_if_some(self, origin: Option<&'a str>) -> Self {
|
|
|
|
if let Some(origin) = origin {
|
|
|
|
self.origin(origin)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_protection(
|
|
|
|
s.system_id.to_glib_none().0,
|
|
|
|
s.data.as_mut_ptr(),
|
|
|
|
s.origin.to_glib_none().0,
|
|
|
|
)
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct SegmentDoneBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-12-09 16:20:21 +00:00
|
|
|
position: GenericFormattedValue,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> SegmentDoneBuilder<'a> {
|
2017-12-09 16:20:21 +00:00
|
|
|
fn new(position: GenericFormattedValue) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
position,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_segment_done(s.position.format().into_glib(), s.position.value())
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct GapBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2021-10-17 11:27:44 +00:00
|
|
|
timestamp: ClockTime,
|
|
|
|
duration: Option<ClockTime>,
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_20")]
|
2021-07-09 12:51:19 +00:00
|
|
|
gap_flags: Option<crate::GapFlags>,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> GapBuilder<'a> {
|
2021-10-17 11:27:44 +00:00
|
|
|
fn new(timestamp: ClockTime) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
timestamp,
|
2021-04-28 22:29:13 +00:00
|
|
|
duration: None,
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_20")]
|
2021-07-09 12:51:19 +00:00
|
|
|
gap_flags: None,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_20")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
|
2021-07-09 12:51:19 +00:00
|
|
|
pub fn gap_flags(mut self, flags: crate::GapFlags) -> Self {
|
|
|
|
self.gap_flags = Some(flags);
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
#[cfg(feature = "v1_20")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
|
|
|
|
pub fn gap_flags_if(self, flags: crate::GapFlags, predicate: bool) -> Self {
|
|
|
|
if predicate {
|
|
|
|
self.gap_flags(flags)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-29 16:04:34 +00:00
|
|
|
#[cfg(feature = "v1_20")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
|
|
|
|
pub fn gap_flags_if_some(self, flags: Option<crate::GapFlags>) -> Self {
|
|
|
|
if let Some(flags) = flags {
|
|
|
|
self.gap_flags(flags)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn duration(mut self, duration: impl Into<Option<ClockTime>>) -> Self {
|
2021-04-28 22:29:13 +00:00
|
|
|
self.duration = duration.into();
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
pub fn duration_if(self, duration: ClockTime, predicate: bool) -> Self {
|
|
|
|
if predicate {
|
|
|
|
self.duration(duration)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-17 12:38:56 +00:00
|
|
|
pub fn duration_if_some(self, duration: Option<ClockTime>) -> Self {
|
|
|
|
if let Some(duration) = duration {
|
|
|
|
self.duration(duration)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-09 12:51:19 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
#[allow(clippy::let_and_return)]
|
|
|
|
let ev = ffi::gst_event_new_gap(s.timestamp.into_glib(), s.duration.into_glib());
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_20")]
|
2021-07-09 12:51:19 +00:00
|
|
|
if let Some(ref flags) = s.gap_flags {
|
|
|
|
ffi::gst_event_set_gap_flags(ev, flags.into_glib());
|
|
|
|
}
|
|
|
|
|
|
|
|
ev
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2021-10-17 11:27:44 +00:00
|
|
|
pub struct InstantRateChangeBuilder<'a> {
|
|
|
|
builder: EventBuilder<'a>,
|
|
|
|
multiplier: f64,
|
|
|
|
new_flags: crate::SegmentFlags,
|
|
|
|
}
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_18")]
|
|
|
|
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
2021-10-17 11:27:44 +00:00
|
|
|
impl<'a> InstantRateChangeBuilder<'a> {
|
|
|
|
fn new(multiplier: f64, new_flags: crate::SegmentFlags) -> Self {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self {
|
|
|
|
builder: EventBuilder::new(),
|
|
|
|
multiplier,
|
|
|
|
new_flags,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_instant_rate_change(
|
|
|
|
s.multiplier,
|
|
|
|
s.new_flags.into_glib()
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct QosBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2020-11-21 13:46:48 +00:00
|
|
|
type_: crate::QOSType,
|
2017-07-30 14:06:44 +00:00
|
|
|
proportion: f64,
|
|
|
|
diff: i64,
|
2021-10-17 11:27:44 +00:00
|
|
|
timestamp: Option<ClockTime>,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> QosBuilder<'a> {
|
2021-04-28 22:29:13 +00:00
|
|
|
fn new(type_: crate::QOSType, proportion: f64, diff: i64) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
type_,
|
|
|
|
proportion,
|
|
|
|
diff,
|
2021-04-28 22:29:13 +00:00
|
|
|
timestamp: None,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn timestamp(mut self, timestamp: impl Into<Option<ClockTime>>) -> Self {
|
2021-04-28 22:29:13 +00:00
|
|
|
self.timestamp = timestamp.into();
|
|
|
|
self
|
|
|
|
}
|
2024-04-17 12:38:56 +00:00
|
|
|
|
2024-06-14 15:00:36 +00:00
|
|
|
pub fn timestamp_if(self, timestamp: ClockTime, predicate: bool) -> Self {
|
|
|
|
if predicate {
|
|
|
|
self.timestamp(timestamp)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-17 12:38:56 +00:00
|
|
|
pub fn timestamp_if_some(self, timestamp: Option<ClockTime>) -> Self {
|
|
|
|
if let Some(timestamp) = timestamp {
|
|
|
|
self.timestamp(timestamp)
|
|
|
|
} else {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
2021-04-28 22:29:13 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| ffi::gst_event_new_qos(
|
2021-04-27 15:15:46 +00:00
|
|
|
s.type_.into_glib(),
|
2017-12-20 17:30:14 +00:00
|
|
|
s.proportion,
|
|
|
|
s.diff,
|
2021-04-27 15:15:46 +00:00
|
|
|
s.timestamp.into_glib(),
|
2017-12-20 17:30:14 +00:00
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct SeekBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
rate: f64,
|
2020-11-21 13:46:48 +00:00
|
|
|
flags: crate::SeekFlags,
|
|
|
|
start_type: crate::SeekType,
|
2017-12-09 16:20:21 +00:00
|
|
|
start: GenericFormattedValue,
|
2020-11-21 13:46:48 +00:00
|
|
|
stop_type: crate::SeekType,
|
2017-12-09 16:20:21 +00:00
|
|
|
stop: GenericFormattedValue,
|
2019-04-23 16:53:10 +00:00
|
|
|
#[allow(unused)]
|
2021-10-17 11:27:44 +00:00
|
|
|
trickmode_interval: Option<ClockTime>,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> SeekBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(
|
2017-07-31 11:16:42 +00:00
|
|
|
rate: f64,
|
2020-11-21 13:46:48 +00:00
|
|
|
flags: crate::SeekFlags,
|
|
|
|
start_type: crate::SeekType,
|
2017-12-09 16:20:21 +00:00
|
|
|
start: GenericFormattedValue,
|
2020-11-21 13:46:48 +00:00
|
|
|
stop_type: crate::SeekType,
|
2017-12-09 16:20:21 +00:00
|
|
|
stop: GenericFormattedValue,
|
2017-07-31 11:16:42 +00:00
|
|
|
) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
rate,
|
|
|
|
flags,
|
2017-07-30 14:06:44 +00:00
|
|
|
start_type,
|
|
|
|
start,
|
|
|
|
stop_type,
|
|
|
|
stop,
|
2019-04-23 16:53:10 +00:00
|
|
|
trickmode_interval: None,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 11:27:44 +00:00
|
|
|
pub fn trickmode_interval(mut self, trickmode_interval: impl Into<Option<ClockTime>>) -> Self {
|
2021-04-28 22:29:13 +00:00
|
|
|
self.trickmode_interval = trickmode_interval.into();
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2019-04-23 16:53:10 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
2019-09-07 10:08:09 +00:00
|
|
|
#[allow(clippy::let_and_return)]
|
2019-04-23 16:53:10 +00:00
|
|
|
{
|
2020-11-21 13:46:48 +00:00
|
|
|
let ev = ffi::gst_event_new_seek(
|
2019-09-07 10:08:09 +00:00
|
|
|
s.rate,
|
2021-04-27 15:15:46 +00:00
|
|
|
s.start.format().into_glib(),
|
|
|
|
s.flags.into_glib(),
|
|
|
|
s.start_type.into_glib(),
|
2021-04-11 19:39:50 +00:00
|
|
|
s.start.value(),
|
2021-04-27 15:15:46 +00:00
|
|
|
s.stop_type.into_glib(),
|
2021-04-11 19:39:50 +00:00
|
|
|
s.stop.value(),
|
2019-09-07 10:08:09 +00:00
|
|
|
);
|
|
|
|
|
2023-05-04 05:55:48 +00:00
|
|
|
#[cfg(feature = "v1_16")]
|
2020-11-19 10:08:50 +00:00
|
|
|
if let Some(trickmode_interval) = s.trickmode_interval {
|
2021-04-27 15:15:46 +00:00
|
|
|
ffi::gst_event_set_seek_trickmode_interval(ev, trickmode_interval.into_glib());
|
2019-04-23 16:53:10 +00:00
|
|
|
}
|
|
|
|
|
2019-09-07 10:08:09 +00:00
|
|
|
ev
|
|
|
|
}
|
2019-04-23 16:53:10 +00:00
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct NavigationBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Option<Structure>,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> NavigationBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(structure: Structure) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Some(structure),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &mut Self| {
|
2020-03-09 10:55:14 +00:00
|
|
|
let structure = s.structure.take().unwrap();
|
2022-05-06 19:41:15 +00:00
|
|
|
ffi::gst_event_new_navigation(structure.into_glib_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct LatencyBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2021-10-17 11:27:44 +00:00
|
|
|
latency: ClockTime,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> LatencyBuilder<'a> {
|
2021-10-17 11:27:44 +00:00
|
|
|
fn new(latency: ClockTime) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
latency,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| { ffi::gst_event_new_latency(s.latency.into_glib()) });
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct StepBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-12-09 16:20:21 +00:00
|
|
|
amount: GenericFormattedValue,
|
2017-07-30 14:06:44 +00:00
|
|
|
rate: f64,
|
|
|
|
flush: bool,
|
|
|
|
intermediate: bool,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> StepBuilder<'a> {
|
2017-12-09 16:20:21 +00:00
|
|
|
fn new(amount: GenericFormattedValue, rate: f64, flush: bool, intermediate: bool) -> Self {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
amount,
|
|
|
|
rate,
|
|
|
|
flush,
|
|
|
|
intermediate,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_step(
|
|
|
|
s.amount.format().into_glib(),
|
|
|
|
s.amount.value() as u64,
|
|
|
|
s.rate,
|
|
|
|
s.flush.into_glib(),
|
|
|
|
s.intermediate.into_glib(),
|
|
|
|
)
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct ReconfigureBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> ReconfigureBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new() -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|_| { ffi::gst_event_new_reconfigure() });
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub struct TocSelectBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
uid: &'a str,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> TocSelectBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(uid: &'a str) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
uid,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
|
|
|
ffi::gst_event_new_toc_select(s.uid.to_glib_none().0)
|
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub struct SelectStreamsBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
streams: &'a [&'a str],
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> SelectStreamsBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(streams: &'a [&'a str]) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2018-07-20 07:21:06 +00:00
|
|
|
streams,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 09:48:21 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
2024-05-16 13:59:15 +00:00
|
|
|
ffi::gst_event_new_select_streams(s.streams.to_glib_none().0)
|
2021-10-17 09:48:21 +00:00
|
|
|
});
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct CustomUpstreamBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Option<Structure>,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> CustomUpstreamBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(structure: Structure) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Some(structure),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &mut Self| {
|
2020-03-09 10:55:14 +00:00
|
|
|
let structure = s.structure.take().unwrap();
|
2022-05-06 19:41:15 +00:00
|
|
|
ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_UPSTREAM, structure.into_glib_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct CustomDownstreamBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Option<Structure>,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> CustomDownstreamBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(structure: Structure) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Some(structure),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &mut Self| {
|
2020-03-09 10:55:14 +00:00
|
|
|
let structure = s.structure.take().unwrap();
|
2022-05-06 19:41:15 +00:00
|
|
|
ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM, structure.into_glib_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct CustomDownstreamOobBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Option<Structure>,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> CustomDownstreamOobBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(structure: Structure) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Some(structure),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &mut Self| {
|
2020-03-09 10:55:14 +00:00
|
|
|
let structure = s.structure.take().unwrap();
|
2022-05-06 19:41:15 +00:00
|
|
|
ffi::gst_event_new_custom(
|
|
|
|
ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB,
|
|
|
|
structure.into_glib_ptr(),
|
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct CustomDownstreamStickyBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Option<Structure>,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> CustomDownstreamStickyBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(structure: Structure) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Some(structure),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &mut Self| {
|
2020-03-09 10:55:14 +00:00
|
|
|
let structure = s.structure.take().unwrap();
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_event_new_custom(
|
|
|
|
ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY,
|
2022-05-06 19:41:15 +00:00
|
|
|
structure.into_glib_ptr(),
|
2020-03-09 10:55:14 +00:00
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct CustomBothBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Option<Structure>,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> CustomBothBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(structure: Structure) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Some(structure),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &mut Self| {
|
2020-03-09 10:55:14 +00:00
|
|
|
let structure = s.structure.take().unwrap();
|
2022-05-06 19:41:15 +00:00
|
|
|
ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH, structure.into_glib_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-03 23:17:29 +00:00
|
|
|
#[must_use = "The builder must be built to be used"]
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct CustomBothOobBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Option<Structure>,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> CustomBothOobBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(structure: Structure) -> Self {
|
|
|
|
skip_assert_initialized!();
|
2017-07-30 14:06:44 +00:00
|
|
|
Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder::new(),
|
2017-07-30 14:06:44 +00:00
|
|
|
structure: Some(structure),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &mut Self| {
|
2020-03-09 10:55:14 +00:00
|
|
|
let structure = s.structure.take().unwrap();
|
2022-05-06 19:41:15 +00:00
|
|
|
ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH_OOB, structure.into_glib_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
2018-01-29 10:58:25 +00:00
|
|
|
|
2018-01-27 11:52:03 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
2023-12-31 13:49:42 +00:00
|
|
|
#[allow(deprecated)]
|
2018-01-27 11:52:03 +00:00
|
|
|
fn test_simple() {
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::init().unwrap();
|
2018-01-27 11:52:03 +00:00
|
|
|
|
|
|
|
// Event without arguments
|
2020-06-23 15:52:51 +00:00
|
|
|
let flush_start_evt = FlushStart::new();
|
2018-01-27 11:52:03 +00:00
|
|
|
match flush_start_evt.view() {
|
|
|
|
EventView::FlushStart(flush_start_evt) => {
|
2018-01-29 10:31:12 +00:00
|
|
|
assert!(!flush_start_evt.is_sticky());
|
2021-04-11 19:39:50 +00:00
|
|
|
assert!(flush_start_evt.structure().is_none());
|
2018-02-22 10:18:37 +00:00
|
|
|
}
|
2018-01-27 11:52:03 +00:00
|
|
|
_ => panic!("flush_start_evt.view() is not an EventView::FlushStart(_)"),
|
|
|
|
}
|
|
|
|
|
2020-06-23 15:52:51 +00:00
|
|
|
let flush_start_evt = FlushStart::builder()
|
2018-01-27 11:52:03 +00:00
|
|
|
.other_fields(&[("extra-field", &true)])
|
|
|
|
.build();
|
|
|
|
match flush_start_evt.view() {
|
|
|
|
EventView::FlushStart(flush_start_evt) => {
|
2021-04-11 19:39:50 +00:00
|
|
|
assert!(flush_start_evt.structure().is_some());
|
|
|
|
if let Some(other_fields) = flush_start_evt.structure() {
|
2018-01-27 11:52:03 +00:00
|
|
|
assert!(other_fields.has_field("extra-field"));
|
|
|
|
}
|
2018-02-22 10:18:37 +00:00
|
|
|
}
|
2018-01-27 11:52:03 +00:00
|
|
|
_ => panic!("flush_start_evt.view() is not an EventView::FlushStart(_)"),
|
|
|
|
}
|
|
|
|
|
|
|
|
// Event with arguments
|
2020-06-23 15:52:51 +00:00
|
|
|
let flush_stop_evt = FlushStop::builder(true)
|
2023-12-31 13:49:42 +00:00
|
|
|
.other_field("extra-field", true)
|
2018-01-27 11:52:03 +00:00
|
|
|
.build();
|
|
|
|
match flush_stop_evt.view() {
|
|
|
|
EventView::FlushStop(flush_stop_evt) => {
|
2021-06-20 07:03:46 +00:00
|
|
|
assert!(flush_stop_evt.resets_time());
|
2021-04-11 19:39:50 +00:00
|
|
|
assert!(flush_stop_evt.structure().is_some());
|
|
|
|
if let Some(other_fields) = flush_stop_evt.structure() {
|
2018-01-27 11:52:03 +00:00
|
|
|
assert!(other_fields.has_field("extra-field"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => panic!("flush_stop_evt.view() is not an EventView::FlushStop(_)"),
|
|
|
|
}
|
|
|
|
}
|
2020-11-19 20:10:13 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_get_structure_mut() {
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::init().unwrap();
|
2020-11-19 20:10:13 +00:00
|
|
|
|
|
|
|
let mut flush_start_evt = FlushStart::new();
|
|
|
|
|
|
|
|
{
|
|
|
|
let flush_start_evt = flush_start_evt.get_mut().unwrap();
|
|
|
|
let structure = flush_start_evt.structure_mut();
|
2022-11-01 09:10:57 +00:00
|
|
|
structure.set("test", 42u32);
|
2020-11-19 20:10:13 +00:00
|
|
|
}
|
|
|
|
|
2021-04-11 19:39:50 +00:00
|
|
|
let structure = flush_start_evt.structure().unwrap();
|
2021-04-20 07:19:02 +00:00
|
|
|
assert_eq!(structure.get("test"), Ok(42u32));
|
2020-11-19 20:10:13 +00:00
|
|
|
}
|
2022-01-18 09:57:22 +00:00
|
|
|
|
|
|
|
#[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);
|
|
|
|
}
|
2024-05-16 13:59:15 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_select_streams() {
|
|
|
|
crate::init().unwrap();
|
|
|
|
|
|
|
|
let s = ["foo", "bar"].to_vec();
|
|
|
|
let event = crate::event::SelectStreams::new(&s);
|
|
|
|
let streams = match event.view() {
|
|
|
|
EventView::SelectStreams(streams) => streams.streams(),
|
|
|
|
_ => unreachable!(),
|
|
|
|
};
|
|
|
|
assert_eq!(streams, s);
|
|
|
|
}
|
2018-01-27 11:52:03 +00:00
|
|
|
}
|