forked from mirrors/gstreamer-rs
rtp_buffer: Add methods to manipulate padding
Open Rust APIs for: * gst_rtp_buffer_get_padding * gst_rtp_buffer_set_padding
This commit is contained in:
parent
33f75191d5
commit
668a9bbf58
1 changed files with 39 additions and 0 deletions
|
@ -184,6 +184,11 @@ impl<'a> RTPBuffer<'a, Writable> {
|
||||||
ffi::gst_rtp_buffer_remove_extension_data(&mut self.rtp_buffer);
|
ffi::gst_rtp_buffer_remove_extension_data(&mut self.rtp_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_rtp_buffer_set_padding")]
|
||||||
|
pub fn set_padding(&mut self, padding: bool) {
|
||||||
|
unsafe { ffi::gst_rtp_buffer_set_padding(&mut self.rtp_buffer, padding.into_glib()) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> RTPBuffer<'a, T> {
|
impl<'a, T> RTPBuffer<'a, T> {
|
||||||
|
@ -345,6 +350,16 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "get_padding")]
|
||||||
|
#[doc(alias = "gst_rtp_buffer_get_padding")]
|
||||||
|
pub fn has_padding(&self) -> bool {
|
||||||
|
unsafe {
|
||||||
|
from_glib(ffi::gst_rtp_buffer_get_padding(
|
||||||
|
glib::translate::mut_override(&self.rtp_buffer),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> Drop for RTPBuffer<'a, T> {
|
impl<'a, T> Drop for RTPBuffer<'a, T> {
|
||||||
|
@ -542,4 +557,28 @@ mod tests {
|
||||||
assert_eq!(appbits, extracted_appbits);
|
assert_eq!(appbits, extracted_appbits);
|
||||||
assert_eq!(data, &extension_data);
|
assert_eq!(data, &extension_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_padding() {
|
||||||
|
gst::init().unwrap();
|
||||||
|
|
||||||
|
let csrc_count = 2;
|
||||||
|
let payload_size = 16;
|
||||||
|
let mut buffer = gst::Buffer::new_rtp_with_sizes(payload_size, 4, csrc_count).unwrap();
|
||||||
|
{
|
||||||
|
let rtp_buffer = RTPBuffer::from_buffer_readable(&buffer).unwrap();
|
||||||
|
assert!(rtp_buffer.has_padding());
|
||||||
|
}
|
||||||
|
{
|
||||||
|
let buffer = buffer.get_mut().unwrap();
|
||||||
|
let mut rtp_buffer = RTPBuffer::from_buffer_writable(buffer).unwrap();
|
||||||
|
|
||||||
|
rtp_buffer.set_padding(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let rtp_buffer = RTPBuffer::from_buffer_readable(&buffer).unwrap();
|
||||||
|
assert!(!rtp_buffer.has_padding());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue