gstreamer-sdp: Update manual code to 2018 edition

This commit is contained in:
Sebastian Dröge 2020-11-22 12:38:16 +02:00
parent 113c8fa055
commit e18cc55049
11 changed files with 234 additions and 303 deletions

View file

@ -11,29 +11,27 @@ homepage = "https://gstreamer.freedesktop.org"
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_sdp/" documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_sdp/"
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"] keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
build = "build.rs" build = "build.rs"
edition = "2018"
[dependencies] [dependencies]
glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" } ffi = { package = "gstreamer-sdp-sys", path = "../gstreamer-sdp/sys", features = ["v1_8"] }
gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer-sys = { path = "../gstreamer/sys", features = ["v1_8"] }
gstreamer-sdp-sys = { path = "../gstreamer-sdp/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_8_1 = ["gstreamer-sdp-sys/v1_8_1"] v1_8_1 = ["ffi/v1_8_1"]
v1_10 = ["gstreamer/v1_10", "gstreamer-sdp-sys/v1_10", "v1_8_1"] v1_10 = ["gst/v1_10", "ffi/v1_10", "v1_8_1"]
v1_12 = ["gstreamer/v1_12", "gstreamer-sdp-sys/v1_12", "v1_10"] v1_12 = ["gst/v1_12", "ffi/v1_12", "v1_10"]
v1_14 = ["gstreamer/v1_14", "gstreamer-sdp-sys/v1_14", "v1_12"] v1_14 = ["gst/v1_14", "ffi/v1_14", "v1_12"]
v1_16 = ["gstreamer/v1_16", "gstreamer-sdp-sys/v1_16", "v1_14"] v1_16 = ["gst/v1_16", "ffi/v1_16", "v1_14"]
v1_18 = ["gstreamer/v1_18", "gstreamer-sdp-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-sdp-sys/dox", "glib/dox", "gstreamer/dox"] dox = ["v1_18", "ffi/dox", "glib/dox", "gst/dox"]
[package.metadata.docs.rs] [package.metadata.docs.rs]
features = ["dox", "embed-lgpl-docs"] features = ["dox", "embed-lgpl-docs"]

View file

@ -8,17 +8,11 @@
#![cfg_attr(feature = "dox", feature(doc_cfg))] #![cfg_attr(feature = "dox", feature(doc_cfg))]
#[macro_use] pub use ffi;
extern crate glib;
extern crate glib_sys;
extern crate gobject_sys;
extern crate gstreamer as gst;
extern crate gstreamer_sdp_sys as gst_sdp_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.");
} }
}; };
@ -33,26 +27,26 @@ 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::*;
mod sdp_attribute; mod sdp_attribute;
pub use sdp_attribute::*; pub use crate::sdp_attribute::*;
mod sdp_bandwidth; mod sdp_bandwidth;
pub use sdp_bandwidth::*; pub use crate::sdp_bandwidth::*;
mod sdp_connection; mod sdp_connection;
pub use sdp_connection::*; pub use crate::sdp_connection::*;
mod sdp_key; mod sdp_key;
pub use sdp_key::*; pub use crate::sdp_key::*;
pub mod sdp_media; pub mod sdp_media;
pub use sdp_media::{SDPMedia, SDPMediaRef}; pub use crate::sdp_media::{SDPMedia, SDPMediaRef};
pub mod sdp_message; pub mod sdp_message;
pub use sdp_message::{SDPMessage, SDPMessageRef}; pub use crate::sdp_message::{SDPMessage, SDPMessageRef};
mod sdp_origin; mod sdp_origin;
pub use sdp_origin::*; pub use crate::sdp_origin::*;
mod sdp_time; mod sdp_time;
pub use sdp_time::*; pub use crate::sdp_time::*;
mod sdp_zone; mod sdp_zone;
pub use sdp_zone::*; pub use crate::sdp_zone::*;
// 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
@ -60,5 +54,5 @@ 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::*;
} }

View file

@ -11,10 +11,9 @@ use std::fmt;
use std::mem; use std::mem;
use glib::translate::*; use glib::translate::*;
use gst_sdp_sys;
#[repr(transparent)] #[repr(transparent)]
pub struct SDPAttribute(pub(crate) gst_sdp_sys::GstSDPAttribute); pub struct SDPAttribute(pub(crate) ffi::GstSDPAttribute);
unsafe impl Send for SDPAttribute {} unsafe impl Send for SDPAttribute {}
unsafe impl Sync for SDPAttribute {} unsafe impl Sync for SDPAttribute {}
@ -24,7 +23,7 @@ impl SDPAttribute {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut attr = mem::MaybeUninit::zeroed(); let mut attr = mem::MaybeUninit::zeroed();
gst_sdp_sys::gst_sdp_attribute_set( ffi::gst_sdp_attribute_set(
attr.as_mut_ptr(), attr.as_mut_ptr(),
key.to_glib_none().0, key.to_glib_none().0,
value.to_glib_none().0, value.to_glib_none().0,
@ -59,7 +58,7 @@ impl Clone for SDPAttribute {
impl Drop for SDPAttribute { impl Drop for SDPAttribute {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_attribute_clear(&mut self.0); ffi::gst_sdp_attribute_clear(&mut self.0);
} }
} }
} }

View file

@ -11,10 +11,9 @@ use std::fmt;
use std::mem; use std::mem;
use glib::translate::*; use glib::translate::*;
use gst_sdp_sys;
#[repr(transparent)] #[repr(transparent)]
pub struct SDPBandwidth(pub(crate) gst_sdp_sys::GstSDPBandwidth); pub struct SDPBandwidth(pub(crate) ffi::GstSDPBandwidth);
unsafe impl Send for SDPBandwidth {} unsafe impl Send for SDPBandwidth {}
unsafe impl Sync for SDPBandwidth {} unsafe impl Sync for SDPBandwidth {}
@ -24,7 +23,7 @@ impl SDPBandwidth {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut bw = mem::MaybeUninit::zeroed(); let mut bw = mem::MaybeUninit::zeroed();
gst_sdp_sys::gst_sdp_bandwidth_set(bw.as_mut_ptr(), bwtype.to_glib_none().0, bandwidth); ffi::gst_sdp_bandwidth_set(bw.as_mut_ptr(), bwtype.to_glib_none().0, bandwidth);
SDPBandwidth(bw.assume_init()) SDPBandwidth(bw.assume_init())
} }
} }
@ -49,7 +48,7 @@ impl Clone for SDPBandwidth {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut bw = mem::MaybeUninit::zeroed(); let mut bw = mem::MaybeUninit::zeroed();
gst_sdp_sys::gst_sdp_bandwidth_set(bw.as_mut_ptr(), self.0.bwtype, self.0.bandwidth); ffi::gst_sdp_bandwidth_set(bw.as_mut_ptr(), self.0.bwtype, self.0.bandwidth);
SDPBandwidth(bw.assume_init()) SDPBandwidth(bw.assume_init())
} }
} }
@ -58,7 +57,7 @@ impl Clone for SDPBandwidth {
impl Drop for SDPBandwidth { impl Drop for SDPBandwidth {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_bandwidth_clear(&mut self.0); ffi::gst_sdp_bandwidth_clear(&mut self.0);
} }
} }
} }

View file

@ -11,10 +11,9 @@ use std::fmt;
use std::mem; use std::mem;
use glib::translate::*; use glib::translate::*;
use gst_sdp_sys;
#[repr(transparent)] #[repr(transparent)]
pub struct SDPConnection(pub(crate) gst_sdp_sys::GstSDPConnection); pub struct SDPConnection(pub(crate) ffi::GstSDPConnection);
unsafe impl Send for SDPConnection {} unsafe impl Send for SDPConnection {}
unsafe impl Sync for SDPConnection {} unsafe impl Sync for SDPConnection {}
@ -24,7 +23,7 @@ impl SDPConnection {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut conn = mem::MaybeUninit::zeroed(); let mut conn = mem::MaybeUninit::zeroed();
gst_sdp_sys::gst_sdp_connection_set( ffi::gst_sdp_connection_set(
conn.as_mut_ptr(), conn.as_mut_ptr(),
nettype.to_glib_none().0, nettype.to_glib_none().0,
addrtype.to_glib_none().0, addrtype.to_glib_none().0,
@ -80,7 +79,7 @@ impl Clone for SDPConnection {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut conn = mem::MaybeUninit::zeroed(); let mut conn = mem::MaybeUninit::zeroed();
gst_sdp_sys::gst_sdp_connection_set( ffi::gst_sdp_connection_set(
conn.as_mut_ptr(), conn.as_mut_ptr(),
self.0.nettype, self.0.nettype,
self.0.addrtype, self.0.addrtype,
@ -96,7 +95,7 @@ impl Clone for SDPConnection {
impl Drop for SDPConnection { impl Drop for SDPConnection {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_connection_clear(&mut self.0); ffi::gst_sdp_connection_clear(&mut self.0);
} }
} }
} }

View file

@ -9,10 +9,8 @@
use std::ffi::CStr; use std::ffi::CStr;
use std::fmt; use std::fmt;
use gst_sdp_sys;
#[repr(transparent)] #[repr(transparent)]
pub struct SDPKey(gst_sdp_sys::GstSDPKey); pub struct SDPKey(ffi::GstSDPKey);
unsafe impl Send for SDPKey {} unsafe impl Send for SDPKey {}
unsafe impl Sync for SDPKey {} unsafe impl Sync for SDPKey {}

View file

@ -14,27 +14,24 @@ use std::ops;
use std::ptr; use std::ptr;
use glib::translate::*; use glib::translate::*;
use gst;
use gst_sdp_sys; use crate::sdp_attribute::SDPAttribute;
use crate::sdp_bandwidth::SDPBandwidth;
use crate::sdp_connection::SDPConnection;
use crate::sdp_key::SDPKey;
use sdp_attribute::SDPAttribute; glib::glib_wrapper! {
use sdp_bandwidth::SDPBandwidth;
use sdp_connection::SDPConnection;
use sdp_key::SDPKey;
glib_wrapper! {
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SDPMedia(Boxed<gst_sdp_sys::GstSDPMedia>); pub struct SDPMedia(Boxed<ffi::GstSDPMedia>);
match fn { match fn {
copy => |ptr| { copy => |ptr| {
let mut copy = ptr::null_mut(); let mut copy = ptr::null_mut();
gst_sdp_sys::gst_sdp_media_copy(ptr as *const gst_sdp_sys::GstSDPMedia, &mut copy); ffi::gst_sdp_media_copy(ptr as *const ffi::GstSDPMedia, &mut copy);
copy copy
}, },
free => |ptr| { free => |ptr| {
gst_sdp_sys::gst_sdp_media_free(ptr); ffi::gst_sdp_media_free(ptr);
}, },
} }
} }
@ -44,7 +41,7 @@ impl SDPMedia {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut media = ptr::null_mut(); let mut media = ptr::null_mut();
gst_sdp_sys::gst_sdp_media_new(&mut media); ffi::gst_sdp_media_new(&mut media);
from_glib_full(media) from_glib_full(media)
} }
} }
@ -86,7 +83,7 @@ impl fmt::Display for SDPMedia {
} }
#[repr(transparent)] #[repr(transparent)]
pub struct SDPMediaRef(gst_sdp_sys::GstSDPMedia); pub struct SDPMediaRef(ffi::GstSDPMedia);
impl fmt::Debug for SDPMediaRef { impl fmt::Debug for SDPMediaRef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -132,18 +129,12 @@ unsafe impl Sync for SDPMediaRef {}
impl SDPMediaRef { impl SDPMediaRef {
pub fn add_attribute(&mut self, key: &str, value: Option<&str>) { pub fn add_attribute(&mut self, key: &str, value: Option<&str>) {
let value = value.to_glib_none(); let value = value.to_glib_none();
unsafe { unsafe { ffi::gst_sdp_media_add_attribute(&mut self.0, key.to_glib_none().0, value.0) };
gst_sdp_sys::gst_sdp_media_add_attribute(&mut self.0, key.to_glib_none().0, value.0)
};
} }
pub fn add_bandwidth(&mut self, bwtype: &str, bandwidth: u32) { pub fn add_bandwidth(&mut self, bwtype: &str, bandwidth: u32) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_media_add_bandwidth( ffi::gst_sdp_media_add_bandwidth(&mut self.0, bwtype.to_glib_none().0, bandwidth)
&mut self.0,
bwtype.to_glib_none().0,
bandwidth,
)
}; };
} }
@ -156,7 +147,7 @@ impl SDPMediaRef {
addr_number: u32, addr_number: u32,
) { ) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_media_add_connection( ffi::gst_sdp_media_add_connection(
&mut self.0, &mut self.0,
nettype.to_glib_none().0, nettype.to_glib_none().0,
addrtype.to_glib_none().0, addrtype.to_glib_none().0,
@ -168,14 +159,14 @@ impl SDPMediaRef {
} }
pub fn add_format(&mut self, format: &str) { pub fn add_format(&mut self, format: &str) {
unsafe { gst_sdp_sys::gst_sdp_media_add_format(&mut self.0, format.to_glib_none().0) }; unsafe { ffi::gst_sdp_media_add_format(&mut self.0, format.to_glib_none().0) };
} }
pub fn as_text(&self) -> Result<String, glib::error::BoolError> { pub fn as_text(&self) -> Result<String, glib::error::BoolError> {
unsafe { unsafe {
match from_glib_full(gst_sdp_sys::gst_sdp_media_as_text(&self.0)) { match from_glib_full(ffi::gst_sdp_media_as_text(&self.0)) {
Some(s) => Ok(s), Some(s) => Ok(s),
None => Err(glib_bool_error!( None => Err(glib::glib_bool_error!(
"Failed to convert the contents of media to a text string" "Failed to convert the contents of media to a text string"
)), )),
} }
@ -199,28 +190,27 @@ impl SDPMediaRef {
} }
pub fn attributes_len(&self) -> u32 { pub fn attributes_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_media_attributes_len(&self.0) } unsafe { ffi::gst_sdp_media_attributes_len(&self.0) }
} }
pub fn attributes_to_caps(&self, caps: &mut gst::CapsRef) -> Result<(), ()> { pub fn attributes_to_caps(&self, caps: &mut gst::CapsRef) -> Result<(), ()> {
let result = let result = unsafe { ffi::gst_sdp_media_attributes_to_caps(&self.0, caps.as_mut_ptr()) };
unsafe { gst_sdp_sys::gst_sdp_media_attributes_to_caps(&self.0, caps.as_mut_ptr()) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
pub fn bandwidths_len(&self) -> u32 { pub fn bandwidths_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_media_bandwidths_len(&self.0) } unsafe { ffi::gst_sdp_media_bandwidths_len(&self.0) }
} }
pub fn connections_len(&self) -> u32 { pub fn connections_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_media_connections_len(&self.0) } unsafe { ffi::gst_sdp_media_connections_len(&self.0) }
} }
pub fn formats_len(&self) -> u32 { pub fn formats_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_media_formats_len(&self.0) } unsafe { ffi::gst_sdp_media_formats_len(&self.0) }
} }
pub fn get_attribute(&self, idx: u32) -> Option<&SDPAttribute> { pub fn get_attribute(&self, idx: u32) -> Option<&SDPAttribute> {
@ -229,7 +219,7 @@ impl SDPMediaRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_media_get_attribute(&self.0, idx); let ptr = ffi::gst_sdp_media_get_attribute(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -240,7 +230,7 @@ impl SDPMediaRef {
pub fn get_attribute_val(&self, key: &str) -> Option<&str> { pub fn get_attribute_val(&self, key: &str) -> Option<&str> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_media_get_attribute_val(&self.0, key.to_glib_none().0); let ptr = ffi::gst_sdp_media_get_attribute_val(&self.0, key.to_glib_none().0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -255,8 +245,7 @@ impl SDPMediaRef {
pub fn get_attribute_val_n(&self, key: &str, nth: u32) -> Option<&str> { pub fn get_attribute_val_n(&self, key: &str, nth: u32) -> Option<&str> {
unsafe { unsafe {
let ptr = let ptr = ffi::gst_sdp_media_get_attribute_val_n(&self.0, key.to_glib_none().0, nth);
gst_sdp_sys::gst_sdp_media_get_attribute_val_n(&self.0, key.to_glib_none().0, nth);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -275,7 +264,7 @@ impl SDPMediaRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_media_get_bandwidth(&self.0, idx); let ptr = ffi::gst_sdp_media_get_bandwidth(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -285,7 +274,7 @@ impl SDPMediaRef {
} }
pub fn get_caps_from_media(&self, pt: i32) -> Option<gst::Caps> { pub fn get_caps_from_media(&self, pt: i32) -> Option<gst::Caps> {
unsafe { from_glib_full(gst_sdp_sys::gst_sdp_media_get_caps_from_media(&self.0, pt)) } unsafe { from_glib_full(ffi::gst_sdp_media_get_caps_from_media(&self.0, pt)) }
} }
pub fn get_connection(&self, idx: u32) -> Option<&SDPConnection> { pub fn get_connection(&self, idx: u32) -> Option<&SDPConnection> {
@ -294,7 +283,7 @@ impl SDPMediaRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_media_get_connection(&self.0, idx); let ptr = ffi::gst_sdp_media_get_connection(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -309,7 +298,7 @@ impl SDPMediaRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_media_get_format(&self.0, idx); let ptr = ffi::gst_sdp_media_get_format(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -324,7 +313,7 @@ impl SDPMediaRef {
pub fn get_information(&self) -> Option<&str> { pub fn get_information(&self) -> Option<&str> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_media_get_information(&self.0); let ptr = ffi::gst_sdp_media_get_information(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -339,7 +328,7 @@ impl SDPMediaRef {
pub fn get_key(&self) -> Option<&SDPKey> { pub fn get_key(&self) -> Option<&SDPKey> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_media_get_key(&self.0); let ptr = ffi::gst_sdp_media_get_key(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -350,7 +339,7 @@ impl SDPMediaRef {
pub fn get_media(&self) -> Option<&str> { pub fn get_media(&self) -> Option<&str> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_media_get_media(&self.0); let ptr = ffi::gst_sdp_media_get_media(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -364,16 +353,16 @@ impl SDPMediaRef {
} }
pub fn get_num_ports(&self) -> u32 { pub fn get_num_ports(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_media_get_num_ports(&self.0) } unsafe { ffi::gst_sdp_media_get_num_ports(&self.0) }
} }
pub fn get_port(&self) -> u32 { pub fn get_port(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_media_get_port(&self.0) } unsafe { ffi::gst_sdp_media_get_port(&self.0) }
} }
pub fn get_proto(&self) -> Option<&str> { pub fn get_proto(&self) -> Option<&str> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_media_get_proto(&self.0); let ptr = ffi::gst_sdp_media_get_proto(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -395,10 +384,9 @@ impl SDPMediaRef {
let idx = idx.map(|idx| idx as i32).unwrap_or(-1); let idx = idx.map(|idx| idx as i32).unwrap_or(-1);
let mut attr = mem::ManuallyDrop::new(attr); let mut attr = mem::ManuallyDrop::new(attr);
let result = let result = unsafe { ffi::gst_sdp_media_insert_attribute(&mut self.0, idx, &mut attr.0) };
unsafe { gst_sdp_sys::gst_sdp_media_insert_attribute(&mut self.0, idx, &mut attr.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -412,10 +400,9 @@ impl SDPMediaRef {
let idx = idx.map(|idx| idx as i32).unwrap_or(-1); let idx = idx.map(|idx| idx as i32).unwrap_or(-1);
let mut bw = mem::ManuallyDrop::new(bw); let mut bw = mem::ManuallyDrop::new(bw);
let result = let result = unsafe { ffi::gst_sdp_media_insert_bandwidth(&mut self.0, idx, &mut bw.0) };
unsafe { gst_sdp_sys::gst_sdp_media_insert_bandwidth(&mut self.0, idx, &mut bw.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -429,10 +416,9 @@ impl SDPMediaRef {
let idx = idx.map(|idx| idx as i32).unwrap_or(-1); let idx = idx.map(|idx| idx as i32).unwrap_or(-1);
let mut conn = mem::ManuallyDrop::new(conn); let mut conn = mem::ManuallyDrop::new(conn);
let result = let result = unsafe { ffi::gst_sdp_media_insert_connection(&mut self.0, idx, &mut conn.0) };
unsafe { gst_sdp_sys::gst_sdp_media_insert_connection(&mut self.0, idx, &mut conn.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -445,11 +431,10 @@ impl SDPMediaRef {
} }
let idx = idx.map(|idx| idx as i32).unwrap_or(-1); let idx = idx.map(|idx| idx as i32).unwrap_or(-1);
let result = unsafe { let result =
gst_sdp_sys::gst_sdp_media_insert_format(&mut self.0, idx, format.to_glib_none().0) unsafe { ffi::gst_sdp_media_insert_format(&mut self.0, idx, format.to_glib_none().0) };
};
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -459,9 +444,9 @@ impl SDPMediaRef {
return Err(()); return Err(());
} }
let result = unsafe { gst_sdp_sys::gst_sdp_media_remove_attribute(&mut self.0, idx) }; let result = unsafe { ffi::gst_sdp_media_remove_attribute(&mut self.0, idx) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -471,9 +456,9 @@ impl SDPMediaRef {
return Err(()); return Err(());
} }
let result = unsafe { gst_sdp_sys::gst_sdp_media_remove_bandwidth(&mut self.0, idx) }; let result = unsafe { ffi::gst_sdp_media_remove_bandwidth(&mut self.0, idx) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -483,9 +468,9 @@ impl SDPMediaRef {
return Err(()); return Err(());
} }
let result = unsafe { gst_sdp_sys::gst_sdp_media_remove_connection(&mut self.0, idx) }; let result = unsafe { ffi::gst_sdp_media_remove_connection(&mut self.0, idx) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -495,9 +480,9 @@ impl SDPMediaRef {
return Err(()); return Err(());
} }
let result = unsafe { gst_sdp_sys::gst_sdp_media_remove_format(&mut self.0, idx) }; let result = unsafe { ffi::gst_sdp_media_remove_format(&mut self.0, idx) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -508,10 +493,9 @@ impl SDPMediaRef {
} }
let mut attr = mem::ManuallyDrop::new(attr); let mut attr = mem::ManuallyDrop::new(attr);
let result = let result = unsafe { ffi::gst_sdp_media_replace_attribute(&mut self.0, idx, &mut attr.0) };
unsafe { gst_sdp_sys::gst_sdp_media_replace_attribute(&mut self.0, idx, &mut attr.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -522,10 +506,9 @@ impl SDPMediaRef {
} }
let mut bw = mem::ManuallyDrop::new(bw); let mut bw = mem::ManuallyDrop::new(bw);
let result = let result = unsafe { ffi::gst_sdp_media_replace_bandwidth(&mut self.0, idx, &mut bw.0) };
unsafe { gst_sdp_sys::gst_sdp_media_replace_bandwidth(&mut self.0, idx, &mut bw.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -537,9 +520,9 @@ impl SDPMediaRef {
let mut conn = mem::ManuallyDrop::new(conn); let mut conn = mem::ManuallyDrop::new(conn);
let result = let result =
unsafe { gst_sdp_sys::gst_sdp_media_replace_connection(&mut self.0, idx, &mut conn.0) }; unsafe { ffi::gst_sdp_media_replace_connection(&mut self.0, idx, &mut conn.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -549,53 +532,46 @@ impl SDPMediaRef {
return Err(()); return Err(());
} }
let result = unsafe { let result =
gst_sdp_sys::gst_sdp_media_replace_format(&mut self.0, idx, format.to_glib_none().0) unsafe { ffi::gst_sdp_media_replace_format(&mut self.0, idx, format.to_glib_none().0) };
};
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
pub fn set_information(&mut self, information: &str) { pub fn set_information(&mut self, information: &str) {
unsafe { unsafe { ffi::gst_sdp_media_set_information(&mut self.0, information.to_glib_none().0) };
gst_sdp_sys::gst_sdp_media_set_information(&mut self.0, information.to_glib_none().0)
};
} }
pub fn set_key(&mut self, type_: &str, data: &str) { pub fn set_key(&mut self, type_: &str, data: &str) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_media_set_key( ffi::gst_sdp_media_set_key(&mut self.0, type_.to_glib_none().0, data.to_glib_none().0)
&mut self.0,
type_.to_glib_none().0,
data.to_glib_none().0,
)
}; };
} }
pub fn set_media(&mut self, med: &str) { pub fn set_media(&mut self, med: &str) {
unsafe { gst_sdp_sys::gst_sdp_media_set_media(&mut self.0, med.to_glib_none().0) }; unsafe { ffi::gst_sdp_media_set_media(&mut self.0, med.to_glib_none().0) };
} }
pub fn set_port_info(&mut self, port: u32, num_ports: u32) { pub fn set_port_info(&mut self, port: u32, num_ports: u32) {
unsafe { gst_sdp_sys::gst_sdp_media_set_port_info(&mut self.0, port, num_ports) }; unsafe { ffi::gst_sdp_media_set_port_info(&mut self.0, port, num_ports) };
} }
pub fn set_proto(&mut self, proto: &str) { pub fn set_proto(&mut self, proto: &str) {
unsafe { gst_sdp_sys::gst_sdp_media_set_proto(&mut self.0, proto.to_glib_none().0) }; unsafe { ffi::gst_sdp_media_set_proto(&mut self.0, proto.to_glib_none().0) };
} }
pub fn set_media_from_caps(caps: &gst::Caps, media: &mut SDPMedia) -> Result<(), ()> { pub fn set_media_from_caps(caps: &gst::Caps, media: &mut SDPMedia) -> Result<(), ()> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
let result = unsafe { let result = unsafe {
gst_sdp_sys::gst_sdp_media_set_media_from_caps( ffi::gst_sdp_media_set_media_from_caps(
caps.to_glib_none().0, caps.to_glib_none().0,
media.to_glib_none_mut().0, media.to_glib_none_mut().0,
) )
}; };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -619,7 +595,7 @@ impl ToOwned for SDPMediaRef {
fn to_owned(&self) -> SDPMedia { fn to_owned(&self) -> SDPMedia {
unsafe { unsafe {
let mut ptr = ptr::null_mut(); let mut ptr = ptr::null_mut();
gst_sdp_sys::gst_sdp_media_copy(&self.0, &mut ptr); ffi::gst_sdp_media_copy(&self.0, &mut ptr);
from_glib_full(ptr) from_glib_full(ptr)
} }
} }

View file

@ -14,28 +14,25 @@ use std::ops;
use std::ptr; use std::ptr;
use glib::translate::*; use glib::translate::*;
use gobject_sys;
use gst;
use gst_sdp_sys;
use sdp_attribute::SDPAttribute; use crate::sdp_attribute::SDPAttribute;
use sdp_bandwidth::SDPBandwidth; use crate::sdp_bandwidth::SDPBandwidth;
use sdp_connection::SDPConnection; use crate::sdp_connection::SDPConnection;
use sdp_key::SDPKey; use crate::sdp_key::SDPKey;
use sdp_media::SDPMedia; use crate::sdp_media::SDPMedia;
use sdp_media::SDPMediaRef; use crate::sdp_media::SDPMediaRef;
use sdp_origin::SDPOrigin; use crate::sdp_origin::SDPOrigin;
use sdp_time::SDPTime; use crate::sdp_time::SDPTime;
use sdp_zone::SDPZone; use crate::sdp_zone::SDPZone;
glib_wrapper! { glib::glib_wrapper! {
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SDPMessage(Boxed<gst_sdp_sys::GstSDPMessage>); pub struct SDPMessage(Boxed<ffi::GstSDPMessage>);
match fn { match fn {
copy => |ptr| gobject_sys::g_boxed_copy(gst_sdp_sys::gst_sdp_message_get_type(), ptr as *mut _) as *mut gst_sdp_sys::GstSDPMessage, copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gst_sdp_message_get_type(), ptr as *mut _) as *mut ffi::GstSDPMessage,
free => |ptr| gobject_sys::g_boxed_free(gst_sdp_sys::gst_sdp_message_get_type(), ptr as *mut _), free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gst_sdp_message_get_type(), ptr as *mut _),
get_type => || gst_sdp_sys::gst_sdp_message_get_type(), get_type => || ffi::gst_sdp_message_get_type(),
} }
} }
@ -79,7 +76,7 @@ impl SDPMessage {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut msg = ptr::null_mut(); let mut msg = ptr::null_mut();
gst_sdp_sys::gst_sdp_message_new(&mut msg); ffi::gst_sdp_message_new(&mut msg);
from_glib_full(msg) from_glib_full(msg)
} }
} }
@ -89,13 +86,12 @@ impl SDPMessage {
unsafe { unsafe {
let size = data.len() as u32; let size = data.len() as u32;
let mut msg = ptr::null_mut(); let mut msg = ptr::null_mut();
gst_sdp_sys::gst_sdp_message_new(&mut msg); ffi::gst_sdp_message_new(&mut msg);
let result = let result = ffi::gst_sdp_message_parse_buffer(data.to_glib_none().0, size, msg);
gst_sdp_sys::gst_sdp_message_parse_buffer(data.to_glib_none().0, size, msg);
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(from_glib_full(msg)), ffi::GST_SDP_OK => Ok(from_glib_full(msg)),
_ => { _ => {
gst_sdp_sys::gst_sdp_message_uninit(msg); ffi::gst_sdp_message_uninit(msg);
Err(()) Err(())
} }
} }
@ -106,12 +102,12 @@ impl SDPMessage {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut msg = ptr::null_mut(); let mut msg = ptr::null_mut();
gst_sdp_sys::gst_sdp_message_new(&mut msg); ffi::gst_sdp_message_new(&mut msg);
let result = gst_sdp_sys::gst_sdp_message_parse_uri(uri.to_glib_none().0, msg); let result = ffi::gst_sdp_message_parse_uri(uri.to_glib_none().0, msg);
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(from_glib_full(msg)), ffi::GST_SDP_OK => Ok(from_glib_full(msg)),
_ => { _ => {
gst_sdp_sys::gst_sdp_message_uninit(msg); ffi::gst_sdp_message_uninit(msg);
Err(()) Err(())
} }
} }
@ -120,7 +116,7 @@ impl SDPMessage {
} }
#[repr(transparent)] #[repr(transparent)]
pub struct SDPMessageRef(gst_sdp_sys::GstSDPMessage); pub struct SDPMessageRef(ffi::GstSDPMessage);
impl fmt::Debug for SDPMessageRef { impl fmt::Debug for SDPMessageRef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -170,7 +166,7 @@ unsafe impl Sync for SDPMessageRef {}
impl SDPMessageRef { impl SDPMessageRef {
pub fn add_attribute(&mut self, key: &str, value: Option<&str>) { pub fn add_attribute(&mut self, key: &str, value: Option<&str>) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_message_add_attribute( ffi::gst_sdp_message_add_attribute(
&mut self.0, &mut self.0,
key.to_glib_none().0, key.to_glib_none().0,
value.to_glib_none().0, value.to_glib_none().0,
@ -179,25 +175,25 @@ impl SDPMessageRef {
} }
pub fn add_email(&mut self, email: &str) { pub fn add_email(&mut self, email: &str) {
unsafe { gst_sdp_sys::gst_sdp_message_add_email(&mut self.0, email.to_glib_none().0) }; unsafe { ffi::gst_sdp_message_add_email(&mut self.0, email.to_glib_none().0) };
} }
pub fn add_media(&mut self, media: SDPMedia) { pub fn add_media(&mut self, media: SDPMedia) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_message_add_media( ffi::gst_sdp_message_add_media(
&mut self.0, &mut self.0,
media.to_glib_none().0 as *mut gst_sdp_sys::GstSDPMedia, media.to_glib_none().0 as *mut ffi::GstSDPMedia,
); );
} }
} }
pub fn add_phone(&mut self, phone: &str) { pub fn add_phone(&mut self, phone: &str) {
unsafe { gst_sdp_sys::gst_sdp_message_add_phone(&mut self.0, phone.to_glib_none().0) }; unsafe { ffi::gst_sdp_message_add_phone(&mut self.0, phone.to_glib_none().0) };
} }
pub fn add_time(&mut self, start: &str, stop: &str, repeat: &[&str]) { pub fn add_time(&mut self, start: &str, stop: &str, repeat: &[&str]) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_message_add_time( ffi::gst_sdp_message_add_time(
&mut self.0, &mut self.0,
start.to_glib_none().0, start.to_glib_none().0,
stop.to_glib_none().0, stop.to_glib_none().0,
@ -208,7 +204,7 @@ impl SDPMessageRef {
pub fn add_zone(&mut self, adj_time: &str, typed_time: &str) { pub fn add_zone(&mut self, adj_time: &str, typed_time: &str) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_message_add_zone( ffi::gst_sdp_message_add_zone(
&mut self.0, &mut self.0,
adj_time.to_glib_none().0, adj_time.to_glib_none().0,
typed_time.to_glib_none().0, typed_time.to_glib_none().0,
@ -218,9 +214,9 @@ impl SDPMessageRef {
pub fn as_text(&self) -> Result<String, glib::error::BoolError> { pub fn as_text(&self) -> Result<String, glib::error::BoolError> {
unsafe { unsafe {
match from_glib_full(gst_sdp_sys::gst_sdp_message_as_text(&self.0)) { match from_glib_full(ffi::gst_sdp_message_as_text(&self.0)) {
Some(s) => Ok(s), Some(s) => Ok(s),
None => Err(glib_bool_error!( None => Err(glib::glib_bool_error!(
"Failed to convert the contents of message to a text string" "Failed to convert the contents of message to a text string"
)), )),
} }
@ -228,28 +224,27 @@ impl SDPMessageRef {
} }
pub fn attributes_len(&self) -> u32 { pub fn attributes_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_message_attributes_len(&self.0) } unsafe { ffi::gst_sdp_message_attributes_len(&self.0) }
} }
pub fn attributes_to_caps(&self, caps: &mut gst::CapsRef) -> Result<(), ()> { pub fn attributes_to_caps(&self, caps: &mut gst::CapsRef) -> Result<(), ()> {
let result = let result = unsafe { ffi::gst_sdp_message_attributes_to_caps(&self.0, caps.as_mut_ptr()) };
unsafe { gst_sdp_sys::gst_sdp_message_attributes_to_caps(&self.0, caps.as_mut_ptr()) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
pub fn bandwidths_len(&self) -> u32 { pub fn bandwidths_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_message_bandwidths_len(&self.0) } unsafe { ffi::gst_sdp_message_bandwidths_len(&self.0) }
} }
pub fn dump(&self) { pub fn dump(&self) {
unsafe { gst_sdp_sys::gst_sdp_message_dump(&self.0) }; unsafe { ffi::gst_sdp_message_dump(&self.0) };
} }
pub fn emails_len(&self) -> u32 { pub fn emails_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_message_emails_len(&self.0) } unsafe { ffi::gst_sdp_message_emails_len(&self.0) }
} }
pub fn get_attribute(&self, idx: u32) -> Option<&SDPAttribute> { pub fn get_attribute(&self, idx: u32) -> Option<&SDPAttribute> {
@ -258,7 +253,7 @@ impl SDPMessageRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_attribute(&self.0, idx); let ptr = ffi::gst_sdp_message_get_attribute(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -269,7 +264,7 @@ impl SDPMessageRef {
pub fn get_attribute_val(&self, key: &str) -> Option<&str> { pub fn get_attribute_val(&self, key: &str) -> Option<&str> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_attribute_val(&self.0, key.to_glib_none().0); let ptr = ffi::gst_sdp_message_get_attribute_val(&self.0, key.to_glib_none().0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -284,11 +279,7 @@ impl SDPMessageRef {
pub fn get_attribute_val_n(&self, key: &str, nth: u32) -> Option<&str> { pub fn get_attribute_val_n(&self, key: &str, nth: u32) -> Option<&str> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_attribute_val_n( let ptr = ffi::gst_sdp_message_get_attribute_val_n(&self.0, key.to_glib_none().0, nth);
&self.0,
key.to_glib_none().0,
nth,
);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -307,7 +298,7 @@ impl SDPMessageRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_bandwidth(&self.0, idx); let ptr = ffi::gst_sdp_message_get_bandwidth(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -318,7 +309,7 @@ impl SDPMessageRef {
pub fn get_connection(&self) -> Option<&SDPConnection> { pub fn get_connection(&self) -> Option<&SDPConnection> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_connection(&self.0); let ptr = ffi::gst_sdp_message_get_connection(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -333,7 +324,7 @@ impl SDPMessageRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_email(&self.0, idx); let ptr = ffi::gst_sdp_message_get_email(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -348,7 +339,7 @@ impl SDPMessageRef {
pub fn get_information(&self) -> Option<&str> { pub fn get_information(&self) -> Option<&str> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_information(&self.0); let ptr = ffi::gst_sdp_message_get_information(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -363,7 +354,7 @@ impl SDPMessageRef {
pub fn get_key(&self) -> Option<&SDPKey> { pub fn get_key(&self) -> Option<&SDPKey> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_key(&self.0); let ptr = ffi::gst_sdp_message_get_key(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -378,7 +369,7 @@ impl SDPMessageRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_media(&self.0, idx); let ptr = ffi::gst_sdp_message_get_media(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -393,7 +384,7 @@ impl SDPMessageRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_media(&self.0, idx); let ptr = ffi::gst_sdp_message_get_media(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -404,7 +395,7 @@ impl SDPMessageRef {
pub fn get_origin(&self) -> Option<&SDPOrigin> { pub fn get_origin(&self) -> Option<&SDPOrigin> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_origin(&self.0); let ptr = ffi::gst_sdp_message_get_origin(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -419,7 +410,7 @@ impl SDPMessageRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_phone(&self.0, idx); let ptr = ffi::gst_sdp_message_get_phone(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -434,7 +425,7 @@ impl SDPMessageRef {
pub fn get_session_name(&self) -> Option<&str> { pub fn get_session_name(&self) -> Option<&str> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_session_name(&self.0); let ptr = ffi::gst_sdp_message_get_session_name(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -453,7 +444,7 @@ impl SDPMessageRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_time(&self.0, idx); let ptr = ffi::gst_sdp_message_get_time(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -464,7 +455,7 @@ impl SDPMessageRef {
pub fn get_uri(&self) -> Option<&str> { pub fn get_uri(&self) -> Option<&str> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_uri(&self.0); let ptr = ffi::gst_sdp_message_get_uri(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -479,7 +470,7 @@ impl SDPMessageRef {
pub fn get_version(&self) -> Option<&str> { pub fn get_version(&self) -> Option<&str> {
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_version(&self.0); let ptr = ffi::gst_sdp_message_get_version(&self.0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -498,7 +489,7 @@ impl SDPMessageRef {
} }
unsafe { unsafe {
let ptr = gst_sdp_sys::gst_sdp_message_get_zone(&self.0, idx); let ptr = ffi::gst_sdp_message_get_zone(&self.0, idx);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -517,9 +508,9 @@ impl SDPMessageRef {
let idx = idx.map(|idx| idx as i32).unwrap_or(-1); let idx = idx.map(|idx| idx as i32).unwrap_or(-1);
let mut attr = mem::ManuallyDrop::new(attr); let mut attr = mem::ManuallyDrop::new(attr);
let result = let result =
unsafe { gst_sdp_sys::gst_sdp_message_insert_attribute(&mut self.0, idx, &mut attr.0) }; unsafe { ffi::gst_sdp_message_insert_attribute(&mut self.0, idx, &mut attr.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -533,10 +524,9 @@ impl SDPMessageRef {
let idx = idx.map(|idx| idx as i32).unwrap_or(-1); let idx = idx.map(|idx| idx as i32).unwrap_or(-1);
let mut bw = mem::ManuallyDrop::new(bw); let mut bw = mem::ManuallyDrop::new(bw);
let result = let result = unsafe { ffi::gst_sdp_message_insert_bandwidth(&mut self.0, idx, &mut bw.0) };
unsafe { gst_sdp_sys::gst_sdp_message_insert_bandwidth(&mut self.0, idx, &mut bw.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -549,11 +539,10 @@ impl SDPMessageRef {
} }
let idx = idx.map(|idx| idx as i32).unwrap_or(-1); let idx = idx.map(|idx| idx as i32).unwrap_or(-1);
let result = unsafe { let result =
gst_sdp_sys::gst_sdp_message_insert_email(&mut self.0, idx, email.to_glib_none().0) unsafe { ffi::gst_sdp_message_insert_email(&mut self.0, idx, email.to_glib_none().0) };
};
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -566,11 +555,10 @@ impl SDPMessageRef {
} }
let idx = idx.map(|idx| idx as i32).unwrap_or(-1); let idx = idx.map(|idx| idx as i32).unwrap_or(-1);
let result = unsafe { let result =
gst_sdp_sys::gst_sdp_message_insert_phone(&mut self.0, idx, phone.to_glib_none().0) unsafe { ffi::gst_sdp_message_insert_phone(&mut self.0, idx, phone.to_glib_none().0) };
};
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -584,10 +572,9 @@ impl SDPMessageRef {
let idx = idx.map(|idx| idx as i32).unwrap_or(-1); let idx = idx.map(|idx| idx as i32).unwrap_or(-1);
let mut time = mem::ManuallyDrop::new(time); let mut time = mem::ManuallyDrop::new(time);
let result = let result = unsafe { ffi::gst_sdp_message_insert_time(&mut self.0, idx, &mut time.0) };
unsafe { gst_sdp_sys::gst_sdp_message_insert_time(&mut self.0, idx, &mut time.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -601,20 +588,19 @@ impl SDPMessageRef {
let idx = idx.map(|idx| idx as i32).unwrap_or(-1); let idx = idx.map(|idx| idx as i32).unwrap_or(-1);
let mut zone = mem::ManuallyDrop::new(zone); let mut zone = mem::ManuallyDrop::new(zone);
let result = let result = unsafe { ffi::gst_sdp_message_insert_zone(&mut self.0, idx, &mut zone.0) };
unsafe { gst_sdp_sys::gst_sdp_message_insert_zone(&mut self.0, idx, &mut zone.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
pub fn medias_len(&self) -> u32 { pub fn medias_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_message_medias_len(&self.0) } unsafe { ffi::gst_sdp_message_medias_len(&self.0) }
} }
pub fn phones_len(&self) -> u32 { pub fn phones_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_message_phones_len(&self.0) } unsafe { ffi::gst_sdp_message_phones_len(&self.0) }
} }
pub fn remove_attribute(&mut self, idx: u32) -> Result<(), ()> { pub fn remove_attribute(&mut self, idx: u32) -> Result<(), ()> {
@ -622,9 +608,9 @@ impl SDPMessageRef {
return Err(()); return Err(());
} }
let result = unsafe { gst_sdp_sys::gst_sdp_message_remove_attribute(&mut self.0, idx) }; let result = unsafe { ffi::gst_sdp_message_remove_attribute(&mut self.0, idx) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -634,9 +620,9 @@ impl SDPMessageRef {
return Err(()); return Err(());
} }
let result = unsafe { gst_sdp_sys::gst_sdp_message_remove_bandwidth(&mut self.0, idx) }; let result = unsafe { ffi::gst_sdp_message_remove_bandwidth(&mut self.0, idx) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -646,9 +632,9 @@ impl SDPMessageRef {
return Err(()); return Err(());
} }
let result = unsafe { gst_sdp_sys::gst_sdp_message_remove_email(&mut self.0, idx) }; let result = unsafe { ffi::gst_sdp_message_remove_email(&mut self.0, idx) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -658,9 +644,9 @@ impl SDPMessageRef {
return Err(()); return Err(());
} }
let result = unsafe { gst_sdp_sys::gst_sdp_message_remove_phone(&mut self.0, idx) }; let result = unsafe { ffi::gst_sdp_message_remove_phone(&mut self.0, idx) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -670,9 +656,9 @@ impl SDPMessageRef {
return Err(()); return Err(());
} }
let result = unsafe { gst_sdp_sys::gst_sdp_message_remove_time(&mut self.0, idx) }; let result = unsafe { ffi::gst_sdp_message_remove_time(&mut self.0, idx) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -682,9 +668,9 @@ impl SDPMessageRef {
return Err(()); return Err(());
} }
let result = unsafe { gst_sdp_sys::gst_sdp_message_remove_zone(&mut self.0, idx) }; let result = unsafe { ffi::gst_sdp_message_remove_zone(&mut self.0, idx) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -695,11 +681,10 @@ impl SDPMessageRef {
} }
let mut attr = mem::ManuallyDrop::new(attr); let mut attr = mem::ManuallyDrop::new(attr);
let result = unsafe { let result =
gst_sdp_sys::gst_sdp_message_replace_attribute(&mut self.0, idx, &mut attr.0) unsafe { ffi::gst_sdp_message_replace_attribute(&mut self.0, idx, &mut attr.0) };
};
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -710,10 +695,9 @@ impl SDPMessageRef {
} }
let mut bw = mem::ManuallyDrop::new(bw); let mut bw = mem::ManuallyDrop::new(bw);
let result = let result = unsafe { ffi::gst_sdp_message_replace_bandwidth(&mut self.0, idx, &mut bw.0) };
unsafe { gst_sdp_sys::gst_sdp_message_replace_bandwidth(&mut self.0, idx, &mut bw.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -723,11 +707,10 @@ impl SDPMessageRef {
return Err(()); return Err(());
} }
let result = unsafe { let result =
gst_sdp_sys::gst_sdp_message_replace_email(&mut self.0, idx, email.to_glib_none().0) unsafe { ffi::gst_sdp_message_replace_email(&mut self.0, idx, email.to_glib_none().0) };
};
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -737,11 +720,10 @@ impl SDPMessageRef {
return Err(()); return Err(());
} }
let result = unsafe { let result =
gst_sdp_sys::gst_sdp_message_replace_phone(&mut self.0, idx, phone.to_glib_none().0) unsafe { ffi::gst_sdp_message_replace_phone(&mut self.0, idx, phone.to_glib_none().0) };
};
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -752,10 +734,9 @@ impl SDPMessageRef {
} }
let mut time = mem::ManuallyDrop::new(time); let mut time = mem::ManuallyDrop::new(time);
let result = let result = unsafe { ffi::gst_sdp_message_replace_time(&mut self.0, idx, &mut time.0) };
unsafe { gst_sdp_sys::gst_sdp_message_replace_time(&mut self.0, idx, &mut time.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -766,10 +747,9 @@ impl SDPMessageRef {
} }
let mut zone = mem::ManuallyDrop::new(zone); let mut zone = mem::ManuallyDrop::new(zone);
let result = let result = unsafe { ffi::gst_sdp_message_replace_zone(&mut self.0, idx, &mut zone.0) };
unsafe { gst_sdp_sys::gst_sdp_message_replace_zone(&mut self.0, idx, &mut zone.0) };
match result { match result {
gst_sdp_sys::GST_SDP_OK => Ok(()), ffi::GST_SDP_OK => Ok(()),
_ => Err(()), _ => Err(()),
} }
} }
@ -783,7 +763,7 @@ impl SDPMessageRef {
addr_number: u32, addr_number: u32,
) { ) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_message_set_connection( ffi::gst_sdp_message_set_connection(
&mut self.0, &mut self.0,
nettype.to_glib_none().0, nettype.to_glib_none().0,
addrtype.to_glib_none().0, addrtype.to_glib_none().0,
@ -795,18 +775,12 @@ impl SDPMessageRef {
} }
pub fn set_information(&mut self, information: &str) { pub fn set_information(&mut self, information: &str) {
unsafe { unsafe { ffi::gst_sdp_message_set_information(&mut self.0, information.to_glib_none().0) };
gst_sdp_sys::gst_sdp_message_set_information(&mut self.0, information.to_glib_none().0)
};
} }
pub fn set_key(&mut self, type_: &str, data: &str) { pub fn set_key(&mut self, type_: &str, data: &str) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_message_set_key( ffi::gst_sdp_message_set_key(&mut self.0, type_.to_glib_none().0, data.to_glib_none().0)
&mut self.0,
type_.to_glib_none().0,
data.to_glib_none().0,
)
}; };
} }
@ -820,7 +794,7 @@ impl SDPMessageRef {
addr: &str, addr: &str,
) { ) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_message_set_origin( ffi::gst_sdp_message_set_origin(
&mut self.0, &mut self.0,
username.to_glib_none().0, username.to_glib_none().0,
sess_id.to_glib_none().0, sess_id.to_glib_none().0,
@ -834,38 +808,37 @@ impl SDPMessageRef {
pub fn set_session_name(&mut self, session_name: &str) { pub fn set_session_name(&mut self, session_name: &str) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_message_set_session_name( ffi::gst_sdp_message_set_session_name(&mut self.0, session_name.to_glib_none().0)
&mut self.0,
session_name.to_glib_none().0,
)
}; };
} }
pub fn set_uri(&mut self, uri: &str) { pub fn set_uri(&mut self, uri: &str) {
unsafe { gst_sdp_sys::gst_sdp_message_set_uri(&mut self.0, uri.to_glib_none().0) }; unsafe { ffi::gst_sdp_message_set_uri(&mut self.0, uri.to_glib_none().0) };
} }
pub fn set_version(&mut self, version: &str) { pub fn set_version(&mut self, version: &str) {
unsafe { gst_sdp_sys::gst_sdp_message_set_version(&mut self.0, version.to_glib_none().0) }; unsafe { ffi::gst_sdp_message_set_version(&mut self.0, version.to_glib_none().0) };
} }
pub fn times_len(&self) -> u32 { pub fn times_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_message_times_len(&self.0) } unsafe { ffi::gst_sdp_message_times_len(&self.0) }
} }
pub fn zones_len(&self) -> u32 { pub fn zones_len(&self) -> u32 {
unsafe { gst_sdp_sys::gst_sdp_message_zones_len(&self.0) } unsafe { ffi::gst_sdp_message_zones_len(&self.0) }
} }
pub fn as_uri(&self, scheme: &str) -> Result<String, glib::error::BoolError> { pub fn as_uri(&self, scheme: &str) -> Result<String, glib::error::BoolError> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
match from_glib_full(gst_sdp_sys::gst_sdp_message_as_uri( match from_glib_full(ffi::gst_sdp_message_as_uri(
scheme.to_glib_none().0, scheme.to_glib_none().0,
&self.0, &self.0,
)) { )) {
Some(s) => Ok(s), Some(s) => Ok(s),
None => Err(glib_bool_error!("Failed to create an URI from message")), None => Err(glib::glib_bool_error!(
"Failed to create an URI from message"
)),
} }
} }
} }
@ -921,7 +894,7 @@ impl ToOwned for SDPMessageRef {
fn to_owned(&self) -> SDPMessage { fn to_owned(&self) -> SDPMessage {
unsafe { unsafe {
let mut ptr = ptr::null_mut(); let mut ptr = ptr::null_mut();
gst_sdp_sys::gst_sdp_message_copy(&self.0, &mut ptr); ffi::gst_sdp_message_copy(&self.0, &mut ptr);
from_glib_full(ptr) from_glib_full(ptr)
} }
} }
@ -929,13 +902,13 @@ impl ToOwned for SDPMessageRef {
impl glib::types::StaticType for SDPMessageRef { impl glib::types::StaticType for SDPMessageRef {
fn static_type() -> glib::types::Type { fn static_type() -> glib::types::Type {
unsafe { from_glib(gst_sdp_sys::gst_sdp_message_get_type()) } unsafe { from_glib(ffi::gst_sdp_message_get_type()) }
} }
} }
impl<'a> glib::value::FromValueOptional<'a> for &'a SDPMessageRef { impl<'a> glib::value::FromValueOptional<'a> for &'a SDPMessageRef {
unsafe fn from_value_optional(v: &'a glib::Value) -> Option<Self> { unsafe fn from_value_optional(v: &'a glib::Value) -> Option<Self> {
let ptr = gobject_sys::g_value_get_boxed(v.to_glib_none().0); let ptr = glib::gobject_ffi::g_value_get_boxed(v.to_glib_none().0);
if ptr.is_null() { if ptr.is_null() {
None None
} else { } else {
@ -946,9 +919,9 @@ impl<'a> glib::value::FromValueOptional<'a> for &'a SDPMessageRef {
impl glib::value::SetValue for SDPMessageRef { impl glib::value::SetValue for SDPMessageRef {
unsafe fn set_value(v: &mut glib::Value, s: &Self) { unsafe fn set_value(v: &mut glib::Value, s: &Self) {
gobject_sys::g_value_set_boxed( glib::gobject_ffi::g_value_set_boxed(
v.to_glib_none_mut().0, v.to_glib_none_mut().0,
s as *const SDPMessageRef as glib_sys::gpointer, s as *const SDPMessageRef as glib::ffi::gpointer,
); );
} }
} }
@ -956,12 +929,12 @@ impl glib::value::SetValue for SDPMessageRef {
impl glib::value::SetValueOptional for SDPMessageRef { impl glib::value::SetValueOptional for SDPMessageRef {
unsafe fn set_value_optional(v: &mut glib::Value, s: Option<&Self>) { unsafe fn set_value_optional(v: &mut glib::Value, s: Option<&Self>) {
if let Some(s) = s { if let Some(s) = s {
gobject_sys::g_value_set_boxed( glib::gobject_ffi::g_value_set_boxed(
v.to_glib_none_mut().0, v.to_glib_none_mut().0,
s as *const SDPMessageRef as glib_sys::gpointer, s as *const SDPMessageRef as glib::ffi::gpointer,
); );
} else { } else {
gobject_sys::g_value_set_boxed(v.to_glib_none_mut().0, ptr::null_mut()); glib::gobject_ffi::g_value_set_boxed(v.to_glib_none_mut().0, ptr::null_mut());
} }
} }
} }
@ -1156,8 +1129,7 @@ define_iter!(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use crate::SDPMessage;
use SDPMessage;
fn init() { fn init() {
gst::init().unwrap(); gst::init().unwrap();

View file

@ -9,10 +9,8 @@
use std::ffi::CStr; use std::ffi::CStr;
use std::fmt; use std::fmt;
use gst_sdp_sys;
#[repr(transparent)] #[repr(transparent)]
pub struct SDPOrigin(pub(crate) gst_sdp_sys::GstSDPOrigin); pub struct SDPOrigin(pub(crate) ffi::GstSDPOrigin);
unsafe impl Send for SDPOrigin {} unsafe impl Send for SDPOrigin {}
unsafe impl Sync for SDPOrigin {} unsafe impl Sync for SDPOrigin {}

View file

@ -13,10 +13,9 @@ use std::os::raw::c_char;
use std::ptr; use std::ptr;
use glib::translate::*; use glib::translate::*;
use gst_sdp_sys;
#[repr(transparent)] #[repr(transparent)]
pub struct SDPTime(pub(crate) gst_sdp_sys::GstSDPTime); pub struct SDPTime(pub(crate) ffi::GstSDPTime);
unsafe impl Send for SDPTime {} unsafe impl Send for SDPTime {}
unsafe impl Sync for SDPTime {} unsafe impl Sync for SDPTime {}
@ -26,7 +25,7 @@ impl SDPTime {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut time = mem::MaybeUninit::zeroed(); let mut time = mem::MaybeUninit::zeroed();
gst_sdp_sys::gst_sdp_time_set( ffi::gst_sdp_time_set(
time.as_mut_ptr(), time.as_mut_ptr(),
start.to_glib_none().0, start.to_glib_none().0,
stop.to_glib_none().0, stop.to_glib_none().0,
@ -80,7 +79,7 @@ impl Clone for SDPTime {
#[allow(clippy::cast_ptr_alignment)] #[allow(clippy::cast_ptr_alignment)]
unsafe { unsafe {
let mut time = mem::MaybeUninit::zeroed(); let mut time = mem::MaybeUninit::zeroed();
gst_sdp_sys::gst_sdp_time_set( ffi::gst_sdp_time_set(
time.as_mut_ptr(), time.as_mut_ptr(),
self.0.start, self.0.start,
self.0.stop, self.0.stop,
@ -98,7 +97,7 @@ impl Clone for SDPTime {
impl Drop for SDPTime { impl Drop for SDPTime {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_time_clear(&mut self.0); ffi::gst_sdp_time_clear(&mut self.0);
} }
} }
} }

View file

@ -11,10 +11,9 @@ use std::fmt;
use std::mem; use std::mem;
use glib::translate::*; use glib::translate::*;
use gst_sdp_sys;
#[repr(transparent)] #[repr(transparent)]
pub struct SDPZone(pub(crate) gst_sdp_sys::GstSDPZone); pub struct SDPZone(pub(crate) ffi::GstSDPZone);
unsafe impl Send for SDPZone {} unsafe impl Send for SDPZone {}
unsafe impl Sync for SDPZone {} unsafe impl Sync for SDPZone {}
@ -24,7 +23,7 @@ impl SDPZone {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut zone = mem::MaybeUninit::zeroed(); let mut zone = mem::MaybeUninit::zeroed();
gst_sdp_sys::gst_sdp_zone_set( ffi::gst_sdp_zone_set(
zone.as_mut_ptr(), zone.as_mut_ptr(),
time.to_glib_none().0, time.to_glib_none().0,
typed_time.to_glib_none().0, typed_time.to_glib_none().0,
@ -59,7 +58,7 @@ impl Clone for SDPZone {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { unsafe {
let mut zone = mem::MaybeUninit::zeroed(); let mut zone = mem::MaybeUninit::zeroed();
gst_sdp_sys::gst_sdp_zone_set(zone.as_mut_ptr(), self.0.time, self.0.typed_time); ffi::gst_sdp_zone_set(zone.as_mut_ptr(), self.0.time, self.0.typed_time);
SDPZone(zone.assume_init()) SDPZone(zone.assume_init())
} }
} }
@ -68,7 +67,7 @@ impl Clone for SDPZone {
impl Drop for SDPZone { impl Drop for SDPZone {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
gst_sdp_sys::gst_sdp_zone_clear(&mut self.0); ffi::gst_sdp_zone_clear(&mut self.0);
} }
} }
} }