mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
examples: webrtc: rust: Update to gstreamer-rs 0.21
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5181>
This commit is contained in:
parent
f3cd913b3c
commit
ae28e1035e
10 changed files with 1383 additions and 1068 deletions
547
subprojects/gst-examples/webrtc/janus/rust/Cargo.lock
generated
547
subprojects/gst-examples/webrtc/janus/rust/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -11,15 +11,15 @@ clap = { version = "4", features = ["derive"] }
|
|||
anyhow = "1"
|
||||
url = "2"
|
||||
rand = "0.8"
|
||||
async-tungstenite = { version = "0.20", features = ["gio-runtime"] }
|
||||
gst = { package = "gstreamer", version = "0.20" }
|
||||
gst-webrtc = { package = "gstreamer-webrtc", version = "0.20" }
|
||||
gst-sdp = { package = "gstreamer-sdp", version = "0.20" }
|
||||
async-tungstenite = { version = "0.23", features = ["gio-runtime"] }
|
||||
gst = { package = "gstreamer", version = "0.21" }
|
||||
gst-webrtc = { package = "gstreamer-webrtc", version = "0.21" }
|
||||
gst-sdp = { package = "gstreamer-sdp", version = "0.21" }
|
||||
serde = "1"
|
||||
serde_derive = "1"
|
||||
serde_json = "1.0.53"
|
||||
http = "0.2"
|
||||
glib = "0.17"
|
||||
gio = "0.17"
|
||||
glib = "0.18"
|
||||
gio = "0.18"
|
||||
log = "0.4.8"
|
||||
env_logger = "0.10"
|
||||
|
|
|
@ -503,10 +503,11 @@ impl JanusGateway {
|
|||
.static_pad("sink")
|
||||
.expect("Failed to get sink pad from encoder");
|
||||
|
||||
if let Ok(video_ghost_pad) = gst::GhostPad::with_target(Some("video_sink"), &sinkpad) {
|
||||
let video_ghost_pad = gst::GhostPad::builder_with_target(&sinkpad)?
|
||||
.name("video_sink")
|
||||
.build();
|
||||
encode_bin.add_pad(&video_ghost_pad)?;
|
||||
srcpad.link(&video_ghost_pad)?;
|
||||
}
|
||||
|
||||
let sinkpad2 = webrtcbin
|
||||
.request_pad_simple("sink_%u")
|
||||
|
@ -515,11 +516,11 @@ impl JanusGateway {
|
|||
.by_name("webrtc-vsink")
|
||||
.expect("No webrtc-vsink found");
|
||||
let srcpad = vsink.static_pad("src").expect("Element without src pad");
|
||||
if let Ok(webrtc_ghost_pad) = gst::GhostPad::with_target(Some("webrtc_video_src"), &srcpad)
|
||||
{
|
||||
let webrtc_ghost_pad = gst::GhostPad::builder_with_target(&srcpad)?
|
||||
.name("webrtc_video_src")
|
||||
.build();
|
||||
encode_bin.add_pad(&webrtc_ghost_pad)?;
|
||||
webrtc_ghost_pad.link(&sinkpad2)?;
|
||||
}
|
||||
|
||||
let transceiver = webrtcbin.emit_by_name::<glib::Object>("get-transceiver", &[&0i32]);
|
||||
transceiver.set_property("do-nack", false);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
use anyhow::bail;
|
||||
use gst::prelude::*;
|
||||
use std::sync::{Arc, Weak};
|
||||
use std::sync::{Arc, Mutex, Weak};
|
||||
|
||||
mod janus;
|
||||
|
||||
|
@ -36,6 +36,7 @@ struct AppWeak(Weak<AppInner>);
|
|||
#[derive(Debug)]
|
||||
struct AppInner {
|
||||
pipeline: gst::Pipeline,
|
||||
bus_watch: Mutex<Option<gst::bus::BusWatchGuard>>,
|
||||
}
|
||||
|
||||
// To be able to access the App's fields directly
|
||||
|
@ -71,18 +72,24 @@ impl App {
|
|||
.expect("Couldn't downcast pipeline");
|
||||
|
||||
let bus = pipeline.bus().unwrap();
|
||||
let app = App(Arc::new(AppInner { pipeline }));
|
||||
let app = App(Arc::new(AppInner {
|
||||
pipeline,
|
||||
bus_watch: Mutex::default(),
|
||||
}));
|
||||
|
||||
let app_weak = app.downgrade();
|
||||
bus.add_watch_local(move |_bus, msg| {
|
||||
let app = upgrade_weak!(app_weak, glib::Continue(false));
|
||||
let bus_watch = bus
|
||||
.add_watch_local(move |_bus, msg| {
|
||||
let app = upgrade_weak!(app_weak, glib::ControlFlow::Break);
|
||||
|
||||
if app.handle_pipeline_message(msg).is_err() {
|
||||
return glib::Continue(false);
|
||||
return glib::ControlFlow::Break;
|
||||
}
|
||||
glib::Continue(true)
|
||||
glib::ControlFlow::Continue
|
||||
})
|
||||
.expect("Unable to add bus watch");
|
||||
*app.0.bus_watch.lock().unwrap() = Some(bus_watch);
|
||||
|
||||
Ok(app)
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,13 +10,13 @@ async-std = "1"
|
|||
clap = { version = "4", features = ["derive"] }
|
||||
anyhow = "1"
|
||||
rand = "0.8"
|
||||
async-tungstenite = { version = "0.20", features = ["async-std-runtime", "async-native-tls"] }
|
||||
gst = { package = "gstreamer", version = "0.20" }
|
||||
gst-webrtc = { package = "gstreamer-webrtc", version = "0.20" }
|
||||
gst-sdp = { package = "gstreamer-sdp", version = "0.20" }
|
||||
async-tungstenite = { version = "0.23", features = ["async-std-runtime", "async-native-tls"] }
|
||||
gst = { package = "gstreamer", version = "0.21" }
|
||||
gst-webrtc = { package = "gstreamer-webrtc", version = "0.21" }
|
||||
gst-sdp = { package = "gstreamer-sdp", version = "0.21" }
|
||||
serde = "1"
|
||||
serde_derive = "1"
|
||||
serde_json = "1"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
cocoa = "0.24"
|
||||
cocoa = "0.25"
|
||||
|
|
|
@ -321,21 +321,21 @@ impl App {
|
|||
let audio_queue = peer_bin
|
||||
.by_name("audio-queue")
|
||||
.expect("can't find audio-queue");
|
||||
let audio_sink_pad = gst::GhostPad::with_target(
|
||||
Some("audio_sink"),
|
||||
&audio_queue.static_pad("sink").unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let audio_sink_pad =
|
||||
gst::GhostPad::builder_with_target(&audio_queue.static_pad("sink").unwrap())
|
||||
.unwrap()
|
||||
.name("audio_sink")
|
||||
.build();
|
||||
peer_bin.add_pad(&audio_sink_pad).unwrap();
|
||||
|
||||
let video_queue = peer_bin
|
||||
.by_name("video-queue")
|
||||
.expect("can't find video-queue");
|
||||
let video_sink_pad = gst::GhostPad::with_target(
|
||||
Some("video_sink"),
|
||||
&video_queue.static_pad("sink").unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let video_sink_pad =
|
||||
gst::GhostPad::builder_with_target(&video_queue.static_pad("sink").unwrap())
|
||||
.unwrap()
|
||||
.name("video_sink")
|
||||
.build();
|
||||
peer_bin.add_pad(&video_sink_pad).unwrap();
|
||||
|
||||
let peer = Peer(Arc::new(PeerInner {
|
||||
|
@ -837,14 +837,12 @@ impl Peer {
|
|||
|
||||
// Add a ghost pad on our conv bin that proxies the sink pad of the decodebin
|
||||
let dbin = conv.by_name("dbin").unwrap();
|
||||
let sinkpad =
|
||||
gst::GhostPad::with_target(Some("sink"), &dbin.static_pad("sink").unwrap()).unwrap();
|
||||
let sinkpad = gst::GhostPad::with_target(&dbin.static_pad("sink").unwrap()).unwrap();
|
||||
conv.add_pad(&sinkpad).unwrap();
|
||||
|
||||
// And another one that proxies the source pad of the last element
|
||||
let src = conv.by_name("src").unwrap();
|
||||
let srcpad =
|
||||
gst::GhostPad::with_target(Some("src"), &src.static_pad("src").unwrap()).unwrap();
|
||||
let srcpad = gst::GhostPad::with_target(&src.static_pad("src").unwrap()).unwrap();
|
||||
conv.add_pad(&srcpad).unwrap();
|
||||
|
||||
self.bin.add(&conv).unwrap();
|
||||
|
@ -856,11 +854,17 @@ impl Peer {
|
|||
|
||||
// And then add a new ghost pad to the peer bin that proxies the source pad we added above
|
||||
if media_type == "video" {
|
||||
let srcpad = gst::GhostPad::with_target(Some("video_src"), &srcpad).unwrap();
|
||||
let srcpad = gst::GhostPad::builder_with_target(&srcpad)
|
||||
.unwrap()
|
||||
.name("video_src")
|
||||
.build();
|
||||
srcpad.set_active(true).unwrap();
|
||||
self.bin.add_pad(&srcpad).unwrap();
|
||||
} else if media_type == "audio" {
|
||||
let srcpad = gst::GhostPad::with_target(Some("audio_src"), &srcpad).unwrap();
|
||||
let srcpad = gst::GhostPad::builder_with_target(&srcpad)
|
||||
.unwrap()
|
||||
.name("audio_src")
|
||||
.build();
|
||||
srcpad.set_active(true).unwrap();
|
||||
self.bin.add_pad(&srcpad).unwrap();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,14 +10,14 @@ async-std = "1"
|
|||
clap = { version = "4", features = ["derive"] }
|
||||
anyhow = "1"
|
||||
rand = "0.8"
|
||||
async-tungstenite = { version = "0.20", features = ["async-std-runtime", "async-native-tls"] }
|
||||
gst = { package = "gstreamer", version = "0.20" }
|
||||
gst-rtp = { package = "gstreamer-rtp", version = "0.20", features = ["v1_20"] }
|
||||
gst-webrtc = { package = "gstreamer-webrtc", version = "0.20" }
|
||||
gst-sdp = { package = "gstreamer-sdp", version = "0.20" }
|
||||
async-tungstenite = { version = "0.23", features = ["async-std-runtime", "async-native-tls"] }
|
||||
gst = { package = "gstreamer", version = "0.21" }
|
||||
gst-rtp = { package = "gstreamer-rtp", version = "0.21", features = ["v1_20"] }
|
||||
gst-webrtc = { package = "gstreamer-webrtc", version = "0.21" }
|
||||
gst-sdp = { package = "gstreamer-sdp", version = "0.21" }
|
||||
serde = "1"
|
||||
serde_derive = "1"
|
||||
serde_json = "1"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
cocoa = "0.24"
|
||||
cocoa = "0.25"
|
||||
|
|
|
@ -377,7 +377,7 @@ impl App {
|
|||
bail!("Answer creation future got no response");
|
||||
}
|
||||
Err(err) => {
|
||||
bail!("Answer creation future got error response: {err:?}", err);
|
||||
bail!("Answer creation future got error response: {err:?}");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue