gstreamer_rtp/
rtp_header_extension.rs1use glib::{object::IsA, translate::*};
2
3use crate::{ffi, RTPHeaderExtension, RTPHeaderExtensionFlags};
4
5pub trait RTPHeaderExtensionExtManual: IsA<RTPHeaderExtension> + 'static {
6 #[doc(alias = "gst_rtp_header_extension_read")]
7 fn read(
8 &self,
9 read_flags: RTPHeaderExtensionFlags,
10 data: &[u8],
11 buffer: &mut gst::BufferRef,
12 ) -> bool {
13 let size = data.len();
14 unsafe {
15 from_glib(ffi::gst_rtp_header_extension_read(
16 self.as_ref().to_glib_none().0,
17 read_flags.into_glib(),
18 data.to_glib_none().0,
19 size,
20 buffer.as_mut_ptr(),
21 ))
22 }
23 }
24
25 #[doc(alias = "gst_rtp_header_extension_write")]
26 fn write(
27 &self,
28 input_meta: &gst::Buffer,
29 write_flags: RTPHeaderExtensionFlags,
30 output: &gst::BufferRef,
31 data: &mut [u8],
32 ) -> Result<usize, glib::BoolError> {
33 let size = data.len();
34 unsafe {
35 let res = ffi::gst_rtp_header_extension_write(
36 self.as_ref().to_glib_none().0,
37 input_meta.to_glib_none().0,
38 write_flags.into_glib(),
39 mut_override(output.as_ptr()),
40 data.to_glib_none().0,
41 size,
42 );
43
44 if res < 0 {
45 Err(glib::bool_error!("Failed to write header extension"))
46 } else {
47 Ok(res as usize)
48 }
49 }
50 }
51
52 #[doc(alias = "gst_rtp_header_extension_set_caps_from_attributes")]
53 fn set_caps_from_attributes(&self, caps: &mut gst::CapsRef) -> bool {
54 unsafe {
55 from_glib(ffi::gst_rtp_header_extension_set_caps_from_attributes(
56 self.as_ref().to_glib_none().0,
57 caps.as_mut_ptr(),
58 ))
59 }
60 }
61
62 #[doc(alias = "gst_rtp_header_extension_set_caps_from_attributes_helper")]
63 fn set_caps_from_attributes_helper(&self, caps: &mut gst::CapsRef, attributes: &str) -> bool {
64 unsafe {
65 from_glib(
66 ffi::gst_rtp_header_extension_set_caps_from_attributes_helper(
67 self.as_ref().to_glib_none().0,
68 caps.as_mut_ptr(),
69 attributes.to_glib_none().0,
70 ),
71 )
72 }
73 }
74
75 #[doc(alias = "gst_rtp_header_extension_update_non_rtp_src_caps")]
76 fn update_non_rtp_src_caps(&self, caps: &mut gst::CapsRef) -> bool {
77 unsafe {
78 from_glib(ffi::gst_rtp_header_extension_update_non_rtp_src_caps(
79 self.as_ref().to_glib_none().0,
80 caps.as_mut_ptr(),
81 ))
82 }
83 }
84}
85
86impl<O: IsA<RTPHeaderExtension>> RTPHeaderExtensionExtManual for O {}