mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-09-02 01:43:49 +00:00
gst: manual changes further to QueryType generation
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1740>
This commit is contained in:
parent
98b5eb593e
commit
bf982f4221
1 changed files with 48 additions and 0 deletions
|
@ -15,12 +15,33 @@ use crate::{
|
|||
ffi,
|
||||
format::{CompatibleFormattedValue, FormattedValue, GenericFormattedValue},
|
||||
structure::*,
|
||||
QueryType,
|
||||
};
|
||||
|
||||
mini_object_wrapper!(Query, QueryRef, ffi::GstQuery, || {
|
||||
ffi::gst_query_get_type()
|
||||
});
|
||||
|
||||
impl QueryType {
|
||||
#[doc(alias = "GST_QUERY_IS_UPSTREAM")]
|
||||
#[inline]
|
||||
pub fn is_upstream(self) -> bool {
|
||||
(self.into_glib() as u32) & ffi::GST_QUERY_TYPE_UPSTREAM != 0
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_QUERY_IS_DOWNSTREAM")]
|
||||
#[inline]
|
||||
pub fn is_downstream(self) -> bool {
|
||||
(self.into_glib() as u32) & ffi::GST_QUERY_TYPE_DOWNSTREAM != 0
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_QUERY_IS_SERIALIZED")]
|
||||
#[inline]
|
||||
pub fn is_serialized(self) -> bool {
|
||||
(self.into_glib() as u32) & ffi::GST_QUERY_TYPE_SERIALIZED != 0
|
||||
}
|
||||
}
|
||||
|
||||
impl QueryRef {
|
||||
#[doc(alias = "get_structure")]
|
||||
#[doc(alias = "gst_query_get_structure")]
|
||||
|
@ -64,6 +85,13 @@ impl QueryRef {
|
|||
unsafe { ((*self.as_ptr()).type_ as u32) & ffi::GST_QUERY_TYPE_SERIALIZED != 0 }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_type")]
|
||||
#[doc(alias = "GST_QUERY_TYPE")]
|
||||
#[inline]
|
||||
pub fn type_(&self) -> QueryType {
|
||||
unsafe { from_glib((*self.as_ptr()).type_) }
|
||||
}
|
||||
|
||||
pub fn view(&self) -> QueryView {
|
||||
unsafe {
|
||||
let type_ = (*self.as_ptr()).type_;
|
||||
|
@ -2185,4 +2213,24 @@ mod tests {
|
|||
uri_q.set_uri::<str>(None);
|
||||
*/
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn query_type() {
|
||||
crate::init().unwrap();
|
||||
|
||||
assert!(!QueryType::Allocation.is_upstream());
|
||||
assert!(QueryType::Allocation.is_downstream());
|
||||
assert!(QueryType::Allocation.is_serialized());
|
||||
|
||||
assert!(QueryType::Latency.is_upstream());
|
||||
assert!(QueryType::Latency.is_downstream());
|
||||
assert!(!QueryType::Latency.is_serialized());
|
||||
|
||||
assert!(QueryType::Scheduling.is_upstream());
|
||||
assert!(!QueryType::Scheduling.is_downstream());
|
||||
assert!(!QueryType::Scheduling.is_serialized());
|
||||
|
||||
let lat = Latency::new();
|
||||
assert_eq!(lat.type_(), QueryType::Latency);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue