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-29 11:58:54 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use std::{
|
|
|
|
borrow::{Borrow, BorrowMut},
|
|
|
|
ffi::CStr,
|
|
|
|
fmt, mem,
|
|
|
|
ops::{Deref, DerefMut},
|
|
|
|
ptr,
|
|
|
|
};
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use glib::{object::IsA, translate::*};
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use crate::{
|
|
|
|
format::{CompatibleFormattedValue, FormattedValue, GenericFormattedValue},
|
|
|
|
structure::*,
|
|
|
|
};
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2020-12-20 15:09:22 +00:00
|
|
|
mini_object_wrapper!(Query, QueryRef, ffi::GstQuery, || {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_get_type()
|
2018-09-28 15:11:46 +00:00
|
|
|
});
|
2017-07-29 11:58:54 +00:00
|
|
|
|
|
|
|
impl QueryRef {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_structure")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_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-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let structure = ffi::gst_query_get_structure(self.as_mut_ptr());
|
2017-12-06 11:43:37 +00:00
|
|
|
if structure.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(StructureRef::from_glib_borrow(structure))
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_mut_structure")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_writable_structure")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn structure_mut(&mut self) -> &mut StructureRef {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let structure = ffi::gst_query_writable_structure(self.as_mut_ptr());
|
2017-07-29 11:58:54 +00:00
|
|
|
StructureRef::from_glib_borrow_mut(structure)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_QUERY_IS_DOWNSTREAM")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2017-07-29 11:58:54 +00:00
|
|
|
pub fn is_downstream(&self) -> bool {
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { ((*self.as_ptr()).type_ as u32) & ffi::GST_QUERY_TYPE_DOWNSTREAM != 0 }
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_QUERY_IS_UPSTREAM")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2017-07-29 11:58:54 +00:00
|
|
|
pub fn is_upstream(&self) -> bool {
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { ((*self.as_ptr()).type_ as u32) & ffi::GST_QUERY_TYPE_UPSTREAM != 0 }
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "GST_QUERY_IS_SERIALIZED")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2017-07-29 11:58:54 +00:00
|
|
|
pub fn is_serialized(&self) -> bool {
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { ((*self.as_ptr()).type_ as u32) & ffi::GST_QUERY_TYPE_SERIALIZED != 0 }
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
pub fn view(&self) -> QueryView {
|
|
|
|
unsafe {
|
|
|
|
let type_ = (*self.as_ptr()).type_;
|
|
|
|
|
|
|
|
match type_ {
|
|
|
|
ffi::GST_QUERY_POSITION => Position::view(self),
|
|
|
|
ffi::GST_QUERY_DURATION => Duration::view(self),
|
|
|
|
ffi::GST_QUERY_LATENCY => Latency::view(self),
|
|
|
|
ffi::GST_QUERY_SEEKING => Seeking::view(self),
|
|
|
|
ffi::GST_QUERY_SEGMENT => Segment::view(self),
|
|
|
|
ffi::GST_QUERY_CONVERT => Convert::view(self),
|
|
|
|
ffi::GST_QUERY_FORMATS => Formats::view(self),
|
|
|
|
ffi::GST_QUERY_BUFFERING => Buffering::view(self),
|
|
|
|
ffi::GST_QUERY_CUSTOM => Custom::view(self),
|
|
|
|
ffi::GST_QUERY_URI => Uri::view(self),
|
|
|
|
ffi::GST_QUERY_ALLOCATION => Allocation::view(self),
|
|
|
|
ffi::GST_QUERY_SCHEDULING => Scheduling::view(self),
|
|
|
|
ffi::GST_QUERY_ACCEPT_CAPS => AcceptCaps::view(self),
|
|
|
|
ffi::GST_QUERY_CAPS => Caps::view(self),
|
|
|
|
ffi::GST_QUERY_DRAIN => Drain::view(self),
|
|
|
|
ffi::GST_QUERY_CONTEXT => Context::view(self),
|
2022-04-06 06:51:19 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::GST_QUERY_BITRATE => Bitrate::view(self),
|
2022-04-06 06:51:37 +00:00
|
|
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
|
|
|
ffi::GST_QUERY_SELECTABLE => Selectable::view(self),
|
2022-01-18 09:57:22 +00:00
|
|
|
_ => Other::view(self),
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
pub fn view_mut(&mut self) -> QueryViewMut {
|
|
|
|
unsafe {
|
|
|
|
let type_ = (*self.as_ptr()).type_;
|
|
|
|
|
|
|
|
match type_ {
|
|
|
|
ffi::GST_QUERY_POSITION => Position::view_mut(self),
|
|
|
|
ffi::GST_QUERY_DURATION => Duration::view_mut(self),
|
|
|
|
ffi::GST_QUERY_LATENCY => Latency::view_mut(self),
|
|
|
|
ffi::GST_QUERY_SEEKING => Seeking::view_mut(self),
|
|
|
|
ffi::GST_QUERY_SEGMENT => Segment::view_mut(self),
|
|
|
|
ffi::GST_QUERY_CONVERT => Convert::view_mut(self),
|
|
|
|
ffi::GST_QUERY_FORMATS => Formats::view_mut(self),
|
|
|
|
ffi::GST_QUERY_BUFFERING => Buffering::view_mut(self),
|
|
|
|
ffi::GST_QUERY_CUSTOM => Custom::view_mut(self),
|
|
|
|
ffi::GST_QUERY_URI => Uri::view_mut(self),
|
|
|
|
ffi::GST_QUERY_ALLOCATION => Allocation::view_mut(self),
|
|
|
|
ffi::GST_QUERY_SCHEDULING => Scheduling::view_mut(self),
|
|
|
|
ffi::GST_QUERY_ACCEPT_CAPS => AcceptCaps::view_mut(self),
|
|
|
|
ffi::GST_QUERY_CAPS => Caps::view_mut(self),
|
|
|
|
ffi::GST_QUERY_DRAIN => Drain::view_mut(self),
|
|
|
|
ffi::GST_QUERY_CONTEXT => Context::view_mut(self),
|
2022-04-06 06:51:19 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::GST_QUERY_BITRATE => Bitrate::view_mut(self),
|
2022-04-06 06:51:37 +00:00
|
|
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
|
|
|
ffi::GST_QUERY_SELECTABLE => Selectable::view_mut(self),
|
2022-01-18 09:57:22 +00:00
|
|
|
_ => Other::view_mut(self),
|
|
|
|
}
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-29 21:12:46 +00:00
|
|
|
impl fmt::Debug for Query {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
QueryRef::fmt(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:21:20 +00:00
|
|
|
impl fmt::Debug for QueryRef {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
f.debug_struct("Query")
|
2022-08-11 14:02:02 +00:00
|
|
|
.field("ptr", &self.as_ptr())
|
2017-12-01 17:02:53 +00:00
|
|
|
.field("type", &unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let type_ = ffi::gst_query_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
|
|
|
})
|
2021-04-11 19:39:50 +00:00
|
|
|
.field("structure", &self.structure())
|
2017-12-01 09:21:20 +00:00
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
#[non_exhaustive]
|
|
|
|
pub enum QueryView<'a> {
|
|
|
|
Position(&'a Position),
|
|
|
|
Duration(&'a Duration),
|
|
|
|
Latency(&'a Latency),
|
|
|
|
Seeking(&'a Seeking),
|
|
|
|
Segment(&'a Segment),
|
|
|
|
Convert(&'a Convert),
|
|
|
|
Formats(&'a Formats),
|
|
|
|
Buffering(&'a Buffering),
|
|
|
|
Custom(&'a Custom),
|
|
|
|
Uri(&'a Uri),
|
|
|
|
Allocation(&'a Allocation),
|
|
|
|
Scheduling(&'a Scheduling),
|
|
|
|
AcceptCaps(&'a AcceptCaps),
|
|
|
|
Caps(&'a Caps),
|
|
|
|
Drain(&'a Drain),
|
|
|
|
Context(&'a Context),
|
2022-04-06 06:51:19 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2022-01-18 09:57:22 +00:00
|
|
|
Bitrate(&'a Bitrate),
|
2022-04-06 06:51:37 +00:00
|
|
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
|
|
|
Selectable(&'a Selectable),
|
2022-01-18 09:57:22 +00:00
|
|
|
Other(&'a Other),
|
2018-02-15 14:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
2021-10-17 09:50:14 +00:00
|
|
|
#[non_exhaustive]
|
2022-01-18 09:57:22 +00:00
|
|
|
pub enum QueryViewMut<'a> {
|
|
|
|
Position(&'a mut Position),
|
|
|
|
Duration(&'a mut Duration),
|
|
|
|
Latency(&'a mut Latency),
|
|
|
|
Seeking(&'a mut Seeking),
|
|
|
|
Segment(&'a mut Segment),
|
|
|
|
Convert(&'a mut Convert),
|
|
|
|
Formats(&'a mut Formats),
|
|
|
|
Buffering(&'a mut Buffering),
|
|
|
|
Custom(&'a mut Custom),
|
|
|
|
Uri(&'a mut Uri),
|
|
|
|
Allocation(&'a mut Allocation),
|
|
|
|
Scheduling(&'a mut Scheduling),
|
|
|
|
AcceptCaps(&'a mut AcceptCaps),
|
|
|
|
Caps(&'a mut Caps),
|
|
|
|
Drain(&'a mut Drain),
|
|
|
|
Context(&'a mut Context),
|
2022-04-06 06:51:19 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2022-01-18 09:57:22 +00:00
|
|
|
Bitrate(&'a mut Bitrate),
|
2022-04-06 06:51:37 +00:00
|
|
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
|
|
|
Selectable(&'a mut Selectable),
|
2022-01-18 09:57:22 +00:00
|
|
|
Other(&'a mut Other),
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
macro_rules! declare_concrete_query(
|
|
|
|
($name:ident, $param:ident) => {
|
2018-02-15 14:05:51 +00:00
|
|
|
#[derive(Debug)]
|
2022-01-18 09:57:22 +00:00
|
|
|
#[repr(transparent)]
|
|
|
|
pub struct $name<$param = QueryRef>($param);
|
2018-01-29 10:31:12 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl $name {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn query(&self) -> &QueryRef {
|
2022-01-18 09:57:22 +00:00
|
|
|
unsafe { &*(self as *const Self as *const QueryRef) }
|
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
pub fn query_mut(&mut self) -> &mut QueryRef {
|
|
|
|
unsafe { &mut *(self as *mut Self as *mut QueryRef) }
|
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
unsafe fn view(query: &QueryRef) -> QueryView<'_> {
|
|
|
|
let query = &*(query as *const QueryRef as *const Self);
|
|
|
|
QueryView::$name(query)
|
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
unsafe fn view_mut(query: &mut QueryRef) -> QueryViewMut<'_> {
|
|
|
|
let query = &mut *(query as *mut QueryRef as *mut Self);
|
|
|
|
QueryViewMut::$name(query)
|
2018-01-29 10:31:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Deref for $name {
|
2018-01-29 10:31:12 +00:00
|
|
|
type Target = QueryRef;
|
|
|
|
|
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.query()
|
2018-01-29 10:31:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl DerefMut for $name {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
|
|
self.query_mut()
|
|
|
|
}
|
|
|
|
}
|
2018-02-15 14:05:51 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl ToOwned for $name {
|
|
|
|
type Owned = $name<Query>;
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
fn to_owned(&self) -> Self::Owned {
|
|
|
|
$name::<Query>(self.copy())
|
2018-02-15 14:05:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl $name<Query> {
|
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(|query| unsafe { &mut *(query as *mut QueryRef as *mut $name) })
|
2018-01-29 10:31:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-15 14:05:51 +00:00
|
|
|
impl Deref for $name<Query> {
|
2022-01-18 09:57:22 +00:00
|
|
|
type Target = $name;
|
2018-01-29 10:31:12 +00:00
|
|
|
|
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
|
|
|
unsafe { &*(self.0.as_ptr() as *const Self::Target) }
|
2018-02-15 14:05:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DerefMut for $name<Query> {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2018-02-15 14:05:51 +00:00
|
|
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
2022-12-25 10:47:02 +00:00
|
|
|
debug_assert!(self.0.is_writable());
|
2022-01-18 09:57:22 +00:00
|
|
|
unsafe { &mut *(self.0.as_mut_ptr() as *mut Self::Target) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Borrow<$name> for $name<Query> {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
fn borrow(&self) -> &$name {
|
|
|
|
&*self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl BorrowMut<$name> for $name<Query> {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-01-18 09:57:22 +00:00
|
|
|
fn borrow_mut(&mut self) -> &mut $name {
|
|
|
|
&mut *self
|
2018-02-15 14:05:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<$name<Query>> for Query {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2018-02-15 14:05:51 +00:00
|
|
|
fn from(concrete: $name<Query>) -> Self {
|
2020-03-22 14:18:47 +00:00
|
|
|
skip_assert_initialized!();
|
2021-10-17 09:38:59 +00:00
|
|
|
concrete.0
|
2018-01-29 10:31:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
declare_concrete_query!(Position, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Position<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_position")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(fmt: crate::Format) -> Self {
|
2020-06-23 17:24:17 +00:00
|
|
|
assert_initialized_main_thread!();
|
2021-04-27 15:15:46 +00:00
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_position(fmt.into_glib()))) }
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Position {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_position")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn result(&self) -> GenericFormattedValue {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut pos = mem::MaybeUninit::uninit();
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_position(self.as_mut_ptr(), fmt.as_mut_ptr(), pos.as_mut_ptr());
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), pos.assume_init())
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_format")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_position")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn format(&self) -> crate::Format {
|
2017-11-11 11:22:31 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
2017-11-11 11:22:31 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_position(self.as_mut_ptr(), fmt.as_mut_ptr(), ptr::null_mut());
|
2017-11-11 11:22:31 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(fmt.assume_init())
|
2017-11-11 11:22:31 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_position")]
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn set(&mut self, pos: impl FormattedValue) {
|
2021-04-11 19:39:50 +00:00
|
|
|
assert_eq!(pos.format(), self.format());
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2022-07-03 16:04:06 +00:00
|
|
|
ffi::gst_query_set_position(
|
|
|
|
self.as_mut_ptr(),
|
|
|
|
pos.format().into_glib(),
|
|
|
|
pos.into_raw_value(),
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Duration, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Duration<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_duration")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(fmt: crate::Format) -> Self {
|
2020-06-23 17:24:17 +00:00
|
|
|
assert_initialized_main_thread!();
|
2021-04-27 15:15:46 +00:00
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_duration(fmt.into_glib()))) }
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Duration {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_duration")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn result(&self) -> GenericFormattedValue {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut pos = mem::MaybeUninit::uninit();
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_duration(self.as_mut_ptr(), fmt.as_mut_ptr(), pos.as_mut_ptr());
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), pos.assume_init())
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_format")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_duration")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn format(&self) -> crate::Format {
|
2017-11-11 11:22:31 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
2017-11-11 11:22:31 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_duration(self.as_mut_ptr(), fmt.as_mut_ptr(), ptr::null_mut());
|
2017-11-11 11:22:31 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(fmt.assume_init())
|
2017-11-11 11:22:31 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_duration")]
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn set(&mut self, dur: impl FormattedValue) {
|
2021-04-11 19:39:50 +00:00
|
|
|
assert_eq!(dur.format(), self.format());
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2022-07-03 16:04:06 +00:00
|
|
|
ffi::gst_query_set_duration(
|
|
|
|
self.as_mut_ptr(),
|
|
|
|
dur.format().into_glib(),
|
|
|
|
dur.into_raw_value(),
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Latency, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Latency<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_latency")]
|
2020-06-23 17:24:17 +00:00
|
|
|
pub fn new() -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_latency())) }
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Latency<Query> {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Latency {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_latency")]
|
2021-04-28 22:29:13 +00:00
|
|
|
pub fn result(&self) -> (bool, crate::ClockTime, Option<crate::ClockTime>) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut live = mem::MaybeUninit::uninit();
|
|
|
|
let mut min = mem::MaybeUninit::uninit();
|
|
|
|
let mut max = mem::MaybeUninit::uninit();
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_latency(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
live.as_mut_ptr(),
|
|
|
|
min.as_mut_ptr(),
|
|
|
|
max.as_mut_ptr(),
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
(
|
|
|
|
from_glib(live.assume_init()),
|
2021-04-28 22:29:13 +00:00
|
|
|
try_from_glib(min.assume_init()).expect("undefined min latency"),
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(max.assume_init()),
|
|
|
|
)
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_latency")]
|
2021-04-28 22:29:13 +00:00
|
|
|
pub fn set(
|
|
|
|
&mut self,
|
|
|
|
live: bool,
|
|
|
|
min: crate::ClockTime,
|
|
|
|
max: impl Into<Option<crate::ClockTime>>,
|
|
|
|
) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_set_latency(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
live.into_glib(),
|
|
|
|
min.into_glib(),
|
2021-04-28 22:29:13 +00:00
|
|
|
max.into().into_glib(),
|
2017-12-05 20:43:37 +00:00
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Seeking, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Seeking<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_seeking")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(fmt: crate::Format) -> Self {
|
2020-06-23 17:24:17 +00:00
|
|
|
assert_initialized_main_thread!();
|
2021-04-27 15:15:46 +00:00
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_seeking(fmt.into_glib()))) }
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Seeking {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_seeking")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn result(&self) -> (bool, GenericFormattedValue, GenericFormattedValue) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut seekable = mem::MaybeUninit::uninit();
|
|
|
|
let mut start = mem::MaybeUninit::uninit();
|
|
|
|
let mut end = mem::MaybeUninit::uninit();
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_seeking(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
fmt.as_mut_ptr(),
|
|
|
|
seekable.as_mut_ptr(),
|
|
|
|
start.as_mut_ptr(),
|
|
|
|
end.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2017-11-11 10:21:55 +00:00
|
|
|
(
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(seekable.assume_init()),
|
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), start.assume_init()),
|
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), end.assume_init()),
|
2017-11-11 10:21:55 +00:00
|
|
|
)
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_format")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_seeking")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn format(&self) -> crate::Format {
|
2017-11-11 11:22:31 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_seeking(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
fmt.as_mut_ptr(),
|
2017-11-11 11:22:31 +00:00
|
|
|
ptr::null_mut(),
|
|
|
|
ptr::null_mut(),
|
|
|
|
ptr::null_mut(),
|
|
|
|
);
|
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(fmt.assume_init())
|
2017-11-11 11:22:31 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_seeking")]
|
2022-07-05 11:13:50 +00:00
|
|
|
pub fn set<V: FormattedValue>(
|
|
|
|
&mut self,
|
|
|
|
seekable: bool,
|
|
|
|
start: V,
|
|
|
|
end: impl CompatibleFormattedValue<V>,
|
|
|
|
) {
|
2021-04-11 19:39:50 +00:00
|
|
|
assert_eq!(self.format(), start.format());
|
2022-07-05 11:13:50 +00:00
|
|
|
let end = end.try_into_checked(start).unwrap();
|
2017-11-11 10:21:55 +00:00
|
|
|
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_set_seeking(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
start.format().into_glib(),
|
|
|
|
seekable.into_glib(),
|
2022-07-03 16:04:06 +00:00
|
|
|
start.into_raw_value(),
|
|
|
|
end.into_raw_value(),
|
2017-07-31 11:16:42 +00:00
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Segment, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Segment<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_segment")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(fmt: crate::Format) -> Self {
|
2020-06-23 17:24:17 +00:00
|
|
|
assert_initialized_main_thread!();
|
2021-04-27 15:15:46 +00:00
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_segment(fmt.into_glib()))) }
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Segment {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_segment")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn result(&self) -> (f64, GenericFormattedValue, GenericFormattedValue) {
|
2017-07-29 11:58:54 +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 start = mem::MaybeUninit::uninit();
|
|
|
|
let mut stop = mem::MaybeUninit::uninit();
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_segment(
|
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(),
|
|
|
|
start.as_mut_ptr(),
|
|
|
|
stop.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
|
|
|
rate.assume_init(),
|
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), start.assume_init()),
|
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), stop.assume_init()),
|
2017-11-11 10:21:55 +00:00
|
|
|
)
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_format")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_segment")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn format(&self) -> crate::Format {
|
2017-11-11 11:22:31 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
2017-11-11 11:22:31 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_segment(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2017-11-11 11:22:31 +00:00
|
|
|
ptr::null_mut(),
|
2019-07-11 12:34:28 +00:00
|
|
|
fmt.as_mut_ptr(),
|
2017-11-11 11:22:31 +00:00
|
|
|
ptr::null_mut(),
|
|
|
|
ptr::null_mut(),
|
|
|
|
);
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(fmt.assume_init())
|
2017-11-11 11:22:31 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_segment")]
|
2022-07-05 11:13:50 +00:00
|
|
|
pub fn set<V: FormattedValue>(
|
|
|
|
&mut self,
|
|
|
|
rate: f64,
|
|
|
|
start: V,
|
|
|
|
stop: impl CompatibleFormattedValue<V>,
|
|
|
|
) {
|
|
|
|
let stop = stop.try_into_checked(start).unwrap();
|
2017-11-11 10:21:55 +00:00
|
|
|
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_set_segment(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2017-11-11 10:21:55 +00:00
|
|
|
rate,
|
2021-04-27 15:15:46 +00:00
|
|
|
start.format().into_glib(),
|
2022-07-03 16:04:06 +00:00
|
|
|
start.into_raw_value(),
|
|
|
|
stop.into_raw_value(),
|
2017-11-11 10:21:55 +00:00
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Convert, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Convert<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_convert")]
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn new(value: impl FormattedValue, dest_fmt: crate::Format) -> Self {
|
2020-06-23 17:24:17 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
Self(from_glib_full(ffi::gst_query_new_convert(
|
2021-04-27 15:15:46 +00:00
|
|
|
value.format().into_glib(),
|
2022-07-03 16:04:06 +00:00
|
|
|
value.into_raw_value(),
|
2021-04-27 15:15:46 +00:00
|
|
|
dest_fmt.into_glib(),
|
2020-06-23 17:24:17 +00:00
|
|
|
)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Convert {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_convert")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn result(&self) -> (GenericFormattedValue, GenericFormattedValue) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut src_fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut src = mem::MaybeUninit::uninit();
|
|
|
|
let mut dest_fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut dest = mem::MaybeUninit::uninit();
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_convert(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
src_fmt.as_mut_ptr(),
|
|
|
|
src.as_mut_ptr(),
|
|
|
|
dest_fmt.as_mut_ptr(),
|
|
|
|
dest.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(src_fmt.assume_init()), src.assume_init()),
|
|
|
|
GenericFormattedValue::new(from_glib(dest_fmt.assume_init()), dest.assume_init()),
|
2017-11-11 10:21:55 +00:00
|
|
|
)
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_convert")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn get(&self) -> (GenericFormattedValue, crate::Format) {
|
2017-11-11 11:22:31 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut src_fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut src = mem::MaybeUninit::uninit();
|
|
|
|
let mut dest_fmt = mem::MaybeUninit::uninit();
|
2017-11-11 11:22:31 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_convert(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
src_fmt.as_mut_ptr(),
|
|
|
|
src.as_mut_ptr(),
|
|
|
|
dest_fmt.as_mut_ptr(),
|
2017-11-11 11:22:31 +00:00
|
|
|
ptr::null_mut(),
|
|
|
|
);
|
|
|
|
(
|
2019-07-11 12:34:28 +00:00
|
|
|
GenericFormattedValue::new(from_glib(src_fmt.assume_init()), src.assume_init()),
|
|
|
|
from_glib(dest_fmt.assume_init()),
|
2017-11-11 11:22:31 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_convert")]
|
2022-07-03 16:04:06 +00:00
|
|
|
pub fn set(&mut self, src: impl FormattedValue, dest: impl FormattedValue) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_set_convert(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
src.format().into_glib(),
|
2022-07-03 16:04:06 +00:00
|
|
|
src.into_raw_value(),
|
2021-04-27 15:15:46 +00:00
|
|
|
dest.format().into_glib(),
|
2022-07-03 16:04:06 +00:00
|
|
|
dest.into_raw_value(),
|
2017-07-31 11:16:42 +00:00
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Formats, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Formats<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_formats")]
|
2020-06-23 17:24:17 +00:00
|
|
|
pub fn new() -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_formats())) }
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Formats<Query> {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Formats {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_n_formats")]
|
|
|
|
#[doc(alias = "gst_query_parse_nth_format")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn result(&self) -> Vec<crate::Format> {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut n = mem::MaybeUninit::uninit();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_n_formats(self.as_mut_ptr(), n.as_mut_ptr());
|
2019-07-11 12:34:28 +00:00
|
|
|
let n = n.assume_init();
|
2017-07-29 11:58:54 +00:00
|
|
|
let mut res = Vec::with_capacity(n as usize);
|
|
|
|
|
|
|
|
for i in 0..n {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_nth_format(self.as_mut_ptr(), i, fmt.as_mut_ptr());
|
2019-07-11 12:34:28 +00:00
|
|
|
res.push(from_glib(fmt.assume_init()));
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
res
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_set_formats")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_formatsv")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn set(&mut self, formats: &[crate::Format]) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2021-04-27 15:15:46 +00:00
|
|
|
let v: Vec<_> = formats.iter().map(|f| f.into_glib()).collect();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_set_formatsv(self.as_mut_ptr(), v.len() as i32, v.as_ptr() as *mut _);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Buffering, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Buffering<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_buffering")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(fmt: crate::Format) -> Self {
|
2020-06-23 17:24:17 +00:00
|
|
|
assert_initialized_main_thread!();
|
2021-04-27 15:15:46 +00:00
|
|
|
unsafe {
|
|
|
|
Self(from_glib_full(ffi::gst_query_new_buffering(
|
|
|
|
fmt.into_glib(),
|
|
|
|
)))
|
|
|
|
}
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Buffering {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_format")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_buffering_range")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn format(&self) -> crate::Format {
|
2017-11-11 11:22:31 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
2017-11-11 11:22:31 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_buffering_range(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
fmt.as_mut_ptr(),
|
2017-11-11 11:22:31 +00:00
|
|
|
ptr::null_mut(),
|
|
|
|
ptr::null_mut(),
|
|
|
|
ptr::null_mut(),
|
|
|
|
);
|
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(fmt.assume_init())
|
2017-11-11 11:22:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_percent")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_parse_buffering_percent")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn percent(&self) -> (bool, i32) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut busy = mem::MaybeUninit::uninit();
|
|
|
|
let mut percent = mem::MaybeUninit::uninit();
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_buffering_percent(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
busy.as_mut_ptr(),
|
|
|
|
percent.as_mut_ptr(),
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
(from_glib(busy.assume_init()), percent.assume_init())
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_range")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_parse_buffering_range")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn range(&self) -> (GenericFormattedValue, GenericFormattedValue, i64) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
|
|
|
let mut start = mem::MaybeUninit::uninit();
|
|
|
|
let mut stop = mem::MaybeUninit::uninit();
|
|
|
|
let mut estimated_total = mem::MaybeUninit::uninit();
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_buffering_range(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
fmt.as_mut_ptr(),
|
|
|
|
start.as_mut_ptr(),
|
|
|
|
stop.as_mut_ptr(),
|
|
|
|
estimated_total.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()), start.assume_init()),
|
|
|
|
GenericFormattedValue::new(from_glib(fmt.assume_init()), stop.assume_init()),
|
|
|
|
estimated_total.assume_init(),
|
2017-11-11 10:21:55 +00:00
|
|
|
)
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_stats")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_parse_buffering_stats")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn stats(&self) -> (crate::BufferingMode, i32, i32, i64) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut mode = mem::MaybeUninit::uninit();
|
|
|
|
let mut avg_in = mem::MaybeUninit::uninit();
|
|
|
|
let mut avg_out = mem::MaybeUninit::uninit();
|
|
|
|
let mut buffering_left = mem::MaybeUninit::uninit();
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_buffering_stats(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
mode.as_mut_ptr(),
|
|
|
|
avg_in.as_mut_ptr(),
|
|
|
|
avg_out.as_mut_ptr(),
|
|
|
|
buffering_left.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
(
|
|
|
|
from_glib(mode.assume_init()),
|
|
|
|
avg_in.assume_init(),
|
|
|
|
avg_out.assume_init(),
|
|
|
|
buffering_left.assume_init(),
|
|
|
|
)
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_ranges")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_get_n_buffering_ranges")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_nth_buffering_range")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn ranges(&self) -> Vec<(GenericFormattedValue, GenericFormattedValue)> {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut fmt = mem::MaybeUninit::uninit();
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_buffering_range(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
fmt.as_mut_ptr(),
|
2017-11-11 10:21:55 +00:00
|
|
|
ptr::null_mut(),
|
|
|
|
ptr::null_mut(),
|
|
|
|
ptr::null_mut(),
|
|
|
|
);
|
2019-07-11 12:34:28 +00:00
|
|
|
let fmt = from_glib(fmt.assume_init());
|
2017-11-11 10:21:55 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
let n = ffi::gst_query_get_n_buffering_ranges(self.as_mut_ptr());
|
2017-07-29 11:58:54 +00:00
|
|
|
let mut res = Vec::with_capacity(n as usize);
|
|
|
|
for i in 0..n {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut start = mem::MaybeUninit::uninit();
|
|
|
|
let mut stop = mem::MaybeUninit::uninit();
|
2020-11-21 13:46:48 +00:00
|
|
|
let s: bool = from_glib(ffi::gst_query_parse_nth_buffering_range(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
i,
|
2019-07-11 12:34:28 +00:00
|
|
|
start.as_mut_ptr(),
|
|
|
|
stop.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
));
|
2017-07-29 11:58:54 +00:00
|
|
|
if s {
|
2017-11-11 10:21:55 +00:00
|
|
|
res.push((
|
2019-07-11 12:34:28 +00:00
|
|
|
GenericFormattedValue::new(fmt, start.assume_init()),
|
|
|
|
GenericFormattedValue::new(fmt, stop.assume_init()),
|
2017-11-11 10:21:55 +00:00
|
|
|
));
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
res
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_set_buffering_percent")]
|
2017-07-29 11:58:54 +00:00
|
|
|
pub fn set_percent(&mut self, busy: bool, percent: i32) {
|
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_set_buffering_percent(self.as_mut_ptr(), busy.into_glib(), percent);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_set_buffering_range")]
|
2022-07-05 11:13:50 +00:00
|
|
|
pub fn set_range<V: FormattedValue>(
|
|
|
|
&mut self,
|
|
|
|
start: V,
|
|
|
|
stop: impl CompatibleFormattedValue<V>,
|
|
|
|
estimated_total: i64,
|
|
|
|
) {
|
2021-04-11 19:39:50 +00:00
|
|
|
assert_eq!(self.format(), start.format());
|
2022-07-05 11:13:50 +00:00
|
|
|
let stop = stop.try_into_checked(start).unwrap();
|
2017-11-11 10:21:55 +00:00
|
|
|
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_set_buffering_range(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
start.format().into_glib(),
|
2022-07-03 16:04:06 +00:00
|
|
|
start.into_raw_value(),
|
|
|
|
stop.into_raw_value(),
|
2017-07-31 11:16:42 +00:00
|
|
|
estimated_total,
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_set_buffering_stats")]
|
2017-07-31 11:16:42 +00:00
|
|
|
pub fn set_stats(
|
|
|
|
&mut self,
|
2020-11-21 13:46:48 +00:00
|
|
|
mode: crate::BufferingMode,
|
2017-07-31 11:16:42 +00:00
|
|
|
avg_in: i32,
|
|
|
|
avg_out: i32,
|
|
|
|
buffering_left: i64,
|
|
|
|
) {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_set_buffering_stats(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
mode.into_glib(),
|
2017-07-31 11:16:42 +00:00
|
|
|
avg_in,
|
|
|
|
avg_out,
|
|
|
|
buffering_left,
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_add_buffering_range")]
|
2022-07-05 11:13:50 +00:00
|
|
|
pub fn add_buffering_ranges<V: FormattedValue, U: CompatibleFormattedValue<V> + Copy>(
|
|
|
|
&mut self,
|
|
|
|
ranges: &[(V, U)],
|
|
|
|
) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2021-04-11 19:39:50 +00:00
|
|
|
let fmt = self.format();
|
2017-11-11 10:21:55 +00:00
|
|
|
|
2017-07-29 11:58:54 +00:00
|
|
|
for &(start, stop) in ranges {
|
2021-04-11 19:39:50 +00:00
|
|
|
assert_eq!(start.format(), fmt);
|
2022-07-05 11:13:50 +00:00
|
|
|
let stop = stop.try_into_checked(start).unwrap();
|
2022-07-03 16:04:06 +00:00
|
|
|
ffi::gst_query_add_buffering_range(
|
|
|
|
self.as_mut_ptr(),
|
|
|
|
start.into_raw_value(),
|
|
|
|
stop.into_raw_value(),
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Custom, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Custom<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_custom")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(structure: crate::Structure) -> Self {
|
2022-12-25 10:47:02 +00:00
|
|
|
skip_assert_initialized!();
|
2020-06-23 17:24:17 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
Self(from_glib_full(ffi::gst_query_new_custom(
|
|
|
|
ffi::GST_QUERY_CUSTOM,
|
2022-05-06 19:41:15 +00:00
|
|
|
structure.into_glib_ptr(),
|
2020-06-23 17:24:17 +00:00
|
|
|
)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Uri, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Uri<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_uri")]
|
2020-06-23 17:24:17 +00:00
|
|
|
pub fn new() -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_uri())) }
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Uri<Query> {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Uri {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_uri")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_parse_uri")]
|
2022-10-18 11:16:04 +00:00
|
|
|
pub fn uri(&self) -> Option<glib::GString> {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
|
|
|
let mut uri = ptr::null_mut();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_uri(self.as_mut_ptr(), &mut uri);
|
2017-07-29 11:58:54 +00:00
|
|
|
from_glib_full(uri)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_redirection")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_parse_uri_redirection")]
|
|
|
|
#[doc(alias = "gst_query_parse_uri_redirection_permanent")]
|
2022-10-18 11:16:04 +00:00
|
|
|
pub fn redirection(&self) -> (Option<glib::GString>, bool) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
|
|
|
let mut uri = ptr::null_mut();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_uri_redirection(self.as_mut_ptr(), &mut uri);
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut permanent = mem::MaybeUninit::uninit();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_uri_redirection_permanent(
|
|
|
|
self.as_mut_ptr(),
|
|
|
|
permanent.as_mut_ptr(),
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
(from_glib_full(uri), from_glib(permanent.assume_init()))
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_uri")]
|
2022-10-20 16:39:12 +00:00
|
|
|
pub fn set_uri<'a, T>(&mut self, uri: impl Into<Option<&'a T>>)
|
|
|
|
where
|
|
|
|
T: 'a + AsRef<str> + ?Sized,
|
|
|
|
{
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2022-10-20 16:39:12 +00:00
|
|
|
ffi::gst_query_set_uri(
|
|
|
|
self.as_mut_ptr(),
|
|
|
|
uri.into().map(AsRef::as_ref).to_glib_none().0,
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_set_uri_redirection")]
|
|
|
|
#[doc(alias = "gst_query_set_uri_redirection_permanent")]
|
2022-10-20 16:39:12 +00:00
|
|
|
pub fn set_redirection<'a, T>(&mut self, uri: impl Into<Option<&'a T>>, permanent: bool)
|
|
|
|
where
|
|
|
|
T: 'a + AsRef<str> + ?Sized,
|
|
|
|
{
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2022-10-20 16:39:12 +00:00
|
|
|
ffi::gst_query_set_uri_redirection(
|
|
|
|
self.as_mut_ptr(),
|
|
|
|
uri.into().map(AsRef::as_ref).to_glib_none().0,
|
|
|
|
);
|
2021-04-27 15:15:46 +00:00
|
|
|
ffi::gst_query_set_uri_redirection_permanent(
|
|
|
|
self.0.as_mut_ptr(),
|
|
|
|
permanent.into_glib(),
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Allocation, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Allocation<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_allocation")]
|
2023-01-19 14:08:16 +00:00
|
|
|
pub fn new(caps: Option<&crate::Caps>, need_pool: bool) -> Self {
|
2022-12-25 10:47:02 +00:00
|
|
|
skip_assert_initialized!();
|
2020-06-23 17:24:17 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
Self(from_glib_full(ffi::gst_query_new_allocation(
|
2023-01-19 14:08:16 +00:00
|
|
|
caps.map(|caps| caps.as_mut_ptr())
|
|
|
|
.unwrap_or(ptr::null_mut()),
|
2021-04-27 15:15:46 +00:00
|
|
|
need_pool.into_glib(),
|
2020-06-23 17:24:17 +00:00
|
|
|
)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Allocation {
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_allocation")]
|
2023-01-19 14:08:16 +00:00
|
|
|
pub fn get(&self) -> (Option<&crate::CapsRef>, bool) {
|
2018-10-01 19:56:32 +00:00
|
|
|
unsafe {
|
|
|
|
let mut caps = ptr::null_mut();
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut need_pool = mem::MaybeUninit::uninit();
|
2018-10-01 19:56:32 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_allocation(self.as_mut_ptr(), &mut caps, need_pool.as_mut_ptr());
|
2019-07-11 12:34:28 +00:00
|
|
|
(
|
2023-01-19 14:08:16 +00:00
|
|
|
if caps.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
|
|
|
Some(crate::CapsRef::from_ptr(caps))
|
|
|
|
},
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(need_pool.assume_init()),
|
|
|
|
)
|
2018-10-01 19:56:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_allocation")]
|
2023-01-19 14:08:16 +00:00
|
|
|
pub fn get_owned(&self) -> (Option<crate::Caps>, bool) {
|
2019-05-23 11:28:09 +00:00
|
|
|
unsafe {
|
|
|
|
let (caps, need_pool) = self.get();
|
2023-01-19 14:08:16 +00:00
|
|
|
(caps.map(|caps| from_glib_none(caps.as_ptr())), need_pool)
|
2019-05-23 11:28:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-12 14:46:41 +00:00
|
|
|
#[doc(alias = "gst_allocation_params")]
|
|
|
|
#[doc(alias = "gst_query_get_n_allocation_params")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_nth_allocation_param")]
|
2021-10-12 14:46:41 +00:00
|
|
|
pub fn allocation_params(&self) -> Vec<(Option<crate::Allocator>, crate::AllocationParams)> {
|
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
let n = ffi::gst_query_get_n_allocation_params(self.as_mut_ptr());
|
2021-10-12 14:46:41 +00:00
|
|
|
let mut params = Vec::with_capacity(n as usize);
|
|
|
|
for i in 0..n {
|
|
|
|
let mut allocator = ptr::null_mut();
|
|
|
|
let mut p = mem::MaybeUninit::uninit();
|
|
|
|
ffi::gst_query_parse_nth_allocation_param(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-10-12 14:46:41 +00:00
|
|
|
i,
|
|
|
|
&mut allocator,
|
|
|
|
p.as_mut_ptr(),
|
|
|
|
);
|
|
|
|
params.push((from_glib_full(allocator), from_glib(p.assume_init())));
|
|
|
|
}
|
|
|
|
|
|
|
|
params
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_allocation_pools")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_get_n_allocation_pools")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_nth_allocation_pool")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn allocation_pools(&self) -> Vec<(Option<crate::BufferPool>, u32, u32, u32)> {
|
2018-10-01 19:56:32 +00:00
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
let n = ffi::gst_query_get_n_allocation_pools(self.as_mut_ptr());
|
2018-10-01 19:56:32 +00:00
|
|
|
let mut pools = Vec::with_capacity(n as usize);
|
|
|
|
for i in 0..n {
|
|
|
|
let mut pool = ptr::null_mut();
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut size = mem::MaybeUninit::uninit();
|
|
|
|
let mut min_buffers = mem::MaybeUninit::uninit();
|
|
|
|
let mut max_buffers = mem::MaybeUninit::uninit();
|
2018-10-01 19:56:32 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_nth_allocation_pool(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.0.as_mut_ptr(),
|
2018-10-01 19:56:32 +00:00
|
|
|
i,
|
|
|
|
&mut pool,
|
2019-07-11 12:34:28 +00:00
|
|
|
size.as_mut_ptr(),
|
|
|
|
min_buffers.as_mut_ptr(),
|
|
|
|
max_buffers.as_mut_ptr(),
|
2018-10-01 19:56:32 +00:00
|
|
|
);
|
2019-07-11 12:34:28 +00:00
|
|
|
pools.push((
|
|
|
|
from_glib_full(pool),
|
|
|
|
size.assume_init(),
|
|
|
|
min_buffers.assume_init(),
|
|
|
|
max_buffers.assume_init(),
|
|
|
|
));
|
2018-10-01 19:56:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pools
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_allocation_metas")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_get_n_allocation_metas")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_nth_allocation_meta")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn allocation_metas(&self) -> Vec<(glib::Type, Option<&crate::StructureRef>)> {
|
2018-10-01 19:56:32 +00:00
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
let n = ffi::gst_query_get_n_allocation_metas(self.0.as_mut_ptr());
|
2018-10-01 19:56:32 +00:00
|
|
|
let mut metas = Vec::with_capacity(n as usize);
|
|
|
|
for i in 0..n {
|
|
|
|
let mut structure = ptr::null();
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
let api =
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_nth_allocation_meta(self.as_mut_ptr(), i, &mut structure);
|
2018-10-01 19:56:32 +00:00
|
|
|
metas.push((
|
|
|
|
from_glib(api),
|
|
|
|
if structure.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
2020-11-21 13:46:48 +00:00
|
|
|
Some(crate::StructureRef::from_glib_borrow(structure))
|
2018-10-01 19:56:32 +00:00
|
|
|
},
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
metas
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_find_allocation_meta")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn find_allocation_meta<U: crate::MetaAPI>(&self) -> Option<u32> {
|
2018-10-01 19:56:32 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut idx = mem::MaybeUninit::uninit();
|
2020-11-21 13:46:48 +00:00
|
|
|
if ffi::gst_query_find_allocation_meta(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
U::meta_api().into_glib(),
|
2019-07-11 12:34:28 +00:00
|
|
|
idx.as_mut_ptr(),
|
2020-11-21 13:46:48 +00:00
|
|
|
) != glib::ffi::GFALSE
|
2018-10-01 19:56:32 +00:00
|
|
|
{
|
2019-07-11 12:34:28 +00:00
|
|
|
Some(idx.assume_init())
|
2018-10-01 19:56:32 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_add_allocation_pool")]
|
2018-10-01 19:56:32 +00:00
|
|
|
pub fn add_allocation_pool(
|
|
|
|
&mut self,
|
2021-10-12 15:48:55 +00:00
|
|
|
pool: Option<&impl IsA<crate::BufferPool>>,
|
2018-10-01 19:56:32 +00:00
|
|
|
size: u32,
|
|
|
|
min_buffers: u32,
|
|
|
|
max_buffers: u32,
|
|
|
|
) {
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_add_allocation_pool(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-10-12 15:48:55 +00:00
|
|
|
pool.to_glib_none().0 as *mut ffi::GstBufferPool,
|
2018-10-01 19:56:32 +00:00
|
|
|
size,
|
|
|
|
min_buffers,
|
|
|
|
max_buffers,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_nth_allocation_pool")]
|
2018-10-01 19:56:32 +00:00
|
|
|
pub fn set_nth_allocation_pool(
|
|
|
|
&mut self,
|
|
|
|
idx: u32,
|
2021-10-12 15:48:55 +00:00
|
|
|
pool: Option<&impl IsA<crate::BufferPool>>,
|
2018-10-01 19:56:32 +00:00
|
|
|
size: u32,
|
|
|
|
min_buffers: u32,
|
|
|
|
max_buffers: u32,
|
|
|
|
) {
|
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
let n = ffi::gst_query_get_n_allocation_pools(self.as_mut_ptr());
|
2021-10-12 15:48:55 +00:00
|
|
|
assert!(idx < n);
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_set_nth_allocation_pool(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2018-10-01 19:56:32 +00:00
|
|
|
idx,
|
2021-10-12 15:48:55 +00:00
|
|
|
pool.to_glib_none().0 as *mut ffi::GstBufferPool,
|
2018-10-01 19:56:32 +00:00
|
|
|
size,
|
|
|
|
min_buffers,
|
|
|
|
max_buffers,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_remove_nth_allocation_pool")]
|
2018-10-01 19:56:32 +00:00
|
|
|
pub fn remove_nth_allocation_pool(&mut self, idx: u32) {
|
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
let n = ffi::gst_query_get_n_allocation_pools(self.as_mut_ptr());
|
2021-10-12 15:48:55 +00:00
|
|
|
assert!(idx < n);
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_remove_nth_allocation_pool(self.as_mut_ptr(), idx);
|
2018-10-01 19:56:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-12 14:46:41 +00:00
|
|
|
#[doc(alias = "gst_query_add_allocation_param")]
|
|
|
|
pub fn add_allocation_param(
|
|
|
|
&mut self,
|
|
|
|
allocator: Option<&impl IsA<crate::Allocator>>,
|
|
|
|
params: crate::AllocationParams,
|
|
|
|
) {
|
|
|
|
unsafe {
|
|
|
|
ffi::gst_query_add_allocation_param(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-10-12 14:46:41 +00:00
|
|
|
allocator.to_glib_none().0 as *mut ffi::GstAllocator,
|
|
|
|
params.as_ptr(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(alias = "gst_query_set_nth_allocation_param")]
|
|
|
|
pub fn set_nth_allocation_param(
|
|
|
|
&mut self,
|
|
|
|
idx: u32,
|
|
|
|
allocator: Option<&impl IsA<crate::Allocator>>,
|
|
|
|
params: crate::AllocationParams,
|
|
|
|
) {
|
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
let n = ffi::gst_query_get_n_allocation_params(self.as_mut_ptr());
|
2021-10-12 14:46:41 +00:00
|
|
|
assert!(idx < n);
|
|
|
|
ffi::gst_query_set_nth_allocation_param(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-10-12 14:46:41 +00:00
|
|
|
idx,
|
|
|
|
allocator.to_glib_none().0 as *mut ffi::GstAllocator,
|
|
|
|
params.as_ptr(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(alias = "gst_query_remove_nth_allocation_param")]
|
|
|
|
pub fn remove_nth_allocation_param(&mut self, idx: u32) {
|
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
let n = ffi::gst_query_get_n_allocation_params(self.as_mut_ptr());
|
2021-10-12 14:46:41 +00:00
|
|
|
assert!(idx < n);
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_remove_nth_allocation_param(self.as_mut_ptr(), idx);
|
2021-10-12 14:46:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_add_allocation_meta")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn add_allocation_meta<U: crate::MetaAPI>(
|
|
|
|
&mut self,
|
|
|
|
structure: Option<&crate::StructureRef>,
|
|
|
|
) {
|
2018-10-01 19:56:32 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_add_allocation_meta(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
U::meta_api().into_glib(),
|
2018-10-01 19:56:32 +00:00
|
|
|
if let Some(structure) = structure {
|
|
|
|
structure.as_ptr()
|
|
|
|
} else {
|
|
|
|
ptr::null()
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_remove_nth_allocation_meta")]
|
2018-10-01 19:56:32 +00:00
|
|
|
pub fn remove_nth_allocation_meta(&mut self, idx: u32) {
|
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
let n = ffi::gst_query_get_n_allocation_metas(self.as_mut_ptr());
|
2021-10-12 15:48:55 +00:00
|
|
|
assert!(idx < n);
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_remove_nth_allocation_meta(self.as_mut_ptr(), idx);
|
2018-10-01 19:56:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Scheduling, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Scheduling<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_scheduling")]
|
2020-06-23 17:24:17 +00:00
|
|
|
pub fn new() -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_scheduling())) }
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Scheduling<Query> {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Scheduling {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_has_scheduling_mode")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn has_scheduling_mode(&self, mode: crate::PadMode) -> bool {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
from_glib(ffi::gst_query_has_scheduling_mode(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
mode.into_glib(),
|
2017-07-31 11:16:42 +00:00
|
|
|
))
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_has_scheduling_mode_with_flags")]
|
2017-07-31 11:16:42 +00:00
|
|
|
pub fn has_scheduling_mode_with_flags(
|
|
|
|
&self,
|
2020-11-21 13:46:48 +00:00
|
|
|
mode: crate::PadMode,
|
|
|
|
flags: crate::SchedulingFlags,
|
2017-07-31 11:16:42 +00:00
|
|
|
) -> bool {
|
2017-08-30 11:39:09 +00:00
|
|
|
skip_assert_initialized!();
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
from_glib(ffi::gst_query_has_scheduling_mode_with_flags(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
mode.into_glib(),
|
|
|
|
flags.into_glib(),
|
2017-07-31 11:16:42 +00:00
|
|
|
))
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_scheduling_modes")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_get_n_scheduling_modes")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn scheduling_modes(&self) -> Vec<crate::PadMode> {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
let n = ffi::gst_query_get_n_scheduling_modes(self.as_mut_ptr());
|
2017-07-29 11:58:54 +00:00
|
|
|
let mut res = Vec::with_capacity(n as usize);
|
|
|
|
for i in 0..n {
|
2020-11-21 13:46:48 +00:00
|
|
|
res.push(from_glib(ffi::gst_query_parse_nth_scheduling_mode(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
i,
|
|
|
|
)));
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
res
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_scheduling")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn result(&self) -> (crate::SchedulingFlags, i32, i32, i32) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut flags = mem::MaybeUninit::uninit();
|
|
|
|
let mut minsize = mem::MaybeUninit::uninit();
|
|
|
|
let mut maxsize = mem::MaybeUninit::uninit();
|
|
|
|
let mut align = mem::MaybeUninit::uninit();
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_parse_scheduling(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2019-07-11 12:34:28 +00:00
|
|
|
flags.as_mut_ptr(),
|
|
|
|
minsize.as_mut_ptr(),
|
|
|
|
maxsize.as_mut_ptr(),
|
|
|
|
align.as_mut_ptr(),
|
2017-07-31 11:16:42 +00:00
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2019-07-11 12:34:28 +00:00
|
|
|
(
|
|
|
|
from_glib(flags.assume_init()),
|
|
|
|
minsize.assume_init(),
|
|
|
|
maxsize.assume_init(),
|
|
|
|
align.assume_init(),
|
|
|
|
)
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_add_scheduling_mode")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn add_scheduling_modes(&mut self, modes: &[crate::PadMode]) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
|
|
|
for mode in modes {
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_add_scheduling_mode(self.as_mut_ptr(), mode.into_glib());
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_scheduling")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn set(&mut self, flags: crate::SchedulingFlags, minsize: i32, maxsize: i32, align: i32) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_query_set_scheduling(
|
2022-01-18 09:57:22 +00:00
|
|
|
self.as_mut_ptr(),
|
2021-04-27 15:15:46 +00:00
|
|
|
flags.into_glib(),
|
2017-07-31 11:16:42 +00:00
|
|
|
minsize,
|
|
|
|
maxsize,
|
|
|
|
align,
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(AcceptCaps, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl AcceptCaps<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_accept_caps")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(caps: &crate::Caps) -> Self {
|
2022-12-25 10:47:02 +00:00
|
|
|
skip_assert_initialized!();
|
2020-06-23 17:24:17 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
Self(from_glib_full(ffi::gst_query_new_accept_caps(
|
2020-06-23 17:24:17 +00:00
|
|
|
caps.as_mut_ptr(),
|
|
|
|
)))
|
|
|
|
}
|
|
|
|
}
|
2022-01-17 17:33:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl AcceptCaps {
|
2022-01-17 17:33:13 +00:00
|
|
|
#[doc(alias = "get_caps")]
|
|
|
|
#[doc(alias = "gst_query_parse_accept_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_query_parse_accept_caps(self.as_mut_ptr(), &mut caps);
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::CapsRef::from_ptr(caps)
|
2017-07-29 11:58:54 +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_query_parse_accept_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
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_parse_accept_caps_result")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn result(&self) -> bool {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut accepted = mem::MaybeUninit::uninit();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_accept_caps_result(self.as_mut_ptr(), accepted.as_mut_ptr());
|
2019-07-11 12:34:28 +00:00
|
|
|
from_glib(accepted.assume_init())
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_set_accept_caps_result")]
|
2017-07-29 11:58:54 +00:00
|
|
|
pub fn set_result(&mut self, accepted: bool) {
|
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_set_accept_caps_result(self.as_mut_ptr(), accepted.into_glib());
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Caps, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Caps<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_caps")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn new(filter: Option<&crate::Caps>) -> Self {
|
2022-12-25 10:47:02 +00:00
|
|
|
skip_assert_initialized!();
|
2020-06-23 17:24:17 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
Self(from_glib_full(ffi::gst_query_new_caps(
|
2020-06-23 17:24:17 +00:00
|
|
|
filter.to_glib_none().0,
|
|
|
|
)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Caps {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_filter")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_caps")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn filter(&self) -> Option<&crate::CapsRef> {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
|
|
|
let mut caps = ptr::null_mut();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_caps(self.as_mut_ptr(), &mut caps);
|
2017-12-17 09:32:01 +00:00
|
|
|
if caps.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
2020-11-21 13:46:48 +00:00
|
|
|
Some(crate::CapsRef::from_ptr(caps))
|
2017-12-17 09:32:01 +00:00
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_filter_owned")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_caps")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn filter_owned(&self) -> Option<crate::Caps> {
|
|
|
|
unsafe { self.filter().map(|caps| from_glib_none(caps.as_ptr())) }
|
2019-05-23 11:28:09 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_parse_caps_result")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn result(&self) -> Option<&crate::CapsRef> {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
|
|
|
let mut caps = ptr::null_mut();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_caps_result(self.as_mut_ptr(), &mut caps);
|
2017-12-17 09:32:01 +00:00
|
|
|
if caps.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
2020-11-21 13:46:48 +00:00
|
|
|
Some(crate::CapsRef::from_ptr(caps))
|
2017-12-17 09:32:01 +00:00
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-23 11:28:09 +00:00
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_result_owned")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_caps_result")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn result_owned(&self) -> Option<crate::Caps> {
|
|
|
|
unsafe { self.result().map(|caps| from_glib_none(caps.as_ptr())) }
|
2019-05-23 11:28:09 +00:00
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_set_caps_result")]
|
2022-10-20 16:39:12 +00:00
|
|
|
pub fn set_result<'a>(&mut self, caps: impl Into<Option<&'a crate::Caps>>) {
|
2017-07-29 11:58:54 +00:00
|
|
|
unsafe {
|
2022-10-18 11:16:04 +00:00
|
|
|
ffi::gst_query_set_caps_result(
|
|
|
|
self.as_mut_ptr(),
|
2022-10-20 16:39:12 +00:00
|
|
|
caps.into()
|
|
|
|
.map(|caps| caps.as_mut_ptr())
|
2022-10-18 11:16:04 +00:00
|
|
|
.unwrap_or(ptr::null_mut()),
|
|
|
|
);
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Drain, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Drain<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_drain")]
|
2020-06-23 17:24:17 +00:00
|
|
|
pub fn new() -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_drain())) }
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Drain<Query> {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Context, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Context<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_context")]
|
2020-06-23 17:24:17 +00:00
|
|
|
pub fn new(context_type: &str) -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
Self(from_glib_full(ffi::gst_query_new_context(
|
2020-06-23 17:24:17 +00:00
|
|
|
context_type.to_glib_none().0,
|
|
|
|
)))
|
|
|
|
}
|
|
|
|
}
|
2022-01-18 09:57:22 +00:00
|
|
|
}
|
2020-06-23 17:24:17 +00:00
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Context {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_context")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_parse_context")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn context(&self) -> Option<&crate::ContextRef> {
|
2017-08-02 17:58:33 +00:00
|
|
|
unsafe {
|
|
|
|
let mut context = ptr::null_mut();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_context(self.as_mut_ptr(), &mut context);
|
2017-08-02 17:58:33 +00:00
|
|
|
if context.is_null() {
|
|
|
|
None
|
|
|
|
} else {
|
2020-11-21 13:46:48 +00:00
|
|
|
Some(crate::ContextRef::from_ptr(context))
|
2017-08-02 17:58:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_context_owned")]
|
2021-11-13 09:01:59 +00:00
|
|
|
#[doc(alias = "gst_query_parse_context")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn context_owned(&self) -> Option<crate::Context> {
|
2019-05-23 11:28:09 +00:00
|
|
|
unsafe {
|
2021-04-11 19:39:50 +00:00
|
|
|
self.context()
|
2019-05-23 11:28:09 +00:00
|
|
|
.map(|context| from_glib_none(context.as_ptr()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_context_type")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_parse_context_type")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn context_type(&self) -> &str {
|
2017-08-02 17:58:33 +00:00
|
|
|
unsafe {
|
|
|
|
let mut context_type = ptr::null();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_context_type(self.as_mut_ptr(), &mut context_type);
|
2022-01-17 17:33:13 +00:00
|
|
|
CStr::from_ptr(context_type).to_str().unwrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_context")]
|
2022-10-20 16:39:12 +00:00
|
|
|
pub fn set_context<'a>(&mut self, context: impl Into<Option<&'a crate::Context>>) {
|
2017-08-02 17:58:33 +00:00
|
|
|
unsafe {
|
2022-10-18 11:16:04 +00:00
|
|
|
ffi::gst_query_set_context(
|
|
|
|
self.as_mut_ptr(),
|
|
|
|
context
|
2022-10-20 16:39:12 +00:00
|
|
|
.into()
|
2022-10-18 11:16:04 +00:00
|
|
|
.map(|context| context.as_mut_ptr())
|
|
|
|
.unwrap_or(ptr::null_mut()),
|
|
|
|
);
|
2017-08-02 17:58:33 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 06:51:19 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2019-04-23 16:53:10 +00:00
|
|
|
declare_concrete_query!(Bitrate, T);
|
2020-06-23 17:24:17 +00:00
|
|
|
|
2020-11-27 13:37:49 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Bitrate<Query> {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_new_bitrate")]
|
2020-06-23 17:24:17 +00:00
|
|
|
pub fn new() -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_bitrate())) }
|
2020-06-23 17:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-27 13:37:49 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2020-06-23 17:24:17 +00:00
|
|
|
impl Default for Bitrate<Query> {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-06 06:51:19 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2022-01-18 09:57:22 +00:00
|
|
|
impl Bitrate {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_bitrate")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_parse_bitrate")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn bitrate(&self) -> u32 {
|
2019-04-23 16:53:10 +00:00
|
|
|
unsafe {
|
2019-07-11 12:34:28 +00:00
|
|
|
let mut bitrate = mem::MaybeUninit::uninit();
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_parse_bitrate(self.as_mut_ptr(), bitrate.as_mut_ptr());
|
2019-07-11 12:34:28 +00:00
|
|
|
bitrate.assume_init()
|
2019-04-23 16:53:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_query_set_bitrate")]
|
2019-04-23 16:53:10 +00:00
|
|
|
pub fn set_bitrate(&mut self, bitrate: u32) {
|
|
|
|
unsafe {
|
2022-01-18 09:57:22 +00:00
|
|
|
ffi::gst_query_set_bitrate(self.as_mut_ptr(), bitrate);
|
2019-04-23 16:53:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-06 06:51:37 +00:00
|
|
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
|
|
|
declare_concrete_query!(Selectable, T);
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
|
|
|
impl Selectable<Query> {
|
|
|
|
#[doc(alias = "gst_query_new_selectable")]
|
|
|
|
pub fn new() -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe { Self(from_glib_full(ffi::gst_query_new_selectable())) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
|
|
|
impl Default for Selectable<Query> {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
|
|
|
impl Selectable {
|
|
|
|
#[doc(alias = "get_selectable")]
|
|
|
|
#[doc(alias = "gst_query_parse_selectable")]
|
|
|
|
pub fn selectable(&self) -> bool {
|
|
|
|
unsafe {
|
|
|
|
let mut selectable = mem::MaybeUninit::uninit();
|
|
|
|
ffi::gst_query_parse_selectable(self.as_mut_ptr(), selectable.as_mut_ptr());
|
|
|
|
from_glib(selectable.assume_init())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(alias = "gst_query_set_selectable")]
|
|
|
|
pub fn set_selectable(&mut self, selectable: bool) {
|
|
|
|
unsafe {
|
|
|
|
ffi::gst_query_set_selectable(self.as_mut_ptr(), selectable.into_glib());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:31:12 +00:00
|
|
|
declare_concrete_query!(Other, T);
|
2017-07-29 11:58:54 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
2020-10-27 17:27:16 +00:00
|
|
|
use crate::ClockTime;
|
2017-07-29 11:58:54 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_writability() {
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::init().unwrap();
|
2017-07-29 11:58:54 +00:00
|
|
|
|
2018-02-15 14:05:51 +00:00
|
|
|
fn check_mut(query: &mut QueryRef) {
|
2020-03-22 14:18:47 +00:00
|
|
|
skip_assert_initialized!();
|
2018-02-15 14:05:51 +00:00
|
|
|
match query.view_mut() {
|
2022-01-18 09:57:22 +00:00
|
|
|
QueryViewMut::Position(p) => {
|
2021-04-11 19:39:50 +00:00
|
|
|
let pos = p.result();
|
2020-10-27 17:27:16 +00:00
|
|
|
assert_eq!(pos.try_into(), Ok(ClockTime::NONE));
|
|
|
|
p.set(Some(3 * ClockTime::SECOND));
|
2021-04-11 19:39:50 +00:00
|
|
|
let pos = p.result();
|
2020-10-27 17:27:16 +00:00
|
|
|
assert_eq!(pos.try_into(), Ok(Some(3 * ClockTime::SECOND)));
|
2018-02-15 14:05:51 +00:00
|
|
|
}
|
|
|
|
_ => panic!("Wrong concrete Query in Query"),
|
2017-07-31 11:16:42 +00:00
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
|
2018-02-15 14:05:51 +00:00
|
|
|
fn check_ref(query: &QueryRef) {
|
2020-03-22 14:18:47 +00:00
|
|
|
skip_assert_initialized!();
|
2018-02-15 14:05:51 +00:00
|
|
|
match query.view() {
|
2022-01-18 09:57:22 +00:00
|
|
|
QueryView::Position(p) => {
|
2021-04-11 19:39:50 +00:00
|
|
|
let pos = p.result();
|
2020-10-27 17:27:16 +00:00
|
|
|
assert_eq!(pos.try_into(), Ok(Some(3 * ClockTime::SECOND)));
|
2022-08-11 14:02:02 +00:00
|
|
|
assert!(!p.as_mut_ptr().is_null());
|
2018-02-15 14:05:51 +00:00
|
|
|
}
|
|
|
|
_ => panic!("Wrong concrete Query in Query"),
|
2017-07-31 11:16:42 +00:00
|
|
|
}
|
2018-02-15 14:05:51 +00:00
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
let mut p = Position::new(crate::Format::Time);
|
2021-04-11 19:39:50 +00:00
|
|
|
let pos = p.result();
|
2020-10-27 17:27:16 +00:00
|
|
|
assert_eq!(pos.try_into(), Ok(ClockTime::NONE));
|
2018-02-15 14:05:51 +00:00
|
|
|
|
2022-11-01 09:10:57 +00:00
|
|
|
p.structure_mut().set("check_mut", true);
|
2018-02-15 14:05:51 +00:00
|
|
|
|
|
|
|
// deref
|
|
|
|
assert!(!p.is_serialized());
|
|
|
|
|
|
|
|
{
|
|
|
|
check_mut(&mut p);
|
|
|
|
|
2021-04-11 19:39:50 +00:00
|
|
|
let structure = p.structure();
|
2018-02-15 14:05:51 +00:00
|
|
|
structure.unwrap().has_field("check_mut");
|
|
|
|
|
|
|
|
// Expected: cannot borrow `p` as mutable because it is also borrowed as immutable
|
|
|
|
//check_mut(&mut p);
|
|
|
|
}
|
|
|
|
|
|
|
|
check_ref(&p);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_into_query() {
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::init().unwrap();
|
|
|
|
let d = Duration::new(crate::Format::Time);
|
2018-02-15 14:05:51 +00:00
|
|
|
|
|
|
|
let mut query: Query = d.into();
|
|
|
|
assert!(query.is_writable());
|
|
|
|
|
|
|
|
let query = query.make_mut();
|
2022-01-18 09:57:22 +00:00
|
|
|
if let QueryViewMut::Duration(d) = query.view_mut() {
|
2020-10-27 17:27:16 +00:00
|
|
|
d.set(Some(2 * ClockTime::SECOND));
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 09:57:22 +00:00
|
|
|
if let QueryView::Duration(d) = query.view() {
|
2021-04-11 19:39:50 +00:00
|
|
|
let duration = d.result();
|
2020-10-27 17:27:16 +00:00
|
|
|
assert_eq!(duration.try_into(), Ok(Some(2 * ClockTime::SECOND)));
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-15 14:05:51 +00:00
|
|
|
|
|
|
|
#[test]
|
2019-03-19 07:58:20 +00:00
|
|
|
fn test_concrete_to_sys() {
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::init().unwrap();
|
2018-02-15 14:05:51 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
let p = Position::new(crate::Format::Time);
|
2022-08-11 14:02:02 +00:00
|
|
|
assert!(!p.as_mut_ptr().is_null());
|
2018-02-15 14:05:51 +00:00
|
|
|
}
|
2022-10-20 16:39:12 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn allocation_need_pool() {
|
|
|
|
crate::init().unwrap();
|
|
|
|
|
2023-01-19 14:08:16 +00:00
|
|
|
let mut a = Allocation::new(Some(&crate::Caps::new_empty_simple("foo/bar")), true);
|
2022-10-20 16:39:12 +00:00
|
|
|
let pool = crate::BufferPool::new();
|
|
|
|
a.add_allocation_pool(Some(&pool), 1024, 1, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn allocation_do_not_need_pool() {
|
|
|
|
crate::init().unwrap();
|
|
|
|
|
2023-01-19 14:08:16 +00:00
|
|
|
let mut a = Allocation::new(Some(&crate::Caps::new_empty_simple("foo/bar")), false);
|
2022-10-20 16:39:12 +00:00
|
|
|
a.add_allocation_pool(crate::BufferPool::NONE, 1024, 1, 4);
|
|
|
|
|
|
|
|
// cannot infer type of the type parameter `T` declared on the enum `Option`
|
|
|
|
//a.add_allocation_pool(None, 1024, 1, 4);
|
|
|
|
|
|
|
|
// This would be possible if we moved the `crate::BufferPool`
|
|
|
|
// as a generic argument instead of using current arg type:
|
|
|
|
// - `pool: Option<&impl IsA<crate::BufferPool>>`
|
|
|
|
//a.add_allocation_pool::<crate::BufferPool>(None, 1024, 1, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn set_uri() {
|
|
|
|
crate::init().unwrap();
|
|
|
|
|
|
|
|
let mut uri_q = Uri::new();
|
|
|
|
uri_q.set_uri("https://test.org");
|
|
|
|
uri_q.set_uri(&String::from("https://test.org"));
|
|
|
|
|
|
|
|
uri_q.set_uri(Some("https://test.org"));
|
|
|
|
uri_q.set_uri(Some(&String::from("https://test.org")));
|
|
|
|
|
|
|
|
// FIXME: this is commented out for now due to an inconsistent
|
|
|
|
// assertion in `GStreamer` which results in critical logs.
|
|
|
|
/*
|
|
|
|
let none: Option<&str> = None;
|
|
|
|
uri_q.set_uri(none);
|
|
|
|
|
|
|
|
let none: Option<String> = None;
|
|
|
|
uri_q.set_uri(none.as_ref());
|
|
|
|
|
|
|
|
uri_q.set_uri::<str>(None);
|
|
|
|
*/
|
|
|
|
}
|
2017-07-29 11:58:54 +00:00
|
|
|
}
|