[MediaStream] VideoTrack should respond to MediaStreamTrack state changes
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Nov 2015 02:52:16 +0000 (02:52 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Nov 2015 02:52:16 +0000 (02:52 +0000)
commit92706a2d5a043e11458765b4b75f187d944ce543
tree9f83e4dc586081209ef51dad0948a7d09f98d655
parentc6b94bcd2b9e561dbebc30c24605325a2f7f0877
[MediaStream] VideoTrack should respond to MediaStreamTrack state changes
https://bugs.webkit.org/show_bug.cgi?id=151299

Reviewed by Jer Noble.

Source/WebCore:

Test: fast/mediastream/MediaStream-video-element-track-stop.html

* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::ended): Check m_ended.
(WebCore::MediaStreamTrack::stopProducingData): Set m_ended before telling private track to
  stop so we won't fire an 'ended' event.
(WebCore::MediaStreamTrack::trackEnded): Set m_ended, add comments from spec.
* Modules/mediastream/MediaStreamTrack.h:

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerTimeChanged): Live streams have infinite duration,
  not indefinite.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::platformLayer): Return NULL when displayMode
  is None.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::currentDisplayMode): Calculate current
  displayMode based on MediaStream state.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateDisplayMode): Renamed from
  setPausedImageVisible, use m_displayMode. Don't start/stop clock, it makes more sense
  to do that in play and pause.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::play): Start clock.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::pause): Stop clock.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::currentReadyState): Call updateDisplayMode.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::activeStatusChanged): Ditto.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateIntrinsicSize):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::createPreviewLayers): Always try to create
  both layers if necessary.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::renderingModeChanged): New, update displayMode
  and call back to the media element.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::characteristicsChanged):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateTracks): Get rid of some unused locals.
  React to a change in the enabled video track.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::paintCurrentFrameInContext): Paint black when
  the active video track is disabled.
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setPausedImageVisible): Deleted.

* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::updateActiveState): Split the logic of updating the active video
  track out into updateActiveVideoTrack.
(WebCore::MediaStreamPrivate::hasVideo): Check for track.ended.
(WebCore::MediaStreamPrivate::hasAudio): Ditto.
(WebCore::MediaStreamPrivate::paintCurrentFrameInContext): Don't call the source directly.
(WebCore::MediaStreamPrivate::updateActiveVideoTrack): New.
(WebCore::MediaStreamPrivate::trackEnabledChanged): Call updateActiveVideoTrack.
(WebCore::MediaStreamPrivate::trackEnded): new.
* platform/mediastream/MediaStreamPrivate.h:

* platform/mediastream/MediaStreamTrackPrivate.cpp:
(WebCore::MediaStreamTrackPrivate::setEnabled): Call observers if enabled state changes.
(WebCore::MediaStreamTrackPrivate::endTrack): Call observers.
(WebCore::MediaStreamTrackPrivate::paintCurrentFrameInContext): New.
(WebCore::MediaStreamTrackPrivate::preventSourceFromStopping): Add comments.
* platform/mediastream/MediaStreamTrackPrivate.h:

* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::paintCurrentFrameInContext): Remove a commented-out line.

LayoutTests:

* fast/mediastream/MediaStream-video-element-expected.txt:
* fast/mediastream/MediaStream-video-element-track-stop-expected.txt: Added.
* fast/mediastream/MediaStream-video-element-track-stop.html: Added.
* fast/mediastream/MediaStream-video-element.html:
* platform/gtk/TestExpectations: Skip new test.
* platform/ios-simulator/TestExpectations: Ditto.
* platform/mac-wk2/TestExpectations: Ditto.
* platform/win/TestExpectations: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192503 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/MediaStream-video-element-expected.txt
LayoutTests/fast/mediastream/MediaStream-video-element-track-stop-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/MediaStream-video-element-track-stop.html [new file with mode: 0644]
LayoutTests/fast/mediastream/MediaStream-video-element.html
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios-simulator/TestExpectations
LayoutTests/platform/mac-mavericks/fast/mediastream/MediaStream-video-element-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
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/mock/MockRealtimeVideoSource.cpp