diff --git a/Cargo.lock b/Cargo.lock index 56bcb08..410608b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3248,6 +3248,7 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" name = "vcs-camera-satellite" version = "0.1.0" dependencies = [ + "anyhow", "config", "gst-plugin-webrtc", "gstreamer", diff --git a/Cargo.toml b/Cargo.toml index 8887cbe..7872daf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow = "1.0.86" config = "0.14.0" gst-plugin-webrtc = "0.13.0" gstreamer = { version = "0.23.0", features = ["v1_22"] } diff --git a/src/main.rs b/src/main.rs index 7726dd5..4b3653f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,41 @@ - mod signaller; -fn main() { - println!("Hello, world!"); +// 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/" } +use gstrswebrtc; + +use anyhow::Error; +use gstreamer::prelude::*; +use gstrswebrtc::signaller as signaller_interface; +use gstrswebrtc::webrtcsink; + +fn main() -> Result<(), Error> { + gstreamer::init()?; + + let custom_signaller = signaller::MyCustomSignaller::new(); + let webrtcsink = webrtcsink::BaseWebRTCSink::with_signaller( + signaller_interface::Signallable::from(custom_signaller), + ); + + let pipeline = gstreamer::Pipeline::new(); + + let video_src = gstreamer::ElementFactory::make("videotestsrc").build().unwrap(); + + pipeline + .add_many([&video_src, webrtcsink.upcast_ref()]) + .unwrap(); + video_src + .link(webrtcsink.upcast_ref::()) + .unwrap(); + + let bus = pipeline.bus().unwrap(); + + pipeline.set_state(gstreamer::State::Playing).unwrap(); + + let _msg = bus.timed_pop_filtered(gstreamer::ClockTime::NONE, &[gstreamer::MessageType::Eos]); + + pipeline.set_state(gstreamer::State::Null).unwrap(); + + Ok(()) }