Skip to content

Commit

Permalink
[GStreamer][WebRTC] Caps negotiation failure when ssrc-audio-level RT…
Browse files Browse the repository at this point in the history
…P extension is requested

https://bugs.webkit.org/show_bug.cgi?id=271519

Reviewed by Xabier Rodriguez-Calvar.

When not present in caps, the vad support of the ssrc-audio-level extension should be enabled. In
order to prevent caps negotiation issues with downstream, explicitely set it.

* LayoutTests/platform/glib/fast/mediastream/RTCPeerConnection-inspect-answer-expected.txt:
* LayoutTests/platform/glib/fast/mediastream/RTCPeerConnection-inspect-offer-expected.txt:
* Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h:
* Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceGStreamer.cpp:
(WebCore::RealtimeOutgoingAudioSourceGStreamer::setPayloadType):

Canonical link: https://commits.webkit.org/278738@main
  • Loading branch information
philn committed May 14, 2024
1 parent dd78bd9 commit d6d7f3e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ a=extmap:1 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extension
a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:5 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=fmtp:96 minptime=10;useinbandfec=1
a=recvonly
a=fingerprint:sha-256 {fingerprint:OK}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ a=extmap:1 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extension
a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:5 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=fmtp:96 minptime=10;useinbandfec=1
a=rtpmap:9 G722/8000
a=rtcp-fb:9 transport-cc
Expand Down Expand Up @@ -74,6 +75,7 @@ a=extmap:1 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extension
a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:5 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=fmtp:96 minptime=10;useinbandfec=1
a=rtpmap:9 G722/8000
a=rtcp-fb:9 transport-cc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,25 +179,26 @@ class GStreamerRegistryScanner {
void fillAudioRtpCapabilities(Configuration, RTCRtpCapabilities&);
void fillVideoRtpCapabilities(Configuration, RTCRtpCapabilities&);

#define WEBRTC_EXPERIMENTS_HDREXT "http://www.webrtc.org/experiments/rtp-hdrext/"
Vector<const char*> m_commonRtpExtensions {
"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",
"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",
WEBRTC_EXPERIMENTS_HDREXT "abs-send-time",
GST_RTP_HDREXT_BASE "sdes:mid",
GST_RTP_HDREXT_BASE "sdes:repaired-rtp-stream-id",
GST_RTP_HDREXT_BASE "sdes:rtp-stream-id",
GST_RTP_HDREXT_BASE "toffset"
};
Vector<const char*> m_allAudioRtpExtensions {
// This extension triggers caps negotiation issues. See https://bugs.webkit.org/show_bug.cgi?id=271519.
// "urn:ietf:params:rtp-hdrext:ssrc-audio-level"
GST_RTP_HDREXT_BASE "ssrc-audio-level"
};
Vector<const char*> m_allVideoRtpExtensions {
"http://www.webrtc.org/experiments/rtp-hdrext/color-space",
"http://www.webrtc.org/experiments/rtp-hdrext/playout-delay",
"http://www.webrtc.org/experiments/rtp-hdrext/video-content-type",
"http://www.webrtc.org/experiments/rtp-hdrext/video-timing",
WEBRTC_EXPERIMENTS_HDREXT "color-space",
WEBRTC_EXPERIMENTS_HDREXT "playout-delay",
WEBRTC_EXPERIMENTS_HDREXT "video-content-type",
WEBRTC_EXPERIMENTS_HDREXT "video-timing",
"urn:3gpp:video-orientation"
};
#undef WEBRTC_EXPERIMENTS_HDREXT

std::optional<Vector<RTCRtpCapabilities::HeaderExtensionCapability>> m_audioRtpExtensions;
std::optional<Vector<RTCRtpCapabilities::HeaderExtensionCapability>> m_videoRtpExtensions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,42 @@ bool RealtimeOutgoingAudioSourceGStreamer::setPayloadType(const GRefPtr<GstCaps>
}

auto rtpCaps = adoptGRef(gst_caps_new_empty());

// When not present in caps, the vad support of the ssrc-audio-level extension should be
// enabled. In order to prevent caps negotiation issues with downstream, explicitely set it.
unsigned totalFields = gst_structure_n_fields(structure.get());
for (unsigned i = 0; i < totalFields; i++) {
auto fieldName = makeString(gst_structure_nth_field_name(structure.get(), i));
if (!fieldName.startsWith("extmap-"_s))
continue;

const auto value = gst_structure_get_value(structure.get(), fieldName.ascii().data());
if (!G_VALUE_HOLDS_STRING(value))
continue;

const char* uri = g_value_get_string(value);
if (!g_str_equal(uri, GST_RTP_HDREXT_BASE "ssrc-audio-level"))
continue;

GValue arrayValue G_VALUE_INIT;
gst_value_array_init(&arrayValue, 3);

GValue stringValue G_VALUE_INIT;
g_value_init(&stringValue, G_TYPE_STRING);

g_value_set_static_string(&stringValue, "");
gst_value_array_append_value(&arrayValue, &stringValue);

g_value_set_string(&stringValue, uri);
gst_value_array_append_value(&arrayValue, &stringValue);

g_value_set_static_string(&stringValue, "vad=on");
gst_value_array_append_and_take_value(&arrayValue, &stringValue);

gst_structure_remove_field(structure.get(), fieldName.ascii().data());
gst_structure_take_value(structure.get(), fieldName.ascii().data(), &arrayValue);
}

gst_caps_append_structure(rtpCaps.get(), structure.release());

g_object_set(m_inputCapsFilter.get(), "caps", m_inputCaps.get(), nullptr);
Expand Down

0 comments on commit d6d7f3e

Please sign in to comment.