Skip to content

Commit

Permalink
Various manual 1.14 API additions and remove deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege authored and charlie-ht committed Oct 28, 2018
1 parent 74fa57a commit 509579d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 52 deletions.
10 changes: 0 additions & 10 deletions gstreamer/src/auto/pad_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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!();
Expand Down
17 changes: 17 additions & 0 deletions gstreamer/src/bufferlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
36 changes: 18 additions & 18 deletions gstreamer/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)>,
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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!();
Expand All @@ -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());
}
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions gstreamer/src/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 0 additions & 19 deletions gstreamer/src/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 509579d

Please sign in to comment.