rtp_buffer: bind buffer getters

* Expose the buffer field, useful to look up flags and meta

* Expose the payload_buffer API, useful to avoid copies, for instance
  when storing in an adapter

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1008>
This commit is contained in:
Mathieu Duponchelle 2022-04-14 01:10:04 +02:00 committed by Sebastian Dröge
parent 05e59747ab
commit 433fa3da5c
2 changed files with 24 additions and 0 deletions

View file

@ -3,6 +3,7 @@
#![cfg_attr(feature = "dox", feature(doc_cfg))]
#![allow(clippy::manual_range_contains)]
#![allow(clippy::non_send_fields_in_send_ty)]
#![allow(clippy::missing_safety_doc)]
#![doc = include_str!("../README.md")]
pub use ffi;

View file

@ -304,6 +304,29 @@ impl<'a, T> RTPBuffer<'a, T> {
}
}
#[doc(alias = "get_payload_buffer")]
#[doc(alias = "gst_rtp_buffer_get_payload_buffer")]
pub fn payload_buffer(&self) -> Result<gst::Buffer, glib::BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::gst_rtp_buffer_get_payload_buffer(
glib::translate::mut_override(&self.rtp_buffer),
))
.ok_or_else(|| glib::bool_error!("Failed to get payload buffer"))
}
}
pub fn buffer(&self) -> Option<&gst::BufferRef> {
unsafe {
let ptr = self.rtp_buffer.buffer;
if ptr.is_null() {
None
} else {
Some(gst::BufferRef::from_ptr(ptr))
}
}
}
#[doc(alias = "get_extension")]
pub fn is_extension(&self) -> bool {
unsafe {