mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-23 01:51:06 +00:00
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:
parent
05e59747ab
commit
433fa3da5c
2 changed files with 24 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue