Update for glib::Boxed ToGlibPtr<*mut _> trait impl addition

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1192>
This commit is contained in:
Sebastian Dröge 2023-01-17 09:59:02 +02:00
parent c2e7abd128
commit 82cf6e7842
8 changed files with 20 additions and 48 deletions

View file

@ -16,17 +16,11 @@ glib::wrapper! {
impl ControlPoint {
pub fn timestamp(&self) -> gst::ClockTime {
unsafe {
let ptr = self.to_glib_none().0;
try_from_glib((*ptr).timestamp).expect("undefined timestamp")
}
unsafe { try_from_glib((*self.as_ptr()).timestamp).expect("undefined timestamp") }
}
pub fn value(&self) -> f64 {
unsafe {
let ptr = self.to_glib_none().0;
(*ptr).value
}
unsafe { (*self.as_ptr()).value }
}
}

View file

@ -2,22 +2,16 @@
use std::ffi::CStr;
use glib::translate::*;
use crate::PlayVisualization;
impl PlayVisualization {
pub fn name(&self) -> &str {
unsafe {
CStr::from_ptr((*self.to_glib_none().0).name)
.to_str()
.unwrap()
}
unsafe { CStr::from_ptr((*self.as_ptr()).name).to_str().unwrap() }
}
pub fn description(&self) -> &str {
unsafe {
CStr::from_ptr((*self.to_glib_none().0).description)
CStr::from_ptr((*self.as_ptr()).description)
.to_str()
.unwrap()
}

View file

@ -2,22 +2,16 @@
use std::ffi::CStr;
use glib::translate::*;
use crate::PlayerVisualization;
impl PlayerVisualization {
pub fn name(&self) -> &str {
unsafe {
CStr::from_ptr((*self.to_glib_none().0).name)
.to_str()
.unwrap()
}
unsafe { CStr::from_ptr((*self.as_ptr()).name).to_str().unwrap() }
}
pub fn description(&self) -> &str {
unsafe {
CStr::from_ptr((*self.to_glib_none().0).description)
CStr::from_ptr((*self.as_ptr()).description)
.to_str()
.unwrap()
}

View file

@ -1,7 +1,5 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use std::mem;
use glib::{prelude::*, subclass::prelude::*, translate::*};
use crate::RTSPClient;
@ -783,10 +781,7 @@ unsafe extern "C" fn client_create_sdp<T: RTSPClientImpl>(
let instance = &*(ptr as *mut T::Instance);
let imp = instance.imp();
let sdp = mem::ManuallyDrop::new(imp.create_sdp(&from_glib_borrow(media)));
let ptr = sdp.to_glib_none().0;
ptr as *mut _
imp.create_sdp(&from_glib_borrow(media)).into_glib_ptr()
}
unsafe extern "C" fn client_configure_client_media<T: RTSPClientImpl>(

View file

@ -57,7 +57,7 @@ impl ops::Deref for SDPMedia {
type Target = SDPMediaRef;
fn deref(&self) -> &SDPMediaRef {
unsafe { &*(self.to_glib_none().0 as *const SDPMediaRef) }
unsafe { &*(self.as_ptr() as *const SDPMediaRef) }
}
}

View file

@ -52,7 +52,7 @@ impl ops::Deref for SDPMessage {
type Target = SDPMessageRef;
fn deref(&self) -> &SDPMessageRef {
unsafe { &*(self.to_glib_none().0 as *const SDPMessageRef) }
unsafe { &*(self.as_ptr() as *const SDPMessageRef) }
}
}
@ -190,10 +190,7 @@ impl SDPMessageRef {
#[doc(alias = "gst_sdp_message_add_media")]
pub fn add_media(&mut self, media: SDPMedia) {
unsafe {
ffi::gst_sdp_message_add_media(
&mut self.0,
media.to_glib_none().0 as *mut ffi::GstSDPMedia,
);
ffi::gst_sdp_message_add_media(&mut self.0, media.as_ptr() as *mut ffi::GstSDPMedia);
}
}

View file

@ -2,14 +2,12 @@
use std::ffi::CStr;
use glib::translate::*;
use crate::WebRTCICECandidateStats;
impl WebRTCICECandidateStats {
pub fn ipaddr(&self) -> Option<&str> {
unsafe {
let ptr = (*self.to_glib_none().0).ipaddr;
let ptr = (*self.as_ptr()).ipaddr;
if ptr.is_null() {
None
} else {
@ -19,16 +17,16 @@ impl WebRTCICECandidateStats {
}
pub fn port(&self) -> u32 {
unsafe { (*self.to_glib_none().0).port }
unsafe { (*self.as_ptr()).port }
}
pub fn stream_id(&self) -> u32 {
unsafe { (*self.to_glib_none().0).stream_id }
unsafe { (*self.as_ptr()).stream_id }
}
pub fn type_(&self) -> Option<&str> {
unsafe {
let ptr = (*self.to_glib_none().0).type_;
let ptr = (*self.as_ptr()).type_;
if ptr.is_null() {
None
} else {
@ -39,7 +37,7 @@ impl WebRTCICECandidateStats {
pub fn proto(&self) -> Option<&str> {
unsafe {
let ptr = (*self.to_glib_none().0).proto;
let ptr = (*self.as_ptr()).proto;
if ptr.is_null() {
None
} else {
@ -50,7 +48,7 @@ impl WebRTCICECandidateStats {
pub fn relay_proto(&self) -> Option<&str> {
unsafe {
let ptr = (*self.to_glib_none().0).relay_proto;
let ptr = (*self.as_ptr()).relay_proto;
if ptr.is_null() {
None
} else {
@ -60,12 +58,12 @@ impl WebRTCICECandidateStats {
}
pub fn prio(&self) -> u32 {
unsafe { (*self.to_glib_none().0).prio }
unsafe { (*self.as_ptr()).prio }
}
pub fn url(&self) -> Option<&str> {
unsafe {
let ptr = (*self.to_glib_none().0).url;
let ptr = (*self.as_ptr()).url;
if ptr.is_null() {
None
} else {

View file

@ -21,11 +21,11 @@ impl WebRTCSessionDescription {
#[doc(alias = "get_type")]
pub fn type_(&self) -> crate::WebRTCSDPType {
unsafe { from_glib((*self.to_glib_none().0).type_) }
unsafe { from_glib((*self.as_ptr()).type_) }
}
#[doc(alias = "get_sdp")]
pub fn sdp(&self) -> gst_sdp::SDPMessage {
unsafe { from_glib_none((*self.to_glib_none().0).sdp) }
unsafe { from_glib_none((*self.as_ptr()).sdp) }
}
}