diff --git a/examples/src/bin/rtsp-server-subclass.rs b/examples/src/bin/rtsp-server-subclass.rs index 9accaedf0..7964fa324 100644 --- a/examples/src/bin/rtsp-server-subclass.rs +++ b/examples/src/bin/rtsp-server-subclass.rs @@ -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:?}"); + } } } diff --git a/gstreamer-rtsp-server/src/rtsp_context.rs b/gstreamer-rtsp-server/src/rtsp_context.rs index cda3e3c2c..3be5b399d 100644 --- a/gstreamer-rtsp-server/src/rtsp_context.rs +++ b/gstreamer-rtsp-server/src/rtsp_context.rs @@ -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); 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)]