2017-07-30 14:06:44 +00:00
|
|
|
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
use gst_sys;
|
2017-07-30 14:06:44 +00:00
|
|
|
use structure::*;
|
2018-04-25 08:10:06 +00:00
|
|
|
use GenericFormattedValue;
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2017-11-29 16:55:56 +00:00
|
|
|
use std::cmp;
|
2017-07-30 14:06:44 +00:00
|
|
|
use std::ffi::CStr;
|
2018-04-01 08:30:03 +00:00
|
|
|
use std::fmt;
|
|
|
|
use std::mem;
|
2020-01-24 15:46:18 +00:00
|
|
|
use std::num::NonZeroU32;
|
2018-01-29 10:31:12 +00:00
|
|
|
use std::ops::Deref;
|
2018-04-01 08:30:03 +00:00
|
|
|
use std::ptr;
|
2017-07-30 14:06:44 +00:00
|
|
|
|
|
|
|
use glib;
|
2020-01-24 15:46:18 +00:00
|
|
|
use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr};
|
2018-04-01 08:30:03 +00:00
|
|
|
use glib::value::ToSendValue;
|
2017-08-02 17:09:00 +00:00
|
|
|
|
2017-11-12 12:33:02 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2017-08-02 17:09:00 +00:00
|
|
|
use glib::translate::FromGlibPtrContainer;
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2017-11-29 16:55:56 +00:00
|
|
|
use EventType;
|
|
|
|
|
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 {
|
|
|
|
pub fn next() -> Self {
|
|
|
|
unsafe {
|
|
|
|
let v = gst_sys::gst_util_seqnum_next();
|
|
|
|
if v == 0 {
|
|
|
|
Seqnum::next()
|
|
|
|
} else {
|
|
|
|
Seqnum(NonZeroU32::new_unchecked(v))
|
|
|
|
}
|
|
|
|
}
|
2017-12-05 19:32:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-24 15:46:18 +00:00
|
|
|
impl ToGlib for Seqnum {
|
|
|
|
type GlibType = u32;
|
2017-12-05 19:32:16 +00:00
|
|
|
|
2020-01-24 15:46:18 +00:00
|
|
|
fn to_glib(&self) -> u32 {
|
|
|
|
self.0.get()
|
2017-12-05 19:32:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-06 08:25:07 +00:00
|
|
|
impl cmp::PartialOrd for Seqnum {
|
|
|
|
fn partial_cmp(&self, other: &Seqnum) -> Option<cmp::Ordering> {
|
|
|
|
Some(self.cmp(other))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl cmp::Ord for Seqnum {
|
|
|
|
fn cmp(&self, other: &Seqnum) -> cmp::Ordering {
|
|
|
|
unsafe {
|
2020-01-24 15:46:18 +00:00
|
|
|
let ret = gst_sys::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 {
|
|
|
|
pub fn next() -> Self {
|
|
|
|
unsafe {
|
|
|
|
let v = gst_sys::gst_util_group_id_next();
|
|
|
|
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 {
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn is_upstream(self) -> bool {
|
2019-03-19 07:58:20 +00:00
|
|
|
(self.to_glib() as u32) & gst_sys::GST_EVENT_TYPE_UPSTREAM != 0
|
2017-11-29 16:55:56 +00:00
|
|
|
}
|
|
|
|
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn is_downstream(self) -> bool {
|
2019-03-19 07:58:20 +00:00
|
|
|
(self.to_glib() as u32) & gst_sys::GST_EVENT_TYPE_DOWNSTREAM != 0
|
2017-11-29 16:55:56 +00:00
|
|
|
}
|
|
|
|
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn is_serialized(self) -> bool {
|
2019-03-19 07:58:20 +00:00
|
|
|
(self.to_glib() as u32) & gst_sys::GST_EVENT_TYPE_SERIALIZED != 0
|
2017-11-29 16:55:56 +00:00
|
|
|
}
|
|
|
|
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn is_sticky(self) -> bool {
|
2019-03-19 07:58:20 +00:00
|
|
|
(self.to_glib() as u32) & gst_sys::GST_EVENT_TYPE_STICKY != 0
|
2017-11-29 16:55:56 +00:00
|
|
|
}
|
|
|
|
|
2018-07-20 07:21:06 +00:00
|
|
|
pub fn is_sticky_multi(self) -> bool {
|
2019-03-19 07:58:20 +00:00
|
|
|
(self.to_glib() as u32) & gst_sys::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;
|
|
|
|
}
|
|
|
|
|
|
|
|
let v1 = self.to_glib() as u32;
|
|
|
|
let v2 = other.to_glib() as u32;
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
let stream_start = gst_sys::GST_EVENT_STREAM_START as u32;
|
|
|
|
let segment = gst_sys::GST_EVENT_SEGMENT as u32;
|
|
|
|
let eos = gst_sys::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-06-29 21:12:46 +00:00
|
|
|
gst_define_mini_object_wrapper!(Event, EventRef, gst_sys::GstEvent, || {
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_get_type()
|
2018-09-28 15:11:46 +00:00
|
|
|
});
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl EventRef {
|
2017-12-05 19:32:16 +00:00
|
|
|
pub fn get_seqnum(&self) -> Seqnum {
|
2020-01-24 15:46:18 +00:00
|
|
|
unsafe {
|
|
|
|
let seqnum = gst_sys::gst_event_get_seqnum(self.as_mut_ptr());
|
|
|
|
assert_ne!(seqnum, 0);
|
|
|
|
Seqnum(NonZeroU32::new_unchecked(seqnum))
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_running_time_offset(&self) -> i64 {
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe { gst_sys::gst_event_get_running_time_offset(self.as_mut_ptr()) }
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2017-12-03 15:13:46 +00:00
|
|
|
pub fn set_running_time_offset(&mut self, offset: i64) {
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe { gst_sys::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
|
|
|
|
2017-12-01 09:21:20 +00:00
|
|
|
pub fn get_structure(&self) -> Option<&StructureRef> {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
2019-03-19 07:58:20 +00:00
|
|
|
let structure = gst_sys::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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_upstream(&self) -> bool {
|
2017-11-29 16:55:56 +00:00
|
|
|
self.get_type().is_upstream()
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_downstream(&self) -> bool {
|
2017-11-29 16:55:56 +00:00
|
|
|
self.get_type().is_downstream()
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_serialized(&self) -> bool {
|
2017-11-29 16:55:56 +00:00
|
|
|
self.get_type().is_serialized()
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_sticky(&self) -> bool {
|
2017-11-29 16:55:56 +00:00
|
|
|
self.get_type().is_sticky()
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_sticky_multi(&self) -> bool {
|
2017-11-29 16:55:56 +00:00
|
|
|
self.get_type().is_sticky_multi()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_type(&self) -> EventType {
|
|
|
|
unsafe { from_glib((*self.as_ptr()).type_) }
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn view(&self) -> EventView {
|
|
|
|
let type_ = unsafe { (*self.as_ptr()).type_ };
|
|
|
|
|
2017-09-10 11:54:43 +00:00
|
|
|
match type_ {
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::GST_EVENT_FLUSH_START => EventView::FlushStart(FlushStart(self)),
|
|
|
|
gst_sys::GST_EVENT_FLUSH_STOP => EventView::FlushStop(FlushStop(self)),
|
|
|
|
gst_sys::GST_EVENT_STREAM_START => EventView::StreamStart(StreamStart(self)),
|
|
|
|
gst_sys::GST_EVENT_CAPS => EventView::Caps(Caps(self)),
|
|
|
|
gst_sys::GST_EVENT_SEGMENT => EventView::Segment(Segment(self)),
|
|
|
|
gst_sys::GST_EVENT_STREAM_COLLECTION => {
|
|
|
|
EventView::StreamCollection(StreamCollection(self))
|
|
|
|
}
|
|
|
|
gst_sys::GST_EVENT_TAG => EventView::Tag(Tag(self)),
|
|
|
|
gst_sys::GST_EVENT_BUFFERSIZE => EventView::BufferSize(BufferSize(self)),
|
|
|
|
gst_sys::GST_EVENT_SINK_MESSAGE => EventView::SinkMessage(SinkMessage(self)),
|
|
|
|
gst_sys::GST_EVENT_STREAM_GROUP_DONE => {
|
|
|
|
EventView::StreamGroupDone(StreamGroupDone(self))
|
|
|
|
}
|
|
|
|
gst_sys::GST_EVENT_EOS => EventView::Eos(Eos(self)),
|
|
|
|
gst_sys::GST_EVENT_TOC => EventView::Toc(Toc(self)),
|
|
|
|
gst_sys::GST_EVENT_PROTECTION => EventView::Protection(Protection(self)),
|
|
|
|
gst_sys::GST_EVENT_SEGMENT_DONE => EventView::SegmentDone(SegmentDone(self)),
|
|
|
|
gst_sys::GST_EVENT_GAP => EventView::Gap(Gap(self)),
|
|
|
|
gst_sys::GST_EVENT_QOS => EventView::Qos(Qos(self)),
|
|
|
|
gst_sys::GST_EVENT_SEEK => EventView::Seek(Seek(self)),
|
|
|
|
gst_sys::GST_EVENT_NAVIGATION => EventView::Navigation(Navigation(self)),
|
|
|
|
gst_sys::GST_EVENT_LATENCY => EventView::Latency(Latency(self)),
|
|
|
|
gst_sys::GST_EVENT_STEP => EventView::Step(Step(self)),
|
|
|
|
gst_sys::GST_EVENT_RECONFIGURE => EventView::Reconfigure(Reconfigure(self)),
|
|
|
|
gst_sys::GST_EVENT_TOC_SELECT => EventView::TocSelect(TocSelect(self)),
|
|
|
|
gst_sys::GST_EVENT_SELECT_STREAMS => EventView::SelectStreams(SelectStreams(self)),
|
|
|
|
gst_sys::GST_EVENT_CUSTOM_UPSTREAM => EventView::CustomUpstream(CustomUpstream(self)),
|
|
|
|
gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM => {
|
|
|
|
EventView::CustomDownstream(CustomDownstream(self))
|
|
|
|
}
|
|
|
|
gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM_OOB => {
|
2017-09-10 11:54:43 +00:00
|
|
|
EventView::CustomDownstreamOob(CustomDownstreamOob(self))
|
|
|
|
}
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY => {
|
2017-09-10 11:54:43 +00:00
|
|
|
EventView::CustomDownstreamSticky(CustomDownstreamSticky(self))
|
|
|
|
}
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::GST_EVENT_CUSTOM_BOTH => EventView::CustomBoth(CustomBoth(self)),
|
|
|
|
gst_sys::GST_EVENT_CUSTOM_BOTH_OOB => EventView::CustomBothOob(CustomBothOob(self)),
|
2017-09-10 11:54:43 +00:00
|
|
|
_ => EventView::Other,
|
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")
|
2018-07-27 10:36:40 +00:00
|
|
|
.field("ptr", unsafe { &self.as_ptr() })
|
2017-12-01 17:02:53 +00:00
|
|
|
.field("type", &unsafe {
|
2019-03-19 07:58:20 +00:00
|
|
|
let type_ = gst_sys::gst_event_type_get_name((*self.as_ptr()).type_);
|
2017-12-01 09:21:20 +00:00
|
|
|
CStr::from_ptr(type_).to_str().unwrap()
|
2018-10-08 12:02:23 +00:00
|
|
|
})
|
|
|
|
.field("seqnum", &self.get_seqnum())
|
2017-12-01 09:21:20 +00:00
|
|
|
.field("structure", &self.get_structure())
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-22 14:55:59 +00:00
|
|
|
#[derive(Debug)]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub enum EventView<'a> {
|
|
|
|
FlushStart(FlushStart<'a>),
|
|
|
|
FlushStop(FlushStop<'a>),
|
|
|
|
StreamStart(StreamStart<'a>),
|
|
|
|
Caps(Caps<'a>),
|
|
|
|
Segment(Segment<'a>),
|
|
|
|
StreamCollection(StreamCollection<'a>),
|
|
|
|
Tag(Tag<'a>),
|
|
|
|
BufferSize(BufferSize<'a>),
|
|
|
|
SinkMessage(SinkMessage<'a>),
|
|
|
|
StreamGroupDone(StreamGroupDone<'a>),
|
|
|
|
Eos(Eos<'a>),
|
|
|
|
Toc(Toc<'a>),
|
|
|
|
Protection(Protection<'a>),
|
|
|
|
SegmentDone(SegmentDone<'a>),
|
|
|
|
Gap(Gap<'a>),
|
|
|
|
Qos(Qos<'a>),
|
|
|
|
Seek(Seek<'a>),
|
|
|
|
Navigation(Navigation<'a>),
|
|
|
|
Latency(Latency<'a>),
|
|
|
|
Step(Step<'a>),
|
|
|
|
Reconfigure(Reconfigure<'a>),
|
|
|
|
TocSelect(TocSelect<'a>),
|
|
|
|
SelectStreams(SelectStreams<'a>),
|
|
|
|
CustomUpstream(CustomUpstream<'a>),
|
|
|
|
CustomDownstream(CustomDownstream<'a>),
|
|
|
|
CustomDownstreamOob(CustomDownstreamOob<'a>),
|
|
|
|
CustomDownstreamSticky(CustomDownstreamSticky<'a>),
|
|
|
|
CustomBoth(CustomBoth<'a>),
|
|
|
|
CustomBothOob(CustomBothOob<'a>),
|
|
|
|
Other,
|
|
|
|
__NonExhaustive,
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
macro_rules! declare_concrete_event(
|
|
|
|
($name:ident) => {
|
2019-01-22 14:55:59 +00:00
|
|
|
#[derive(Debug)]
|
2018-01-29 10:31:12 +00:00
|
|
|
pub struct $name<'a>(&'a EventRef);
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
impl<'a> Deref for $name<'a> {
|
|
|
|
type Target = EventRef;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
declare_concrete_event!(FlushStart);
|
2020-06-23 15:52:51 +00:00
|
|
|
impl<'a> FlushStart<'a> {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new() -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder().build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder() -> FlushStartBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
FlushStartBuilder::new()
|
|
|
|
}
|
|
|
|
}
|
2018-01-29 10:31:12 +00:00
|
|
|
|
|
|
|
declare_concrete_event!(FlushStop);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> FlushStop<'a> {
|
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()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(reset_time: bool) -> FlushStopBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
FlushStopBuilder::new(reset_time)
|
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn get_reset_time(&self) -> bool {
|
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut reset_time = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
gst_sys::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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(StreamStart);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> StreamStart<'a> {
|
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)
|
|
|
|
}
|
|
|
|
|
2017-12-16 15:30:50 +00:00
|
|
|
pub fn get_stream_id(&self) -> &'a str {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
|
|
|
let mut stream_id = ptr::null();
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_stream_flags(&self) -> ::StreamFlags {
|
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut stream_flags = mem::MaybeUninit::uninit();
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
gst_sys::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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-24 15:46:18 +00:00
|
|
|
pub fn get_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
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
gst_sys::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
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2020-05-17 10:32:33 +00:00
|
|
|
pub fn get_stream(&self) -> Option<::Stream> {
|
|
|
|
unsafe {
|
|
|
|
let mut stream = ptr::null_mut();
|
|
|
|
gst_sys::gst_event_parse_stream(self.as_mut_ptr(), &mut stream);
|
|
|
|
from_glib_full(stream)
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Caps);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> Caps<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(caps: &::Caps) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(caps).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(caps: &::Caps) -> CapsBuilder {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CapsBuilder::new(caps)
|
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn get_caps(&self) -> &'a ::CapsRef {
|
|
|
|
unsafe {
|
|
|
|
let mut caps = ptr::null_mut();
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_parse_caps(self.as_mut_ptr(), &mut caps);
|
2017-07-30 14:06:44 +00:00
|
|
|
::CapsRef::from_ptr(caps)
|
|
|
|
}
|
|
|
|
}
|
2019-05-23 11:28:09 +00:00
|
|
|
|
|
|
|
pub fn get_caps_owned(&self) -> ::Caps {
|
|
|
|
unsafe { from_glib_none(self.get_caps().as_ptr()) }
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Segment);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> Segment<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new<F: ::FormattedValue>(segment: &::FormattedSegment<F>) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(segment).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder<F: ::FormattedValue>(segment: &::FormattedSegment<F>) -> SegmentBuilder {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
SegmentBuilder::new(segment.as_ref())
|
|
|
|
}
|
|
|
|
|
2017-12-16 15:30:50 +00:00
|
|
|
pub fn get_segment(&self) -> &'a ::Segment {
|
2017-07-30 14:06:44 +00:00
|
|
|
unsafe {
|
|
|
|
let mut segment = ptr::null();
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_parse_segment(self.as_mut_ptr(), &mut segment);
|
|
|
|
&*(segment as *mut gst_sys::GstSegment as *mut ::Segment)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(StreamCollection);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> StreamCollection<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(stream_collection: &::StreamCollection) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(stream_collection).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2020-06-23 15:52:51 +00:00
|
|
|
pub fn builder(stream_collection: &::StreamCollection) -> StreamCollectionBuilder {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
StreamCollectionBuilder::new(stream_collection)
|
|
|
|
}
|
|
|
|
|
2017-11-12 12:33:02 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn get_stream_collection(&self) -> ::StreamCollection {
|
|
|
|
unsafe {
|
|
|
|
let mut stream_collection = ptr::null_mut();
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Tag);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> Tag<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(tags: ::TagList) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(tags).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(tags: ::TagList) -> TagBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
TagBuilder::new(tags)
|
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn get_tag(&self) -> &'a ::TagListRef {
|
|
|
|
unsafe {
|
|
|
|
let mut tags = ptr::null_mut();
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_parse_tag(self.as_mut_ptr(), &mut tags);
|
2017-07-30 14:06:44 +00:00
|
|
|
::TagListRef::from_ptr(tags)
|
|
|
|
}
|
|
|
|
}
|
2019-05-23 11:28:09 +00:00
|
|
|
|
|
|
|
pub fn get_tag_owned(&self) -> ::TagList {
|
|
|
|
unsafe { from_glib_none(self.get_tag().as_ptr()) }
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(BufferSize);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> BufferSize<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new<V: Into<GenericFormattedValue>>(minsize: V, maxsize: V, async: bool) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(minsize, maxsize, async).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder<V: Into<GenericFormattedValue>>(
|
|
|
|
minsize: V,
|
|
|
|
maxsize: V,
|
|
|
|
async: bool,
|
|
|
|
) -> BufferSizeBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let minsize = minsize.into();
|
|
|
|
let maxsize = maxsize.into();
|
|
|
|
assert_eq!(minsize.get_format(), maxsize.get_format());
|
|
|
|
|
|
|
|
BufferSizeBuilder::new(minsize, maxsize, async)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_parse_buffer_size(
|
2018-01-29 10:31:12 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(SinkMessage);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> SinkMessage<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(name: &'a str, msg: &'a ::Message) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(name, msg).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(name: &'a str, msg: &'a ::Message) -> SinkMessageBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
SinkMessageBuilder::new(name, msg)
|
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn get_message(&self) -> ::Message {
|
|
|
|
unsafe {
|
|
|
|
let mut msg = ptr::null_mut();
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_parse_sink_message(self.as_mut_ptr(), &mut msg);
|
2017-07-30 14:06:44 +00:00
|
|
|
from_glib_full(msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(StreamGroupDone);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> StreamGroupDone<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
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()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2020-06-23 15:52:51 +00:00
|
|
|
pub fn builder(group_id: GroupId) -> StreamGroupDoneBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
StreamGroupDoneBuilder::new(group_id)
|
|
|
|
}
|
|
|
|
|
2017-11-12 12:33:02 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2017-12-05 19:32:16 +00:00
|
|
|
pub fn get_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
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
gst_sys::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();
|
|
|
|
assert_ne!(group_id, 0);
|
|
|
|
GroupId(NonZeroU32::new_unchecked(group_id))
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Eos);
|
2020-06-23 15:52:51 +00:00
|
|
|
impl<'a> Eos<'a> {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new() -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder().build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder() -> EosBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
EosBuilder::new()
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Toc);
|
2017-08-08 20:37:48 +00:00
|
|
|
impl<'a> Toc<'a> {
|
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
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(toc: &::Toc, updated: bool) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(toc, updated).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(toc: &::Toc, updated: bool) -> TocBuilder {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
TocBuilder::new(toc, updated)
|
|
|
|
}
|
|
|
|
|
2017-08-08 20:37:48 +00:00
|
|
|
pub fn get_toc(&self) -> (&'a ::TocRef, bool) {
|
|
|
|
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
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
gst_sys::gst_event_parse_toc(self.as_mut_ptr(), &mut toc, updated.as_mut_ptr());
|
|
|
|
(::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
|
|
|
|
|
|
|
pub fn get_toc_owned(&self) -> (::Toc, bool) {
|
|
|
|
unsafe {
|
|
|
|
let (toc, updated) = self.get_toc();
|
|
|
|
(from_glib_none(toc.as_ptr()), updated)
|
|
|
|
}
|
|
|
|
}
|
2017-08-08 20:37:48 +00:00
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Protection);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> Protection<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(system_id: &'a str, data: &'a ::Buffer) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(system_id, data).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(system_id: &'a str, data: &'a ::Buffer) -> ProtectionBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
ProtectionBuilder::new(system_id, data)
|
|
|
|
}
|
|
|
|
|
2017-12-16 15:30:50 +00:00
|
|
|
pub fn get(&self) -> (&'a str, &'a ::BufferRef, Option<&'a 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();
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_parse_protection(
|
2018-01-29 10:31:12 +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(),
|
|
|
|
::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
|
|
|
|
|
|
|
pub fn get_owned(&self) -> (&'a str, ::Buffer, Option<&'a str>) {
|
|
|
|
unsafe {
|
|
|
|
let (system_id, buffer, origin) = self.get();
|
|
|
|
(system_id, from_glib_none(buffer.as_ptr()), origin)
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(SegmentDone);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> SegmentDone<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new<V: Into<GenericFormattedValue>>(position: V) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(position).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder<V: Into<GenericFormattedValue>>(position: V) -> SegmentDoneBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let position = position.into();
|
|
|
|
SegmentDoneBuilder::new(position)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
gst_sys::gst_event_parse_segment_done(
|
|
|
|
self.as_mut_ptr(),
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Gap);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> Gap<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(timestamp: ::ClockTime, duration: ::ClockTime) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(timestamp, duration).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(timestamp: ::ClockTime, duration: ::ClockTime) -> GapBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
GapBuilder::new(timestamp, duration)
|
|
|
|
}
|
|
|
|
|
2017-12-05 19:36:56 +00:00
|
|
|
pub fn get(&self) -> (::ClockTime, ::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
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
gst_sys::gst_event_parse_gap(
|
|
|
|
self.as_mut_ptr(),
|
|
|
|
timestamp.as_mut_ptr(),
|
|
|
|
duration.as_mut_ptr(),
|
|
|
|
);
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
(
|
|
|
|
from_glib(timestamp.assume_init()),
|
|
|
|
from_glib(duration.assume_init()),
|
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Qos);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> Qos<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(type_: ::QOSType, proportion: f64, diff: i64, timestamp: ::ClockTime) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(type_, proportion, diff, timestamp).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(
|
|
|
|
type_: ::QOSType,
|
|
|
|
proportion: f64,
|
|
|
|
diff: i64,
|
|
|
|
timestamp: ::ClockTime,
|
|
|
|
) -> QosBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
QosBuilder::new(type_, proportion, diff, timestamp)
|
|
|
|
}
|
|
|
|
|
2017-12-05 20:43:37 +00:00
|
|
|
pub fn get(&self) -> (::QOSType, f64, i64, ::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
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_parse_qos(
|
2018-01-29 10:31:12 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Seek);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> Seek<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new<V: Into<GenericFormattedValue>>(
|
|
|
|
rate: f64,
|
|
|
|
flags: ::SeekFlags,
|
|
|
|
start_type: ::SeekType,
|
|
|
|
start: V,
|
|
|
|
stop_type: ::SeekType,
|
|
|
|
stop: V,
|
|
|
|
) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(rate, flags, start_type, start, stop_type, stop).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder<V: Into<GenericFormattedValue>>(
|
|
|
|
rate: f64,
|
|
|
|
flags: ::SeekFlags,
|
|
|
|
start_type: ::SeekType,
|
|
|
|
start: V,
|
|
|
|
stop_type: ::SeekType,
|
|
|
|
stop: V,
|
|
|
|
) -> SeekBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let start = start.into();
|
|
|
|
let stop = stop.into();
|
|
|
|
assert_eq!(start.get_format(), stop.get_format());
|
|
|
|
|
|
|
|
SeekBuilder::new(rate, flags, start_type, start, stop_type, stop)
|
|
|
|
}
|
|
|
|
|
2017-11-11 10:21:55 +00:00
|
|
|
pub fn get(
|
|
|
|
&self,
|
|
|
|
) -> (
|
|
|
|
f64,
|
|
|
|
::SeekFlags,
|
|
|
|
::SeekType,
|
2017-12-09 16:20:21 +00:00
|
|
|
GenericFormattedValue,
|
2017-11-11 10:21:55 +00:00
|
|
|
::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
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_parse_seek(
|
2018-01-29 10:31:12 +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
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2019-04-23 16:53:10 +00:00
|
|
|
pub fn get_trickmode_interval(&self) -> ::ClockTime {
|
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut trickmode_interval = mem::MaybeUninit::uninit();
|
2019-04-23 16:53:10 +00:00
|
|
|
|
|
|
|
gst_sys::gst_event_parse_seek_trickmode_interval(
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Navigation);
|
2020-06-23 15:52:51 +00:00
|
|
|
impl<'a> Navigation<'a> {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(structure: ::Structure) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(structure: ::Structure) -> NavigationBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
NavigationBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Latency);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> Latency<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(latency: ::ClockTime) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(latency).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(latency: ::ClockTime) -> LatencyBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
LatencyBuilder::new(latency)
|
|
|
|
}
|
|
|
|
|
2017-12-05 20:43:37 +00:00
|
|
|
pub fn get_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
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
gst_sys::gst_event_parse_latency(self.as_mut_ptr(), latency.as_mut_ptr());
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(latency.assume_init())
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Step);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> Step<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new<V: Into<GenericFormattedValue>>(
|
|
|
|
amount: V,
|
|
|
|
rate: f64,
|
|
|
|
flush: bool,
|
|
|
|
intermediate: bool,
|
|
|
|
) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(amount.into(), rate, flush, intermediate).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder<V: Into<GenericFormattedValue>>(
|
|
|
|
amount: V,
|
|
|
|
rate: f64,
|
|
|
|
flush: bool,
|
|
|
|
intermediate: bool,
|
|
|
|
) -> StepBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
StepBuilder::new(amount.into(), rate, flush, intermediate)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_parse_step(
|
2018-01-29 10:31:12 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(Reconfigure);
|
2020-06-23 15:52:51 +00:00
|
|
|
impl<'a> Reconfigure<'a> {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new() -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder().build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder() -> ReconfigureBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
ReconfigureBuilder::new()
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(TocSelect);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> TocSelect<'a> {
|
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)
|
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn get_uid(&self) -> &'a str {
|
|
|
|
unsafe {
|
|
|
|
let mut uid = ptr::null_mut();
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(SelectStreams);
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> SelectStreams<'a> {
|
2020-06-23 15:52:51 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2020-06-23 15:52:51 +00:00
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(streams: &'a [&'a str]) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(streams).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2020-06-23 15:52:51 +00:00
|
|
|
pub fn builder(streams: &'a [&'a str]) -> SelectStreamsBuilder {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
SelectStreamsBuilder::new(streams)
|
|
|
|
}
|
|
|
|
|
2017-11-12 12:33:02 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn get_streams(&self) -> Vec<String> {
|
|
|
|
unsafe {
|
|
|
|
let mut streams = ptr::null_mut();
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(CustomUpstream);
|
2020-06-23 15:52:51 +00:00
|
|
|
impl<'a> CustomUpstream<'a> {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(structure: ::Structure) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(structure: ::Structure) -> CustomUpstreamBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomUpstreamBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(CustomDownstream);
|
2020-06-23 15:52:51 +00:00
|
|
|
impl<'a> CustomDownstream<'a> {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(structure: ::Structure) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(structure: ::Structure) -> CustomDownstreamBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomDownstreamBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(CustomDownstreamOob);
|
2020-06-23 15:52:51 +00:00
|
|
|
impl<'a> CustomDownstreamOob<'a> {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(structure: ::Structure) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(structure: ::Structure) -> CustomDownstreamOobBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomDownstreamOobBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(CustomDownstreamSticky);
|
2020-06-23 15:52:51 +00:00
|
|
|
impl<'a> CustomDownstreamSticky<'a> {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(structure: ::Structure) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(structure: ::Structure) -> CustomDownstreamStickyBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomDownstreamStickyBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(CustomBoth);
|
2020-06-23 15:52:51 +00:00
|
|
|
impl<'a> CustomBoth<'a> {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(structure: ::Structure) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(structure: ::Structure) -> CustomBothBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomBothBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_event!(CustomBothOob);
|
2020-06-23 15:52:51 +00:00
|
|
|
impl<'a> CustomBothOob<'a> {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
pub fn new(structure: ::Structure) -> Event {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
Self::builder(structure).build()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn builder(structure: ::Structure) -> CustomBothOobBuilder<'a> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
CustomBothOobBuilder::new(structure)
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 14:06:44 +00:00
|
|
|
|
2018-01-29 10:58:25 +00:00
|
|
|
struct EventBuilder<'a> {
|
|
|
|
seqnum: Option<Seqnum>,
|
|
|
|
running_time_offset: Option<i64>,
|
2019-06-06 06:09:34 +00:00
|
|
|
other_fields: Vec<(&'a str, &'a dyn ToSendValue)>,
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 06:09:34 +00:00
|
|
|
fn other_fields(self, other_fields: &[(&'a str, &'a dyn ToSendValue)]) -> Self {
|
2018-01-29 10:58:25 +00:00
|
|
|
Self {
|
2018-07-27 10:36:40 +00:00
|
|
|
other_fields: self
|
|
|
|
.other_fields
|
2018-02-22 10:18:37 +00:00
|
|
|
.iter()
|
|
|
|
.cloned()
|
2018-01-29 10:58:25 +00:00
|
|
|
.chain(other_fields.iter().cloned())
|
|
|
|
.collect(),
|
2018-02-22 10:18:37 +00:00
|
|
|
..self
|
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) => {
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-28 08:32:13 +00:00
|
|
|
#[allow(clippy::needless_update)]
|
2019-06-06 06:09:34 +00:00
|
|
|
pub fn other_fields(self, other_fields: &[(&'a str, &'a dyn ToSendValue)]) -> 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
pub fn build(mut self) -> Event {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
|
|
|
let event = $new_fn(&mut self);
|
2018-01-29 10:58:25 +00:00
|
|
|
if let Some(seqnum) = self.builder.seqnum {
|
2020-01-24 15:46:18 +00:00
|
|
|
gst_sys::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 {
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::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() {
|
2017-09-13 19:38:19 +00:00
|
|
|
let s = StructureRef::from_glib_borrow_mut(
|
2020-04-24 09:46:16 +00:00
|
|
|
gst_sys::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 {
|
2017-11-15 17:18:58 +00:00
|
|
|
s.set_value(k, v.to_send_value());
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|_| gst_sys::gst_event_new_flush_start());
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_flush_stop(
|
|
|
|
s.reset_time.to_glib()
|
|
|
|
));
|
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,
|
|
|
|
flags: Option<::StreamFlags>,
|
2017-12-05 19:32:16 +00:00
|
|
|
group_id: Option<GroupId>,
|
2020-05-17 10:32:33 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2020-05-17 10:32:33 +00:00
|
|
|
stream: Option<::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
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2020-05-17 10:32:33 +00:00
|
|
|
stream: None,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn flags(self, flags: ::StreamFlags) -> Self {
|
|
|
|
Self {
|
|
|
|
flags: Some(flags),
|
2017-07-31 11:16:42 +00:00
|
|
|
..self
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-17 10:32:33 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2020-05-17 10:32:33 +00:00
|
|
|
pub fn stream(self, stream: ::Stream) -> Self {
|
|
|
|
Self {
|
|
|
|
stream: Some(stream),
|
|
|
|
..self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| {
|
2019-03-19 07:58:20 +00:00
|
|
|
let ev = gst_sys::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 {
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_set_stream_flags(ev, flags.to_glib());
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
if let Some(group_id) = s.group_id {
|
2020-01-24 15:46:18 +00:00
|
|
|
gst_sys::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
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2020-05-17 10:32:33 +00:00
|
|
|
{
|
|
|
|
if let Some(ref stream) = s.stream {
|
|
|
|
gst_sys::gst_event_set_stream(ev, stream.to_glib_none().0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
ev
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct CapsBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
caps: &'a ::Caps,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> CapsBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(caps: &'a ::Caps) -> 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
|
|
|
caps,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_caps(s.caps.as_mut_ptr()));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct SegmentBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
segment: &'a ::Segment,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> SegmentBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(segment: &'a ::Segment) -> 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
|
|
|
segment,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_segment(
|
|
|
|
s.segment.to_glib_none().0
|
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 12:33:02 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2017-07-30 14:06:44 +00:00
|
|
|
pub struct StreamCollectionBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:15:34 +00:00
|
|
|
stream_collection: &'a ::StreamCollection,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-11-12 12:33:02 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> StreamCollectionBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(stream_collection: &'a ::StreamCollection) -> 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_collection,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_stream_collection(
|
2017-12-20 17:30:14 +00:00
|
|
|
s.stream_collection.to_glib_none().0
|
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct TagBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
tags: Option<::TagList>,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> TagBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(tags: ::TagList) -> 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
|
|
|
tags: Some(tags),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
event_builder_generic_impl!(|s: &mut Self| {
|
|
|
|
let tags = s.tags.take().unwrap();
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::gst_event_new_tag(tags.into_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-09-13 19:38:19 +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,
|
2017-07-30 14:06:44 +00:00
|
|
|
async: bool,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
impl<'a> BufferSizeBuilder<'a> {
|
2017-12-09 16:20:21 +00:00
|
|
|
fn new(minsize: GenericFormattedValue, maxsize: GenericFormattedValue, 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,
|
|
|
|
async,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_buffer_size(
|
2017-12-20 17:30:14 +00:00
|
|
|
s.minsize.get_format().to_glib(),
|
|
|
|
s.minsize.get_value(),
|
|
|
|
s.maxsize.get_value(),
|
|
|
|
s.async.to_glib(),
|
|
|
|
));
|
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,
|
|
|
|
msg: &'a ::Message,
|
|
|
|
}
|
2020-06-23 15:52:51 +00:00
|
|
|
|
2017-07-30 14:06:44 +00:00
|
|
|
impl<'a> SinkMessageBuilder<'a> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(name: &'a str, msg: &'a ::Message) -> 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
|
|
|
name,
|
|
|
|
msg,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_sink_message(
|
2017-12-20 17:30:14 +00:00
|
|
|
s.name.to_glib_none().0,
|
|
|
|
s.msg.as_mut_ptr()
|
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 12:33:02 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
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-11-12 12:33:02 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_stream_group_done(
|
2020-01-24 15:46:18 +00:00
|
|
|
s.group_id.0.get()
|
2017-12-20 17:30:14 +00:00
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|_| gst_sys::gst_event_new_eos());
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2017-08-08 20:37:48 +00:00
|
|
|
pub struct TocBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-08-08 20:37:48 +00:00
|
|
|
toc: &'a ::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> {
|
2017-08-30 11:39:09 +00:00
|
|
|
fn new(toc: &'a ::Toc, updated: 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
|
|
|
toc,
|
|
|
|
updated,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_toc(
|
2017-12-20 17:30:14 +00:00
|
|
|
s.toc.to_glib_none().0,
|
|
|
|
s.updated.to_glib()
|
|
|
|
));
|
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,
|
|
|
|
data: &'a ::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> {
|
2017-12-16 15:30:50 +00:00
|
|
|
fn new(system_id: &'a str, data: &'a ::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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_protection(
|
2017-12-20 17:30:14 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_segment_done(
|
2017-12-20 17:30:14 +00:00
|
|
|
s.position.get_format().to_glib(),
|
|
|
|
s.position.get_value()
|
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct GapBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-12-05 19:36:56 +00:00
|
|
|
timestamp: ::ClockTime,
|
|
|
|
duration: ::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> GapBuilder<'a> {
|
2017-12-05 19:36:56 +00:00
|
|
|
fn new(timestamp: ::ClockTime, duration: ::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,
|
|
|
|
duration,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_gap(
|
2017-12-20 17:30:14 +00:00
|
|
|
s.timestamp.to_glib(),
|
|
|
|
s.duration.to_glib()
|
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct QosBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-07-30 14:06:44 +00:00
|
|
|
type_: ::QOSType,
|
|
|
|
proportion: f64,
|
|
|
|
diff: i64,
|
2017-12-05 20:43:37 +00:00
|
|
|
timestamp: ::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> {
|
2017-12-05 20:43:37 +00:00
|
|
|
fn new(type_: ::QOSType, proportion: f64, diff: i64, 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
|
|
|
type_,
|
|
|
|
proportion,
|
|
|
|
diff,
|
|
|
|
timestamp,
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_qos(
|
2017-12-20 17:30:14 +00:00
|
|
|
s.type_.to_glib(),
|
|
|
|
s.proportion,
|
|
|
|
s.diff,
|
|
|
|
s.timestamp.to_glib(),
|
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
flags: ::SeekFlags,
|
|
|
|
start_type: ::SeekType,
|
2017-12-09 16:20:21 +00:00
|
|
|
start: GenericFormattedValue,
|
2017-07-30 14:06:44 +00:00
|
|
|
stop_type: ::SeekType,
|
2017-12-09 16:20:21 +00:00
|
|
|
stop: GenericFormattedValue,
|
2019-04-23 16:53:10 +00:00
|
|
|
#[allow(unused)]
|
|
|
|
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,
|
|
|
|
flags: ::SeekFlags,
|
|
|
|
start_type: ::SeekType,
|
2017-12-09 16:20:21 +00:00
|
|
|
start: GenericFormattedValue,
|
2017-07-31 11:16:42 +00:00
|
|
|
stop_type: ::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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2019-09-07 10:08:09 +00:00
|
|
|
let ev = gst_sys::gst_event_new_seek(
|
|
|
|
s.rate,
|
|
|
|
s.start.get_format().to_glib(),
|
|
|
|
s.flags.to_glib(),
|
|
|
|
s.start_type.to_glib(),
|
|
|
|
s.start.get_value(),
|
|
|
|
s.stop_type.to_glib(),
|
|
|
|
s.stop.get_value(),
|
|
|
|
);
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2019-09-07 10:08:09 +00:00
|
|
|
{
|
|
|
|
if let Some(trickmode_interval) = s.trickmode_interval {
|
|
|
|
gst_sys::gst_event_set_seek_trickmode_interval(
|
|
|
|
ev,
|
|
|
|
trickmode_interval.to_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
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
gst_sys::gst_event_new_navigation(structure.into_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-09-13 19:38:19 +00:00
|
|
|
pub struct LatencyBuilder<'a> {
|
2018-01-29 10:58:25 +00:00
|
|
|
builder: EventBuilder<'a>,
|
2017-12-05 20:43:37 +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> {
|
2017-12-05 20:43:37 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_latency(s.latency.to_glib()));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_step(
|
2017-12-20 17:30:14 +00:00
|
|
|
s.amount.get_format().to_glib(),
|
|
|
|
s.amount.get_value() as u64,
|
|
|
|
s.rate,
|
|
|
|
s.flush.to_glib(),
|
|
|
|
s.intermediate.to_glib(),
|
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|_| gst_sys::gst_event_new_reconfigure());
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_toc_select(
|
|
|
|
s.uid.to_glib_none().0
|
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 12:33:02 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
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-11-12 12:33:02 +00:00
|
|
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
2020-11-19 09:56:42 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))]
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 07:58:20 +00:00
|
|
|
event_builder_generic_impl!(|s: &Self| gst_sys::gst_event_new_select_streams(
|
2017-12-20 17:30:14 +00:00
|
|
|
s.streams.to_glib_full()
|
|
|
|
));
|
2017-07-30 14:06:44 +00:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
gst_sys::gst_event_new_custom(gst_sys::GST_EVENT_CUSTOM_UPSTREAM, structure.into_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
gst_sys::gst_event_new_custom(gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM, structure.into_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
gst_sys::gst_event_new_custom(
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM_OOB,
|
2020-03-09 10:55:14 +00:00
|
|
|
structure.into_ptr(),
|
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
gst_sys::gst_event_new_custom(
|
2019-03-19 07:58:20 +00:00
|
|
|
gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY,
|
2020-03-09 10:55:14 +00:00
|
|
|
structure.into_ptr(),
|
|
|
|
)
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
gst_sys::gst_event_new_custom(gst_sys::GST_EVENT_CUSTOM_BOTH, structure.into_ptr())
|
2017-07-30 14:06:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
gst_sys::gst_event_new_custom(gst_sys::GST_EVENT_CUSTOM_BOTH_OOB, structure.into_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]
|
|
|
|
fn test_simple() {
|
|
|
|
::init().unwrap();
|
|
|
|
|
|
|
|
// 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());
|
|
|
|
assert!(flush_start_evt.get_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) => {
|
2018-01-29 10:31:12 +00:00
|
|
|
assert!(flush_start_evt.get_structure().is_some());
|
|
|
|
if let Some(other_fields) = flush_start_evt.get_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)
|
2018-01-27 11:52:03 +00:00
|
|
|
.other_fields(&[("extra-field", &true)])
|
|
|
|
.build();
|
|
|
|
match flush_stop_evt.view() {
|
|
|
|
EventView::FlushStop(flush_stop_evt) => {
|
|
|
|
assert_eq!(flush_stop_evt.get_reset_time(), true);
|
2018-01-29 10:31:12 +00:00
|
|
|
assert!(flush_stop_evt.get_structure().is_some());
|
|
|
|
if let Some(other_fields) = flush_stop_evt.get_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(_)"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|