[Mac] Audio tracks tagged as 'describes-video' are not automatically selected when...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 May 2015 23:15:37 +0000 (23:15 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 May 2015 23:15:37 +0000 (23:15 +0000)
commit4d403750f8a6bab950b41dad421c20d9f4166c70
tree3530f635ab31f2bfb49006dedc035cad9e50681d
parent7ee879406eca47bf6524eecbc85835f2fec6deef
[Mac] Audio tracks tagged as 'describes-video' are not automatically selected when that system accessibility option is set.
https://bugs.webkit.org/show_bug.cgi?id=145228

Reviewed by Eric Carlson.

Source/WebCore:

Tests: http/tests/media/hls/hls-accessiblity-describes-video.html
       media/accessiblity-describes-video.html

Add support to CaptionUserPreferences to return the user's preferred audio characteristics,
including "public.accessibility.describes-video". When the media accessibility options change,
trigger the HTMLMediaElement to update the list of tracks, and chose a new audio track if
appropriate. Manually filter those tracks matching the requested characteristics in
MediaSelectionGroupAVFObjC.  Allow these characteristics to be overrided by Internals for
testing purposes.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::captionPreferencesChanged): Call tracksChanged().
(WebCore::HTMLMediaElement::mediaPlayerPreferredAudioCharacteristics): Pass through to the page's caption preferences.
* html/HTMLMediaElement.h:
* page/CaptionUserPreferences.cpp:
(WebCore::CaptionUserPreferences::setPreferredAudioCharacteristic): Simple setter.
(WebCore::CaptionUserPreferences::preferredAudioCharacteristics): Simple getter.
* page/CaptionUserPreferences.h:
* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::CaptionUserPreferencesMediaAF::~CaptionUserPreferencesMediaAF): Unregister for audio characteristics change notifications.
(WebCore::CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges): Register for same.
(WebCore::CaptionUserPreferencesMediaAF::setPreferredAudioCharacteristic): If in testing mode, pass to superclass; otherwise no-op.
(WebCore::CaptionUserPreferencesMediaAF::preferredAudioCharacteristics): If in testing mode, pass to superclass;
    otherwise, ask the media accessibility framework.
* page/CaptionUserPreferencesMediaAF.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::tracksChanged): Pass through to m_private.
(WebCore::MediaPlayer::preferredAudioCharacteristics): Pass through to HTMLMediaElement.
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerPreferredAudioCharacteristics): Added; return empty vector by default.
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::tracksChanged): Added; no-op by default.
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
* platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.h:
* platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm:
(WebCore::MediaSelectionGroupAVFObjC::create): Added characteristics parameter.
(WebCore::MediaSelectionGroupAVFObjC::MediaSelectionGroupAVFObjC): Ditto.
(WebCore::MediaSelectionGroupAVFObjC::updateOptions): Add an additional filter against the
    passed-in characteristics.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::determineChangedTracksFromNewTracksAndOldItems): Pass the characteristics to the media selection group.
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateAudioTracks): Pass in the user's preferred characteristics.
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoTracks): Pass in an empty vector.
* testing/Internals.cpp:
(WebCore::Internals::userPreferredAudioCharacteristics): Added; return the current setting.
(WebCore::Internals::setUserPreferredAudioCharacteristic): Added; pass through to CaptionUserPreferences.
* testing/Internals.h:
* testing/Internals.idl:

Add soft link macros which account for a possible failure to look up constants.

* platform/cf/MediaAccessibilitySoftLink.cpp:
* platform/cf/MediaAccessibilitySoftLink.h:
* platform/mac/SoftLinking.h:
* platform/win/SoftLinking.h:

LayoutTests:

* http/tests/media/hls/hls-accessiblity-describes-video-expected.txt: Added.
* http/tests/media/hls/hls-accessiblity-describes-video.html: Added.
* http/tests/media/resources/hls/audio-describes-video.m3u8: Added.
* http/tests/media/resources/hls/english/description.aac: Added.
* http/tests/media/resources/hls/english/description.m3u8: Added.
* media/accessiblity-describes-video-expected.txt: Added.
* media/accessiblity-describes-video.html: Added.
* media/content/audio-describes-video.mp4: Added.
* platform/mac-mavericks/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184799 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/media/hls/hls-accessiblity-describes-video-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/media/hls/hls-accessiblity-describes-video.html [new file with mode: 0644]
LayoutTests/http/tests/media/resources/hls/audio-describes-video.m3u8 [new file with mode: 0644]
LayoutTests/http/tests/media/resources/hls/english/description.aac [new file with mode: 0644]
LayoutTests/http/tests/media/resources/hls/english/description.m3u8 [new file with mode: 0644]
LayoutTests/media/accessiblity-describes-video-expected.txt [new file with mode: 0644]
LayoutTests/media/accessiblity-describes-video.html [new file with mode: 0644]
LayoutTests/media/content/audio-describes-video.mp4 [new file with mode: 0644]
LayoutTests/platform/mac-mavericks/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/page/CaptionUserPreferences.cpp
Source/WebCore/page/CaptionUserPreferences.h
Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp
Source/WebCore/page/CaptionUserPreferencesMediaAF.h
Source/WebCore/platform/cf/MediaAccessibilitySoftLink.cpp
Source/WebCore/platform/cf/MediaAccessibilitySoftLink.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
Source/WebCore/platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/mac/SoftLinking.h
Source/WebCore/platform/win/SoftLinking.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl