mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-09-28 06:42:08 +00:00
Various manual 1.14 API additions and remove deprecated functions
This commit is contained in:
parent
4864a1e089
commit
0112d22804
5 changed files with 34 additions and 51 deletions
|
@ -7,8 +7,6 @@ use Object;
|
||||||
use Pad;
|
use Pad;
|
||||||
use PadDirection;
|
use PadDirection;
|
||||||
use PadPresence;
|
use PadPresence;
|
||||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
||||||
use StaticPadTemplate;
|
|
||||||
use ffi;
|
use ffi;
|
||||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||||
use glib;
|
use glib;
|
||||||
|
@ -41,14 +39,6 @@ impl PadTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
||||||
pub fn new_from_static_pad_template_with_gtype(pad_template: &mut StaticPadTemplate, pad_type: glib::types::Type) -> PadTemplate {
|
|
||||||
assert_initialized_main_thread!();
|
|
||||||
unsafe {
|
|
||||||
from_glib_none(ffi::gst_pad_template_new_from_static_pad_template_with_gtype(pad_template.to_glib_none_mut().0, pad_type.to_glib()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||||
pub fn new_with_gtype(name_template: &str, direction: PadDirection, presence: PadPresence, caps: &Caps, pad_type: glib::types::Type) -> PadTemplate {
|
pub fn new_with_gtype(name_template: &str, direction: PadDirection, presence: PadPresence, caps: &Caps, pad_type: glib::types::Type) -> PadTemplate {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
|
@ -65,10 +65,27 @@ impl BufferListRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||||
|
pub fn get_writable(&mut self, idx: u32) -> Option<&mut BufferRef> {
|
||||||
|
unsafe {
|
||||||
|
let ptr = ffi::gst_buffer_list_get_writable(self.as_mut_ptr(), idx);
|
||||||
|
if ptr.is_null() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(BufferRef::from_mut_ptr(ptr))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
unsafe { ffi::gst_buffer_list_length(self.as_mut_ptr()) as usize }
|
unsafe { ffi::gst_buffer_list_length(self.as_mut_ptr()) as usize }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||||
|
pub fn calculate_size(&self) -> usize {
|
||||||
|
unsafe { ffi::gst_buffer_list_calculate_size(self.as_mut_ptr()) as usize }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.len() == 0
|
self.len() == 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -1160,6 +1160,7 @@ impl<'a> Redirect<'a> {
|
||||||
struct MessageBuilder<'a> {
|
struct MessageBuilder<'a> {
|
||||||
src: Option<Object>,
|
src: Option<Object>,
|
||||||
seqnum: Option<Seqnum>,
|
seqnum: Option<Seqnum>,
|
||||||
|
#[allow(unused)]
|
||||||
other_fields: Vec<(&'a str, &'a ToSendValue)>,
|
other_fields: Vec<(&'a str, &'a ToSendValue)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1189,15 +1190,15 @@ impl<'a> MessageBuilder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: restore clone_and_chain_other_fields method and condition it to the "v1_14" feature
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||||
/*fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
|
fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
|
||||||
Self {
|
Self {
|
||||||
other_fields: self.other_fields.iter().cloned()
|
other_fields: self.other_fields.iter().cloned()
|
||||||
.chain(other_fields.iter().cloned())
|
.chain(other_fields.iter().cloned())
|
||||||
.collect(),
|
.collect(),
|
||||||
.. self
|
.. self
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! message_builder_generic_impl {
|
macro_rules! message_builder_generic_impl {
|
||||||
|
@ -1216,13 +1217,13 @@ macro_rules! message_builder_generic_impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: restore other_fields method and condition it to the "v1_14" feature
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||||
/*pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
|
pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
|
||||||
Self {
|
Self {
|
||||||
builder: self.builder.other_fields(other_fields),
|
builder: self.builder.other_fields(other_fields),
|
||||||
.. self
|
.. self
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
pub fn build(mut self) -> Message {
|
pub fn build(mut self) -> Message {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
@ -1233,18 +1234,17 @@ macro_rules! message_builder_generic_impl {
|
||||||
ffi::gst_message_set_seqnum(msg, seqnum.to_glib());
|
ffi::gst_message_set_seqnum(msg, seqnum.to_glib());
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.builder.other_fields.is_empty() {
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||||
// issue with argument-less messages. We need the function
|
{
|
||||||
// ffi::gst_message_writable_structure to sort this out
|
if !self.builder.other_fields.is_empty() {
|
||||||
// and this function will be available in GStreamer 1.14
|
let structure = ffi::gst_message_writable_structure(msg);
|
||||||
// See https://github.com/sdroege/gstreamer-rs/pull/75
|
|
||||||
// and https://bugzilla.gnome.org/show_bug.cgi?id=792928
|
|
||||||
let structure = ffi::gst_message_get_structure(msg);
|
|
||||||
if !structure.is_null() {
|
|
||||||
let structure = StructureRef::from_glib_borrow_mut(structure as *mut _);
|
|
||||||
|
|
||||||
for (k, v) in self.builder.other_fields {
|
if !structure.is_null() {
|
||||||
structure.set_value(k, v.to_send_value());
|
let structure = StructureRef::from_glib_borrow_mut(structure as *mut _);
|
||||||
|
|
||||||
|
for (k, v) in self.builder.other_fields {
|
||||||
|
structure.set_value(k, v.to_send_value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,11 +93,6 @@ impl SampleRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deprecated(since = "0.10.1", note = "please use `get_info` instead")]
|
|
||||||
pub fn get_structure(&self) -> Option<&StructureRef> {
|
|
||||||
self.get_info()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StaticType for SampleRef {
|
impl StaticType for SampleRef {
|
||||||
|
|
|
@ -265,25 +265,6 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_position<V: Into<T>>(&self, running_time: V) -> T {
|
|
||||||
let running_time = running_time.into();
|
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
|
||||||
assert_eq!(self.get_format(), running_time.get_format());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
T::from_raw(
|
|
||||||
self.get_format(),
|
|
||||||
ffi::gst_segment_to_position(
|
|
||||||
&self.0,
|
|
||||||
self.get_format().to_glib(),
|
|
||||||
running_time.to_raw_value() as u64,
|
|
||||||
) as i64,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn to_running_time<V: Into<T>>(&self, position: V) -> T {
|
pub fn to_running_time<V: Into<T>>(&self, position: V) -> T {
|
||||||
let position = position.into();
|
let position = position.into();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue