Changeset 179549 in webkit


Ignore:
Timestamp:
Feb 3, 2015 9:27:55 AM (9 years ago)
Author:
jer.noble@apple.com
Message:

[Mac] HLS audio is not correctly selected according to system language
https://bugs.webkit.org/show_bug.cgi?id=140398
rdar://problem/19218487

Reviewed by Darin Adler.

Source/WebCore:

Test: http/tests/media/hls/hls-audio-tracks-locale-selection.html

When AVMediaSelectionOptions come and go and no explicit track selection choice has
been made, automatically pick the most appropriate track according to the user's
current preferred locale settings.

  • platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.h:
  • platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm:

(WebCore::MediaSelectionGroupAVFObjC::MediaSelectionGroupAVFObjC): Set m_shouldSelectOptionAutomatically

to true by default.

(WebCore::MediaSelectionGroupAVFObjC::updateOptions): If m_shouldSelectOptionAutomatically is set

pick the most appropriate media selection option.

(WebCore::MediaSelectionGroupAVFObjC::setSelectedOption): Set m_shouldSelectOptionAutomatically to false.

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Remove these automatic selection

requests as they are ineffective when -appliesMediaSelectionCriteriaAutomatically is NO.

LayoutTests:

  • http/tests/media/hls/hls-audio-tracks-locale-selection-expected.txt: Added.
  • http/tests/media/hls/hls-audio-tracks-locale-selection.html: Added.
  • http/tests/media/resources/hls/audio-tracks.m3u8:
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r179543 r179549  
     12015-02-03  Jer Noble  <jer.noble@apple.com>
     2
     3        [Mac] HLS audio is not correctly selected according to system language
     4        https://bugs.webkit.org/show_bug.cgi?id=140398
     5        rdar://problem/19218487
     6
     7        Reviewed by Darin Adler.
     8
     9        * http/tests/media/hls/hls-audio-tracks-locale-selection-expected.txt: Added.
     10        * http/tests/media/hls/hls-audio-tracks-locale-selection.html: Added.
     11        * http/tests/media/resources/hls/audio-tracks.m3u8:
     12
    1132015-02-03  Piotr Krysiewicz  <p.krysiewicz@samsung.com>
    214
  • trunk/LayoutTests/http/tests/media/resources/hls/audio-tracks.m3u8

    r174823 r179549  
    11#EXTM3U
    22
    3 #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="bipbop_audio",LANGUAGE="eng",NAME="English Sound",AUTOSELECT=YES,DEFAULT=YES
    4 #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="bipbop_audio",LANGUAGE="fre",NAME="French Sound",AUTOSELECT=NO,DEFAULT=NO,URI="french/prog_index.m3u8"
    5 #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="bipbop_audio",LANGUAGE="spa",NAME="Spanish Sound",AUTOSELECT=NO,DEFAULT=NO,URI="spanish/prog_index.m3u8"
     3#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="bipbop_audio",LANGUAGE="en-US",NAME="English Sound",AUTOSELECT=YES,DEFAULT=YES
     4#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="bipbop_audio",LANGUAGE="fr-FR",NAME="French Sound",AUTOSELECT=NO,DEFAULT=NO,URI="french/prog_index.m3u8"
     5#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="bipbop_audio",LANGUAGE="es-US",NAME="Spanish Sound",AUTOSELECT=NO,DEFAULT=NO,URI="spanish/prog_index.m3u8"
    66
    77#EXT-X-STREAM-INF:BANDWIDTH=634451,CODECS="mp4a.40.2, avc1.4d401e",RESOLUTION=640x480,AUDIO="bipbop_audio"
  • trunk/Source/WebCore/ChangeLog

    r179548 r179549  
     12015-02-03  Jer Noble  <jer.noble@apple.com>
     2
     3        [Mac] HLS audio is not correctly selected according to system language
     4        https://bugs.webkit.org/show_bug.cgi?id=140398
     5        rdar://problem/19218487
     6
     7        Reviewed by Darin Adler.
     8
     9        Test: http/tests/media/hls/hls-audio-tracks-locale-selection.html
     10
     11        When AVMediaSelectionOptions come and go and no explicit track selection choice has
     12        been made, automatically pick the most appropriate track according to the user's
     13        current preferred locale settings.
     14
     15        * platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.h:
     16        * platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm:
     17        (WebCore::MediaSelectionGroupAVFObjC::MediaSelectionGroupAVFObjC): Set m_shouldSelectOptionAutomatically
     18            to true by default.
     19        (WebCore::MediaSelectionGroupAVFObjC::updateOptions): If m_shouldSelectOptionAutomatically is set
     20            pick the most appropriate media selection option.
     21        (WebCore::MediaSelectionGroupAVFObjC::setSelectedOption): Set m_shouldSelectOptionAutomatically to false.
     22        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     23        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Remove these automatic selection
     24            requests as they are ineffective when -appliesMediaSelectionCriteriaAutomatically is NO.
     25
    1262015-02-03  Darin Adler  <darin@apple.com>
    227
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.h

    r176459 r179549  
    9090    RetainPtr<AVMediaSelectionGroup> m_mediaSelectionGroup;
    9191    OptionContainer m_options;
    92     MediaSelectionOptionAVFObjC* m_selectedOption;
     92    MediaSelectionOptionAVFObjC* m_selectedOption { nullptr };
    9393    Timer m_selectionTimer;
     94    bool m_shouldSelectOptionAutomatically { true };
    9495};
    9596
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm

    r179473 r179549  
    2929#if ENABLE(VIDEO_TRACK)
    3030
     31#import "Language.h"
    3132#import "SoftLinking.h"
    3233#import <AVFoundation/AVAsset.h>
     
    3637#import <wtf/HashMap.h>
    3738#import <wtf/HashSet.h>
     39#import <wtf/text/WTFString.h>
    3840
    3941SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
     
    8991    : m_playerItem(item)
    9092    , m_mediaSelectionGroup(group)
    91     , m_selectedOption(nullptr)
    9293    , m_selectionTimer(*this, &MediaSelectionGroupAVFObjC::selectionTimerFired)
    9394{
     
    129130        m_options.set(addedAVOption, addedOption.release());
    130131    }
     132
     133    if (!m_shouldSelectOptionAutomatically)
     134        return;
     135
     136    RetainPtr<NSMutableArray> nsLanguages = adoptNS([[NSMutableArray alloc] initWithCapacity:userPreferredLanguages().size()]);
     137    for (auto& language : userPreferredLanguages())
     138        [nsLanguages addObject:(NSString*)language];
     139    NSArray* filteredOptions = [getAVMediaSelectionGroupClass() mediaSelectionOptionsFromArray:[m_mediaSelectionGroup options] filteredAndSortedAccordingToPreferredLanguages:nsLanguages.get()];
     140
     141    if (![filteredOptions count])
     142        return;
     143
     144    AVMediaSelectionOption* preferredOption = [filteredOptions objectAtIndex:0];
     145    if (m_selectedOption && m_selectedOption->avMediaSelectionOption() == preferredOption)
     146        return;
     147
     148    ASSERT(m_options.contains(preferredOption));
     149    m_selectedOption = m_options.get(preferredOption);
     150    m_selectionTimer.startOneShot(0);
    131151}
    132152
     
    136156        return;
    137157
     158    m_shouldSelectOptionAutomatically = false;
    138159    m_selectedOption = option;
    139160    if (m_selectionTimer.isActive())
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r179364 r179549  
    936936#endif
    937937
    938 #if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
    939         [m_avPlayerItem selectMediaOptionAutomaticallyInMediaSelectionGroup:safeMediaSelectionGroupForLegibleMedia()];
    940         [m_avPlayerItem selectMediaOptionAutomaticallyInMediaSelectionGroup:safeMediaSelectionGroupForAudibleMedia()];
    941         [m_avPlayerItem selectMediaOptionAutomaticallyInMediaSelectionGroup:safeMediaSelectionGroupForVisualMedia()];
    942 #endif
    943 
    944938#if ENABLE(WEB_AUDIO) && USE(MEDIATOOLBOX)
    945939    if (m_provider)
Note: See TracChangeset for help on using the changeset viewer.