From ed54734825c6e820b6d79a1569242ddbb4f5c59c Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 2 Apr 2024 15:57:58 +0200 Subject: [PATCH] examples: set perfect-timestamp=true on opusenc Fix audio streaming on Chrome, see https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1524 Part-of: --- .../gst-examples/webrtc/android/app/src/main/jni/webrtc.c | 2 +- .../webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c | 2 +- .../gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c | 2 +- .../webrtc/sendonly/webrtc-unidirectional-h264.c | 2 +- .../sendrecv/gst-java/src/main/java/WebrtcSendRecv.java | 2 +- .../webrtc/sendrecv/gst-sharp/WebRTCSendRecv.cs | 2 +- .../gst-examples/webrtc/sendrecv/gst/webrtc-sendrecv.c | 2 +- .../gst-examples/webrtc/sendrecv/gst/webrtc_sendrecv.py | 6 +++--- .../gst-plugins-bad/tests/examples/webrtc/webrtcswap.c | 4 ++-- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-examples/webrtc/android/app/src/main/jni/webrtc.c b/subprojects/gst-examples/webrtc/android/app/src/main/jni/webrtc.c index 2897fa57ba..661cdbdbc6 100644 --- a/subprojects/gst-examples/webrtc/android/app/src/main/jni/webrtc.c +++ b/subprojects/gst-examples/webrtc/android/app/src/main/jni/webrtc.c @@ -390,7 +390,7 @@ start_pipeline (WebRTC * webrtc) "ahcsrc device-facing=front ! video/x-raw,width=[320,1280] ! queue max-size-buffers=1 ! videoconvert ! " "vp8enc keyframe-max-dist=30 deadline=1 error-resilient=default ! rtpvp8pay picture-id-mode=15-bit mtu=1300 ! " "queue max-size-time=300000000 ! " RTP_CAPS_VP8 " ! sendrecv.sink_0 " - "openslessrc ! queue ! audioconvert ! audioresample ! audiorate ! queue ! opusenc ! rtpopuspay ! " + "openslessrc ! queue ! audioconvert ! audioresample ! audiorate ! queue ! opusenc perfect-timestamp=true ! rtpopuspay ! " "queue ! " RTP_CAPS_OPUS " ! sendrecv.sink_1 ", &error); if (error) { diff --git a/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c b/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c index 87dd87be15..21e5c7cb02 100644 --- a/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c +++ b/subprojects/gst-examples/webrtc/multiparty-sendrecv/gst/mp-webrtc-sendrecv.c @@ -458,7 +458,7 @@ start_pipeline (void) * inside the same pipeline. We start by connecting it to a fakesink so that * we can preroll early. */ pipeline = gst_parse_launch ("tee name=audiotee ! queue ! fakesink " - "audiotestsrc is-live=true wave=red-noise ! queue ! opusenc ! rtpopuspay ! " + "audiotestsrc is-live=true wave=red-noise ! queue ! opusenc perfect-timestamp=true ! rtpopuspay ! " "queue ! " RTP_CAPS_OPUS (96) " ! audiotee. ", &error); if (error) { diff --git a/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c b/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c index 7222ccbb91..835528b058 100644 --- a/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c +++ b/subprojects/gst-examples/webrtc/sendonly/webrtc-recvonly-h264.c @@ -329,7 +329,7 @@ create_receiver_entry (SoupWebsocketConnection * connection) receiver_entry->pipeline = gst_parse_launch ("webrtcbin name=webrtcbin stun-server=stun://" STUN_SERVER " " - "audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! " + "audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc perfect-timestamp=true ! rtpopuspay ! " "queue ! " RTP_CAPS_OPUS "97 ! webrtcbin. ", &error); if (error != NULL) { g_error ("Could not create WebRTC pipeline: %s\n", error->message); diff --git a/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c b/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c index b53719550d..6c785d035b 100644 --- a/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c +++ b/subprojects/gst-examples/webrtc/sendonly/webrtc-unidirectional-h264.c @@ -249,7 +249,7 @@ create_receiver_entry (SoupWebsocketConnection * connection) "application/x-rtp,media=video,encoding-name=H264,payload=" RTP_PAYLOAD_TYPE " ! webrtcbin. " "autoaudiosrc ! queue max-size-buffers=1 leaky=downstream" - " ! audioconvert ! audioresample ! opusenc ! rtpopuspay pt=" + " ! audioconvert ! audioresample ! opusenc perfect-timestamp=true ! rtpopuspay pt=" RTP_AUDIO_PAYLOAD_TYPE " ! application/x-rtp, encoding-name=OPUS !" " webrtcbin. ", &error); if (error != NULL) { diff --git a/subprojects/gst-examples/webrtc/sendrecv/gst-java/src/main/java/WebrtcSendRecv.java b/subprojects/gst-examples/webrtc/sendrecv/gst-java/src/main/java/WebrtcSendRecv.java index 7aea74a8d3..8b081d72b8 100644 --- a/subprojects/gst-examples/webrtc/sendrecv/gst-java/src/main/java/WebrtcSendRecv.java +++ b/subprojects/gst-examples/webrtc/sendrecv/gst-java/src/main/java/WebrtcSendRecv.java @@ -30,7 +30,7 @@ public class WebrtcSendRecv { private static final Logger logger = LoggerFactory.getLogger(WebrtcSendRecv.class); private static final String REMOTE_SERVER_URL = "wss://webrtc.gstreamer.net:8443"; private static final String VIDEO_BIN_DESCRIPTION = "videotestsrc ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay ! queue ! capsfilter caps=application/x-rtp,media=video,encoding-name=VP8,payload=97"; - private static final String AUDIO_BIN_DESCRIPTION = "audiotestsrc ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! queue ! capsfilter caps=application/x-rtp,media=audio,encoding-name=OPUS,payload=96"; + private static final String AUDIO_BIN_DESCRIPTION = "audiotestsrc ! audioconvert ! audioresample ! queue ! opusenc perfect-timestamp=true ! rtpopuspay ! queue ! capsfilter caps=application/x-rtp,media=audio,encoding-name=OPUS,payload=96"; private final String serverUrl; private final String peerId; diff --git a/subprojects/gst-examples/webrtc/sendrecv/gst-sharp/WebRTCSendRecv.cs b/subprojects/gst-examples/webrtc/sendrecv/gst-sharp/WebRTCSendRecv.cs index 7b672ab824..48dc8464c3 100644 --- a/subprojects/gst-examples/webrtc/sendrecv/gst-sharp/WebRTCSendRecv.cs +++ b/subprojects/gst-examples/webrtc/sendrecv/gst-sharp/WebRTCSendRecv.cs @@ -19,7 +19,7 @@ namespace GstWebRTCDemo const string PIPELINE_DESC = @"webrtcbin name=sendrecv bundle-policy=max-bundle videotestsrc is-live=true pattern=ball ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay ! queue ! application/x-rtp,media=video,encoding-name=VP8,payload=97 ! sendrecv. - audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! + audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc perfect-timestamp=true ! rtpopuspay ! queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload=96 ! sendrecv."; readonly int _id; diff --git a/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc-sendrecv.c b/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc-sendrecv.c index 7e4e06f557..35e77135e4 100644 --- a/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc-sendrecv.c +++ b/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc-sendrecv.c @@ -490,7 +490,7 @@ start_pipeline (gboolean create_offer, guint opus_pt, guint vp8_pt) audio_desc = g_strdup_printf ("audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample" - "! queue ! opusenc ! rtpopuspay name=audiopay pt=%u " + "! queue ! opusenc perfect-timestamp=true ! rtpopuspay name=audiopay pt=%u " "! application/x-rtp, encoding-name=OPUS ! queue", opus_pt); audio_bin = gst_parse_bin_from_description (audio_desc, TRUE, &audio_error); g_free (audio_desc); diff --git a/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc_sendrecv.py b/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc_sendrecv.py index 6feef0eb92..bf4abc822e 100755 --- a/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc_sendrecv.py +++ b/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc_sendrecv.py @@ -39,7 +39,7 @@ PIPELINE_DESC_VP8 = WEBRTCBIN + ''' {vsrc} ! videoconvert ! queue ! vp8enc deadline=1 keyframe-max-dist=2000 ! rtpvp8pay picture-id-mode=15-bit ! queue ! application/x-rtp,media=video,encoding-name=VP8,payload={video_pt} ! sendrecv. - {asrc} ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! + {asrc} ! audioconvert ! audioresample ! queue ! opusenc perfect-timestamp=true ! rtpopuspay ! queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload={audio_pt} ! sendrecv. ''' PIPELINE_DESC_H264 = WEBRTCBIN + ''' @@ -47,7 +47,7 @@ PIPELINE_DESC_H264 = WEBRTCBIN + ''' x264enc tune=zerolatency speed-preset=ultrafast key-int-max=30 intra-refresh=true ! rtph264pay aggregate-mode=zero-latency config-interval=-1 ! queue ! application/x-rtp,media=video,encoding-name=H264,payload={video_pt} ! sendrecv. - {asrc} ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! + {asrc} ! audioconvert ! audioresample ! queue ! opusenc perfect-timestamp=true ! rtpopuspay ! queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload={audio_pt} ! sendrecv. ''' # Force I420 because dav1d bundled with Chrome doesn't support 10-bit choma/luma (I420_10LE) @@ -55,7 +55,7 @@ PIPELINE_DESC_AV1 = WEBRTCBIN + ''' {vsrc} ! videoconvert ! queue ! video/x-raw,format=I420 ! svtav1enc preset=13 ! av1parse ! rtpav1pay ! queue ! application/x-rtp,media=video,encoding-name=AV1,payload={video_pt} ! sendrecv. - {asrc} ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! + {asrc} ! audioconvert ! audioresample ! queue ! opusenc perfect-timestamp=true ! rtpopuspay ! queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload={audio_pt} ! sendrecv. ''' PIPELINE_DESC = { diff --git a/subprojects/gst-plugins-bad/tests/examples/webrtc/webrtcswap.c b/subprojects/gst-plugins-bad/tests/examples/webrtc/webrtcswap.c index 02c507dc88..046d3fcee2 100644 --- a/subprojects/gst-plugins-bad/tests/examples/webrtc/webrtcswap.c +++ b/subprojects/gst-plugins-bad/tests/examples/webrtc/webrtcswap.c @@ -172,11 +172,11 @@ main (int argc, char *argv[]) gst_parse_launch ("webrtcbin name=smpte webrtcbin name=ball " "videotestsrc pattern=smpte ! queue ! vp8enc ! rtpvp8pay ! queue ! " "application/x-rtp,media=video,payload=96,encoding-name=VP8 ! smpte.sink_0 " - "audiotestsrc ! opusenc ! rtpopuspay ! queue ! " + "audiotestsrc ! opusenc perfect-timestamp=true ! rtpopuspay ! queue ! " "application/x-rtp,media=audio,payload=97,encoding-name=OPUS ! smpte.sink_1 " "videotestsrc pattern=ball ! queue ! vp8enc ! rtpvp8pay ! queue ! " "application/x-rtp,media=video,payload=96,encoding-name=VP8 ! ball.sink_1 " - "audiotestsrc wave=saw ! opusenc ! rtpopuspay ! queue ! " + "audiotestsrc wave=saw ! opusenc perfect-timestamp=true ! rtpopuspay ! queue ! " "application/x-rtp,media=audio,payload=97,encoding-name=OPUS ! ball.sink_0 ", NULL); bus1 = gst_pipeline_get_bus (GST_PIPELINE (pipe1));