From d274caeb3515fb41353e1b731227da9d6ab8e16c Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Fri, 23 Aug 2024 19:34:48 +0530 Subject: [PATCH] whepsrc: Fix incorrect default caps add-transceiver needs application/x-rtp caps and not raw caps. We were providing raw caps which is incorrect. Part-of: --- docs/plugins/gst_plugins_cache.json | 4 +-- net/webrtchttp/src/whepsrc/imp.rs | 47 +++++++++++++++++++---------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/docs/plugins/gst_plugins_cache.json b/docs/plugins/gst_plugins_cache.json index 95666613..36bf7fa3 100644 --- a/docs/plugins/gst_plugins_cache.json +++ b/docs/plugins/gst_plugins_cache.json @@ -13198,7 +13198,7 @@ "construct": false, "construct-only": false, "controllable": false, - "default": "audio/x-opus", + "default": "application/x-rtp, media=(string)audio, encoding-name=(string)OPUS, payload=(int)96, clock-rate=(int)48000", "mutable": "null", "readable": true, "type": "GstCaps", @@ -13284,7 +13284,7 @@ "construct": false, "construct-only": false, "controllable": false, - "default": "video/x-vp8; video/x-h264; video/x-vp9; video/x-h265; video/x-av1", + "default": "application/x-rtp, media=(string)video, payload=(int)101, encoding-name=(string)VP8, clock-rate=(int)90000; application/x-rtp, media=(string)video, payload=(int)102, encoding-name=(string)VP9, clock-rate=(int)90000; application/x-rtp, media=(string)video, payload=(int)103, encoding-name=(string)H264, clock-rate=(int)90000; application/x-rtp, media=(string)video, payload=(int)104, encoding-name=(string)H265, clock-rate=(int)90000; application/x-rtp, media=(string)video, payload=(int)105, encoding-name=(string)AV1, clock-rate=(int)90000", "mutable": "null", "readable": true, "type": "GstCaps", diff --git a/net/webrtchttp/src/whepsrc/imp.rs b/net/webrtchttp/src/whepsrc/imp.rs index 1a032dd6..31031b62 100644 --- a/net/webrtchttp/src/whepsrc/imp.rs +++ b/net/webrtchttp/src/whepsrc/imp.rs @@ -50,23 +50,38 @@ struct Settings { #[allow(clippy::derivable_impls)] impl Default for Settings { fn default() -> Self { - let video_caps = Some( - [ - "video/x-vp8", - "video/x-h264", - "video/x-vp9", - "video/x-h265", - "video/x-av1", - ] - .into_iter() - .map(gst::Structure::new_empty) - .collect::(), - ); + let video_caps = { + let video = [ + ("VP8", 101), + ("VP9", 102), + ("H264", 103), + ("H265", 104), + ("AV1", 105), + ]; + + let mut video_caps = gst::Caps::new_empty(); + let caps = video_caps.get_mut().unwrap(); + + for (encoding, pt) in video { + let s = gst::Structure::builder("application/x-rtp") + .field("media", "video") + .field("payload", pt) + .field("encoding-name", encoding) + .field("clock-rate", 90000) + .build(); + caps.append_structure(s); + } + + Some(video_caps) + }; + let audio_caps = Some( - ["audio/x-opus"] - .into_iter() - .map(gst::Structure::new_empty) - .collect::(), + gst::Caps::builder("application/x-rtp") + .field("media", "audio") + .field("encoding-name", "OPUS") + .field("payload", 96) + .field("clock-rate", 48000) + .build(), ); Self {