mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 00:26:31 +00:00
gstreamer-rtsp-server: Make virtual methods take wrapper of type, not parent
This commit is contained in:
parent
b861f724c4
commit
3d3bdf9aa3
5 changed files with 459 additions and 312 deletions
|
@ -129,7 +129,7 @@ mod media_factory {
|
|||
impl RTSPMediaFactoryImpl for Factory {
|
||||
fn create_element(
|
||||
&self,
|
||||
_factory: &gst_rtsp_server::RTSPMediaFactory,
|
||||
_factory: &Self::Type,
|
||||
_url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<gst::Element> {
|
||||
// Create a simple VP8 videotestsrc input
|
||||
|
@ -218,7 +218,7 @@ mod media {
|
|||
impl RTSPMediaImpl for Media {
|
||||
fn setup_sdp(
|
||||
&self,
|
||||
media: &gst_rtsp_server::RTSPMedia,
|
||||
media: &Self::Type,
|
||||
sdp: &mut gst_sdp::SDPMessageRef,
|
||||
info: &gst_rtsp_server::subclass::SDPInfo,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
|
@ -284,10 +284,7 @@ mod server {
|
|||
|
||||
// Implementation of gst_rtsp_server::RTSPServer virtual methods
|
||||
impl RTSPServerImpl for Server {
|
||||
fn create_client(
|
||||
&self,
|
||||
server: &gst_rtsp_server::RTSPServer,
|
||||
) -> Option<gst_rtsp_server::RTSPClient> {
|
||||
fn create_client(&self, server: &Self::Type) -> Option<gst_rtsp_server::RTSPClient> {
|
||||
let client = super::client::Client::default();
|
||||
|
||||
// Duplicated from the default implementation
|
||||
|
@ -299,11 +296,7 @@ mod server {
|
|||
Some(client.upcast())
|
||||
}
|
||||
|
||||
fn client_connected(
|
||||
&self,
|
||||
server: &gst_rtsp_server::RTSPServer,
|
||||
client: &gst_rtsp_server::RTSPClient,
|
||||
) {
|
||||
fn client_connected(&self, server: &Self::Type, client: &gst_rtsp_server::RTSPClient) {
|
||||
self.parent_client_connected(server, client);
|
||||
println!("Client {:?} connected", client);
|
||||
}
|
||||
|
@ -372,7 +365,7 @@ mod client {
|
|||
|
||||
// Implementation of gst_rtsp_server::RTSPClient virtual methods
|
||||
impl RTSPClientImpl for Client {
|
||||
fn closed(&self, client: &gst_rtsp_server::RTSPClient) {
|
||||
fn closed(&self, client: &Self::Type) {
|
||||
self.parent_closed(client);
|
||||
println!("Client {:?} closed", client);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -8,6 +8,7 @@
|
|||
|
||||
use gst_rtsp_server_sys;
|
||||
|
||||
use glib::prelude::*;
|
||||
use glib::subclass::prelude::*;
|
||||
use glib::translate::*;
|
||||
|
||||
|
@ -33,43 +34,43 @@ impl SDPInfo {
|
|||
}
|
||||
|
||||
pub trait RTSPMediaImpl: RTSPMediaImplExt + ObjectImpl + Send + Sync {
|
||||
fn handle_message(&self, media: &RTSPMedia, message: &gst::MessageRef) -> bool {
|
||||
fn handle_message(&self, media: &Self::Type, message: &gst::MessageRef) -> bool {
|
||||
self.parent_handle_message(media, message)
|
||||
}
|
||||
|
||||
fn prepare(&self, media: &RTSPMedia, thread: &RTSPThread) -> Result<(), gst::LoggableError> {
|
||||
fn prepare(&self, media: &Self::Type, thread: &RTSPThread) -> Result<(), gst::LoggableError> {
|
||||
self.parent_prepare(media, thread)
|
||||
}
|
||||
|
||||
fn unprepare(&self, media: &RTSPMedia) -> Result<(), gst::LoggableError> {
|
||||
fn unprepare(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_unprepare(media)
|
||||
}
|
||||
|
||||
fn suspend(&self, media: &RTSPMedia) -> Result<(), gst::LoggableError> {
|
||||
fn suspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_suspend(media)
|
||||
}
|
||||
|
||||
fn unsuspend(&self, media: &RTSPMedia) -> Result<(), gst::LoggableError> {
|
||||
fn unsuspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_unsuspend(media)
|
||||
}
|
||||
|
||||
// TODO missing: convert_range
|
||||
|
||||
fn query_position(&self, media: &RTSPMedia) -> Option<gst::ClockTime> {
|
||||
fn query_position(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
||||
self.parent_query_position(media)
|
||||
}
|
||||
|
||||
fn query_stop(&self, media: &RTSPMedia) -> Option<gst::ClockTime> {
|
||||
fn query_stop(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
||||
self.parent_query_stop(media)
|
||||
}
|
||||
|
||||
fn create_rtpbin(&self, media: &RTSPMedia) -> Option<gst::Element> {
|
||||
fn create_rtpbin(&self, media: &Self::Type) -> Option<gst::Element> {
|
||||
self.parent_create_rtpbin(media)
|
||||
}
|
||||
|
||||
fn setup_rtpbin(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
rtpbin: &gst::Element,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_setup_rtpbin(media, rtpbin)
|
||||
|
@ -77,93 +78,96 @@ pub trait RTSPMediaImpl: RTSPMediaImplExt + ObjectImpl + Send + Sync {
|
|||
|
||||
fn setup_sdp(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
sdp: &mut gst_sdp::SDPMessageRef,
|
||||
info: &SDPInfo,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_setup_sdp(media, sdp, info)
|
||||
}
|
||||
|
||||
fn new_stream(&self, media: &RTSPMedia, stream: &::RTSPStream) {
|
||||
fn new_stream(&self, media: &Self::Type, stream: &::RTSPStream) {
|
||||
self.parent_new_stream(media, stream);
|
||||
}
|
||||
|
||||
fn removed_stream(&self, media: &RTSPMedia, stream: &::RTSPStream) {
|
||||
fn removed_stream(&self, media: &Self::Type, stream: &::RTSPStream) {
|
||||
self.parent_removed_stream(media, stream);
|
||||
}
|
||||
|
||||
fn prepared(&self, media: &RTSPMedia) {
|
||||
fn prepared(&self, media: &Self::Type) {
|
||||
self.parent_prepared(media);
|
||||
}
|
||||
|
||||
fn unprepared(&self, media: &RTSPMedia) {
|
||||
fn unprepared(&self, media: &Self::Type) {
|
||||
self.parent_unprepared(media);
|
||||
}
|
||||
|
||||
fn target_state(&self, media: &RTSPMedia, state: gst::State) {
|
||||
fn target_state(&self, media: &Self::Type, state: gst::State) {
|
||||
self.parent_target_state(media, state);
|
||||
}
|
||||
|
||||
fn new_state(&self, media: &RTSPMedia, state: gst::State) {
|
||||
fn new_state(&self, media: &Self::Type, state: gst::State) {
|
||||
self.parent_new_state(media, state);
|
||||
}
|
||||
|
||||
fn handle_sdp(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
sdp: &gst_sdp::SDPMessageRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_handle_sdp(media, sdp)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTSPMediaImplExt {
|
||||
fn parent_handle_message(&self, media: &RTSPMedia, message: &gst::MessageRef) -> bool;
|
||||
pub trait RTSPMediaImplExt: ObjectSubclass {
|
||||
fn parent_handle_message(&self, media: &Self::Type, message: &gst::MessageRef) -> bool;
|
||||
fn parent_prepare(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
thread: &RTSPThread,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_unprepare(&self, media: &RTSPMedia) -> Result<(), gst::LoggableError>;
|
||||
fn parent_suspend(&self, media: &RTSPMedia) -> Result<(), gst::LoggableError>;
|
||||
fn parent_unsuspend(&self, media: &RTSPMedia) -> Result<(), gst::LoggableError>;
|
||||
fn parent_unprepare(&self, media: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
fn parent_suspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
fn parent_unsuspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
// TODO missing: convert_range
|
||||
|
||||
fn parent_query_position(&self, media: &RTSPMedia) -> Option<gst::ClockTime>;
|
||||
fn parent_query_stop(&self, media: &RTSPMedia) -> Option<gst::ClockTime>;
|
||||
fn parent_create_rtpbin(&self, media: &RTSPMedia) -> Option<gst::Element>;
|
||||
fn parent_query_position(&self, media: &Self::Type) -> Option<gst::ClockTime>;
|
||||
fn parent_query_stop(&self, media: &Self::Type) -> Option<gst::ClockTime>;
|
||||
fn parent_create_rtpbin(&self, media: &Self::Type) -> Option<gst::Element>;
|
||||
fn parent_setup_rtpbin(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
rtpbin: &gst::Element,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_setup_sdp(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
sdp: &mut gst_sdp::SDPMessageRef,
|
||||
info: &SDPInfo,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_new_stream(&self, media: &RTSPMedia, stream: &::RTSPStream);
|
||||
fn parent_removed_stream(&self, media: &RTSPMedia, stream: &::RTSPStream);
|
||||
fn parent_prepared(&self, media: &RTSPMedia);
|
||||
fn parent_unprepared(&self, media: &RTSPMedia);
|
||||
fn parent_target_state(&self, media: &RTSPMedia, state: gst::State);
|
||||
fn parent_new_state(&self, media: &RTSPMedia, state: gst::State);
|
||||
fn parent_new_stream(&self, media: &Self::Type, stream: &::RTSPStream);
|
||||
fn parent_removed_stream(&self, media: &Self::Type, stream: &::RTSPStream);
|
||||
fn parent_prepared(&self, media: &Self::Type);
|
||||
fn parent_unprepared(&self, media: &Self::Type);
|
||||
fn parent_target_state(&self, media: &Self::Type, state: gst::State);
|
||||
fn parent_new_state(&self, media: &Self::Type, state: gst::State);
|
||||
fn parent_handle_sdp(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
sdp: &gst_sdp::SDPMessageRef,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
||||
fn parent_handle_message(&self, media: &RTSPMedia, message: &gst::MessageRef) -> bool {
|
||||
fn parent_handle_message(&self, media: &Self::Type, message: &gst::MessageRef) -> bool {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).handle_message {
|
||||
from_glib(f(media.to_glib_none().0, message.as_ptr() as *mut _))
|
||||
from_glib(f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
message.as_ptr() as *mut _,
|
||||
))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -172,7 +176,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
|
||||
fn parent_prepare(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
thread: &RTSPThread,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -181,7 +185,10 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).prepare {
|
||||
gst_result_from_gboolean!(
|
||||
f(media.to_glib_none().0, thread.to_glib_none().0),
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
thread.to_glib_none().0
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `prepare` failed"
|
||||
)
|
||||
|
@ -191,14 +198,14 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unprepare(&self, media: &RTSPMedia) -> Result<(), gst::LoggableError> {
|
||||
fn parent_unprepare(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).unprepare {
|
||||
gst_result_from_gboolean!(
|
||||
f(media.to_glib_none().0),
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `unprepare` failed"
|
||||
)
|
||||
|
@ -208,14 +215,14 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_suspend(&self, media: &RTSPMedia) -> Result<(), gst::LoggableError> {
|
||||
fn parent_suspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).suspend {
|
||||
gst_result_from_gboolean!(
|
||||
f(media.to_glib_none().0),
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `suspend` failed"
|
||||
)
|
||||
|
@ -225,14 +232,14 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unsuspend(&self, media: &RTSPMedia) -> Result<(), gst::LoggableError> {
|
||||
fn parent_unsuspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).unsuspend {
|
||||
gst_result_from_gboolean!(
|
||||
f(media.to_glib_none().0),
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `unsuspend` failed"
|
||||
)
|
||||
|
@ -244,7 +251,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
|
||||
// TODO missing: convert_range
|
||||
|
||||
fn parent_query_position(&self, media: &RTSPMedia) -> Option<gst::ClockTime> {
|
||||
fn parent_query_position(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
||||
unsafe {
|
||||
use std::mem;
|
||||
|
||||
|
@ -253,7 +260,11 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).query_position {
|
||||
let mut position = mem::MaybeUninit::uninit();
|
||||
if f(media.to_glib_none().0, position.as_mut_ptr()) == glib_sys::GFALSE {
|
||||
if f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
position.as_mut_ptr(),
|
||||
) == glib_sys::GFALSE
|
||||
{
|
||||
None
|
||||
} else {
|
||||
Some(from_glib(position.assume_init() as u64))
|
||||
|
@ -264,7 +275,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_query_stop(&self, media: &RTSPMedia) -> Option<gst::ClockTime> {
|
||||
fn parent_query_stop(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
||||
unsafe {
|
||||
use std::mem;
|
||||
|
||||
|
@ -273,7 +284,11 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).query_stop {
|
||||
let mut stop = mem::MaybeUninit::uninit();
|
||||
if f(media.to_glib_none().0, stop.as_mut_ptr()) == glib_sys::GFALSE {
|
||||
if f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
stop.as_mut_ptr(),
|
||||
) == glib_sys::GFALSE
|
||||
{
|
||||
None
|
||||
} else {
|
||||
Some(from_glib(stop.assume_init() as u64))
|
||||
|
@ -284,7 +299,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_create_rtpbin(&self, media: &RTSPMedia) -> Option<gst::Element> {
|
||||
fn parent_create_rtpbin(&self, media: &Self::Type) -> Option<gst::Element> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
|
@ -293,13 +308,13 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
.create_rtpbin
|
||||
.expect("No `create_rtpbin` virtual method implementation in parent class");
|
||||
|
||||
from_glib_none(f(media.to_glib_none().0))
|
||||
from_glib_none(f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_setup_rtpbin(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
rtpbin: &gst::Element,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -313,7 +328,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
gobject_sys::g_object_force_floating(ptr as *mut _);
|
||||
|
||||
let res = gst_result_from_gboolean!(
|
||||
f(media.to_glib_none().0, ptr),
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0, ptr),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `setup_sdp` failed"
|
||||
);
|
||||
|
@ -334,7 +349,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
|
||||
fn parent_setup_sdp(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
sdp: &mut gst_sdp::SDPMessageRef,
|
||||
info: &SDPInfo,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
|
@ -348,7 +363,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
|
||||
gst_result_from_gboolean!(
|
||||
f(
|
||||
media.to_glib_none().0,
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
sdp as *mut _ as *mut gst_sdp_sys::GstSDPMessage,
|
||||
info.0.as_ptr()
|
||||
),
|
||||
|
@ -358,75 +373,87 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_new_stream(&self, media: &RTSPMedia, stream: &::RTSPStream) {
|
||||
fn parent_new_stream(&self, media: &Self::Type, stream: &::RTSPStream) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).new_stream {
|
||||
f(media.to_glib_none().0, stream.to_glib_none().0);
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
stream.to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_removed_stream(&self, media: &RTSPMedia, stream: &::RTSPStream) {
|
||||
fn parent_removed_stream(&self, media: &Self::Type, stream: &::RTSPStream) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).removed_stream {
|
||||
f(media.to_glib_none().0, stream.to_glib_none().0);
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
stream.to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_prepared(&self, media: &RTSPMedia) {
|
||||
fn parent_prepared(&self, media: &Self::Type) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).prepared {
|
||||
f(media.to_glib_none().0);
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_unprepared(&self, media: &RTSPMedia) {
|
||||
fn parent_unprepared(&self, media: &Self::Type) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).unprepared {
|
||||
f(media.to_glib_none().0);
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_target_state(&self, media: &RTSPMedia, state: gst::State) {
|
||||
fn parent_target_state(&self, media: &Self::Type, state: gst::State) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).target_state {
|
||||
f(media.to_glib_none().0, state.to_glib());
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
state.to_glib(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_new_state(&self, media: &RTSPMedia, state: gst::State) {
|
||||
fn parent_new_state(&self, media: &Self::Type, state: gst::State) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).new_state {
|
||||
f(media.to_glib_none().0, state.to_glib());
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
state.to_glib(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_handle_sdp(
|
||||
&self,
|
||||
media: &RTSPMedia,
|
||||
media: &Self::Type,
|
||||
sdp: &gst_sdp::SDPMessageRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -439,7 +466,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
|
||||
gst_result_from_gboolean!(
|
||||
f(
|
||||
media.to_glib_none().0,
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
sdp as *const _ as *mut gst_sdp_sys::GstSDPMessage
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -480,7 +507,7 @@ unsafe extern "C" fn media_handle_message<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.handle_message(&wrap, gst::MessageRef::from_ptr(message))
|
||||
imp.handle_message(wrap.unsafe_cast_ref(), gst::MessageRef::from_ptr(message))
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
|
@ -492,7 +519,7 @@ unsafe extern "C" fn media_prepare<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.prepare(&wrap, &from_glib_borrow(thread)) {
|
||||
match imp.prepare(wrap.unsafe_cast_ref(), &from_glib_borrow(thread)) {
|
||||
Ok(()) => glib_sys::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
|
@ -508,7 +535,7 @@ unsafe extern "C" fn media_unprepare<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.unprepare(&wrap) {
|
||||
match imp.unprepare(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => glib_sys::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
|
@ -524,7 +551,7 @@ unsafe extern "C" fn media_suspend<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.suspend(&wrap) {
|
||||
match imp.suspend(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => glib_sys::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
|
@ -540,7 +567,7 @@ unsafe extern "C" fn media_unsuspend<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.unsuspend(&wrap) {
|
||||
match imp.unsuspend(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => glib_sys::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
|
@ -557,7 +584,7 @@ unsafe extern "C" fn media_query_position<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.query_position(&wrap) {
|
||||
match imp.query_position(wrap.unsafe_cast_ref()) {
|
||||
Some(pos) => {
|
||||
*position = pos.to_glib() as i64;
|
||||
glib_sys::GTRUE
|
||||
|
@ -574,7 +601,7 @@ unsafe extern "C" fn media_query_stop<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.query_stop(&wrap) {
|
||||
match imp.query_stop(wrap.unsafe_cast_ref()) {
|
||||
Some(s) => {
|
||||
*stop = s.to_glib() as i64;
|
||||
glib_sys::GTRUE
|
||||
|
@ -590,7 +617,7 @@ unsafe extern "C" fn media_create_rtpbin<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
let res: *mut gst_sys::GstElement = imp.create_rtpbin(&wrap).to_glib_full();
|
||||
let res: *mut gst_sys::GstElement = imp.create_rtpbin(wrap.unsafe_cast_ref()).to_glib_full();
|
||||
|
||||
if !res.is_null() {
|
||||
gobject_sys::g_object_force_floating(res as *mut _);
|
||||
|
@ -613,7 +640,7 @@ unsafe extern "C" fn media_setup_rtpbin<T: RTSPMediaImpl>(
|
|||
gobject_sys::g_object_ref_sink(rtpbin as *mut _);
|
||||
}
|
||||
|
||||
let res = match imp.setup_rtpbin(&wrap, &from_glib_borrow(rtpbin)) {
|
||||
let res = match imp.setup_rtpbin(wrap.unsafe_cast_ref(), &from_glib_borrow(rtpbin)) {
|
||||
Ok(()) => glib_sys::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
|
@ -637,7 +664,7 @@ unsafe extern "C" fn media_setup_sdp<T: RTSPMediaImpl>(
|
|||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.setup_sdp(
|
||||
&wrap,
|
||||
wrap.unsafe_cast_ref(),
|
||||
&mut *(sdp as *mut gst_sdp::SDPMessageRef),
|
||||
&SDPInfo(ptr::NonNull::new(info).expect("NULL SDPInfo")),
|
||||
) {
|
||||
|
@ -657,7 +684,7 @@ unsafe extern "C" fn media_new_stream<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.new_stream(&wrap, &from_glib_borrow(stream));
|
||||
imp.new_stream(wrap.unsafe_cast_ref(), &from_glib_borrow(stream));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_removed_stream<T: RTSPMediaImpl>(
|
||||
|
@ -668,7 +695,7 @@ unsafe extern "C" fn media_removed_stream<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.removed_stream(&wrap, &from_glib_borrow(stream));
|
||||
imp.removed_stream(wrap.unsafe_cast_ref(), &from_glib_borrow(stream));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_prepared<T: RTSPMediaImpl>(ptr: *mut gst_rtsp_server_sys::GstRTSPMedia) {
|
||||
|
@ -676,7 +703,7 @@ unsafe extern "C" fn media_prepared<T: RTSPMediaImpl>(ptr: *mut gst_rtsp_server_
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.prepared(&wrap);
|
||||
imp.prepared(wrap.unsafe_cast_ref());
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_unprepared<T: RTSPMediaImpl>(
|
||||
|
@ -686,7 +713,7 @@ unsafe extern "C" fn media_unprepared<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.unprepared(&wrap);
|
||||
imp.unprepared(wrap.unsafe_cast_ref());
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_target_state<T: RTSPMediaImpl>(
|
||||
|
@ -697,7 +724,7 @@ unsafe extern "C" fn media_target_state<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.target_state(&wrap, from_glib(state));
|
||||
imp.target_state(wrap.unsafe_cast_ref(), from_glib(state));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_new_state<T: RTSPMediaImpl>(
|
||||
|
@ -708,7 +735,7 @@ unsafe extern "C" fn media_new_state<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.new_state(&wrap, from_glib(state));
|
||||
imp.new_state(wrap.unsafe_cast_ref(), from_glib(state));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_handle_sdp<T: RTSPMediaImpl>(
|
||||
|
@ -719,7 +746,10 @@ unsafe extern "C" fn media_handle_sdp<T: RTSPMediaImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.handle_sdp(&wrap, &*(sdp as *const gst_sdp::SDPMessageRef)) {
|
||||
match imp.handle_sdp(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&*(sdp as *const gst_sdp::SDPMessageRef),
|
||||
) {
|
||||
Ok(()) => glib_sys::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
|
|
|
@ -8,96 +8,85 @@
|
|||
|
||||
use gst_rtsp_server_sys;
|
||||
|
||||
use glib::translate::*;
|
||||
use gst_rtsp;
|
||||
|
||||
use glib::prelude::*;
|
||||
use glib::subclass::prelude::*;
|
||||
use glib::translate::*;
|
||||
|
||||
use gst_rtsp;
|
||||
|
||||
use RTSPMediaFactory;
|
||||
|
||||
use std::mem::transmute;
|
||||
|
||||
pub trait RTSPMediaFactoryImpl: RTSPMediaFactoryImplExt + ObjectImpl + Send + Sync {
|
||||
fn gen_key(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<glib::GString> {
|
||||
fn gen_key(&self, factory: &Self::Type, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> {
|
||||
self.parent_gen_key(factory, url)
|
||||
}
|
||||
|
||||
fn create_element(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<gst::Element> {
|
||||
self.parent_create_element(factory, url)
|
||||
}
|
||||
|
||||
fn construct(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<::RTSPMedia> {
|
||||
fn construct(&self, factory: &Self::Type, url: &gst_rtsp::RTSPUrl) -> Option<::RTSPMedia> {
|
||||
self.parent_construct(factory, url)
|
||||
}
|
||||
|
||||
fn create_pipeline(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
media: &::RTSPMedia,
|
||||
) -> Option<gst::Pipeline> {
|
||||
fn create_pipeline(&self, factory: &Self::Type, media: &::RTSPMedia) -> Option<gst::Pipeline> {
|
||||
self.parent_create_pipeline(factory, media)
|
||||
}
|
||||
|
||||
fn configure(&self, factory: &RTSPMediaFactory, media: &::RTSPMedia) {
|
||||
fn configure(&self, factory: &Self::Type, media: &::RTSPMedia) {
|
||||
self.parent_configure(factory, media)
|
||||
}
|
||||
|
||||
fn media_constructed(&self, factory: &RTSPMediaFactory, media: &::RTSPMedia) {
|
||||
fn media_constructed(&self, factory: &Self::Type, media: &::RTSPMedia) {
|
||||
self.parent_media_constructed(factory, media)
|
||||
}
|
||||
|
||||
fn media_configure(&self, factory: &RTSPMediaFactory, media: &::RTSPMedia) {
|
||||
fn media_configure(&self, factory: &Self::Type, media: &::RTSPMedia) {
|
||||
self.parent_media_configure(factory, media)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTSPMediaFactoryImplExt {
|
||||
pub trait RTSPMediaFactoryImplExt: ObjectSubclass {
|
||||
fn parent_gen_key(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<glib::GString>;
|
||||
|
||||
fn parent_create_element(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<gst::Element>;
|
||||
|
||||
fn parent_construct(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<::RTSPMedia>;
|
||||
|
||||
fn parent_create_pipeline(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
factory: &Self::Type,
|
||||
media: &::RTSPMedia,
|
||||
) -> Option<gst::Pipeline>;
|
||||
|
||||
fn parent_configure(&self, factory: &RTSPMediaFactory, media: &::RTSPMedia);
|
||||
fn parent_configure(&self, factory: &Self::Type, media: &::RTSPMedia);
|
||||
|
||||
fn parent_media_constructed(&self, factory: &RTSPMediaFactory, media: &::RTSPMedia);
|
||||
fn parent_media_configure(&self, factory: &RTSPMediaFactory, media: &::RTSPMedia);
|
||||
fn parent_media_constructed(&self, factory: &Self::Type, media: &::RTSPMedia);
|
||||
fn parent_media_configure(&self, factory: &Self::Type, media: &::RTSPMedia);
|
||||
}
|
||||
|
||||
impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
||||
fn parent_gen_key(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<glib::GString> {
|
||||
unsafe {
|
||||
|
@ -106,14 +95,22 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
as *mut gst_rtsp_server_sys::GstRTSPMediaFactoryClass;
|
||||
(*parent_class)
|
||||
.gen_key
|
||||
.map(|f| from_glib_full(f(factory.to_glib_none().0, url.to_glib_none().0)))
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
factory
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
url.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_create_element(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<gst::Element> {
|
||||
unsafe {
|
||||
|
@ -122,14 +119,22 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
as *mut gst_rtsp_server_sys::GstRTSPMediaFactoryClass;
|
||||
(*parent_class)
|
||||
.create_element
|
||||
.map(|f| from_glib_none(f(factory.to_glib_none().0, url.to_glib_none().0)))
|
||||
.map(|f| {
|
||||
from_glib_none(f(
|
||||
factory
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
url.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_construct(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<::RTSPMedia> {
|
||||
unsafe {
|
||||
|
@ -138,14 +143,22 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
as *mut gst_rtsp_server_sys::GstRTSPMediaFactoryClass;
|
||||
(*parent_class)
|
||||
.construct
|
||||
.map(|f| from_glib_full(f(factory.to_glib_none().0, url.to_glib_none().0)))
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
factory
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
url.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_create_pipeline(
|
||||
&self,
|
||||
factory: &RTSPMediaFactory,
|
||||
factory: &Self::Type,
|
||||
media: &::RTSPMedia,
|
||||
) -> Option<gst::Pipeline> {
|
||||
unsafe {
|
||||
|
@ -155,8 +168,13 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
(*parent_class)
|
||||
.create_pipeline
|
||||
.map(|f| {
|
||||
let ptr = f(factory.to_glib_none().0, media.to_glib_none().0)
|
||||
as *mut gst_sys::GstPipeline;
|
||||
let ptr = f(
|
||||
factory
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
media.to_glib_none().0,
|
||||
) as *mut gst_sys::GstPipeline;
|
||||
|
||||
// See https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/109
|
||||
if gobject_sys::g_object_is_floating(ptr as *mut _) != glib_sys::GFALSE {
|
||||
|
@ -168,35 +186,53 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_configure(&self, factory: &RTSPMediaFactory, media: &::RTSPMedia) {
|
||||
fn parent_configure(&self, factory: &Self::Type, media: &::RTSPMedia) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class = data.as_ref().get_parent_class()
|
||||
as *mut gst_rtsp_server_sys::GstRTSPMediaFactoryClass;
|
||||
if let Some(f) = (*parent_class).configure {
|
||||
f(factory.to_glib_none().0, media.to_glib_none().0);
|
||||
f(
|
||||
factory
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
media.to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_media_constructed(&self, factory: &RTSPMediaFactory, media: &::RTSPMedia) {
|
||||
fn parent_media_constructed(&self, factory: &Self::Type, media: &::RTSPMedia) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class = data.as_ref().get_parent_class()
|
||||
as *mut gst_rtsp_server_sys::GstRTSPMediaFactoryClass;
|
||||
if let Some(f) = (*parent_class).media_constructed {
|
||||
f(factory.to_glib_none().0, media.to_glib_none().0);
|
||||
f(
|
||||
factory
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
media.to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_media_configure(&self, factory: &RTSPMediaFactory, media: &::RTSPMedia) {
|
||||
fn parent_media_configure(&self, factory: &Self::Type, media: &::RTSPMedia) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class = data.as_ref().get_parent_class()
|
||||
as *mut gst_rtsp_server_sys::GstRTSPMediaFactoryClass;
|
||||
if let Some(f) = (*parent_class).media_configure {
|
||||
f(factory.to_glib_none().0, media.to_glib_none().0);
|
||||
f(
|
||||
factory
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
media.to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +259,8 @@ unsafe extern "C" fn factory_gen_key<T: RTSPMediaFactoryImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.gen_key(&wrap, &from_glib_borrow(url)).to_glib_full()
|
||||
imp.gen_key(wrap.unsafe_cast_ref(), &from_glib_borrow(url))
|
||||
.to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn factory_create_element<T: RTSPMediaFactoryImpl>(
|
||||
|
@ -235,7 +272,7 @@ unsafe extern "C" fn factory_create_element<T: RTSPMediaFactoryImpl>(
|
|||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
let element = imp
|
||||
.create_element(&wrap, &from_glib_borrow(url))
|
||||
.create_element(wrap.unsafe_cast_ref(), &from_glib_borrow(url))
|
||||
.to_glib_full();
|
||||
gobject_sys::g_object_force_floating(element as *mut _);
|
||||
element
|
||||
|
@ -249,7 +286,8 @@ unsafe extern "C" fn factory_construct<T: RTSPMediaFactoryImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.construct(&wrap, &from_glib_borrow(url)).to_glib_full()
|
||||
imp.construct(wrap.unsafe_cast_ref(), &from_glib_borrow(url))
|
||||
.to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn factory_create_pipeline<T: RTSPMediaFactoryImpl>(
|
||||
|
@ -266,7 +304,7 @@ unsafe extern "C" fn factory_create_pipeline<T: RTSPMediaFactoryImpl>(
|
|||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
let pipeline: *mut gst_sys::GstPipeline = imp
|
||||
.create_pipeline(&wrap, &from_glib_borrow(media))
|
||||
.create_pipeline(wrap.unsafe_cast_ref(), &from_glib_borrow(media))
|
||||
.to_glib_full();
|
||||
|
||||
// FIXME We somehow need to ensure the pipeline actually stays alive...
|
||||
|
@ -290,7 +328,7 @@ unsafe extern "C" fn factory_configure<T: RTSPMediaFactoryImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.configure(&wrap, &from_glib_borrow(media));
|
||||
imp.configure(wrap.unsafe_cast_ref(), &from_glib_borrow(media));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn factory_media_constructed<T: RTSPMediaFactoryImpl>(
|
||||
|
@ -301,7 +339,7 @@ unsafe extern "C" fn factory_media_constructed<T: RTSPMediaFactoryImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.media_constructed(&wrap, &from_glib_borrow(media));
|
||||
imp.media_constructed(wrap.unsafe_cast_ref(), &from_glib_borrow(media));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn factory_media_configure<T: RTSPMediaFactoryImpl>(
|
||||
|
@ -312,5 +350,5 @@ unsafe extern "C" fn factory_media_configure<T: RTSPMediaFactoryImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.media_configure(&wrap, &from_glib_borrow(media));
|
||||
imp.media_configure(wrap.unsafe_cast_ref(), &from_glib_borrow(media));
|
||||
}
|
||||
|
|
|
@ -8,29 +8,30 @@
|
|||
|
||||
use gst_rtsp_server_sys;
|
||||
|
||||
use glib::prelude::*;
|
||||
use glib::subclass::prelude::*;
|
||||
use glib::translate::*;
|
||||
|
||||
use RTSPServer;
|
||||
|
||||
pub trait RTSPServerImpl: RTSPServerImplExt + ObjectImpl + Send + Sync {
|
||||
fn create_client(&self, server: &RTSPServer) -> Option<::RTSPClient> {
|
||||
fn create_client(&self, server: &Self::Type) -> Option<::RTSPClient> {
|
||||
self.parent_create_client(server)
|
||||
}
|
||||
|
||||
fn client_connected(&self, server: &RTSPServer, client: &::RTSPClient) {
|
||||
fn client_connected(&self, server: &Self::Type, client: &::RTSPClient) {
|
||||
self.parent_client_connected(server, client);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTSPServerImplExt {
|
||||
fn parent_create_client(&self, server: &RTSPServer) -> Option<::RTSPClient>;
|
||||
pub trait RTSPServerImplExt: ObjectSubclass {
|
||||
fn parent_create_client(&self, server: &Self::Type) -> Option<::RTSPClient>;
|
||||
|
||||
fn parent_client_connected(&self, server: &RTSPServer, client: &::RTSPClient);
|
||||
fn parent_client_connected(&self, server: &Self::Type, client: &::RTSPClient);
|
||||
}
|
||||
|
||||
impl<T: RTSPServerImpl> RTSPServerImplExt for T {
|
||||
fn parent_create_client(&self, server: &RTSPServer) -> Option<::RTSPClient> {
|
||||
fn parent_create_client(&self, server: &Self::Type) -> Option<::RTSPClient> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
|
@ -38,17 +39,20 @@ impl<T: RTSPServerImpl> RTSPServerImplExt for T {
|
|||
let f = (*parent_class)
|
||||
.create_client
|
||||
.expect("No `create_client` virtual method implementation in parent class");
|
||||
from_glib_full(f(server.to_glib_none().0))
|
||||
from_glib_full(f(server.unsafe_cast_ref::<RTSPServer>().to_glib_none().0))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_client_connected(&self, server: &RTSPServer, client: &::RTSPClient) {
|
||||
fn parent_client_connected(&self, server: &Self::Type, client: &::RTSPClient) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_rtsp_server_sys::GstRTSPServerClass;
|
||||
if let Some(f) = (*parent_class).client_connected {
|
||||
f(server.to_glib_none().0, client.to_glib_none().0)
|
||||
f(
|
||||
server.unsafe_cast_ref::<RTSPServer>().to_glib_none().0,
|
||||
client.to_glib_none().0,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +73,7 @@ unsafe extern "C" fn server_create_client<T: RTSPServerImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPServer> = from_glib_borrow(ptr);
|
||||
|
||||
imp.create_client(&wrap).to_glib_full()
|
||||
imp.create_client(wrap.unsafe_cast_ref()).to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn server_client_connected<T: RTSPServerImpl>(
|
||||
|
@ -80,5 +84,5 @@ unsafe extern "C" fn server_client_connected<T: RTSPServerImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<RTSPServer> = from_glib_borrow(ptr);
|
||||
|
||||
imp.client_connected(&wrap, &from_glib_borrow(client));
|
||||
imp.client_connected(wrap.unsafe_cast_ref(), &from_glib_borrow(client));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue