Skip to content

Commit

Permalink
Video playback on Nintendo.com fails with "No supported media sources…
Browse files Browse the repository at this point in the history
…" error

https://bugs.webkit.org/show_bug.cgi?id=259077
rdar://110588102

Reviewed by Andy Estes and Eric Carlson.

In macOS Sonoma and iOS 17, the conventions of -isPlayableExtendedMIMEType have
changed, and queries of HLS container types with `codecs=` parameters will start
to return NO where they returned YES in previous versions of those platforms. To
allow existing websites to continue to use those styles of queries, adopt
-isPlayableExtendedMIMEType:options: with a key/value pair that indicates
AVURLAsset should assume the query refers to a HLS stream with ISO-BMFF segments.

* Source/WTF/wtf/PlatformHave.h:
* Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h:
* Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm:
* Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h:
* Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm:
(WebCore::AVAssetMIMETypeCache::canDecodeExtendedType):

Canonical link: https://commits.webkit.org/265933@main
  • Loading branch information
jernoble committed Jul 11, 2023
1 parent c2ba4be commit 3a1caaa
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Source/WTF/wtf/PlatformHave.h
Original file line number Diff line number Diff line change
Expand Up @@ -1459,3 +1459,11 @@
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 140000
#define HAVE_NSVIEW_CLIPSTOBOUNDS_API 1
#endif

#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 140000) \
|| (PLATFORM(MACCATALYST) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 170000) \
|| (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 170000) \
|| (PLATFORM(APPLETV) && __TV_OS_VERSION_MAX_ALLOWED >= 170000) \
|| (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 100000)
#define HAVE_AVURLASSET_ISPLAYABLEEXTENDEDMIMETYPEWITHOPTIONS 1
#endif
3 changes: 3 additions & 0 deletions Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,7 @@ SOFT_LINK_CLASS_FOR_HEADER(PAL, AVAudioPCMBuffer)
SOFT_LINK_CONSTANT_FOR_HEADER(PAL, AVFoundation, AVAssetExportPresetHighestQuality, NSString *)
#define AVAssetExportPresetHighestQuality PAL::get_AVFoundation_AVAssetExportPresetHighestQuality()

SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(PAL, AVFoundation, AVURLAssetExtendedMIMETypePlayabilityTreatSupportedPlaylistMIMETypesAsISOBMFFMediaDataContainersKey, NSString *)
#define AVURLAssetExtendedMIMETypePlayabilityTreatSupportedPlaylistMIMETypesAsISOBMFFMediaDataContainersKey PAL::get_AVFoundation_AVURLAssetExtendedMIMETypePlayabilityTreatSupportedPlaylistMIMETypesAsISOBMFFMediaDataContainersKey()

#endif // USE(AVFOUNDATION)
2 changes: 2 additions & 0 deletions Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,6 @@ static BOOL justReturnsNO()
SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVOutputContextOutputDevicesDidChangeNotification, NSNotificationName, PAL_EXPORT)
#endif // HAVE(AVROUTEPICKERVIEW)

SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetExtendedMIMETypePlayabilityTreatSupportedPlaylistMIMETypesAsISOBMFFMediaDataContainersKey, NSString *, PAL_EXPORT)

#endif // USE(AVFOUNDATION)
11 changes: 11 additions & 0 deletions Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#if USE(APPLE_INTERNAL_SDK)

#import <AVFoundation/AVAssetCache_Private.h>
#import <AVFoundation/AVAsset_Private.h>
#import <AVFoundation/AVCaptureSession_Private.h>
#import <AVFoundation/AVContentKeySession_Private.h>
#import <AVFoundation/AVMediaSelectionGroup_Private.h>
Expand Down Expand Up @@ -486,3 +487,13 @@ NS_ASSUME_NONNULL_END
@property (nonatomic) BOOL preferSandboxedParsing;
@end
#endif

// FIXME: Move into !USE(APPLE_INTERNAL_SDK) section once rdar://111695863 has been in the build a while
#if HAVE(AVURLASSET_ISPLAYABLEEXTENDEDMIMETYPEWITHOPTIONS)
NS_ASSUME_NONNULL_BEGIN
@interface AVURLAsset (IsPlayableExtendedMIMETypeWithOptions)
+ (BOOL)isPlayableExtendedMIMEType:(NSString *)extendedMIMEType options:(nullable NSDictionary<NSString *, id> *)options;
@end
NS_ASSUME_NONNULL_END
#endif

Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ static bool isMultichannelOpusAvailable()
#endif

ASSERT(isAvailable());

#if HAVE(AVURLASSET_ISPLAYABLEEXTENDEDMIMETYPEWITHOPTIONS)
if (PAL::canLoad_AVFoundation_AVURLAssetExtendedMIMETypePlayabilityTreatSupportedPlaylistMIMETypesAsISOBMFFMediaDataContainersKey()
&& [PAL::getAVURLAssetClass() respondsToSelector:@selector(isPlayableExtendedMIMEType:options:)]) {
if ([PAL::getAVURLAssetClass() isPlayableExtendedMIMEType:type.raw() options:@{ AVURLAssetExtendedMIMETypePlayabilityTreatSupportedPlaylistMIMETypesAsISOBMFFMediaDataContainersKey: @YES }])
return true;
} else
#endif
if ([PAL::getAVURLAssetClass() isPlayableExtendedMIMEType:type.raw()])
return true;

Expand Down

0 comments on commit 3a1caaa

Please sign in to comment.