[WebRTC] Removing a MediaStreamTrack from a MediaStream reports no recording to WebKi...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jun 2017 02:49:38 +0000 (02:49 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jun 2017 02:49:38 +0000 (02:49 +0000)
commit3492450780e1f93070e685bca5d35b3cd793f931
tree4dede5cd4ae52fa05ec71351d0ce6f33c022250f
parent239f79a4face94384b36782f13491adca08fe018
[WebRTC] Removing a MediaStreamTrack from a MediaStream reports no recording to WebKit clients
https://bugs.webkit.org/show_bug.cgi?id=173398
<rdar://problem/32592961>

Reviewed by Eric Carlson.

Source/WebCore:

API Test: Tests/WebKit2/MediaStreamTrackDetached.mm

Move the definition of a MediaStream as a MediaProducer from the stream itself to its constituent
MediaStreamTracks. This ensures that, even if a MediaStreamTrack is removed from its stream, the
document (and thus the clients) are notified that media capture is still occurring.

Though MediaStream is no longer a MediaProducer, it still uses the MediaProducer's state concept
to determine when to fire events. However it's mediaState() implementation will be moved into
MediaStreamTrack, and will instead simply bitwise-or together each of it's track's mediaState().

The MediaStream notifies the document that its state has changed asynchronously, so do the same
for MediaStreamTrack (which reduces the number of calls to the client when changes all occur
during a single run loop).

Because the MediaStreamTrackPrivate may be started externally (not by the MediaStreamTrack directly),
add a new client method that notifies observers when the track has been started, and the
MediaStreamTrack will use this notification to update the document with it's new mediaState().

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::MediaStream):
(WebCore::MediaStream::~MediaStream):
(WebCore::MediaStream::mediaState):
(WebCore::MediaStream::statusDidChange):
(WebCore::MediaStream::characteristicsChanged):
(WebCore::MediaStream::pageMutedStateDidChange): Deleted.
* Modules/mediastream/MediaStream.h:
* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::MediaStreamTrack):
(WebCore::MediaStreamTrack::~MediaStreamTrack):
(WebCore::MediaStreamTrack::pageMutedStateDidChange):
(WebCore::MediaStreamTrack::mediaState):
(WebCore::MediaStreamTrack::trackStarted):
(WebCore::MediaStreamTrack::configureTrackRendering):
(WebCore::MediaStreamTrack::stop):
(WebCore::MediaStreamTrack::document):
* Modules/mediastream/MediaStreamTrack.h:
(WebCore::MediaStreamTrack::source):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::trackStarted):
* platform/mediastream/MediaStreamPrivate.h:
* platform/mediastream/MediaStreamTrackPrivate.cpp:
(WebCore::MediaStreamTrackPrivate::sourceStarted):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::start):
* platform/mediastream/RealtimeMediaSource.h:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/MediaStreamTrackDetached.mm: Added.
(-[MediaStreamTrackDetachedUIDelegate _webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:]):
(-[MediaStreamTrackDetachedUIDelegate _webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:]):
(-[MediaStreamTrackDetachedUIDelegate _webView:mediaCaptureStateDidChange:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2/mediastreamtrack-detached.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218375 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/mediastream/MediaStream.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h
Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp
Source/WebCore/platform/mediastream/MediaStreamPrivate.h
Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp
Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h
Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/MediaStreamTrackDetached.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2/mediastreamtrack-detached.html [new file with mode: 0644]