rtsp-server: Add RTSPContext uri getter

Add uri getter from RTSPContext

Fix #469

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1274>
This commit is contained in:
Daniel Pendse 2023-05-30 12:36:08 +02:00 committed by Sebastian Dröge
parent 011d3535bc
commit 545781d241
2 changed files with 28 additions and 2 deletions

View file

@ -303,6 +303,12 @@ mod client {
self.parent_closed();
println!("Client {client:?} closed");
}
fn describe_request(&self, ctx: &gst_rtsp_server::RTSPContext) {
self.parent_describe_request(ctx);
let request_uri = ctx.uri().unwrap().request_uri();
println!("Describe request for uri: {request_uri:?}");
}
}
}

View file

@ -1,11 +1,16 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use std::{marker::PhantomData, ptr};
use std::{
marker::PhantomData,
ptr::{self, addr_of},
};
use glib::translate::*;
use gst_rtsp::RTSPUrl;
#[derive(Debug, PartialEq, Eq)]
#[doc(alias = "GstRTSPContext")]
#[repr(transparent)]
pub struct RTSPContext(ptr::NonNull<ffi::GstRTSPContext>);
impl RTSPContext {
@ -22,7 +27,22 @@ impl RTSPContext {
}
}
// TODO: Add various getters for all the contained fields as needed
#[inline]
pub fn uri(&self) -> Option<&RTSPUrl> {
unsafe {
let ptr = self.0.as_ptr();
if (*ptr).uri.is_null() {
None
} else {
let uri = RTSPUrl::from_glib_ptr_borrow(
addr_of!((*ptr).uri) as *const *const gst_rtsp::ffi::GstRTSPUrl
);
Some(uri)
}
}
}
// TODO: Add additional getters for all the contained fields as needed
}
#[doc(hidden)]