webrtc: Port to new ElementBuilder API

This commit is contained in:
Thibault Saunier 2022-10-19 19:55:40 +02:00
parent ad78936365
commit 37c0239aff

View file

@ -234,7 +234,13 @@ fn create_navigation_event(sink: &super::WebRTCSink, msg: &str) {
/// Wrapper around `gst::ElementFactory::make` with a better error /// Wrapper around `gst::ElementFactory::make` with a better error
/// message /// message
pub fn make_element(element: &str, name: Option<&str>) -> Result<gst::Element, Error> { pub fn make_element(element: &str, name: Option<&str>) -> Result<gst::Element, Error> {
gst::ElementFactory::make(element, name) let mut builder = gst::ElementFactory::make(element);
if let Some(name) = name {
builder = builder.name(name);
}
builder
.build()
.with_context(|| format!("Failed to make element {}", element)) .with_context(|| format!("Failed to make element {}", element))
} }
@ -462,11 +468,13 @@ fn setup_encoding(
let enc = codec let enc = codec
.encoder .encoder
.create(None) .create()
.build()
.with_context(|| format!("Creating encoder {}", codec.encoder.name()))?; .with_context(|| format!("Creating encoder {}", codec.encoder.name()))?;
let pay = codec let pay = codec
.payloader .payloader
.create(None) .create()
.build()
.with_context(|| format!("Creating payloader {}", codec.payloader.name()))?; .with_context(|| format!("Creating payloader {}", codec.payloader.name()))?;
let parse_filter = make_element("capsfilter", None)?; let parse_filter = make_element("capsfilter", None)?;
@ -1416,7 +1424,7 @@ impl WebRTCSink {
let rtpgccbwe = match settings.cc_info.heuristic { let rtpgccbwe = match settings.cc_info.heuristic {
WebRTCSinkCongestionControl::GoogleCongestionControl => { WebRTCSinkCongestionControl::GoogleCongestionControl => {
let rtpgccbwe = match gst::ElementFactory::make("rtpgccbwe", None) { let rtpgccbwe = match gst::ElementFactory::make("rtpgccbwe").build() {
Err(err) => { Err(err) => {
glib::g_warning!( glib::g_warning!(
"webrtcsink", "webrtcsink",