- Revision
- 237908
- Author
- [email protected]
- Date
- 2018-11-06 18:31:30 -0800 (Tue, 06 Nov 2018)
Log Message
Support onremovetrack for RTCPeerConnection removed tracks
https://bugs.webkit.org/show_bug.cgi?id=191299
Reviewed by Eric Carlson.
LayoutTests/imported/w3c:
* web-platform-tests/webrtc/RTCPeerConnection-setRemoteDescription-tracks.https-expected.txt:
Source/WebCore:
When applying SDP, LibWebRTCMediaEndpoint gets notified of a removed track.
In that case, make sure to remove it from its remote stream(s) so as
to notify the application of the changes.
Work around the receiver missing the list of streams by storing in a map
the list of the remote streams for a given remote track.
Covered by rebased test.
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::mediaStreamFromRTCStream):
(WebCore::LibWebRTCMediaEndpoint::removeRemoteTrack):
(WebCore::LibWebRTCMediaEndpoint::removeRemoteStream):
(WebCore::LibWebRTCMediaEndpoint::stop):
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (237907 => 237908)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-11-07 02:08:11 UTC (rev 237907)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-11-07 02:31:30 UTC (rev 237908)
@@ -1,3 +1,12 @@
+2018-11-06 Youenn Fablet <[email protected]>
+
+ Support onremovetrack for RTCPeerConnection removed tracks
+ https://bugs.webkit.org/show_bug.cgi?id=191299
+
+ Reviewed by Eric Carlson.
+
+ * web-platform-tests/webrtc/RTCPeerConnection-setRemoteDescription-tracks.https-expected.txt:
+
2018-11-06 Javier Fernandez <[email protected]>
CSS grid elements with justify-content: space-around have extra whitespace, sometimes a lot
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setRemoteDescription-tracks.https-expected.txt (237907 => 237908)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setRemoteDescription-tracks.https-expected.txt 2018-11-07 02:08:11 UTC (rev 237907)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setRemoteDescription-tracks.https-expected.txt 2018-11-07 02:31:30 UTC (rev 237908)
@@ -1,6 +1,4 @@
-Harness Error (TIMEOUT), message = null
-
PASS addTrack() with a track and no stream makes ontrack fire with a track and no stream.
PASS addTrack() with a track and a stream makes ontrack fire with a track and a stream.
PASS ontrack fires before setRemoteDescription resolves.
@@ -10,9 +8,9 @@
PASS addTrack() with a track and two streams makes ontrack fire with a track and two streams.
PASS ontrack's receiver matches getReceivers().
PASS removeTrack() does not remove the receiver.
-TIMEOUT removeTrack() makes stream.onremovetrack fire and the track to be removed from the stream. Test timed out
-NOTRUN stream.onremovetrack fires before setRemoteDescription resolves.
-NOTRUN removeTrack() makes track.onmute fire and the track to be muted.
-NOTRUN track.onmute fires before setRemoteDescription resolves.
-NOTRUN removeTrack() twice is safe.
+PASS removeTrack() makes stream.onremovetrack fire and the track to be removed from the stream.
+PASS stream.onremovetrack fires before setRemoteDescription resolves.
+PASS removeTrack() makes track.onmute fire and the track to be muted.
+PASS track.onmute fires before setRemoteDescription resolves.
+PASS removeTrack() twice is safe.
Modified: trunk/Source/WebCore/ChangeLog (237907 => 237908)
--- trunk/Source/WebCore/ChangeLog 2018-11-07 02:08:11 UTC (rev 237907)
+++ trunk/Source/WebCore/ChangeLog 2018-11-07 02:31:30 UTC (rev 237908)
@@ -1,3 +1,25 @@
+2018-11-06 Youenn Fablet <[email protected]>
+
+ Support onremovetrack for RTCPeerConnection removed tracks
+ https://bugs.webkit.org/show_bug.cgi?id=191299
+
+ Reviewed by Eric Carlson.
+
+ When applying SDP, LibWebRTCMediaEndpoint gets notified of a removed track.
+ In that case, make sure to remove it from its remote stream(s) so as
+ to notify the application of the changes.
+ Work around the receiver missing the list of streams by storing in a map
+ the list of the remote streams for a given remote track.
+
+ Covered by rebased test.
+
+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+ (WebCore::LibWebRTCMediaEndpoint::mediaStreamFromRTCStream):
+ (WebCore::LibWebRTCMediaEndpoint::removeRemoteTrack):
+ (WebCore::LibWebRTCMediaEndpoint::removeRemoteStream):
+ (WebCore::LibWebRTCMediaEndpoint::stop):
+ * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+
2018-11-06 Timothy Hatcher <[email protected]>
REGRESSION (r237878): css-dark-mode/supported-color-schemes.html is failing on Mojave
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (237907 => 237908)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp 2018-11-07 02:08:11 UTC (rev 237907)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp 2018-11-07 02:31:30 UTC (rev 237908)
@@ -355,9 +355,9 @@
MediaStream& LibWebRTCMediaEndpoint::mediaStreamFromRTCStream(webrtc::MediaStreamInterface& rtcStream)
{
- auto mediaStream = m_streams.ensure(&rtcStream, [&rtcStream, this] {
- auto label = rtcStream.id();
- return MediaStream::create(*m_peerConnectionBackend.connection().scriptExecutionContext(), MediaStreamPrivate::create({ }, fromStdString(label)));
+ auto label = fromStdString(rtcStream.id());
+ auto mediaStream = m_remoteStreamsById.ensure(label, [label, this]() mutable {
+ return MediaStream::create(*m_peerConnectionBackend.connection().scriptExecutionContext(), MediaStreamPrivate::create({ }, WTFMove(label)));
});
return *mediaStream.iterator->value;
}
@@ -408,6 +408,11 @@
streams.append(&mediaStream);
mediaStream.addTrackFromPlatform(track.get());
}
+ auto streamIds = WTF::map(streams, [](auto& stream) -> String {
+ return stream->id();
+ });
+ m_remoteStreamsFromRemoteTrack.add(track.ptr(), WTFMove(streamIds));
+
m_peerConnectionBackend.connection().fireEvent(RTCTrackEvent::create(eventNames().trackEvent,
Event::CanBubble::No, Event::IsCancelable::No, WTFMove(receiver), WTFMove(track), WTFMove(streams), WTFMove(transceiver)));
}
@@ -487,7 +492,14 @@
if (!transceiver)
return;
- transceiver->receiver().track().source().setMuted(true);
+ auto& track = transceiver->receiver().track();
+
+ for (auto& id : m_remoteStreamsFromRemoteTrack.get(&track)) {
+ if (auto stream = m_remoteStreamsById.get(id))
+ stream->privateStream().removeTrack(track.privateTrack(), MediaStreamPrivate::NotifyClientOption::Notify);
+ }
+
+ track.source().setMuted(true);
}
template<typename T>
@@ -543,7 +555,7 @@
void LibWebRTCMediaEndpoint::removeRemoteStream(webrtc::MediaStreamInterface& rtcStream)
{
- bool removed = m_streams.remove(&rtcStream);
+ bool removed = m_remoteStreamsById.remove(fromStdString(rtcStream.id()));
ASSERT_UNUSED(removed, removed);
}
@@ -626,7 +638,8 @@
m_backend->Close();
m_backend = nullptr;
- m_streams.clear();
+ m_remoteStreamsById.clear();
+ m_remoteStreamsFromRemoteTrack.clear();
}
void LibWebRTCMediaEndpoint::OnRenegotiationNeeded()
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h (237907 => 237908)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h 2018-11-07 02:08:11 UTC (rev 237907)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h 2018-11-07 02:31:30 UTC (rev 237908)
@@ -184,7 +184,8 @@
SetLocalSessionDescriptionObserver<LibWebRTCMediaEndpoint> m_setLocalSessionDescriptionObserver;
SetRemoteSessionDescriptionObserver<LibWebRTCMediaEndpoint> m_setRemoteSessionDescriptionObserver;
- HashMap<webrtc::MediaStreamInterface*, RefPtr<MediaStream>> m_streams;
+ HashMap<String, RefPtr<MediaStream>> m_remoteStreamsById;
+ HashMap<MediaStreamTrack*, Vector<String>> m_remoteStreamsFromRemoteTrack;
bool m_isInitiator { false };
Timer m_statsLogTimer;