Commit 0112d228 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Various manual 1.14 API additions and remove deprecated functions

parent 4864a1e0
......@@ -7,8 +7,6 @@ use Object;
use Pad;
use PadDirection;
use PadPresence;
#[cfg(any(feature = "v1_14", feature = "dox"))]
use StaticPadTemplate;
use ffi;
#[cfg(any(feature = "v1_14", feature = "dox"))]
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"))]
pub fn new_with_gtype(name_template: &str, direction: PadDirection, presence: PadPresence, caps: &Caps, pad_type: glib::types::Type) -> PadTemplate {
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 {
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 {
self.len() == 0
}
......
......@@ -1160,6 +1160,7 @@ impl<'a> Redirect<'a> {
struct MessageBuilder<'a> {
src: Option<Object>,
seqnum: Option<Seqnum>,
#[allow(unused)]
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
/*fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
#[cfg(any(feature = "v1_14", feature = "dox"))]
fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
Self {
other_fields: self.other_fields.iter().cloned()
.chain(other_fields.iter().cloned())
.collect(),
.. self
}
}*/
}
}
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
/*pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
#[cfg(any(feature = "v1_14", feature = "dox"))]
pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
Self {
builder: self.builder.other_fields(other_fields),
.. self
}
}*/
}
pub fn build(mut self) -> Message {
assert_initialized_main_thread!();
......@@ -1233,18 +1234,17 @@ macro_rules! message_builder_generic_impl {
ffi::gst_message_set_seqnum(msg, seqnum.to_glib());
}
if !self.builder.other_fields.is_empty() {
// issue with argument-less messages. We need the function
// ffi::gst_message_writable_structure to sort this out
// and this function will be available in GStreamer 1.14
// 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 {
structure.set_value(k, v.to_send_value());
#[cfg(any(feature = "v1_14", feature = "dox"))]
{
if !self.builder.other_fields.is_empty() {
let structure = ffi::gst_message_writable_structure(msg);
if !structure.is_null() {
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 {
......
......@@ -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 {
let position = position.into();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment