Commit 05fec4d9 authored by Bo Du's avatar Bo Du Committed by Sebastian Dröge

Free on error. Use pub(crate). Minor fixes.

parent 3ecd67ee
......@@ -21,12 +21,13 @@ impl MIKEYPayload {
pub fn kemac_add_sub(&mut self, newpay: MIKEYPayload) -> bool {
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 {
&*(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;
#[repr(C)]
pub struct SDPAttribute(pub ffi::GstSDPAttribute);
pub struct SDPAttribute(pub(crate) ffi::GstSDPAttribute);
impl SDPAttribute {
pub fn new(key: &str, value: &str) -> Result<Self, ()> {
......
......@@ -15,7 +15,7 @@ use glib::translate::*;
use auto::SDPResult;
#[repr(C)]
pub struct SDPBandwidth(pub ffi::GstSDPBandwidth);
pub struct SDPBandwidth(pub(crate) ffi::GstSDPBandwidth);
impl SDPBandwidth {
pub fn new(bwtype: &str, bandwidth: u32) -> Result<Self, ()> {
......
......@@ -15,7 +15,7 @@ use glib::translate::*;
use auto::SDPResult;
#[repr(C)]
pub struct SDPConnection(pub ffi::GstSDPConnection);
pub struct SDPConnection(pub(crate) ffi::GstSDPConnection);
impl SDPConnection {
pub fn new(nettype: &str, addrtype: &str, address: &str, ttl: u32, addr_number: u32) -> Result<Self, ()> {
......
......@@ -40,12 +40,15 @@ glib_wrapper! {
}
impl SDPMedia {
pub fn new() -> (SDPResult, SDPMedia) {
pub fn new() -> Result<Self, ()> {
assert_initialized_main_thread!();
unsafe {
let mut media = ptr::null_mut();
let ret = from_glib(ffi::gst_sdp_media_new(&mut media));
(ret, from_glib_full(media))
let result = from_glib(ffi::gst_sdp_media_new(&mut 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));
match result {
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));
match result {
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;
#[repr(C)]
pub struct SDPOrigin(pub ffi::GstSDPOrigin);
pub struct SDPOrigin(pub(crate) ffi::GstSDPOrigin);
impl SDPOrigin {
pub fn username(&self) -> &str {
......
......@@ -16,7 +16,7 @@ use glib::translate::*;
use auto::SDPResult;
#[repr(C)]
pub struct SDPTime(pub ffi::GstSDPTime);
pub struct SDPTime(pub(crate) ffi::GstSDPTime);
impl SDPTime {
pub fn new(start: &str, stop: &str, repeat: &[&str]) -> Result<Self, ()> {
......
......@@ -15,7 +15,7 @@ use glib::translate::*;
use auto::SDPResult;
#[repr(C)]
pub struct SDPZone(pub ffi::GstSDPZone);
pub struct SDPZone(pub(crate) ffi::GstSDPZone);
impl SDPZone {
pub fn new(time: &str, typed_time: &str) -> Result<Self, ()> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment