Skip to content

Commit 631510a

Browse files
committed
Missing media in SDP if setConfiguration() is called after createDataChannel() or addTransceiver() https://bugs.webkit.org/show_bug.cgi?id=273318
Reviewed by Xabier Rodriguez-Calvar. GStreamerMediaEndpoint::setConfiguration() was tearing down the pipeline if one already existed and creating a new one, which is an issue if any data channels or transceivers are created before RTCPeerConnection.setConfiguration(). The issue is fixed by creating the pipeline earlier in GStreamerMediaEndpoint's contructor, so that data channels or transceivers aren't discarded if created/added before setConfiguration(). Credit to Philippe Normand <philn@igalia.com> for finding the issue and fixing it. I wrote the layout test, which fails without his fix. * LayoutTests/webrtc/setConfiguration-after-createDataChannel-or-addTransceiver-expected.txt: Added. * LayoutTests/webrtc/setConfiguration-after-createDataChannel-or-addTransceiver.html: Added. * Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp: (WebCore::GStreamerMediaEndpoint::GStreamerMediaEndpoint): (WebCore::GStreamerMediaEndpoint::setConfiguration): Canonical link: https://commits.webkit.org/278099@main
1 parent 2ac597c commit 631510a

3 files changed

Lines changed: 46 additions & 6 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
PASS setConfiguration after data channel is created
3+
PASS setConfiguration after video transceiver is added
4+
PASS setConfiguration after audio transceiver is added
5+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Testing media fields in SDP when setConfiguration comes after createDataChannel/addTransceiver</title>
6+
<script src="../resources/testharness.js"></script>
7+
<script src="../resources/testharnessreport.js"></script>
8+
</head>
9+
<body>
10+
<script src ="routines.js"></script>
11+
<script>
12+
function testMediaInSDP(addTransceiverOrDataChannel, regex) {
13+
return async (test) => {
14+
const pc = new RTCPeerConnection();
15+
addTransceiverOrDataChannel(pc);
16+
pc.setConfiguration({});
17+
await pc.setLocalDescription();
18+
const sdp = pc.localDescription.sdp;
19+
assert_true(regex.test(sdp));
20+
}
21+
}
22+
23+
promise_test(testMediaInSDP(
24+
pc => pc.createDataChannel("data-channel"),
25+
/\r\nm=application.*webrtc-datachannel\r\n/),
26+
'setConfiguration after data channel is created');
27+
28+
promise_test(testMediaInSDP(
29+
pc => pc.addTransceiver("video"),
30+
/\r\nm=video.*\r\n/),
31+
'setConfiguration after video transceiver is added');
32+
33+
promise_test(testMediaInSDP(
34+
pc => pc.addTransceiver("audio"),
35+
/\r\nm=audio.*\r\n/),
36+
'setConfiguration after audio transceiver is added');
37+
</script>
38+
</body>
39+
</html>

Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ GStreamerMediaEndpoint::GStreamerMediaEndpoint(GStreamerPeerConnectionBackend& p
8080
std::call_once(debugRegisteredFlag, [] {
8181
GST_DEBUG_CATEGORY_INIT(webkit_webrtc_endpoint_debug, "webkitwebrtcendpoint", 0, "WebKit WebRTC end-point");
8282
});
83+
84+
initializePipeline();
8385
}
8486

8587
GStreamerMediaEndpoint::~GStreamerMediaEndpoint()
@@ -244,12 +246,6 @@ void GStreamerMediaEndpoint::disposeElementChain(GstElement* element)
244246

245247
bool GStreamerMediaEndpoint::setConfiguration(MediaEndpointConfiguration& configuration)
246248
{
247-
if (m_pipeline)
248-
teardownPipeline();
249-
250-
if (!initializePipeline())
251-
return false;
252-
253249
auto bundlePolicy = bundlePolicyFromConfiguration(configuration);
254250
auto iceTransportPolicy = iceTransportPolicyFromConfiguration(configuration);
255251
g_object_set(m_webrtcBin.get(), "bundle-policy", bundlePolicy, "ice-transport-policy", iceTransportPolicy, nullptr);

0 commit comments

Comments
 (0)