From fda5aed89fe4d5935c8d3e1e00514b0e9f578f3a Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Tue, 6 Jun 2023 15:41:58 +0200 Subject: [PATCH] webrtcsink: encoded streams: address last review comments Part-of: --- docs/plugins/gst_plugins_cache.json | 12 ++++++------ net/webrtc/src/utils.rs | 16 +++++++++------- net/webrtc/src/webrtcsrc/imp.rs | 4 ++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/plugins/gst_plugins_cache.json b/docs/plugins/gst_plugins_cache.json index 12b5d925..f0647688 100644 --- a/docs/plugins/gst_plugins_cache.json +++ b/docs/plugins/gst_plugins_cache.json @@ -6094,12 +6094,12 @@ "klass": "Sink/Network/WebRTC", "pad-templates": { "audio_%%u": { - "caps": "audio/x-raw:\n", + "caps": "audio/x-raw:\naudio/x-opus:\n", "direction": "sink", "presence": "request" }, "video_%%u": { - "caps": "video/x-raw:\n\nvideo/x-raw(memory:CUDAMemory):\n\nvideo/x-raw(memory:GLMemory):\n\nvideo/x-raw(memory:NVMM):\n", + "caps": "video/x-raw:\n\nvideo/x-raw(memory:CUDAMemory):\n\nvideo/x-raw(memory:GLMemory):\n\nvideo/x-raw(memory:NVMM):\nvideo/x-vp8:\nvideo/x-h264:\nvideo/x-vp9:\nvideo/x-h265:\n", "direction": "sink", "presence": "request" } @@ -6125,12 +6125,12 @@ "klass": "Sink/Network/WebRTC", "pad-templates": { "audio_%%u": { - "caps": "audio/x-raw:\n", + "caps": "audio/x-raw:\naudio/x-opus:\n", "direction": "sink", "presence": "request" }, "video_%%u": { - "caps": "video/x-raw:\n\nvideo/x-raw(memory:CUDAMemory):\n\nvideo/x-raw(memory:GLMemory):\n\nvideo/x-raw(memory:NVMM):\n", + "caps": "video/x-raw:\n\nvideo/x-raw(memory:CUDAMemory):\n\nvideo/x-raw(memory:GLMemory):\n\nvideo/x-raw(memory:NVMM):\nvideo/x-vp8:\nvideo/x-h264:\nvideo/x-vp9:\nvideo/x-h265:\n", "direction": "sink", "presence": "request" } @@ -6156,13 +6156,13 @@ "long-name": "WebRTCSrc", "pad-templates": { "audio_%%u": { - "caps": "audio/x-raw(ANY):\naudio/x-opus:\napplication/x-rtp:\n", + "caps": "audio/x-raw(ANY):\napplication/x-rtp:\naudio/x-opus:\n", "direction": "src", "presence": "sometimes", "type": "GstWebRTCSrcPad" }, "video_%%u": { - "caps": "video/x-raw(ANY):\napplication/x-rtp:\n", + "caps": "video/x-raw(ANY):\napplication/x-rtp:\nvideo/x-vp8:\nvideo/x-h264:\nvideo/x-vp9:\nvideo/x-h265:\n", "direction": "src", "presence": "sometimes", "type": "GstWebRTCSrcPad" diff --git a/net/webrtc/src/utils.rs b/net/webrtc/src/utils.rs index 8d9ee2e2..e92e9a15 100644 --- a/net/webrtc/src/utils.rs +++ b/net/webrtc/src/utils.rs @@ -314,12 +314,10 @@ impl Codec { pub fn build_encoder(&self) -> Option> { self.encoding_info.as_ref().map(|info| { - info.encoder.create().build().with_context(|| { - format!( - "Creating payloader {}", - self.encoding_info.as_ref().unwrap().encoder.name() - ) - }) + info.encoder + .create() + .build() + .with_context(|| format!("Creating payloader {}", info.encoder.name())) }) } @@ -344,7 +342,11 @@ impl Codec { let mut structure_builder = gst::Structure::builder("video/x-raw") .field("pixel-aspect-ratio", gst::Fraction::new(1, 1)); - if self.encoder_name().map(|e| e.as_str() == "nvh264enc").unwrap_or(false) { + if self + .encoder_name() + .map(|e| e.as_str() == "nvh264enc") + .unwrap_or(false) + { // Quirk: nvh264enc can perform conversion from RGB formats, but // doesn't advertise / negotiate colorimetry correctly, leading // to incorrect color display in Chrome (but interestingly not in diff --git a/net/webrtc/src/webrtcsrc/imp.rs b/net/webrtc/src/webrtcsrc/imp.rs index afddb06a..6ca795d2 100644 --- a/net/webrtc/src/webrtcsrc/imp.rs +++ b/net/webrtc/src/webrtcsrc/imp.rs @@ -3,7 +3,7 @@ use gst::prelude::*; use crate::signaller::{prelude::*, Signallable, Signaller}; -use crate::utils::*; +use crate::utils::{Codec, Codecs, AUDIO_CAPS, RTP_CAPS, VIDEO_CAPS}; use crate::webrtcsrc::WebRTCSrcPad; use anyhow::{Context, Error}; use gst::glib; @@ -76,7 +76,7 @@ impl ObjectImpl for WebRTCSrc { gst::ParamSpecArray::builder("audio-codecs") .flags(glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY) .blurb(&format!("Names of audio codecs to be be used during the SDP negotiation. Valid values: [{}]", - Codecs::video_codec_names().into_iter().collect::>().join(", ") + Codecs::audio_codec_names().into_iter().collect::>().join(", ") )) .element_spec(&glib::ParamSpecString::builder("audio-codec-name").build()) .build(),