2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
use glib::prelude::*;
|
2020-02-23 08:00:48 +00:00
|
|
|
use glib::subclass::prelude::*;
|
2020-06-29 21:12:46 +00:00
|
|
|
use glib::translate::*;
|
2020-02-23 08:00:48 +00:00
|
|
|
|
|
|
|
use std::ptr;
|
|
|
|
|
2020-11-22 10:45:51 +00:00
|
|
|
use crate::RTSPMedia;
|
|
|
|
use crate::RTSPThread;
|
2020-02-23 08:00:48 +00:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
2020-11-22 10:45:51 +00:00
|
|
|
pub struct SDPInfo(ptr::NonNull<ffi::GstSDPInfo>);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
|
|
|
impl SDPInfo {
|
|
|
|
pub fn is_ipv6(&self) -> bool {
|
|
|
|
unsafe { from_glib(self.0.as_ref().is_ipv6) }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn server_ip(&self) -> &str {
|
|
|
|
unsafe {
|
|
|
|
use std::ffi::CStr;
|
|
|
|
CStr::from_ptr(self.0.as_ref().server_ip).to_str().unwrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
pub trait RTSPMediaImpl: RTSPMediaImplExt + ObjectImpl + Send + Sync {
|
2020-11-14 16:31:21 +00:00
|
|
|
fn handle_message(&self, media: &Self::Type, message: &gst::MessageRef) -> bool {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_handle_message(media, message)
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn prepare(&self, media: &Self::Type, thread: &RTSPThread) -> Result<(), gst::LoggableError> {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_prepare(media, thread)
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn unprepare(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_unprepare(media)
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn suspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_suspend(media)
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn unsuspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_unsuspend(media)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO missing: convert_range
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn query_position(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_query_position(media)
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn query_stop(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_query_stop(media)
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn create_rtpbin(&self, media: &Self::Type) -> Option<gst::Element> {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_create_rtpbin(media)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn setup_rtpbin(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
rtpbin: &gst::Element,
|
|
|
|
) -> Result<(), gst::LoggableError> {
|
|
|
|
self.parent_setup_rtpbin(media, rtpbin)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn setup_sdp(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
sdp: &mut gst_sdp::SDPMessageRef,
|
|
|
|
info: &SDPInfo,
|
|
|
|
) -> Result<(), gst::LoggableError> {
|
|
|
|
self.parent_setup_sdp(media, sdp, info)
|
|
|
|
}
|
|
|
|
|
2020-11-22 10:45:51 +00:00
|
|
|
fn new_stream(&self, media: &Self::Type, stream: &crate::RTSPStream) {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_new_stream(media, stream);
|
|
|
|
}
|
|
|
|
|
2020-11-22 10:45:51 +00:00
|
|
|
fn removed_stream(&self, media: &Self::Type, stream: &crate::RTSPStream) {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_removed_stream(media, stream);
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn prepared(&self, media: &Self::Type) {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_prepared(media);
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn unprepared(&self, media: &Self::Type) {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_unprepared(media);
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn target_state(&self, media: &Self::Type, state: gst::State) {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_target_state(media, state);
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn new_state(&self, media: &Self::Type, state: gst::State) {
|
2020-02-23 08:00:48 +00:00
|
|
|
self.parent_new_state(media, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn handle_sdp(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
sdp: &gst_sdp::SDPMessageRef,
|
|
|
|
) -> Result<(), gst::LoggableError> {
|
|
|
|
self.parent_handle_sdp(media, sdp)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
pub trait RTSPMediaImplExt: ObjectSubclass {
|
|
|
|
fn parent_handle_message(&self, media: &Self::Type, message: &gst::MessageRef) -> bool;
|
2020-02-23 08:00:48 +00:00
|
|
|
fn parent_prepare(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
thread: &RTSPThread,
|
|
|
|
) -> Result<(), gst::LoggableError>;
|
2020-11-14 16:31:21 +00:00
|
|
|
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>;
|
2020-02-23 08:00:48 +00:00
|
|
|
// TODO missing: convert_range
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
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>;
|
2020-02-23 08:00:48 +00:00
|
|
|
fn parent_setup_rtpbin(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
rtpbin: &gst::Element,
|
|
|
|
) -> Result<(), gst::LoggableError>;
|
|
|
|
fn parent_setup_sdp(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
sdp: &mut gst_sdp::SDPMessageRef,
|
|
|
|
info: &SDPInfo,
|
|
|
|
) -> Result<(), gst::LoggableError>;
|
2020-11-22 10:45:51 +00:00
|
|
|
fn parent_new_stream(&self, media: &Self::Type, stream: &crate::RTSPStream);
|
|
|
|
fn parent_removed_stream(&self, media: &Self::Type, stream: &crate::RTSPStream);
|
2020-11-14 16:31:21 +00:00
|
|
|
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);
|
2020-02-23 08:00:48 +00:00
|
|
|
fn parent_handle_sdp(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
sdp: &gst_sdp::SDPMessageRef,
|
|
|
|
) -> Result<(), gst::LoggableError>;
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_handle_message(&self, media: &Self::Type, message: &gst::MessageRef) -> bool {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).handle_message {
|
2020-11-14 16:31:21 +00:00
|
|
|
from_glib(f(
|
|
|
|
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
|
|
|
message.as_ptr() as *mut _,
|
|
|
|
))
|
2020-02-23 08:00:48 +00:00
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_prepare(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
thread: &RTSPThread,
|
|
|
|
) -> Result<(), gst::LoggableError> {
|
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).prepare {
|
2020-12-20 15:09:22 +00:00
|
|
|
gst::result_from_gboolean!(
|
2020-11-14 16:31:21 +00:00
|
|
|
f(
|
|
|
|
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
|
|
|
thread.to_glib_none().0
|
|
|
|
),
|
2020-02-23 08:00:48 +00:00
|
|
|
gst::CAT_RUST,
|
|
|
|
"Parent function `prepare` failed"
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_unprepare(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).unprepare {
|
2020-12-20 15:09:22 +00:00
|
|
|
gst::result_from_gboolean!(
|
2020-11-14 16:31:21 +00:00
|
|
|
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0),
|
2020-02-23 08:00:48 +00:00
|
|
|
gst::CAT_RUST,
|
|
|
|
"Parent function `unprepare` failed"
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_suspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).suspend {
|
2020-12-20 15:09:22 +00:00
|
|
|
gst::result_from_gboolean!(
|
2020-11-14 16:31:21 +00:00
|
|
|
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0),
|
2020-02-23 08:00:48 +00:00
|
|
|
gst::CAT_RUST,
|
|
|
|
"Parent function `suspend` failed"
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_unsuspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).unsuspend {
|
2020-12-20 15:09:22 +00:00
|
|
|
gst::result_from_gboolean!(
|
2020-11-14 16:31:21 +00:00
|
|
|
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0),
|
2020-02-23 08:00:48 +00:00
|
|
|
gst::CAT_RUST,
|
|
|
|
"Parent function `unsuspend` failed"
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO missing: convert_range
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_query_position(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
|
|
|
use std::mem;
|
|
|
|
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).query_position {
|
|
|
|
let mut position = mem::MaybeUninit::uninit();
|
2020-11-14 16:31:21 +00:00
|
|
|
if f(
|
|
|
|
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
|
|
|
position.as_mut_ptr(),
|
2020-11-22 10:45:51 +00:00
|
|
|
) == glib::ffi::GFALSE
|
2020-11-14 16:31:21 +00:00
|
|
|
{
|
2020-02-23 08:00:48 +00:00
|
|
|
None
|
|
|
|
} else {
|
2021-04-28 22:29:13 +00:00
|
|
|
from_glib(position.assume_init() as u64)
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_query_stop(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
|
|
|
use std::mem;
|
|
|
|
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).query_stop {
|
|
|
|
let mut stop = mem::MaybeUninit::uninit();
|
2020-11-14 16:31:21 +00:00
|
|
|
if f(
|
|
|
|
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
|
|
|
stop.as_mut_ptr(),
|
2020-11-22 10:45:51 +00:00
|
|
|
) == glib::ffi::GFALSE
|
2020-11-14 16:31:21 +00:00
|
|
|
{
|
2020-02-23 08:00:48 +00:00
|
|
|
None
|
|
|
|
} else {
|
2021-04-28 22:29:13 +00:00
|
|
|
from_glib(stop.assume_init() as u64)
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_create_rtpbin(&self, media: &Self::Type) -> Option<gst::Element> {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
let f = (*parent_class)
|
|
|
|
.create_rtpbin
|
|
|
|
.expect("No `create_rtpbin` virtual method implementation in parent class");
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
from_glib_none(f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0))
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_setup_rtpbin(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
rtpbin: &gst::Element,
|
|
|
|
) -> Result<(), gst::LoggableError> {
|
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).setup_rtpbin {
|
|
|
|
let ptr = rtpbin.to_glib_none().0;
|
|
|
|
|
|
|
|
// The C code assumes to pass a floating reference around so let's make sure we do
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::gobject_ffi::g_object_force_floating(ptr as *mut _);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-12-20 15:09:22 +00:00
|
|
|
let res = gst::result_from_gboolean!(
|
2020-11-14 16:31:21 +00:00
|
|
|
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0, ptr),
|
2020-02-23 08:00:48 +00:00
|
|
|
gst::CAT_RUST,
|
|
|
|
"Parent function `setup_sdp` failed"
|
|
|
|
);
|
|
|
|
|
|
|
|
// If the code didn't accidentally sink it then we have to do that
|
|
|
|
// here now so that we don't have any floating reference on our side
|
|
|
|
// anymore
|
2020-11-22 10:45:51 +00:00
|
|
|
if glib::gobject_ffi::g_object_is_floating(ptr as *mut _) != glib::ffi::GFALSE {
|
|
|
|
glib::gobject_ffi::g_object_ref_sink(ptr as *mut _);
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
res
|
|
|
|
} else {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_setup_sdp(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
sdp: &mut gst_sdp::SDPMessageRef,
|
|
|
|
info: &SDPInfo,
|
|
|
|
) -> Result<(), gst::LoggableError> {
|
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
let f = (*parent_class)
|
|
|
|
.setup_sdp
|
|
|
|
.expect("No `setup_sdp` virtual method implementation in parent class");
|
|
|
|
|
2020-12-20 15:09:22 +00:00
|
|
|
gst::result_from_gboolean!(
|
2020-02-23 08:00:48 +00:00
|
|
|
f(
|
2020-11-14 16:31:21 +00:00
|
|
|
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
2020-11-22 10:45:51 +00:00
|
|
|
sdp as *mut _ as *mut gst_sdp::ffi::GstSDPMessage,
|
2020-02-23 08:00:48 +00:00
|
|
|
info.0.as_ptr()
|
|
|
|
),
|
|
|
|
gst::CAT_RUST,
|
|
|
|
"Parent function `setup_sdp` failed"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-22 10:45:51 +00:00
|
|
|
fn parent_new_stream(&self, media: &Self::Type, stream: &crate::RTSPStream) {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).new_stream {
|
2020-11-14 16:31:21 +00:00
|
|
|
f(
|
|
|
|
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
|
|
|
stream.to_glib_none().0,
|
|
|
|
);
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-22 10:45:51 +00:00
|
|
|
fn parent_removed_stream(&self, media: &Self::Type, stream: &crate::RTSPStream) {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).removed_stream {
|
2020-11-14 16:31:21 +00:00
|
|
|
f(
|
|
|
|
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
|
|
|
stream.to_glib_none().0,
|
|
|
|
);
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_prepared(&self, media: &Self::Type) {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).prepared {
|
2020-11-14 16:31:21 +00:00
|
|
|
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0);
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_unprepared(&self, media: &Self::Type) {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).unprepared {
|
2020-11-14 16:31:21 +00:00
|
|
|
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0);
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_target_state(&self, media: &Self::Type, state: gst::State) {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).target_state {
|
2020-11-14 16:31:21 +00:00
|
|
|
f(
|
|
|
|
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
2021-04-27 15:15:46 +00:00
|
|
|
state.into_glib(),
|
2020-11-14 16:31:21 +00:00
|
|
|
);
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
fn parent_new_state(&self, media: &Self::Type, state: gst::State) {
|
2020-02-23 08:00:48 +00:00
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
if let Some(f) = (*parent_class).new_state {
|
2020-11-14 16:31:21 +00:00
|
|
|
f(
|
|
|
|
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
2021-04-27 15:15:46 +00:00
|
|
|
state.into_glib(),
|
2020-11-14 16:31:21 +00:00
|
|
|
);
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parent_handle_sdp(
|
|
|
|
&self,
|
2020-11-14 16:31:21 +00:00
|
|
|
media: &Self::Type,
|
2020-02-23 08:00:48 +00:00
|
|
|
sdp: &gst_sdp::SDPMessageRef,
|
|
|
|
) -> Result<(), gst::LoggableError> {
|
|
|
|
unsafe {
|
2021-04-29 20:06:41 +00:00
|
|
|
let data = Self::type_data();
|
2021-04-11 19:39:50 +00:00
|
|
|
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
2020-02-23 08:00:48 +00:00
|
|
|
let f = (*parent_class)
|
|
|
|
.handle_sdp
|
|
|
|
.expect("No `handle_sdp` virtual method implementation in parent class");
|
|
|
|
|
2020-12-20 15:09:22 +00:00
|
|
|
gst::result_from_gboolean!(
|
2020-02-23 08:00:48 +00:00
|
|
|
f(
|
2020-11-14 16:31:21 +00:00
|
|
|
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
2020-11-22 10:45:51 +00:00
|
|
|
sdp as *const _ as *mut gst_sdp::ffi::GstSDPMessage
|
2020-02-23 08:00:48 +00:00
|
|
|
),
|
|
|
|
gst::CAT_RUST,
|
|
|
|
"Parent function `handle_sdp` failed"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-05 13:18:19 +00:00
|
|
|
unsafe impl<T: RTSPMediaImpl> IsSubclassable<T> for RTSPMedia {
|
2021-03-08 10:06:56 +00:00
|
|
|
fn class_init(klass: &mut glib::Class<Self>) {
|
2021-08-24 05:55:37 +00:00
|
|
|
Self::parent_class_init::<T>(klass);
|
2020-11-05 17:07:31 +00:00
|
|
|
let klass = klass.as_mut();
|
|
|
|
klass.handle_message = Some(media_handle_message::<T>);
|
|
|
|
klass.prepare = Some(media_prepare::<T>);
|
|
|
|
klass.unprepare = Some(media_unprepare::<T>);
|
|
|
|
klass.suspend = Some(media_suspend::<T>);
|
|
|
|
klass.unsuspend = Some(media_unsuspend::<T>);
|
|
|
|
klass.query_position = Some(media_query_position::<T>);
|
|
|
|
klass.query_stop = Some(media_query_stop::<T>);
|
|
|
|
klass.create_rtpbin = Some(media_create_rtpbin::<T>);
|
|
|
|
klass.setup_rtpbin = Some(media_setup_rtpbin::<T>);
|
|
|
|
klass.setup_sdp = Some(media_setup_sdp::<T>);
|
|
|
|
klass.new_stream = Some(media_new_stream::<T>);
|
|
|
|
klass.removed_stream = Some(media_removed_stream::<T>);
|
|
|
|
klass.prepared = Some(media_prepared::<T>);
|
|
|
|
klass.unprepared = Some(media_unprepared::<T>);
|
|
|
|
klass.target_state = Some(media_target_state::<T>);
|
|
|
|
klass.new_state = Some(media_new_state::<T>);
|
|
|
|
klass.handle_sdp = Some(media_handle_sdp::<T>);
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_handle_message<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
message: *mut gst::ffi::GstMessage,
|
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
imp.handle_message(wrap.unsafe_cast_ref(), gst::MessageRef::from_ptr(message))
|
2021-04-27 15:15:46 +00:00
|
|
|
.into_glib()
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_prepare<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
thread: *mut ffi::GstRTSPThread,
|
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
match imp.prepare(wrap.unsafe_cast_ref(), &from_glib_borrow(thread)) {
|
2020-11-22 10:45:51 +00:00
|
|
|
Ok(()) => glib::ffi::GTRUE,
|
2020-02-23 08:00:48 +00:00
|
|
|
Err(err) => {
|
2020-04-05 14:52:56 +00:00
|
|
|
err.log_with_object(&*wrap);
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::ffi::GFALSE
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_unprepare<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
match imp.unprepare(wrap.unsafe_cast_ref()) {
|
2020-11-22 10:45:51 +00:00
|
|
|
Ok(()) => glib::ffi::GTRUE,
|
2020-02-23 08:00:48 +00:00
|
|
|
Err(err) => {
|
2020-04-05 14:52:56 +00:00
|
|
|
err.log_with_object(&*wrap);
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::ffi::GFALSE
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_suspend<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
match imp.suspend(wrap.unsafe_cast_ref()) {
|
2020-11-22 10:45:51 +00:00
|
|
|
Ok(()) => glib::ffi::GTRUE,
|
2020-02-23 08:00:48 +00:00
|
|
|
Err(err) => {
|
2020-04-05 14:52:56 +00:00
|
|
|
err.log_with_object(&*wrap);
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::ffi::GFALSE
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_unsuspend<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
match imp.unsuspend(wrap.unsafe_cast_ref()) {
|
2020-11-22 10:45:51 +00:00
|
|
|
Ok(()) => glib::ffi::GTRUE,
|
2020-02-23 08:00:48 +00:00
|
|
|
Err(err) => {
|
2020-04-05 14:52:56 +00:00
|
|
|
err.log_with_object(&*wrap);
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::ffi::GFALSE
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_query_position<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
2020-02-23 08:00:48 +00:00
|
|
|
position: *mut i64,
|
2020-11-22 10:45:51 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
match imp.query_position(wrap.unsafe_cast_ref()) {
|
2020-02-23 08:00:48 +00:00
|
|
|
Some(pos) => {
|
2021-04-27 15:15:46 +00:00
|
|
|
*position = pos.into_glib() as i64;
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::ffi::GTRUE
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
2020-11-22 10:45:51 +00:00
|
|
|
None => glib::ffi::GFALSE,
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_query_stop<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
2020-02-23 08:00:48 +00:00
|
|
|
stop: *mut i64,
|
2020-11-22 10:45:51 +00:00
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
match imp.query_stop(wrap.unsafe_cast_ref()) {
|
2020-02-23 08:00:48 +00:00
|
|
|
Some(s) => {
|
2021-04-27 15:15:46 +00:00
|
|
|
*stop = s.into_glib() as i64;
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::ffi::GTRUE
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
2020-11-22 10:45:51 +00:00
|
|
|
None => glib::ffi::GFALSE,
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_create_rtpbin<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
) -> *mut gst::ffi::GstElement {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-22 10:45:51 +00:00
|
|
|
let res: *mut gst::ffi::GstElement = imp.create_rtpbin(wrap.unsafe_cast_ref()).to_glib_full();
|
2020-02-23 08:00:48 +00:00
|
|
|
|
|
|
|
if !res.is_null() {
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::gobject_ffi::g_object_force_floating(res as *mut _);
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
res
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_setup_rtpbin<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
rtpbin: *mut gst::ffi::GstElement,
|
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
|
|
|
// If the rtpbin was floating before make sure it is not anymore for now so
|
|
|
|
// we don't accidentally take ownership of it somewhere along the line
|
2020-11-22 10:45:51 +00:00
|
|
|
if glib::gobject_ffi::g_object_is_floating(rtpbin as *mut _) != glib::ffi::GFALSE {
|
|
|
|
glib::gobject_ffi::g_object_ref_sink(rtpbin as *mut _);
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
let res = match imp.setup_rtpbin(wrap.unsafe_cast_ref(), &from_glib_borrow(rtpbin)) {
|
2020-11-22 10:45:51 +00:00
|
|
|
Ok(()) => glib::ffi::GTRUE,
|
2020-02-23 08:00:48 +00:00
|
|
|
Err(err) => {
|
2020-04-05 14:52:56 +00:00
|
|
|
err.log_with_object(&*wrap);
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::ffi::GFALSE
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Ensure that the rtpbin is still floating afterwards here
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::gobject_ffi::g_object_force_floating(rtpbin as *mut _);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
|
|
|
res
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_setup_sdp<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
sdp: *mut gst_sdp::ffi::GstSDPMessage,
|
|
|
|
info: *mut ffi::GstSDPInfo,
|
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
|
|
|
match imp.setup_sdp(
|
2020-11-14 16:31:21 +00:00
|
|
|
wrap.unsafe_cast_ref(),
|
2020-02-23 08:00:48 +00:00
|
|
|
&mut *(sdp as *mut gst_sdp::SDPMessageRef),
|
|
|
|
&SDPInfo(ptr::NonNull::new(info).expect("NULL SDPInfo")),
|
|
|
|
) {
|
2020-11-22 10:45:51 +00:00
|
|
|
Ok(()) => glib::ffi::GTRUE,
|
2020-02-23 08:00:48 +00:00
|
|
|
Err(err) => {
|
2020-04-05 14:52:56 +00:00
|
|
|
err.log_with_object(&*wrap);
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::ffi::GFALSE
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_new_stream<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
stream: *mut ffi::GstRTSPStream,
|
2020-07-25 08:02:04 +00:00
|
|
|
) {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
imp.new_stream(wrap.unsafe_cast_ref(), &from_glib_borrow(stream));
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_removed_stream<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
stream: *mut ffi::GstRTSPStream,
|
2020-07-25 08:02:04 +00:00
|
|
|
) {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
imp.removed_stream(wrap.unsafe_cast_ref(), &from_glib_borrow(stream));
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-22 10:45:51 +00:00
|
|
|
unsafe extern "C" fn media_prepared<T: RTSPMediaImpl>(ptr: *mut ffi::GstRTSPMedia) {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
imp.prepared(wrap.unsafe_cast_ref());
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-22 10:45:51 +00:00
|
|
|
unsafe extern "C" fn media_unprepared<T: RTSPMediaImpl>(ptr: *mut ffi::GstRTSPMedia) {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
imp.unprepared(wrap.unsafe_cast_ref());
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_target_state<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
state: gst::ffi::GstState,
|
2020-07-25 08:02:04 +00:00
|
|
|
) {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
imp.target_state(wrap.unsafe_cast_ref(), from_glib(state));
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_new_state<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
state: gst::ffi::GstState,
|
2020-07-25 08:02:04 +00:00
|
|
|
) {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
imp.new_state(wrap.unsafe_cast_ref(), from_glib(state));
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 08:02:04 +00:00
|
|
|
unsafe extern "C" fn media_handle_sdp<T: RTSPMediaImpl>(
|
2020-11-22 10:45:51 +00:00
|
|
|
ptr: *mut ffi::GstRTSPMedia,
|
|
|
|
sdp: *mut gst_sdp::ffi::GstSDPMessage,
|
|
|
|
) -> glib::ffi::gboolean {
|
2020-02-23 08:00:48 +00:00
|
|
|
let instance = &*(ptr as *mut T::Instance);
|
2021-04-11 19:39:50 +00:00
|
|
|
let imp = instance.impl_();
|
2020-04-05 14:52:56 +00:00
|
|
|
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
2020-02-23 08:00:48 +00:00
|
|
|
|
2020-11-14 16:31:21 +00:00
|
|
|
match imp.handle_sdp(
|
|
|
|
wrap.unsafe_cast_ref(),
|
|
|
|
&*(sdp as *const gst_sdp::SDPMessageRef),
|
|
|
|
) {
|
2020-11-22 10:45:51 +00:00
|
|
|
Ok(()) => glib::ffi::GTRUE,
|
2020-02-23 08:00:48 +00:00
|
|
|
Err(err) => {
|
2020-04-05 14:52:56 +00:00
|
|
|
err.log_with_object(&*wrap);
|
2020-11-22 10:45:51 +00:00
|
|
|
glib::ffi::GFALSE
|
2020-02-23 08:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|