Changeset 201831 in webkit


Ignore:
Timestamp:
Jun 8, 2016 2:07:42 PM (8 years ago)
Author:
eric.carlson@apple.com
Message:

HTMLMediaElement.prototype.canPlayType accounting for 250-750ms first loading theverge.com
https://bugs.webkit.org/show_bug.cgi?id=158335
<rdar://problem/26615416>

Reviewed by Brent Fulgham.

  • WebCore.xcodeproj/project.pbxproj: Add AVFoundationMIMETypeCache.
  • platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h: Added.
  • platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm: Added.

(WebCore::AVFoundationMIMETypeCache::AVFoundationMIMETypeCache):
(WebCore::AVFoundationMIMETypeCache::loadTypes):
(WebCore::AVFoundationMIMETypeCache::types):
(WebCore::AVFoundationMIMETypeCache::singleton):

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

(WebCore::MediaPlayerPrivateAVFoundationObjC::registerMediaEngine): Start MIME type loading.
(WebCore::MediaPlayerPrivateAVFoundationObjC::getSupportedTypes): Use AVFoundationMIMETypeCache.
(WebCore::MediaPlayerPrivateAVFoundationObjC::supportsType): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::supportsKeySystem): Ditto.
(WebCore::avfMIMETypes): Deleted.

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

(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): Start MIME type loading.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isAvailable): Use AVFoundationMIMETypeCache.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes): Ditto.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Ditto.
(WebCore::mimeTypeCache): Deleted.

Location:
trunk/Source/WebCore
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201823 r201831  
     12016-06-08  Eric Carlson  <eric.carlson@apple.com>
     2
     3        HTMLMediaElement.prototype.canPlayType accounting for 250-750ms first loading theverge.com
     4        https://bugs.webkit.org/show_bug.cgi?id=158335
     5        <rdar://problem/26615416>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * WebCore.xcodeproj/project.pbxproj: Add AVFoundationMIMETypeCache.
     10
     11        * platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h: Added.
     12        * platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm: Added.
     13        (WebCore::AVFoundationMIMETypeCache::AVFoundationMIMETypeCache):
     14        (WebCore::AVFoundationMIMETypeCache::loadTypes):
     15        (WebCore::AVFoundationMIMETypeCache::types):
     16        (WebCore::AVFoundationMIMETypeCache::singleton):
     17
     18        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     19        (WebCore::MediaPlayerPrivateAVFoundationObjC::registerMediaEngine): Start MIME type loading.
     20        (WebCore::MediaPlayerPrivateAVFoundationObjC::getSupportedTypes): Use AVFoundationMIMETypeCache.
     21        (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsType): Ditto.
     22        (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsKeySystem): Ditto.
     23        (WebCore::avfMIMETypes): Deleted.
     24
     25        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     26        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): Start MIME type loading.
     27        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isAvailable): Use AVFoundationMIMETypeCache.
     28        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes): Ditto.
     29        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Ditto.
     30        (WebCore::mimeTypeCache): Deleted.
     31
    1322016-06-07  Ryosuke Niwa  <rniwa@webkit.org>
    233
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r201810 r201831  
    113113                070F549E17F2402700169E04 /* AudioDestinationConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 070F549D17F2402700169E04 /* AudioDestinationConsumer.h */; settings = {ATTRIBUTES = (Private, ); }; };
    114114                0711589117DF6F6600EDFE2B /* MediaStreamPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0711588F17DF633700EDFE2B /* MediaStreamPrivate.cpp */; };
     115                0719427F1D088F21002AA51D /* AVFoundationMIMETypeCache.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07C8AD111D073D630087C5CE /* AVFoundationMIMETypeCache.mm */; };
    115116                071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */; };
    116117                071A9EC3168FBC55002629F9 /* TextTrackCueGeneric.h in Headers */ = {isa = PBXBuildFile; fileRef = 071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    77227723                07C59B6617F784BA000FBCBB /* MediaSourceSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourceSettings.h; sourceTree = "<group>"; };
    77237724                07C59B6D17F794F6000FBCBB /* JSMediaStreamTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaStreamTrackCustom.cpp; sourceTree = "<group>"; };
     7725                07C8AD111D073D630087C5CE /* AVFoundationMIMETypeCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AVFoundationMIMETypeCache.mm; sourceTree = "<group>"; };
     7726                07C8AD121D073D630087C5CE /* AVFoundationMIMETypeCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVFoundationMIMETypeCache.h; sourceTree = "<group>"; };
    77247727                07CA120D182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCPeerConnectionCustom.cpp; sourceTree = "<group>"; };
    77257728                07CE77D416712A6A00C55A47 /* InbandTextTrackPrivateClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrackPrivateClient.h; sourceTree = "<group>"; };
     
    2334823351                                CD54A760180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp */,
    2334923352                                CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */,
     23353                                07C8AD111D073D630087C5CE /* AVFoundationMIMETypeCache.mm */,
     23354                                07C8AD121D073D630087C5CE /* AVFoundationMIMETypeCache.h */,
    2335023355                                CDE595941BF166D100A1CBE8 /* CDMSessionAVContentKeySession.h */,
    2335123356                                CDE595931BF166AD00A1CBE8 /* CDMSessionAVContentKeySession.mm */,
     
    3148831493                                078E090717D14CEE00420AA1 /* RTCDTMFSender.cpp in Sources */,
    3148931494                                073794FB19F5864E00E5A045 /* RTCDTMFSenderHandlerMock.cpp in Sources */,
     31495                                0719427F1D088F21002AA51D /* AVFoundationMIMETypeCache.mm in Sources */,
    3149031496                                078E090817D14CEE00420AA1 /* RTCDTMFToneChangeEvent.cpp in Sources */,
    3149131497                                078E090917D14CEE00420AA1 /* RTCIceCandidate.cpp in Sources */,
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r201661 r201831  
    2929#import "MediaPlayerPrivateAVFoundationObjC.h"
    3030
     31#import "AVFoundationMIMETypeCache.h"
    3132#import "AVFoundationSPI.h"
    3233#import "AVTrackPrivateAVFObjCImpl.h"
     
    4647#import "InbandTextTrackPrivateAVFObjC.h"
    4748#import "InbandTextTrackPrivateLegacyAVFObjC.h"
    48 #import "OutOfBandTextTrackPrivateAVF.h"
    49 #import "URL.h"
    5049#import "Logging.h"
    5150#import "MediaPlaybackTargetMac.h"
     
    5352#import "MediaSelectionGroupAVFObjC.h"
    5453#import "MediaTimeAVFoundation.h"
     54#import "OutOfBandTextTrackPrivateAVF.h"
    5555#import "PixelBufferConformerCV.h"
    5656#import "PlatformTimeRanges.h"
     
    6262#import "TextTrackRepresentation.h"
    6363#import "TextureCacheCV.h"
     64#import "URL.h"
    6465#import "UUID.h"
    6566#import "VideoTextureCopierCV.h"
     
    424425void MediaPlayerPrivateAVFoundationObjC::registerMediaEngine(MediaEngineRegistrar registrar)
    425426{
    426     if (isAvailable())
    427         registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateAVFoundationObjC>(player); },
     427    if (!isAvailable())
     428        return;
     429
     430    registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateAVFoundationObjC>(player); },
    428431            getSupportedTypes, supportsType, originsInMediaCache, clearMediaCache, clearMediaCacheForOrigins, supportsKeySystem);
     432    AVFoundationMIMETypeCache::singleton().loadTypes();
    429433}
    430434
     
    16111615}
    16121616
    1613 static const HashSet<String, ASCIICaseInsensitiveHash>& avfMIMETypes()
    1614 {
    1615     static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache = []() {
    1616         HashSet<String, ASCIICaseInsensitiveHash> types;
    1617         for (NSString *type in [AVURLAsset audiovisualMIMETypes])
    1618             types.add(type);
    1619         return types;
    1620     }();
    1621    
    1622     return cache;
    1623 }
    1624 
    16251617RetainPtr<CGImageRef> MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect(float time, const FloatRect& rect)
    16261618{
     
    16471639void MediaPlayerPrivateAVFoundationObjC::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes)
    16481640{
    1649     supportedTypes = avfMIMETypes();
     1641    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::getSupportedTypes");
     1642    supportedTypes = AVFoundationMIMETypeCache::singleton().types();
    16501643}
    16511644
     
    16941687        return MediaPlayer::IsNotSupported;
    16951688
    1696     if (!staticMIMETypeList().contains(parameters.type) && !avfMIMETypes().contains(parameters.type))
     1689    if (!staticMIMETypeList().contains(parameters.type) && !AVFoundationMIMETypeCache::singleton().types().contains(parameters.type))
    16971690        return MediaPlayer::IsNotSupported;
    16981691
     
    17201713            return false;
    17211714
    1722         if (!mimeType.isEmpty() && !staticMIMETypeList().contains(mimeType) && !avfMIMETypes().contains(mimeType))
     1715        if (!mimeType.isEmpty() && !staticMIMETypeList().contains(mimeType) && !AVFoundationMIMETypeCache::singleton().types().contains(mimeType))
    17231716            return false;
    17241717
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r201482 r201831  
    2929#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
    3030
     31#import "AVFoundationMIMETypeCache.h"
    3132#import "CDMSessionAVStreamSession.h"
    3233#import "CDMSessionMediaSourceAVFObjC.h"
     
    203204void MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine(MediaEngineRegistrar registrar)
    204205{
    205     if (isAvailable())
    206         registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateMediaSourceAVFObjC>(player); }, getSupportedTypes,
    207             supportsType, 0, 0, 0, 0);
     206    if (!isAvailable())
     207        return;
     208
     209    registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateMediaSourceAVFObjC>(player); },
     210        getSupportedTypes, supportsType, 0, 0, 0, 0);
     211    AVFoundationMIMETypeCache::singleton().loadTypes();
    208212}
    209213
     
    218222}
    219223
    220 static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache()
    221 {
    222     static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache;
    223     static bool typeListInitialized = false;
    224 
    225     if (typeListInitialized)
    226         return cache;
    227     typeListInitialized = true;
    228 
    229     NSArray *types = [getAVURLAssetClass() audiovisualMIMETypes];
    230     for (NSString *mimeType in types)
    231         cache.get().add(mimeType);
    232    
    233     return cache;
    234 }
    235 
    236224void MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
    237225{
    238     types = mimeTypeCache();
     226    types = AVFoundationMIMETypeCache::singleton().types();
    239227}
    240228
     
    249237#endif
    250238
    251     if (parameters.type.isEmpty() || !mimeTypeCache().contains(parameters.type))
     239    if (parameters.type.isEmpty() || !AVFoundationMIMETypeCache::singleton().types().contains(parameters.type))
    252240        return MediaPlayer::IsNotSupported;
    253241
Note: See TracChangeset for help on using the changeset viewer.