mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 08:36:31 +00:00
Free on error. Use pub(crate). Minor fixes.
This commit is contained in:
parent
3ecd67ee46
commit
05fec4d927
9 changed files with 24 additions and 14 deletions
|
@ -21,12 +21,13 @@ impl MIKEYPayload {
|
||||||
|
|
||||||
pub fn kemac_add_sub(&mut self, newpay: MIKEYPayload) -> bool {
|
pub fn kemac_add_sub(&mut self, newpay: MIKEYPayload) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib(ffi::gst_mikey_payload_kemac_add_sub(self.to_glib_none_mut().0, newpay.to_glib_full()))
|
let ret = from_glib(ffi::gst_mikey_payload_kemac_add_sub(self.to_glib_none_mut().0, newpay.to_glib_full()));
|
||||||
|
mem::forget(newpay);
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
mem::forget(newpay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kemac_get_sub(&self, idx: u32) -> Option<MIKEYPayload> {
|
pub fn kemac_get_sub(&self, idx: u32) -> Option<&MIKEYPayload> {
|
||||||
unsafe {
|
unsafe {
|
||||||
&*(from_glib_none(ffi::gst_mikey_payload_kemac_get_sub(self.to_glib_none().0, idx)) as *mut MIKEYPayload)
|
&*(from_glib_none(ffi::gst_mikey_payload_kemac_get_sub(self.to_glib_none().0, idx)) as *mut MIKEYPayload)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use glib::translate::*;
|
||||||
use auto::SDPResult;
|
use auto::SDPResult;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct SDPAttribute(pub ffi::GstSDPAttribute);
|
pub struct SDPAttribute(pub(crate) ffi::GstSDPAttribute);
|
||||||
|
|
||||||
impl SDPAttribute {
|
impl SDPAttribute {
|
||||||
pub fn new(key: &str, value: &str) -> Result<Self, ()> {
|
pub fn new(key: &str, value: &str) -> Result<Self, ()> {
|
||||||
|
|
|
@ -15,7 +15,7 @@ use glib::translate::*;
|
||||||
use auto::SDPResult;
|
use auto::SDPResult;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct SDPBandwidth(pub ffi::GstSDPBandwidth);
|
pub struct SDPBandwidth(pub(crate) ffi::GstSDPBandwidth);
|
||||||
|
|
||||||
impl SDPBandwidth {
|
impl SDPBandwidth {
|
||||||
pub fn new(bwtype: &str, bandwidth: u32) -> Result<Self, ()> {
|
pub fn new(bwtype: &str, bandwidth: u32) -> Result<Self, ()> {
|
||||||
|
|
|
@ -15,7 +15,7 @@ use glib::translate::*;
|
||||||
use auto::SDPResult;
|
use auto::SDPResult;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct SDPConnection(pub ffi::GstSDPConnection);
|
pub struct SDPConnection(pub(crate) ffi::GstSDPConnection);
|
||||||
|
|
||||||
impl SDPConnection {
|
impl SDPConnection {
|
||||||
pub fn new(nettype: &str, addrtype: &str, address: &str, ttl: u32, addr_number: u32) -> Result<Self, ()> {
|
pub fn new(nettype: &str, addrtype: &str, address: &str, ttl: u32, addr_number: u32) -> Result<Self, ()> {
|
||||||
|
|
|
@ -40,12 +40,15 @@ glib_wrapper! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SDPMedia {
|
impl SDPMedia {
|
||||||
pub fn new() -> (SDPResult, SDPMedia) {
|
pub fn new() -> Result<Self, ()> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut media = ptr::null_mut();
|
let mut media = ptr::null_mut();
|
||||||
let ret = from_glib(ffi::gst_sdp_media_new(&mut media));
|
let result = from_glib(ffi::gst_sdp_media_new(&mut media));
|
||||||
(ret, from_glib_full(media))
|
match result {
|
||||||
|
SDPResult::Ok => Ok(from_glib_full(media)),
|
||||||
|
_ => Err(()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -672,7 +672,10 @@ impl SDPMessage {
|
||||||
let result = from_glib(ffi::gst_sdp_message_parse_buffer(data.to_glib_none().0, size, msg));
|
let result = from_glib(ffi::gst_sdp_message_parse_buffer(data.to_glib_none().0, size, msg));
|
||||||
match result {
|
match result {
|
||||||
SDPResult::Ok => Ok(from_glib_full(msg)),
|
SDPResult::Ok => Ok(from_glib_full(msg)),
|
||||||
_ => Err(()),
|
_ => {
|
||||||
|
glib_ffi::g_free(msg as *mut _);
|
||||||
|
Err(())
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -684,7 +687,10 @@ impl SDPMessage {
|
||||||
let result = from_glib(ffi::gst_sdp_message_parse_uri(uri.to_glib_none().0, msg));
|
let result = from_glib(ffi::gst_sdp_message_parse_uri(uri.to_glib_none().0, msg));
|
||||||
match result {
|
match result {
|
||||||
SDPResult::Ok => Ok(from_glib_full(msg)),
|
SDPResult::Ok => Ok(from_glib_full(msg)),
|
||||||
_ => Err(()),
|
_ => {
|
||||||
|
glib_ffi::g_free(msg as *mut _);
|
||||||
|
Err(())
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use std::ffi::CStr;
|
||||||
use ffi;
|
use ffi;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct SDPOrigin(pub ffi::GstSDPOrigin);
|
pub struct SDPOrigin(pub(crate) ffi::GstSDPOrigin);
|
||||||
|
|
||||||
impl SDPOrigin {
|
impl SDPOrigin {
|
||||||
pub fn username(&self) -> &str {
|
pub fn username(&self) -> &str {
|
||||||
|
|
|
@ -16,7 +16,7 @@ use glib::translate::*;
|
||||||
use auto::SDPResult;
|
use auto::SDPResult;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct SDPTime(pub ffi::GstSDPTime);
|
pub struct SDPTime(pub(crate) ffi::GstSDPTime);
|
||||||
|
|
||||||
impl SDPTime {
|
impl SDPTime {
|
||||||
pub fn new(start: &str, stop: &str, repeat: &[&str]) -> Result<Self, ()> {
|
pub fn new(start: &str, stop: &str, repeat: &[&str]) -> Result<Self, ()> {
|
||||||
|
|
|
@ -15,7 +15,7 @@ use glib::translate::*;
|
||||||
use auto::SDPResult;
|
use auto::SDPResult;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct SDPZone(pub ffi::GstSDPZone);
|
pub struct SDPZone(pub(crate) ffi::GstSDPZone);
|
||||||
|
|
||||||
impl SDPZone {
|
impl SDPZone {
|
||||||
pub fn new(time: &str, typed_time: &str) -> Result<Self, ()> {
|
pub fn new(time: &str, typed_time: &str) -> Result<Self, ()> {
|
||||||
|
|
Loading…
Reference in a new issue