[Media] Expose AudioTracks in the "captions" menu.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 19:11:53 +0000 (19:11 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 19:11:53 +0000 (19:11 +0000)
commit5ec9ae9aa6ed8d549df27eda7c70988878349c88
tree496f205f2864f6ab36c23cfc361d6b74185d2d39
parent75cee8c4998900e5bb009a95f56c95d56a4dd667
[Media] Expose AudioTracks in the "captions" menu.
https://bugs.webkit.org/show_bug.cgi?id=137472

Reviewed by Brent Fulgham.

Source/WebCore:

Test: media/video-controls-audiotracks-trackmenu.html

If more than one AudioTrack is present in the video element, add those tracks to the
captions menu:
* English.lproj/mediaControlsLocalizedStrings.js:
* Modules/mediacontrols/mediaControlsApple.js:
(Controller.prototype.addVideoListeners):
(Controller.prototype.removeVideoListeners):
(Controller.prototype.handleAudioTrackChange):
(Controller.prototype.handleAudioTrackAdd):
(Controller.prototype.handleAudioTrackRemove):
(Controller.prototype.updateCaptionButton):
(Controller.prototype.buildCaptionMenu):
(Controller.prototype.handleCaptionItemKeyUp):
(Controller.prototype.audioTrackItemSelected):
(Controller.prototype.focusSiblingAudioTrackItem):
(Controller.prototype.handleAudioTrackItemKeyUp):

Add support to MediaControlHost for retrieving the sorted audio track list, and the
localized names for every audio track:
* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::sortedTrackListForMenu):
(WebCore::MediaControlsHost::displayNameForTrack):
* Modules/mediacontrols/MediaControlsHost.h:
* Modules/mediacontrols/MediaControlsHost.idl:
* page/CaptionUserPreferences.cpp:
(WebCore::trackDisplayName):
(WebCore::CaptionUserPreferences::displayNameForTrack):
(WebCore::CaptionUserPreferences::sortedTrackListForMenu):
* page/CaptionUserPreferences.h:
* platform/LocalizedStrings.cpp:
(WebCore::audioTrackNoLabelText):
* platform/LocalizedStrings.h:
* platform/efl/LocalizedStringsEfl.cpp:
(WebCore::audioTrackNoLabelText):
* platform/gtk/LocalizedStringsGtk.cpp:
(WebCore::audioTrackNoLabelText):

Drive-by fix; do not recurse into AudioTrackPrivate->setEnabled() when the enabled
state changes.
* html/track/AudioTrack.cpp:
(WebCore::AudioTrack::enabledChanged):

Fix possible out-of-bounds Vector access when adding tracks to a track list by
sorting the list at insert time, rather than inserting into the track's reported
position in the Vector:
* html/track/AudioTrackList.cpp:
(AudioTrackList::append):
* html/track/VideoTrackList.cpp:
(VideoTrackList::append):

Correctly report the trackIndex of audio and video tracks from AVFoundation:
* platform/graphics/avfoundation/AudioTrackPrivateAVF.h:
(WebCore::AudioTrackPrivateAVF::trackIndex):
(WebCore::AudioTrackPrivateAVF::setTrackIndex):
(WebCore::AudioTrackPrivateAVF::AudioTrackPrivateAVF):
* platform/graphics/avfoundation/VideoTrackPrivateAVF.h:
(WebCore::VideoTrackPrivateAVF::trackIndex):
(WebCore::VideoTrackPrivateAVF::setTrackIndex):
(WebCore::VideoTrackPrivateAVF::VideoTrackPrivateAVF):
* platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.mm:
(WebCore::AudioTrackPrivateAVFObjC::resetPropertiesFromTrack):
* platform/graphics/avfoundation/objc/VideoTrackPrivateAVFObjC.cpp:
(WebCore::VideoTrackPrivateAVFObjC::resetPropertiesFromTrack):

LayoutTests:

* media/content/audio-tracks.mp4: Added.
* media/content/audio-tracks.ogg: Added.
* media/content/audio-tracks.webm: Added.
* media/video-controls-audiotracks-trackmenu-expected.txt: Added.
* media/video-controls-audiotracks-trackmenu.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174402 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
LayoutTests/ChangeLog
LayoutTests/media/content/audio-tracks.mp4 [new file with mode: 0644]
LayoutTests/media/content/audio-tracks.ogg [new file with mode: 0644]
LayoutTests/media/content/audio-tracks.webm [new file with mode: 0644]
LayoutTests/media/video-controls-audiotracks-trackmenu-expected.txt [new file with mode: 0644]
LayoutTests/media/video-controls-audiotracks-trackmenu.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/mediaControlsLocalizedStrings.js
Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
Source/WebCore/Modules/mediacontrols/MediaControlsHost.h
Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl
Source/WebCore/Modules/mediacontrols/mediaControlsApple.js
Source/WebCore/html/track/AudioTrack.cpp
Source/WebCore/html/track/AudioTrackList.cpp
Source/WebCore/html/track/VideoTrackList.cpp
Source/WebCore/page/CaptionUserPreferences.cpp
Source/WebCore/page/CaptionUserPreferences.h
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/LocalizedStrings.h
Source/WebCore/platform/efl/LocalizedStringsEfl.cpp
Source/WebCore/platform/graphics/avfoundation/AudioTrackPrivateAVF.h
Source/WebCore/platform/graphics/avfoundation/VideoTrackPrivateAVF.h
Source/WebCore/platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateAVFObjC.cpp
Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp