mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-09-27 14:30:27 +00:00
webrtcsink: add custom signaller example
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1388>
This commit is contained in:
parent
107c610bb0
commit
569dfadcab
4 changed files with 115 additions and 0 deletions
|
@ -93,3 +93,6 @@ name = "webrtcsink-stats-server"
|
|||
|
||||
[[example]]
|
||||
name = "webrtcsink-high-quality-tune"
|
||||
|
||||
[[example]]
|
||||
name = "webrtcsink-custom-signaller"
|
||||
|
|
41
net/webrtc/examples/webrtcsink-custom-signaller/main.rs
Normal file
41
net/webrtc/examples/webrtcsink-custom-signaller/main.rs
Normal file
|
@ -0,0 +1,41 @@
|
|||
mod signaller;
|
||||
|
||||
// from outside the plugin repository, one would need to add plugin package as follows:
|
||||
// [dependencies]
|
||||
// gstrswebrtc = { package = "gst-plugin-webrtc", git = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/" }
|
||||
extern crate gstrswebrtc;
|
||||
|
||||
use anyhow::Error;
|
||||
use gst::prelude::*;
|
||||
use gstrswebrtc::signaller as signaller_interface;
|
||||
use gstrswebrtc::webrtcsink;
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
gst::init()?;
|
||||
|
||||
let custom_signaller = signaller::MyCustomSignaller::new();
|
||||
let webrtcsink = webrtcsink::BaseWebRTCSink::with_signaller(
|
||||
signaller_interface::Signallable::from(custom_signaller),
|
||||
);
|
||||
|
||||
let pipeline = gst::Pipeline::new();
|
||||
|
||||
let video_src = gst::ElementFactory::make("videotestsrc").build().unwrap();
|
||||
|
||||
pipeline
|
||||
.add_many([&video_src, webrtcsink.upcast_ref()])
|
||||
.unwrap();
|
||||
video_src
|
||||
.link(webrtcsink.upcast_ref::<gst::Element>())
|
||||
.unwrap();
|
||||
|
||||
let bus = pipeline.bus().unwrap();
|
||||
|
||||
pipeline.set_state(gst::State::Playing).unwrap();
|
||||
|
||||
let _msg = bus.timed_pop_filtered(gst::ClockTime::NONE, &[gst::MessageType::Eos]);
|
||||
|
||||
pipeline.set_state(gst::State::Null).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
use gst::glib;
|
||||
use gst::subclass::prelude::*;
|
||||
use gst_webrtc::WebRTCSessionDescription;
|
||||
|
||||
use gstrswebrtc::signaller::{Signallable, SignallableImpl};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Signaller {}
|
||||
|
||||
impl Signaller {}
|
||||
|
||||
impl SignallableImpl for Signaller {
|
||||
fn start(&self) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn stop(&self) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn send_sdp(&self, _session_id: &str, _sdp: &WebRTCSessionDescription) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn add_ice(
|
||||
&self,
|
||||
_session_id: &str,
|
||||
_candidate: &str,
|
||||
_sdp_m_line_index: u32,
|
||||
_sdp_mid: Option<String>,
|
||||
) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn end_session(&self, _session_id: &str) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for Signaller {
|
||||
const NAME: &'static str = "MyCustomWebRTCSinkSignaller";
|
||||
type Type = super::MyCustomSignaller;
|
||||
type ParentType = glib::Object;
|
||||
type Interfaces = (Signallable,);
|
||||
}
|
||||
|
||||
impl ObjectImpl for Signaller {}
|
|
@ -0,0 +1,23 @@
|
|||
use gst::glib;
|
||||
use gstrswebrtc::signaller::Signallable;
|
||||
|
||||
mod imp;
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct MyCustomSignaller(ObjectSubclass<imp::Signaller>) @implements Signallable;
|
||||
}
|
||||
|
||||
unsafe impl Send for MyCustomSignaller {}
|
||||
unsafe impl Sync for MyCustomSignaller {}
|
||||
|
||||
impl MyCustomSignaller {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MyCustomSignaller {
|
||||
fn default() -> Self {
|
||||
MyCustomSignaller::new()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue