mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-01-03 13:58:42 +00:00
gstreamer-rtp: Update manual code to 2018 edition
This commit is contained in:
parent
1ea6fac9f4
commit
db8b8be2dd
3 changed files with 72 additions and 99 deletions
|
@ -11,30 +11,28 @@ homepage = "https://gstreamer.freedesktop.org"
|
||||||
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_rtp/"
|
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_rtp/"
|
||||||
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
|
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
once_cell = "1.0"
|
once_cell = "1.0"
|
||||||
glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
|
ffi = { package = "gstreamer-rtp-sys", path = "../gstreamer-rtp/sys", features = ["v1_8"] }
|
||||||
gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
|
|
||||||
gstreamer-sys = { path = "../gstreamer/sys", features = ["v1_8"] }
|
|
||||||
gstreamer-rtp-sys = { path = "../gstreamer-rtp/sys", features = ["v1_8"] }
|
|
||||||
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
|
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
|
||||||
gstreamer = { path = "../gstreamer" }
|
gst = { package = "gstreamer", path = "../gstreamer" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gstreamer-rs-lgpl-docs = { path = "../docs", optional = true }
|
gstreamer-rs-lgpl-docs = { path = "../docs", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
v1_10 = ["gstreamer/v1_10", "gstreamer-rtp-sys/v1_10"]
|
v1_10 = ["gst/v1_10", "ffi/v1_10"]
|
||||||
v1_12 = ["gstreamer/v1_12", "gstreamer-rtp-sys/v1_12", "v1_10"]
|
v1_12 = ["gst/v1_12", "ffi/v1_12", "v1_10"]
|
||||||
v1_14 = ["gstreamer/v1_14", "gstreamer-rtp-sys/v1_14", "v1_12"]
|
v1_14 = ["gst/v1_14", "ffi/v1_14", "v1_12"]
|
||||||
v1_16 = ["gstreamer/v1_16", "gstreamer-rtp-sys/v1_16", "v1_14"]
|
v1_16 = ["gst/v1_16", "ffi/v1_16", "v1_14"]
|
||||||
v1_18 = ["gstreamer/v1_18", "gstreamer-rtp-sys/v1_18", "v1_16"]
|
v1_18 = ["gst/v1_18", "ffi/v1_18", "v1_16"]
|
||||||
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
||||||
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
||||||
dox = ["v1_18", "gstreamer-rtp-sys/dox", "glib/dox", "gstreamer/dox"]
|
dox = ["v1_18", "ffi/dox", "glib/dox", "gst/dox"]
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
dox = ["v1_18", "gstreamer-rtp-sys/dox", "glib/dox", "gstreamer/dox"]
|
dox = ["v1_18", "ffi/dox", "glib/dox", "gst/dox"]
|
||||||
|
|
|
@ -8,22 +8,11 @@
|
||||||
|
|
||||||
#![cfg_attr(feature = "dox", feature(doc_cfg))]
|
#![cfg_attr(feature = "dox", feature(doc_cfg))]
|
||||||
|
|
||||||
#[macro_use]
|
pub use ffi;
|
||||||
extern crate bitflags;
|
|
||||||
extern crate once_cell;
|
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
#[macro_use]
|
|
||||||
extern crate glib;
|
|
||||||
extern crate glib_sys;
|
|
||||||
extern crate gobject_sys;
|
|
||||||
extern crate gstreamer as gst;
|
|
||||||
extern crate gstreamer_rtp_sys as gst_rtp_sys;
|
|
||||||
extern crate gstreamer_sys as gst_sys;
|
|
||||||
|
|
||||||
macro_rules! assert_initialized_main_thread {
|
macro_rules! assert_initialized_main_thread {
|
||||||
() => {
|
() => {
|
||||||
if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE {
|
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
|
||||||
panic!("GStreamer has not been initialized. Call `gst::init` first.");
|
panic!("GStreamer has not been initialized. Call `gst::init` first.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -38,10 +27,10 @@ macro_rules! skip_assert_initialized {
|
||||||
#[allow(clippy::match_same_arms)]
|
#[allow(clippy::match_same_arms)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
mod auto;
|
mod auto;
|
||||||
pub use auto::*;
|
pub use crate::auto::*;
|
||||||
|
|
||||||
pub mod rtp_buffer;
|
pub mod rtp_buffer;
|
||||||
pub use rtp_buffer::{compare_seqnum, RTPBuffer, RTPBufferExt};
|
pub use crate::rtp_buffer::{compare_seqnum, RTPBuffer, RTPBufferExt};
|
||||||
|
|
||||||
// Re-export all the traits in a prelude module, so that applications
|
// Re-export all the traits in a prelude module, so that applications
|
||||||
// can always "use gst::prelude::*" without getting conflicts
|
// can always "use gst::prelude::*" without getting conflicts
|
||||||
|
@ -49,7 +38,7 @@ pub mod prelude {
|
||||||
pub use glib::prelude::*;
|
pub use glib::prelude::*;
|
||||||
pub use gst::prelude::*;
|
pub use gst::prelude::*;
|
||||||
|
|
||||||
pub use auto::traits::*;
|
pub use crate::auto::traits::*;
|
||||||
|
|
||||||
pub use rtp_buffer::RTPBufferExt;
|
pub use crate::rtp_buffer::RTPBufferExt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,11 @@ use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
use gst_rtp_sys;
|
|
||||||
|
|
||||||
pub enum Readable {}
|
pub enum Readable {}
|
||||||
pub enum Writable {}
|
pub enum Writable {}
|
||||||
|
|
||||||
pub struct RTPBuffer<'a, T> {
|
pub struct RTPBuffer<'a, T> {
|
||||||
rtp_buffer: gst_rtp_sys::GstRTPBuffer,
|
rtp_buffer: ffi::GstRTPBuffer,
|
||||||
buffer: &'a gst::Buffer,
|
buffer: &'a gst::Buffer,
|
||||||
phantom: PhantomData<T>,
|
phantom: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
@ -36,9 +34,9 @@ impl<'a> RTPBuffer<'a, Readable> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut rtp_buffer = mem::MaybeUninit::zeroed();
|
let mut rtp_buffer = mem::MaybeUninit::zeroed();
|
||||||
let res: bool = from_glib(gst_rtp_sys::gst_rtp_buffer_map(
|
let res: bool = from_glib(ffi::gst_rtp_buffer_map(
|
||||||
buffer.as_mut_ptr(),
|
buffer.as_mut_ptr(),
|
||||||
gst_sys::GST_MAP_READ,
|
gst::ffi::GST_MAP_READ,
|
||||||
rtp_buffer.as_mut_ptr(),
|
rtp_buffer.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -49,7 +47,7 @@ impl<'a> RTPBuffer<'a, Readable> {
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib_bool_error!("Failed to map RTP buffer readable"))
|
Err(glib::glib_bool_error!("Failed to map RTP buffer readable"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,9 +60,9 @@ impl<'a> RTPBuffer<'a, Writable> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut rtp_buffer = mem::MaybeUninit::zeroed();
|
let mut rtp_buffer = mem::MaybeUninit::zeroed();
|
||||||
let res: bool = from_glib(gst_rtp_sys::gst_rtp_buffer_map(
|
let res: bool = from_glib(ffi::gst_rtp_buffer_map(
|
||||||
buffer.as_mut_ptr(),
|
buffer.as_mut_ptr(),
|
||||||
gst_sys::GST_MAP_READWRITE,
|
gst::ffi::GST_MAP_READWRITE,
|
||||||
rtp_buffer.as_mut_ptr(),
|
rtp_buffer.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -75,47 +73,45 @@ impl<'a> RTPBuffer<'a, Writable> {
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib_bool_error!("Failed to map RTP buffer writable"))
|
Err(glib::glib_bool_error!("Failed to map RTP buffer writable"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_seq(&mut self, seq: u16) {
|
pub fn set_seq(&mut self, seq: u16) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_rtp_sys::gst_rtp_buffer_set_seq(&mut self.rtp_buffer, seq);
|
ffi::gst_rtp_buffer_set_seq(&mut self.rtp_buffer, seq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_marker(&mut self, m: bool) {
|
pub fn set_marker(&mut self, m: bool) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_rtp_sys::gst_rtp_buffer_set_marker(&mut self.rtp_buffer, m.to_glib());
|
ffi::gst_rtp_buffer_set_marker(&mut self.rtp_buffer, m.to_glib());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_payload_type(&mut self, pt: u8) {
|
pub fn set_payload_type(&mut self, pt: u8) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_rtp_sys::gst_rtp_buffer_set_payload_type(&mut self.rtp_buffer, pt);
|
ffi::gst_rtp_buffer_set_payload_type(&mut self.rtp_buffer, pt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_ssrc(&mut self, ssrc: u32) {
|
pub fn set_ssrc(&mut self, ssrc: u32) {
|
||||||
unsafe { gst_rtp_sys::gst_rtp_buffer_set_ssrc(&mut self.rtp_buffer, ssrc) }
|
unsafe { ffi::gst_rtp_buffer_set_ssrc(&mut self.rtp_buffer, ssrc) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_csrc(&mut self, idx: u8, ssrc: u32) {
|
pub fn set_csrc(&mut self, idx: u8, ssrc: u32) {
|
||||||
unsafe { gst_rtp_sys::gst_rtp_buffer_set_csrc(&mut self.rtp_buffer, idx, ssrc) }
|
unsafe { ffi::gst_rtp_buffer_set_csrc(&mut self.rtp_buffer, idx, ssrc) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_timestamp(&mut self, rtptime: u32) {
|
pub fn set_timestamp(&mut self, rtptime: u32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_rtp_sys::gst_rtp_buffer_set_timestamp(&mut self.rtp_buffer, rtptime);
|
ffi::gst_rtp_buffer_set_timestamp(&mut self.rtp_buffer, rtptime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_extension(&mut self, extension: bool) {
|
pub fn set_extension(&mut self, extension: bool) {
|
||||||
unsafe {
|
unsafe { ffi::gst_rtp_buffer_set_extension(&mut self.rtp_buffer, extension.to_glib()) }
|
||||||
gst_rtp_sys::gst_rtp_buffer_set_extension(&mut self.rtp_buffer, extension.to_glib())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_extension_onebyte_header(
|
pub fn add_extension_onebyte_header(
|
||||||
|
@ -132,16 +128,18 @@ impl<'a> RTPBuffer<'a, Writable> {
|
||||||
"data size should be between 1 and 16 (inclusive"
|
"data size should be between 1 and 16 (inclusive"
|
||||||
);
|
);
|
||||||
unsafe {
|
unsafe {
|
||||||
let result: bool = from_glib(gst_rtp_sys::gst_rtp_buffer_add_extension_onebyte_header(
|
let result: bool = from_glib(ffi::gst_rtp_buffer_add_extension_onebyte_header(
|
||||||
&mut self.rtp_buffer,
|
&mut self.rtp_buffer,
|
||||||
id,
|
id,
|
||||||
data.as_ptr() as glib_sys::gconstpointer,
|
data.as_ptr() as glib::ffi::gconstpointer,
|
||||||
data.len() as u32,
|
data.len() as u32,
|
||||||
));
|
));
|
||||||
if result {
|
if result {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib_bool_error!("Failed to add onebyte header extension"))
|
Err(glib::glib_bool_error!(
|
||||||
|
"Failed to add onebyte header extension"
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,18 +157,19 @@ impl<'a> RTPBuffer<'a, Writable> {
|
||||||
);
|
);
|
||||||
assert!(data.len() < 256, "data size should be smaller than 256");
|
assert!(data.len() < 256, "data size should be smaller than 256");
|
||||||
unsafe {
|
unsafe {
|
||||||
let result: bool =
|
let result: bool = from_glib(ffi::gst_rtp_buffer_add_extension_twobytes_header(
|
||||||
from_glib(gst_rtp_sys::gst_rtp_buffer_add_extension_twobytes_header(
|
&mut self.rtp_buffer,
|
||||||
&mut self.rtp_buffer,
|
appbits,
|
||||||
appbits,
|
id,
|
||||||
id,
|
data.as_ptr() as glib::ffi::gconstpointer,
|
||||||
data.as_ptr() as glib_sys::gconstpointer,
|
data.len() as u32,
|
||||||
data.len() as u32,
|
));
|
||||||
));
|
|
||||||
if result {
|
if result {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib_bool_error!("Failed to add twobytes header extension"))
|
Err(glib::glib_bool_error!(
|
||||||
|
"Failed to add twobytes header extension"
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,37 +177,29 @@ impl<'a> RTPBuffer<'a, Writable> {
|
||||||
|
|
||||||
impl<'a, T> RTPBuffer<'a, T> {
|
impl<'a, T> RTPBuffer<'a, T> {
|
||||||
pub fn get_seq(&self) -> u16 {
|
pub fn get_seq(&self) -> u16 {
|
||||||
unsafe {
|
unsafe { ffi::gst_rtp_buffer_get_seq(glib::translate::mut_override(&self.rtp_buffer)) }
|
||||||
gst_rtp_sys::gst_rtp_buffer_get_seq(glib::translate::mut_override(&self.rtp_buffer))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_payload_type(&self) -> u8 {
|
pub fn get_payload_type(&self) -> u8 {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_rtp_sys::gst_rtp_buffer_get_payload_type(glib::translate::mut_override(
|
ffi::gst_rtp_buffer_get_payload_type(glib::translate::mut_override(&self.rtp_buffer))
|
||||||
&self.rtp_buffer,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_ssrc(&self) -> u32 {
|
pub fn get_ssrc(&self) -> u32 {
|
||||||
unsafe {
|
unsafe { ffi::gst_rtp_buffer_get_ssrc(glib::translate::mut_override(&self.rtp_buffer)) }
|
||||||
gst_rtp_sys::gst_rtp_buffer_get_ssrc(glib::translate::mut_override(&self.rtp_buffer))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_timestamp(&self) -> u32 {
|
pub fn get_timestamp(&self) -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_rtp_sys::gst_rtp_buffer_get_timestamp(glib::translate::mut_override(
|
ffi::gst_rtp_buffer_get_timestamp(glib::translate::mut_override(&self.rtp_buffer))
|
||||||
&self.rtp_buffer,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_csrc(&self, idx: u8) -> Option<u32> {
|
pub fn get_csrc(&self, idx: u8) -> Option<u32> {
|
||||||
if idx < self.get_csrc_count() {
|
if idx < self.get_csrc_count() {
|
||||||
unsafe {
|
unsafe {
|
||||||
Some(gst_rtp_sys::gst_rtp_buffer_get_csrc(
|
Some(ffi::gst_rtp_buffer_get_csrc(
|
||||||
glib::translate::mut_override(&self.rtp_buffer),
|
glib::translate::mut_override(&self.rtp_buffer),
|
||||||
idx,
|
idx,
|
||||||
))
|
))
|
||||||
|
@ -220,15 +211,13 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
|
|
||||||
pub fn get_csrc_count(&self) -> u8 {
|
pub fn get_csrc_count(&self) -> u8 {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_rtp_sys::gst_rtp_buffer_get_csrc_count(glib::translate::mut_override(
|
ffi::gst_rtp_buffer_get_csrc_count(glib::translate::mut_override(&self.rtp_buffer))
|
||||||
&self.rtp_buffer,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_marker(&self) -> bool {
|
pub fn get_marker(&self) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib(gst_rtp_sys::gst_rtp_buffer_get_marker(
|
from_glib(ffi::gst_rtp_buffer_get_marker(
|
||||||
glib::translate::mut_override(&self.rtp_buffer),
|
glib::translate::mut_override(&self.rtp_buffer),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -236,9 +225,8 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
|
|
||||||
pub fn get_payload_size(&self) -> u32 {
|
pub fn get_payload_size(&self) -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_rtp_sys::gst_rtp_buffer_get_payload_len(glib::translate::mut_override(
|
ffi::gst_rtp_buffer_get_payload_len(glib::translate::mut_override(&self.rtp_buffer))
|
||||||
&self.rtp_buffer,
|
as u32
|
||||||
)) as u32
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,11 +236,10 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
return Ok(&[]);
|
return Ok(&[]);
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
let pointer = gst_rtp_sys::gst_rtp_buffer_get_payload(glib::translate::mut_override(
|
let pointer =
|
||||||
&self.rtp_buffer,
|
ffi::gst_rtp_buffer_get_payload(glib::translate::mut_override(&self.rtp_buffer));
|
||||||
));
|
|
||||||
if pointer.is_null() {
|
if pointer.is_null() {
|
||||||
Err(glib_bool_error!("Failed to get payload data"))
|
Err(glib::glib_bool_error!("Failed to get payload data"))
|
||||||
} else {
|
} else {
|
||||||
Ok(slice::from_raw_parts(pointer as *const u8, size as usize))
|
Ok(slice::from_raw_parts(pointer as *const u8, size as usize))
|
||||||
}
|
}
|
||||||
|
@ -261,7 +248,7 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
|
|
||||||
pub fn get_extension(&self) -> bool {
|
pub fn get_extension(&self) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib(gst_rtp_sys::gst_rtp_buffer_get_extension(
|
from_glib(ffi::gst_rtp_buffer_get_extension(
|
||||||
glib::translate::mut_override(&self.rtp_buffer),
|
glib::translate::mut_override(&self.rtp_buffer),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -270,7 +257,7 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
pub fn get_extension_bytes(&self) -> Option<(u16, glib::Bytes)> {
|
pub fn get_extension_bytes(&self) -> Option<(u16, glib::Bytes)> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut bits: u16 = 0;
|
let mut bits: u16 = 0;
|
||||||
match from_glib_full(gst_rtp_sys::gst_rtp_buffer_get_extension_bytes(
|
match from_glib_full(ffi::gst_rtp_buffer_get_extension_bytes(
|
||||||
glib::translate::mut_override(&self.rtp_buffer),
|
glib::translate::mut_override(&self.rtp_buffer),
|
||||||
&mut bits,
|
&mut bits,
|
||||||
)) {
|
)) {
|
||||||
|
@ -286,7 +273,7 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
// FIXME: Workaround for gstreamer-rtp-sys having the wrong type for this parameter
|
// FIXME: Workaround for gstreamer-rtp-sys having the wrong type for this parameter
|
||||||
let data_ptr = &mut data as *mut *mut u8 as *mut u8;
|
let data_ptr = &mut data as *mut *mut u8 as *mut u8;
|
||||||
let mut size: u32 = 0;
|
let mut size: u32 = 0;
|
||||||
let result: bool = from_glib(gst_rtp_sys::gst_rtp_buffer_get_extension_onebyte_header(
|
let result: bool = from_glib(ffi::gst_rtp_buffer_get_extension_onebyte_header(
|
||||||
glib::translate::mut_override(&self.rtp_buffer),
|
glib::translate::mut_override(&self.rtp_buffer),
|
||||||
id,
|
id,
|
||||||
nth,
|
nth,
|
||||||
|
@ -308,15 +295,14 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
let data_ptr = &mut data as *mut *mut u8 as *mut u8;
|
let data_ptr = &mut data as *mut *mut u8 as *mut u8;
|
||||||
let mut size: u32 = 0;
|
let mut size: u32 = 0;
|
||||||
let mut appbits = 0;
|
let mut appbits = 0;
|
||||||
let result: bool =
|
let result: bool = from_glib(ffi::gst_rtp_buffer_get_extension_twobytes_header(
|
||||||
from_glib(gst_rtp_sys::gst_rtp_buffer_get_extension_twobytes_header(
|
glib::translate::mut_override(&self.rtp_buffer),
|
||||||
glib::translate::mut_override(&self.rtp_buffer),
|
&mut appbits,
|
||||||
&mut appbits,
|
id,
|
||||||
id,
|
nth,
|
||||||
nth,
|
data_ptr,
|
||||||
data_ptr,
|
&mut size,
|
||||||
&mut size,
|
));
|
||||||
));
|
|
||||||
if result {
|
if result {
|
||||||
Some((
|
Some((
|
||||||
appbits,
|
appbits,
|
||||||
|
@ -332,7 +318,7 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
impl<'a, T> Drop for RTPBuffer<'a, T> {
|
impl<'a, T> Drop for RTPBuffer<'a, T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_rtp_sys::gst_rtp_buffer_unmap(&mut self.rtp_buffer);
|
ffi::gst_rtp_buffer_unmap(&mut self.rtp_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,19 +339,19 @@ impl RTPBufferExt for gst::Buffer {
|
||||||
) -> Result<gst::Buffer, glib::BoolError> {
|
) -> Result<gst::Buffer, glib::BoolError> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(gst_rtp_sys::gst_rtp_buffer_new_allocate(
|
Option::<_>::from_glib_full(ffi::gst_rtp_buffer_new_allocate(
|
||||||
payload_len,
|
payload_len,
|
||||||
pad_len,
|
pad_len,
|
||||||
csrc_count,
|
csrc_count,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib_bool_error!("Failed to allocate new RTP buffer"))
|
.ok_or_else(|| glib::glib_bool_error!("Failed to allocate new RTP buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compare_seqnum(seqnum1: u16, seqnum2: u16) -> i32 {
|
pub fn compare_seqnum(seqnum1: u16, seqnum2: u16) -> i32 {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe { gst_rtp_sys::gst_rtp_buffer_compare_seqnum(seqnum1, seqnum2) }
|
unsafe { ffi::gst_rtp_buffer_compare_seqnum(seqnum1, seqnum2) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in a new issue