RealtimeOutgoing A/V sources should observe their sources only if having a sink
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Nov 2018 19:49:13 +0000 (19:49 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Nov 2018 19:49:13 +0000 (19:49 +0000)
commit54dabe3dbc2492a9bfc694cedd7bcfe1b24b4849
tree60156b7f2a15b5e43b47fb76bbc581df762d8733
parentb95957583fa42a4428635dbccfd87b2bd6ed8f52
RealtimeOutgoing A/V sources should observe their sources only if having a sink
https://bugs.webkit.org/show_bug.cgi?id=191490

Reviewed by Eric Carlson.

Source/WebCore:

Observe the source that generates media based on the sinks:
- Do not observe at creation time
- For first sink, start observing
- When no more sink, stop observing
Apply this principle for both outgoing audio and video sources.
Add locks for the sinks to ensure thread-safety.
Make sinks HashSet which is more robust.

Do some refactoring to better isolate generic outgoing sources from Cocoa/GTK implementations.

Covered by existing tests and updated webrtc/remove-track.html.

* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
(WebCore::RealtimeOutgoingAudioSource::stop):
(WebCore::RealtimeOutgoingAudioSource::AddSink):
(WebCore::RealtimeOutgoingAudioSource::RemoveSink):
(WebCore::RealtimeOutgoingAudioSource::sendAudioFrames):
* platform/mediastream/RealtimeOutgoingAudioSource.h:
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::RealtimeOutgoingVideoSource):
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
(WebCore::RealtimeOutgoingVideoSource::observeSource):
(WebCore::RealtimeOutgoingVideoSource::setSource):
(WebCore::RealtimeOutgoingVideoSource::stop):
(WebCore::RealtimeOutgoingVideoSource::AddOrUpdateSink):
(WebCore::RealtimeOutgoingVideoSource::RemoveSink):
* platform/mediastream/RealtimeOutgoingVideoSource.h:
(WebCore::RealtimeOutgoingVideoSource::isSilenced const):
* platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp:
(WebCore::RealtimeOutgoingAudioSourceLibWebRTC::pullAudioData):
* platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.cpp:
(WebCore::RealtimeOutgoingAudioSourceCocoa::RealtimeOutgoingAudioSourceCocoa):
(WebCore::RealtimeOutgoingAudioSourceCocoa::audioSamplesAvailable):
(WebCore::RealtimeOutgoingAudioSourceCocoa::pullAudioData):
* platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.h:
* platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp:
(WebCore::RealtimeOutgoingVideoSourceCocoa::sampleBufferUpdated):

LayoutTests:

* webrtc/remove-track-expected.txt:
* webrtc/remove-track.html:
Add tests and fixed some flakiness issues on existing tests in the file.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/webrtc/remove-track-expected.txt
LayoutTests/webrtc/remove-track.html
Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/RealtimeOutgoingAudioSource.cpp
Source/WebCore/platform/mediastream/RealtimeOutgoingAudioSource.h
Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp
Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h
Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp
Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.cpp
Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSourceCocoa.cpp
Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp