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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6512>
This commit is contained in:
Guillaume Desmottes 2024-04-02 15:57:58 +02:00 committed by GStreamer Marge Bot
parent 74b171e745
commit ed54734825
9 changed files with 12 additions and 12 deletions

View file

@ -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) {

View file

@ -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) {

View file

@ -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);

View file

@ -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) {

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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 = {

View file

@ -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));