[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 18:46:29 +0000 (18:46 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jun 2017 18:46:29 +0000 (18:46 +0000)
commit1af9ce05e515f2f572e158ca03c49b27583116d3
treebb37a10551689b3dedbca092b5022af98870e9bc
parent36ac6b76c1883278edb3555565137076537a288a
[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@218399 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]