forked from mirrors/gstreamer-rs
query: add constructor on target types
... and deprecate the `Query::new_*` forms.
This commit is contained in:
parent
884e5e4e4a
commit
c94baa4fe8
3 changed files with 231 additions and 6 deletions
|
@ -63,7 +63,7 @@ fn example_main() {
|
||||||
// Create a new position query and send it to the pipeline.
|
// Create a new position query and send it to the pipeline.
|
||||||
// This will traverse all elements in the pipeline, until one feels
|
// This will traverse all elements in the pipeline, until one feels
|
||||||
// capable of answering the query.
|
// capable of answering the query.
|
||||||
let mut q = gst::Query::new_position(gst::Format::Time);
|
let mut q = gst::query::Position::new(gst::Format::Time);
|
||||||
if pipeline.query(&mut q) {
|
if pipeline.query(&mut q) {
|
||||||
Some(q.get_result())
|
Some(q.get_result())
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,7 +77,7 @@ fn example_main() {
|
||||||
// Create a new duration query and send it to the pipeline.
|
// Create a new duration query and send it to the pipeline.
|
||||||
// This will traverse all elements in the pipeline, until one feels
|
// This will traverse all elements in the pipeline, until one feels
|
||||||
// capable of answering the query.
|
// capable of answering the query.
|
||||||
let mut q = gst::Query::new_duration(gst::Format::Time);
|
let mut q = gst::query::Duration::new(gst::Format::Time);
|
||||||
if pipeline.query(&mut q) {
|
if pipeline.query(&mut q) {
|
||||||
Some(q.get_result())
|
Some(q.get_result())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,6 +26,7 @@ gst_define_mini_object_wrapper!(Query, QueryRef, gst_sys::GstQuery, [Debug,], ||
|
||||||
});
|
});
|
||||||
|
|
||||||
impl Query {
|
impl Query {
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Position::new` instead")]
|
||||||
pub fn new_position(fmt: ::Format) -> Position<Self> {
|
pub fn new_position(fmt: ::Format) -> Position<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -35,6 +36,7 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Duration::new` instead")]
|
||||||
pub fn new_duration(fmt: ::Format) -> Duration<Self> {
|
pub fn new_duration(fmt: ::Format) -> Duration<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -44,11 +46,13 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Latency::new` instead")]
|
||||||
pub fn new_latency() -> Latency<Self> {
|
pub fn new_latency() -> Latency<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe { Latency::<Self>(from_glib_full(gst_sys::gst_query_new_latency())) }
|
unsafe { Latency::<Self>(from_glib_full(gst_sys::gst_query_new_latency())) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Seeking::new` instead")]
|
||||||
pub fn new_seeking(fmt: ::Format) -> Seeking<Self> {
|
pub fn new_seeking(fmt: ::Format) -> Seeking<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -58,6 +62,7 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Segment::new` instead")]
|
||||||
pub fn new_segment(fmt: ::Format) -> Segment<Self> {
|
pub fn new_segment(fmt: ::Format) -> Segment<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -67,6 +72,7 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Convert::new` instead")]
|
||||||
pub fn new_convert<V: Into<GenericFormattedValue>>(
|
pub fn new_convert<V: Into<GenericFormattedValue>>(
|
||||||
value: V,
|
value: V,
|
||||||
dest_fmt: ::Format,
|
dest_fmt: ::Format,
|
||||||
|
@ -82,11 +88,13 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Formats::new` instead")]
|
||||||
pub fn new_formats() -> Formats<Self> {
|
pub fn new_formats() -> Formats<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe { Formats::<Self>(from_glib_full(gst_sys::gst_query_new_formats())) }
|
unsafe { Formats::<Self>(from_glib_full(gst_sys::gst_query_new_formats())) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Buffering::new` instead")]
|
||||||
pub fn new_buffering(fmt: ::Format) -> Buffering<Self> {
|
pub fn new_buffering(fmt: ::Format) -> Buffering<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -96,6 +104,7 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Custom::new` instead")]
|
||||||
pub fn new_custom(structure: ::Structure) -> Custom<Self> {
|
pub fn new_custom(structure: ::Structure) -> Custom<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -106,11 +115,13 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Uri::new` instead")]
|
||||||
pub fn new_uri() -> Uri<Self> {
|
pub fn new_uri() -> Uri<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe { Uri::<Self>(from_glib_full(gst_sys::gst_query_new_uri())) }
|
unsafe { Uri::<Self>(from_glib_full(gst_sys::gst_query_new_uri())) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Allocation::new` instead")]
|
||||||
pub fn new_allocation(caps: &::Caps, need_pool: bool) -> Allocation<Self> {
|
pub fn new_allocation(caps: &::Caps, need_pool: bool) -> Allocation<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -121,11 +132,13 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Scheduling::new` instead")]
|
||||||
pub fn new_scheduling() -> Scheduling<Self> {
|
pub fn new_scheduling() -> Scheduling<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe { Scheduling::<Self>(from_glib_full(gst_sys::gst_query_new_scheduling())) }
|
unsafe { Scheduling::<Self>(from_glib_full(gst_sys::gst_query_new_scheduling())) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::AcceptCaps::new` instead")]
|
||||||
pub fn new_accept_caps(caps: &::Caps) -> AcceptCaps<Self> {
|
pub fn new_accept_caps(caps: &::Caps) -> AcceptCaps<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -135,6 +148,7 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Caps::new` instead")]
|
||||||
pub fn new_caps(filter: Option<&::Caps>) -> Caps<Self> {
|
pub fn new_caps(filter: Option<&::Caps>) -> Caps<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -144,11 +158,13 @@ impl Query {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Drain::new` instead")]
|
||||||
pub fn new_drain() -> Drain<Self> {
|
pub fn new_drain() -> Drain<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe { Drain::<Self>(from_glib_full(gst_sys::gst_query_new_drain())) }
|
unsafe { Drain::<Self>(from_glib_full(gst_sys::gst_query_new_drain())) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Context::new` instead")]
|
||||||
pub fn new_context(context_type: &str) -> Context<Self> {
|
pub fn new_context(context_type: &str) -> Context<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -159,6 +175,7 @@ impl Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||||
|
#[deprecated(since = "0.16.0", note = "use `query::Bitrate::new` instead")]
|
||||||
pub fn new_bitrate() -> Bitrate<Self> {
|
pub fn new_bitrate() -> Bitrate<Self> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe { Bitrate::<Self>(from_glib_full(gst_sys::gst_query_new_bitrate())) }
|
unsafe { Bitrate::<Self>(from_glib_full(gst_sys::gst_query_new_bitrate())) }
|
||||||
|
@ -363,6 +380,17 @@ macro_rules! declare_concrete_query(
|
||||||
);
|
);
|
||||||
|
|
||||||
declare_concrete_query!(Position, T);
|
declare_concrete_query!(Position, T);
|
||||||
|
impl Position<Query> {
|
||||||
|
pub fn new(fmt: ::Format) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_position(
|
||||||
|
fmt.to_glib(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Position<T> {
|
impl<T: AsPtr> Position<T> {
|
||||||
pub fn get_result(&self) -> GenericFormattedValue {
|
pub fn get_result(&self) -> GenericFormattedValue {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -401,6 +429,17 @@ impl<T: AsMutPtr> Position<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Duration, T);
|
declare_concrete_query!(Duration, T);
|
||||||
|
impl Duration<Query> {
|
||||||
|
pub fn new(fmt: ::Format) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_duration(
|
||||||
|
fmt.to_glib(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Duration<T> {
|
impl<T: AsPtr> Duration<T> {
|
||||||
pub fn get_result(&self) -> GenericFormattedValue {
|
pub fn get_result(&self) -> GenericFormattedValue {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -439,6 +478,19 @@ impl<T: AsMutPtr> Duration<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Latency, T);
|
declare_concrete_query!(Latency, T);
|
||||||
|
impl Latency<Query> {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe { Self(from_glib_full(gst_sys::gst_query_new_latency())) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Latency<Query> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Latency<T> {
|
impl<T: AsPtr> Latency<T> {
|
||||||
pub fn get_result(&self) -> (bool, ::ClockTime, ::ClockTime) {
|
pub fn get_result(&self) -> (bool, ::ClockTime, ::ClockTime) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -476,9 +528,23 @@ impl<T: AsMutPtr> Latency<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Jitter, T);
|
declare_concrete_query!(Jitter, T);
|
||||||
|
// FIXME no gst_sys::gst_query_new_jitter
|
||||||
|
|
||||||
declare_concrete_query!(Rate, T);
|
declare_concrete_query!(Rate, T);
|
||||||
|
// FIXME no gst_sys::gst_query_new_rate
|
||||||
|
|
||||||
declare_concrete_query!(Seeking, T);
|
declare_concrete_query!(Seeking, T);
|
||||||
|
impl Seeking<Query> {
|
||||||
|
pub fn new(fmt: ::Format) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_seeking(
|
||||||
|
fmt.to_glib(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Seeking<T> {
|
impl<T: AsPtr> Seeking<T> {
|
||||||
pub fn get_result(&self) -> (bool, GenericFormattedValue, GenericFormattedValue) {
|
pub fn get_result(&self) -> (bool, GenericFormattedValue, GenericFormattedValue) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -539,6 +605,17 @@ impl<T: AsMutPtr> Seeking<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Segment, T);
|
declare_concrete_query!(Segment, T);
|
||||||
|
impl Segment<Query> {
|
||||||
|
pub fn new(fmt: ::Format) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_segment(
|
||||||
|
fmt.to_glib(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Segment<T> {
|
impl<T: AsPtr> Segment<T> {
|
||||||
pub fn get_result(&self) -> (f64, GenericFormattedValue, GenericFormattedValue) {
|
pub fn get_result(&self) -> (f64, GenericFormattedValue, GenericFormattedValue) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -598,6 +675,20 @@ impl<T: AsMutPtr> Segment<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Convert, T);
|
declare_concrete_query!(Convert, T);
|
||||||
|
impl Convert<Query> {
|
||||||
|
pub fn new<V: Into<GenericFormattedValue>>(value: V, dest_fmt: ::Format) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
let value = value.into();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_convert(
|
||||||
|
value.get_format().to_glib(),
|
||||||
|
value.get_value(),
|
||||||
|
dest_fmt.to_glib(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Convert<T> {
|
impl<T: AsPtr> Convert<T> {
|
||||||
pub fn get_result(&self) -> (GenericFormattedValue, GenericFormattedValue) {
|
pub fn get_result(&self) -> (GenericFormattedValue, GenericFormattedValue) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -659,6 +750,19 @@ impl<T: AsMutPtr> Convert<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Formats, T);
|
declare_concrete_query!(Formats, T);
|
||||||
|
impl Formats<Query> {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe { Self(from_glib_full(gst_sys::gst_query_new_formats())) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Formats<Query> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Formats<T> {
|
impl<T: AsPtr> Formats<T> {
|
||||||
pub fn get_result(&self) -> Vec<::Format> {
|
pub fn get_result(&self) -> Vec<::Format> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -692,6 +796,17 @@ impl<T: AsMutPtr> Formats<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Buffering, T);
|
declare_concrete_query!(Buffering, T);
|
||||||
|
impl Buffering<Query> {
|
||||||
|
pub fn new(fmt: ::Format) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_buffering(
|
||||||
|
fmt.to_glib(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Buffering<T> {
|
impl<T: AsPtr> Buffering<T> {
|
||||||
pub fn get_format(&self) -> ::Format {
|
pub fn get_format(&self) -> ::Format {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -878,8 +993,32 @@ impl<T: AsMutPtr> Buffering<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Custom, T);
|
declare_concrete_query!(Custom, T);
|
||||||
|
impl Custom<Query> {
|
||||||
|
pub fn new(structure: ::Structure) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_custom(
|
||||||
|
gst_sys::GST_QUERY_CUSTOM,
|
||||||
|
structure.into_ptr(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Uri, T);
|
declare_concrete_query!(Uri, T);
|
||||||
|
impl Uri<Query> {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe { Self(from_glib_full(gst_sys::gst_query_new_uri())) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Uri<Query> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Uri<T> {
|
impl<T: AsPtr> Uri<T> {
|
||||||
pub fn get_uri(&self) -> Option<String> {
|
pub fn get_uri(&self) -> Option<String> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -925,6 +1064,18 @@ impl<T: AsMutPtr> Uri<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Allocation, T);
|
declare_concrete_query!(Allocation, T);
|
||||||
|
impl Allocation<Query> {
|
||||||
|
pub fn new(caps: &::Caps, need_pool: bool) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_allocation(
|
||||||
|
caps.as_mut_ptr(),
|
||||||
|
need_pool.to_glib(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Allocation<T> {
|
impl<T: AsPtr> Allocation<T> {
|
||||||
pub fn get(&self) -> (&::CapsRef, bool) {
|
pub fn get(&self) -> (&::CapsRef, bool) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1086,6 +1237,19 @@ impl<T: AsMutPtr> Allocation<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Scheduling, T);
|
declare_concrete_query!(Scheduling, T);
|
||||||
|
impl Scheduling<Query> {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe { Self(from_glib_full(gst_sys::gst_query_new_scheduling())) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Scheduling<Query> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Scheduling<T> {
|
impl<T: AsPtr> Scheduling<T> {
|
||||||
pub fn has_scheduling_mode(&self, mode: ::PadMode) -> bool {
|
pub fn has_scheduling_mode(&self, mode: ::PadMode) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1174,6 +1338,17 @@ impl<T: AsMutPtr> Scheduling<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(AcceptCaps, T);
|
declare_concrete_query!(AcceptCaps, T);
|
||||||
|
impl AcceptCaps<Query> {
|
||||||
|
pub fn new(caps: &::Caps) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_accept_caps(
|
||||||
|
caps.as_mut_ptr(),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> AcceptCaps<T> {
|
impl<T: AsPtr> AcceptCaps<T> {
|
||||||
pub fn get_caps(&self) -> &::CapsRef {
|
pub fn get_caps(&self) -> &::CapsRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1205,6 +1380,17 @@ impl<T: AsMutPtr> AcceptCaps<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Caps, T);
|
declare_concrete_query!(Caps, T);
|
||||||
|
impl Caps<Query> {
|
||||||
|
pub fn new(filter: Option<&::Caps>) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_caps(
|
||||||
|
filter.to_glib_none().0,
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Caps<T> {
|
impl<T: AsPtr> Caps<T> {
|
||||||
pub fn get_filter(&self) -> Option<&::CapsRef> {
|
pub fn get_filter(&self) -> Option<&::CapsRef> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1248,8 +1434,31 @@ impl<T: AsMutPtr> Caps<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Drain, T);
|
declare_concrete_query!(Drain, T);
|
||||||
|
impl Drain<Query> {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe { Self(from_glib_full(gst_sys::gst_query_new_drain())) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Drain<Query> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Context, T);
|
declare_concrete_query!(Context, T);
|
||||||
|
impl Context<Query> {
|
||||||
|
pub fn new(context_type: &str) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
Self(from_glib_full(gst_sys::gst_query_new_context(
|
||||||
|
context_type.to_glib_none().0,
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Context<T> {
|
impl<T: AsPtr> Context<T> {
|
||||||
pub fn get_context(&self) -> Option<&::ContextRef> {
|
pub fn get_context(&self) -> Option<&::ContextRef> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1288,6 +1497,22 @@ impl<T: AsMutPtr> Context<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_query!(Bitrate, T);
|
declare_concrete_query!(Bitrate, T);
|
||||||
|
|
||||||
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||||
|
impl Bitrate<Query> {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe { Self(from_glib_full(gst_sys::gst_query_new_bitrate())) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||||
|
impl Default for Bitrate<Query> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: AsPtr> Bitrate<T> {
|
impl<T: AsPtr> Bitrate<T> {
|
||||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||||
pub fn get_bitrate(&self) -> u32 {
|
pub fn get_bitrate(&self) -> u32 {
|
||||||
|
@ -1347,7 +1572,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut p = Query::new_position(::Format::Time);
|
let mut p = Position::new(::Format::Time);
|
||||||
let pos = p.get_result();
|
let pos = p.get_result();
|
||||||
assert_eq!(pos.try_into(), Ok(::CLOCK_TIME_NONE));
|
assert_eq!(pos.try_into(), Ok(::CLOCK_TIME_NONE));
|
||||||
|
|
||||||
|
@ -1372,7 +1597,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_into_query() {
|
fn test_into_query() {
|
||||||
::init().unwrap();
|
::init().unwrap();
|
||||||
let d = Query::new_duration(::Format::Time);
|
let d = Duration::new(::Format::Time);
|
||||||
|
|
||||||
let mut query: Query = d.into();
|
let mut query: Query = d.into();
|
||||||
assert!(query.is_writable());
|
assert!(query.is_writable());
|
||||||
|
@ -1398,7 +1623,7 @@ mod tests {
|
||||||
fn test_concrete_to_sys() {
|
fn test_concrete_to_sys() {
|
||||||
::init().unwrap();
|
::init().unwrap();
|
||||||
|
|
||||||
let p = Query::new_position(::Format::Time);
|
let p = Position::new(::Format::Time);
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(!p.as_mut_ptr().is_null());
|
assert!(!p.as_mut_ptr().is_null());
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::Message) {
|
||||||
|
|
||||||
custom_data.playing = new_state == gst::State::Playing;
|
custom_data.playing = new_state == gst::State::Playing;
|
||||||
if custom_data.playing {
|
if custom_data.playing {
|
||||||
let mut seeking = gst::Query::new_seeking(gst::Format::Time);
|
let mut seeking = gst::query::Seeking::new(gst::Format::Time);
|
||||||
if custom_data.playbin.query(&mut seeking) {
|
if custom_data.playbin.query(&mut seeking) {
|
||||||
let (seekable, start, end) = seeking.get_result();
|
let (seekable, start, end) = seeking.get_result();
|
||||||
custom_data.seek_enabled = seekable;
|
custom_data.seek_enabled = seekable;
|
||||||
|
|
Loading…
Reference in a new issue