Add support for in-band text tracks to Mac port
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Dec 2012 16:19:56 +0000 (16:19 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Dec 2012 16:19:56 +0000 (16:19 +0000)
commite910561c3e7d891afbf6521cbfa90d246625df03
tree2d5b2a27b8256458caa1d42dc84064289daf1e4f
parent715bcc50bdc6c5a20097ff17cf502ff0b0509aca
Add support for in-band text tracks to Mac port
https://bugs.webkit.org/show_bug.cgi?id=103663

Reviewed by Sam Weinig.

Source/WebCore:

Test: media/track/track-in-band.html

* GNUmakefile.list.am: Move InbandTextTrackPrivate.h to platform/graphics. Add InbandTextTrackPrivateClient.h.
* Target.pri: Ditto.
* WebCore.gypi: Ditto.

* WebCore.xcodeproj/project.pbxproj: Add new files.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setReadyState): No need to call processInbandTextTracks, in-band tracks
    are now registered by the media engine as they are discovered.
(WebCore::HTMLMediaElement::mediaPlayerDidAddTrack): New, called by the media player when a new
    in-band track is found.
(WebCore::HTMLMediaElement::mediaPlayerDidRemoveTrack): New, called by the media player when an
    in-band track goes away.
* html/HTMLMediaElement.h:

* html/track/InbandTextTrack.cpp:
(WebCore::InbandTextTrack::InbandTextTrack): Use m_private instead of tracksPrivate because
    it is zeroed during assignment.

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::addTextTrack): New MediaPlayerClient method to allow MediaPlayerPrivate subclasses
    to add a new in-band track.
(WebCore::MediaPlayer::removeTextTrack): New MediaPlayerClient method to allow MediaPlayerPrivate subclasses
    to remove a new in-band track.
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:

* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp: Added.
(WebCore::InbandTextTrackPrivateAVF::InbandTextTrackPrivateAVF):
(WebCore::InbandTextTrackPrivateAVF::~InbandTextTrackPrivateAVF):
(WebCore::InbandTextTrackPrivateAVF::processCueAttributes): Convert an attribute string into WebVTT
    cue setting and content strings.
(WebCore::InbandTextTrackPrivateAVF::processCue): Process a new cue.
(WebCore::InbandTextTrackPrivateAVF::disconnect): Clear member variables.
(WebCore::InbandTextTrackPrivateAVF::resetCueValues): Reset cue values to defaults.
(WebCore::InbandTextTrackPrivateAVF::setMode): Set track mode and call player's trackModeChanged.
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h: Added.

* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: Initialize
    m_inbandTrackConfigurationPending.
(WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
(WebCore::MediaPlayerPrivateAVFoundation::seekCompleted): Flush the currently accumulating
    cue so it doesn't get the wrong duration.
(WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): Handle InbandTracksNeedConfiguration.
(WebCore::MediaPlayerPrivateAVFoundation::flushCurrentCue): New, pass the current cue up to the client.
(WebCore::MediaPlayerPrivateAVFoundation::configureInbandTracks): Configure in-band tracks.
(WebCore::MediaPlayerPrivateAVFoundation::trackModeChanged): Schedule a call to configureInbandTracks.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:

* platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h: Added.
* platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm: Added.
(WebCore::InbandTextTrackPrivateAVFObjC::InbandTextTrackPrivateAVFObjC):
(WebCore::InbandTextTrackPrivateAVFObjC::disconnect):
(WebCore::InbandTextTrackPrivateAVFObjC::kind): Return track kind.
(WebCore::InbandTextTrackPrivateAVFObjC::label): Return track label.
(WebCore::InbandTextTrackPrivateAVFObjC::language): Return track language.
(WebCore::InbandTextTrackPrivateAVFObjC::isDefault):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
(MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::playerItem):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC): Initialize m_currentTrack.
(WebCore::MediaPlayerPrivateAVFoundationObjC::cancelLoad): Clear m_legibleOutput.
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Create and initialize m_legibleOutput.
(WebCore::MediaPlayerPrivateAVFoundationObjC::processTextTracks): Called when the player item's
    "tracks" changes, add and remove in-band text tracks as necessary.
(WebCore::MediaPlayerPrivateAVFoundationObjC::processCue): Pass an attributed string to the current
    track to be processed.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setCurrentTrack): Tell AVFoundation to select an in-band track.
(WebCore::MediaPlayerPrivateAVFoundationObjC::currentTrack): Return the current track.
(-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): Legible
    output delegate.

Source/WTF:

* wtf/Platform.h: Define HAVE_AVFOUNDATION_TEXT_TRACK_SUPPORT.

LayoutTests:

Test for initial support for in-band text tracks. New test skipped on all ports that don't
have support in the media engine.

* media/content/counting-subtitled.m4v: Added.
* media/track/track-in-band-expected.txt: Added.
* media/track/track-in-band.html: Added.
* platform/chromium/TestExpectations:
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137161 268f45cc-cd09-0410-ab3c-d52691b4dbfc
34 files changed:
LayoutTests/ChangeLog
LayoutTests/media/content/counting-subtitled.m4v [new file with mode: 0644]
LayoutTests/media/track/track-in-band-expected.txt [new file with mode: 0644]
LayoutTests/media/track/track-in-band.html [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/qt/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/track/InbandTextTrack.cpp
Source/WebCore/html/track/InbandTextTrack.h
Source/WebCore/platform/graphics/InbandTextTrackPrivate.h [moved from Source/WebCore/html/track/InbandTextTrackPrivate.h with 84% similarity]
Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h [new file with mode: 0644]
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm