Changeset 271194 in webkit
- Timestamp:
- Jan 5, 2021, 11:26:14 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 20 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/audio/PlatformMediaSessionManager.cpp (modified) (2 diffs)
-
WebCore/platform/audio/PlatformMediaSessionManager.h (modified) (2 diffs)
-
WebCore/platform/graphics/TrackPrivateBase.cpp (modified) (1 diff)
-
WebCore/platform/graphics/TrackPrivateBase.h (modified) (1 diff)
-
WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm (modified) (3 diffs)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (modified) (8 diffs)
-
WebCore/platform/graphics/cocoa/AudioTrackPrivateWebM.cpp (modified) (1 diff)
-
WebCore/platform/graphics/cocoa/AudioTrackPrivateWebM.h (modified) (1 diff)
-
WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp (modified) (7 diffs)
-
WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h (modified) (1 diff)
-
WebCore/platform/graphics/cocoa/VideoTrackPrivateWebM.cpp (modified) (1 diff)
-
WebCore/platform/graphics/cocoa/VideoTrackPrivateWebM.h (modified) (1 diff)
-
WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm (modified) (2 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Shared/mac/MediaFormatReader/FormatReader.cpp (modified) (1 diff)
-
WebKit/Shared/mac/MediaFormatReader/TrackReader.cpp (modified) (6 diffs)
-
WebKit/Shared/mac/MediaFormatReader/TrackReader.h (modified) (4 diffs)
-
WebKit/WebProcess/WebPage/WebPage.cpp (modified) (1 diff)
-
WebKit/WebProcess/cocoa/WebProcessCocoa.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r271191 r271194 1 2021-01-05 Eric Carlson <eric.carlson@apple.com> 2 3 [Cocoa] WebM format reader doesn't work with a url in a <source> element 4 https://bugs.webkit.org/show_bug.cgi?id=219961 5 <rdar://problem/72399014> 6 7 Reviewed by Andy Estes. 8 9 Work around a CoreMedia bug that makes the format reader fail to load when the 10 AVURLAssetOutOfBandMIMETypeKeyis included in the AVURLAsset options dictionary. 11 Also include some cleanup: 12 - Move the code to check for WebM MIME types from MediaPlayerPrivateAVFoundationObjC 13 to AVAssetMIMETypeCache. 14 - Don't use RuntimeEnabledFeatures in MediaPlayerPrivateAVFoundationObjC. 15 - Register the WebM format reader when creating an AVURLAsset for a WebM url instead 16 of when checking the MIME type. 17 - Cleanup WebM "codecs" parameter parsing. 18 - It is a layering violation to use RuntimeSettings from inside of /platform. 19 20 * platform/audio/PlatformMediaSessionManager.cpp: 21 (WebCore::PlatformMediaSessionManager::webMFormatReaderEnabled): 22 (WebCore::PlatformMediaSessionManager::setWebMFormatReaderEnabled): 23 (WebCore::PlatformMediaSessionManager::vorbisDecoderEnabled): 24 (WebCore::PlatformMediaSessionManager::setVorbisDecoderEnabled): 25 * platform/audio/PlatformMediaSessionManager.h: 26 * platform/graphics/TrackPrivateBase.cpp: 27 (WebCore::TrackPrivateBase::defaultEnabled const): 28 * platform/graphics/TrackPrivateBase.h: 29 * platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm: 30 (WebCore::AVAssetMIMETypeCache::canDecodeExtendedType): 31 (WebCore::AVAssetMIMETypeCache::initializeCache): 32 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 33 (WebCore::registerFormatReaderIfNecessary): 34 (WebCore::willUseWebMFormatReaderForType): 35 (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): 36 (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsTypeAndCodecs): 37 (WebCore::ensureFormatReaderIsRegistered): Deleted. 38 (WebCore::isFormatReaderAvailable): Deleted. 39 * platform/graphics/cocoa/AudioTrackPrivateWebM.cpp: 40 (WebCore::AudioTrackPrivateWebM::defaultEnabled const): 41 * platform/graphics/cocoa/AudioTrackPrivateWebM.h: 42 * platform/graphics/cocoa/SourceBufferParserWebM.cpp: 43 (WebCore::SourceBufferParserWebM::webmMIMETypes): 44 (WebCore::canLoadFormatReader): 45 (WebCore::SourceBufferParserWebM::isWebMFormatReaderAvailable): 46 (WebCore::SourceBufferParserWebM::isContentTypeSupported): 47 * platform/graphics/cocoa/SourceBufferParserWebM.h: 48 * platform/graphics/cocoa/VideoTrackPrivateWebM.cpp: 49 (WebCore::VideoTrackPrivateWebM::defaultEnabled const): 50 * platform/graphics/cocoa/VideoTrackPrivateWebM.h: 51 * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm: 52 (WebCore::isVorbisDecoderAvailable): 53 1 54 2021-01-05 Simon Fraser <simon.fraser@apple.com> 2 55 -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
r269077 r271194 36 36 #if ENABLE(VIDEO) || ENABLE(WEB_AUDIO) 37 37 38 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER) 39 bool PlatformMediaSessionManager::m_webMFormatReaderEnabled; 40 #endif 41 42 #if ENABLE(VORBIS) && PLATFORM(MAC) 43 bool PlatformMediaSessionManager::m_vorbisDecoderEnabled; 44 #endif 45 38 46 static std::unique_ptr<PlatformMediaSessionManager>& sharedPlatformMediaSessionManager() 39 47 { … … 611 619 } 612 620 621 bool PlatformMediaSessionManager::webMFormatReaderEnabled() 622 { 623 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER) 624 return m_webMFormatReaderEnabled; 625 #else 626 return false; 627 #endif 628 } 629 630 void PlatformMediaSessionManager::setWebMFormatReaderEnabled(bool enabled) 631 { 632 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER) 633 m_webMFormatReaderEnabled = enabled; 634 #else 635 UNUSED_PARAM(enabled); 636 #endif 637 } 638 639 bool PlatformMediaSessionManager::vorbisDecoderEnabled() 640 { 641 #if ENABLE(VORBIS) && PLATFORM(MAC) 642 return m_vorbisDecoderEnabled; 643 #else 644 return false; 645 #endif 646 } 647 648 void PlatformMediaSessionManager::setVorbisDecoderEnabled(bool enabled) 649 { 650 #if ENABLE(VORBIS) && PLATFORM(MAC) 651 m_vorbisDecoderEnabled = enabled; 652 #else 653 UNUSED_PARAM(enabled); 654 #endif 655 } 656 613 657 #else // ENABLE(VIDEO) || ENABLE(WEB_AUDIO) 614 658 -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h
r269077 r271194 59 59 WEBCORE_EXPORT static bool shouldDeactivateAudioSession(); 60 60 61 WEBCORE_EXPORT static void setWebMFormatReaderEnabled(bool); 62 WEBCORE_EXPORT static bool webMFormatReaderEnabled(); 63 WEBCORE_EXPORT static void setVorbisDecoderEnabled(bool); 64 WEBCORE_EXPORT static bool vorbisDecoderEnabled(); 65 61 66 virtual ~PlatformMediaSessionManager() = default; 62 67 … … 202 207 GenericTaskQueue<Timer> updateSessionStateQueue; 203 208 209 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER) 210 static bool m_webMFormatReaderEnabled; 211 #endif 212 #if ENABLE(VORBIS) && PLATFORM(MAC) 213 static bool m_vorbisDecoderEnabled; 214 #endif 215 204 216 #if !RELEASE_LOG_DISABLED 205 217 Ref<AggregateLogger> m_logger; -
trunk/Source/WebCore/platform/graphics/TrackPrivateBase.cpp
r270841 r271194 39 39 } 40 40 41 Optional<bool> TrackPrivateBase::defaultEnabled() const 42 { 43 return WTF::nullopt; 44 } 45 41 46 #if !RELEASE_LOG_DISABLED 42 47 -
trunk/Source/WebCore/platform/graphics/TrackPrivateBase.h
r270841 r271194 65 65 virtual int trackIndex() const { return 0; } 66 66 virtual Optional<uint64_t> trackUID() const; 67 virtual Optional<bool> defaultEnabled() const; 67 68 68 69 virtual MediaTime startTimeVariance() const { return MediaTime::zeroTime(); } -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm
r271038 r271194 30 30 31 31 #import "ContentType.h" 32 #import "SourceBufferParserWebM.h" 32 33 #import <pal/cf/CoreMediaSoftLink.h> 33 34 #import <pal/cocoa/AVFoundationSoftLink.h> … … 64 65 #if ENABLE(VIDEO) && USE(AVFOUNDATION) 65 66 ASSERT(isAvailable()); 66 return [PAL::getAVURLAssetClass() isPlayableExtendedMIMEType:type.raw()]; 67 if ([PAL::getAVURLAssetClass() isPlayableExtendedMIMEType:type.raw()]) 68 return true; 69 70 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER) 71 if (SourceBufferParserWebM::isContentTypeSupported(type) == MediaPlayerEnums::SupportsType::IsSupported) 72 return true; 67 73 #endif 74 75 #endif // ENABLE(VIDEO) && USE(AVFOUNDATION) 68 76 69 77 return false; … … 149 157 cache.add(type); 150 158 159 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER) 160 if (SourceBufferParserWebM::isWebMFormatReaderAvailable()) { 161 auto webmTypes = SourceBufferParserWebM::webmMIMETypes(); 162 cache.add(webmTypes.begin(), webmTypes.end()); 163 } 164 #endif 165 151 166 if (m_cacheTypeCallback) 152 167 m_cacheTypeCallback(copyToVector(cache)); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r271038 r271194 57 57 #import "PlatformTimeRanges.h" 58 58 #import "RuntimeApplicationChecks.h" 59 #import "RuntimeEnabledFeatures.h"60 59 #import "SecurityOrigin.h" 61 60 #import "SerializedPlatformDataCueMac.h" … … 101 100 #import <wtf/URL.h> 102 101 #import <wtf/cocoa/VectorCocoa.h> 103 #import <wtf/spi/darwin/OSVariantSPI.h>104 102 #import <wtf/text/CString.h> 105 103 #import <wtf/threads/BinarySemaphore.h> … … 269 267 }); 270 268 return globalQueue; 269 } 270 271 static void registerFormatReaderIfNecessary() 272 { 273 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER) 274 static dispatch_once_t onceToken; 275 dispatch_once(&onceToken, ^{ 276 // Like we do for other media formats, allow the format reader to run in the WebContent or GPU process 277 // (which is already appropriately sandboxed) rather than in a separate MediaToolbox XPC service. 278 RELEASE_ASSERT(isInGPUProcess() || isInWebProcess()); 279 MTRegisterPluginFormatReaderBundleDirectory((__bridge CFURLRef)NSBundle.mainBundle.builtInPlugInsURL); 280 MTPluginFormatReaderDisableSandboxing(); 281 }); 282 #endif 271 283 } 272 284 … … 793 805 } 794 806 807 static bool willUseWebMFormatReaderForType(const String& type) 808 { 809 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER) 810 if (!SourceBufferParserWebM::isWebMFormatReaderAvailable()) 811 return false; 812 813 return equalIgnoringASCIICase(type, "video/webm") || equalIgnoringASCIICase(type, "audio/webm"); 814 #else 815 UNUSED_PARAM(type); 816 return false; 817 #endif 818 } 819 795 820 void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const URL& url, RetainPtr<NSMutableDictionary> options) 796 821 { … … 834 859 835 860 auto type = player()->contentMIMEType(); 836 if (PAL::canLoad_AVFoundation_AVURLAssetOutOfBandMIMETypeKey() && !type.isEmpty() && !player()->contentMIMETypeWasInferredFromExtension()) { 861 862 // Don't advertise WebM MIME types or the format reader won't be loaded until rdar://72405127 is fixed. 863 auto willUseWebMFormatReader = willUseWebMFormatReaderForType(type); 864 865 if (PAL::canLoad_AVFoundation_AVURLAssetOutOfBandMIMETypeKey() && !type.isEmpty() && !player()->contentMIMETypeWasInferredFromExtension() && !willUseWebMFormatReader) { 837 866 auto codecs = player()->contentTypeCodecs(); 838 867 if (!codecs.isEmpty()) { … … 876 905 [options setObject:@NO forKey:AVURLAssetUsesNoPersistentCacheKey]; 877 906 } 907 908 if (willUseWebMFormatReader) 909 registerFormatReaderIfNecessary(); 878 910 879 911 NSURL *cocoaURL = canonicalURL(url); … … 1668 1700 #endif 1669 1701 1670 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)1671 static void ensureFormatReaderIsRegistered()1672 {1673 static dispatch_once_t onceToken;1674 dispatch_once(&onceToken, ^{1675 // Like we do for other media formats, allow the format reader to run in the WebContent or GPU process1676 // (which is already appropriately sandboxed) rather than in a separate MediaToolbox XPC service.1677 RELEASE_ASSERT(isInGPUProcess() || isInWebProcess());1678 MTRegisterPluginFormatReaderBundleDirectory((__bridge CFURLRef)NSBundle.mainBundle.builtInPlugInsURL);1679 MTPluginFormatReaderDisableSandboxing();1680 });1681 }1682 #endif1683 1684 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)1685 static bool isFormatReaderAvailable()1686 {1687 if (!RuntimeEnabledFeatures::sharedFeatures().webMFormatReaderEnabled())1688 return false;1689 1690 #if !USE(APPLE_INTERNAL_SDK)1691 // FIXME (rdar://72320419): If WebKit was built with ad-hoc code-signing,1692 // CoreMedia will only load the format reader plug-in when a user default1693 // is set on Apple internal OSs. That means we cannot currently support WebM1694 // in public SDK builds on customer OSs.1695 if (!os_variant_allows_internal_security_policies("com.apple.WebKit"))1696 return false;1697 #endif1698 1699 return true;1700 }1701 #endif1702 1703 1702 MediaPlayer::SupportsType MediaPlayerPrivateAVFoundationObjC::supportsTypeAndCodecs(const MediaEngineSupportParameters& parameters) 1704 1703 { … … 1710 1709 if (parameters.isMediaStream) 1711 1710 return MediaPlayer::SupportsType::IsNotSupported; 1712 #endif1713 1714 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER)1715 if (isFormatReaderAvailable()) {1716 auto supported = SourceBufferParserWebM::isContentTypeSupported(parameters.type);1717 if (supported != MediaPlayer::SupportsType::IsNotSupported) {1718 ensureFormatReaderIsRegistered();1719 if (supported == MediaPlayer::SupportsType::MayBeSupported)1720 return supported;1721 if (contentTypeMeetsHardwareDecodeRequirements(parameters.type, parameters.contentTypesRequiringHardwareSupport))1722 return MediaPlayer::SupportsType::IsSupported;1723 }1724 }1725 1711 #endif 1726 1712 -
trunk/Source/WebCore/platform/graphics/cocoa/AudioTrackPrivateWebM.cpp
r270841 r271194 59 59 } 60 60 61 Optional<bool> AudioTrackPrivateWebM::defaultEnabled() const 62 { 63 if (m_track.is_enabled.is_present()) 64 return m_track.is_enabled.value(); 65 return WTF::nullopt; 66 } 67 61 68 AtomString AudioTrackPrivateWebM::label() const 62 69 { -
trunk/Source/WebCore/platform/graphics/cocoa/AudioTrackPrivateWebM.h
r270841 r271194 43 43 int trackIndex() const final; 44 44 Optional<uint64_t> trackUID() const final; 45 Optional<bool> defaultEnabled() const final; 45 46 46 47 private: -
trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp
r271086 r271194 36 36 #include "MediaSampleAVFObjC.h" 37 37 #include "NotImplemented.h" 38 #include "PlatformMediaSessionManager.h" 38 39 #include "SharedBuffer.h" 39 40 #include "VP9UtilitiesCocoa.h" … … 49 50 #include <wtf/cf/TypeCastsCF.h> 50 51 #include <wtf/darwin/WeakLinking.h> 52 #include <wtf/spi/darwin/OSVariantSPI.h> 51 53 52 54 #include "CoreVideoSoftLink.h" … … 444 446 }; 445 447 448 const HashSet<String, ASCIICaseInsensitiveHash>& SourceBufferParserWebM::webmMIMETypes() 449 { 450 static auto types = makeNeverDestroyed([] { 451 452 HashSet<String, ASCIICaseInsensitiveHash> types; 453 454 #if ENABLE(VP9) 455 types.add("video/webm"); 456 #endif 457 #if ENABLE(VORBIS) || ENABLE(OPUS) 458 types.add("audio/webm"); 459 #endif 460 461 return types; 462 }()); 463 464 return types; 465 } 466 467 static bool canLoadFormatReader() 468 { 469 #if !HAVE(MT_PLUGIN_FORMAT_READER) 470 return false; 471 #elif USE(APPLE_INTERNAL_SDK) 472 return true; 473 #else 474 // FIXME (rdar://72320419): If WebKit was built with ad-hoc code-signing, 475 // CoreMedia will only load the format reader plug-in when a user default 476 // is set on Apple internal OSs. That means we cannot currently support WebM 477 // in public SDK builds on customer OSs. 478 static bool allowsInternalSecurityPolicies = os_variant_allows_internal_security_policies("com.apple.WebKit"); 479 return allowsInternalSecurityPolicies; 480 #endif // !USE(APPLE_INTERNAL_SDK) 481 } 482 483 bool SourceBufferParserWebM::isWebMFormatReaderAvailable() 484 { 485 return PlatformMediaSessionManager::webMFormatReaderEnabled() && canLoadFormatReader() && isWebmParserAvailable(); 486 } 487 446 488 MediaPlayerEnums::SupportsType SourceBufferParserWebM::isContentTypeSupported(const ContentType& type) 447 489 { … … 450 492 return MediaPlayerEnums::SupportsType::IsNotSupported; 451 493 452 bool isAudioContainerType = WTF::equalIgnoringASCIICase(type.containerType(), "audio/webm"); 453 bool isVideoContainerType = WTF::equalIgnoringASCIICase(type.containerType(), "video/webm"); 494 auto containerType = type.containerType(); 495 bool isAudioContainerType = WTF::equalIgnoringASCIICase(containerType, "audio/webm"); 496 bool isVideoContainerType = WTF::equalIgnoringASCIICase(containerType, "video/webm"); 454 497 if (!isAudioContainerType && !isVideoContainerType) 455 498 return MediaPlayerEnums::SupportsType::IsNotSupported; … … 474 517 return MediaPlayerEnums::SupportsType::IsNotSupported; 475 518 476 String codecsParameter = type.parameter(ContentType::codecsParameter());477 if ( !codecsParameter)519 auto codecs = type.codecs(); 520 if (codecs.isEmpty()) 478 521 return MediaPlayerEnums::SupportsType::MayBeSupported; 479 522 480 auto splitResults = StringView(codecsParameter).split(','); 481 if (splitResults.begin() == splitResults.end()) 482 return MediaPlayerEnums::SupportsType::MayBeSupported; 483 484 for (auto split : splitResults) { 523 for (auto& codec : codecs) { 485 524 #if ENABLE(VP9) 486 if ( split.startsWith("vp09") || split.startsWith("vp08") || equal(split, "vp8") || equal(split, "vp9")) {525 if (codec.startsWith("vp09") || codec.startsWith("vp08") || equal(codec, "vp8") || equal(codec, "vp9")) { 487 526 488 527 if (!isVP9DecoderAvailable()) 489 528 return MediaPlayerEnums::SupportsType::IsNotSupported; 490 529 491 auto codecParameters = parseVPCodecParameters( split);530 auto codecParameters = parseVPCodecParameters(codec); 492 531 if (!codecParameters) 493 532 return MediaPlayerEnums::SupportsType::IsNotSupported; … … 501 540 502 541 #if ENABLE(VORBIS) 503 if ( split== "vorbis") {542 if (codec == "vorbis") { 504 543 if (!isVorbisDecoderAvailable()) 505 544 return MediaPlayerEnums::SupportsType::IsNotSupported; … … 510 549 511 550 #if ENABLE(OPUS) 512 if ( split== "opus") {551 if (codec == "opus") { 513 552 if (!isOpusDecoderAvailable()) 514 553 return MediaPlayerEnums::SupportsType::IsNotSupported; -
trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h
r271038 r271194 61 61 class StreamingVectorReader; 62 62 63 static bool isWebMFormatReaderAvailable(); 63 64 static MediaPlayerEnums::SupportsType isContentTypeSupported(const ContentType&); 65 static const HashSet<String, ASCIICaseInsensitiveHash>& webmMIMETypes(); 64 66 static RefPtr<SourceBufferParserWebM> create(const ContentType&); 65 67 -
trunk/Source/WebCore/platform/graphics/cocoa/VideoTrackPrivateWebM.cpp
r270841 r271194 59 59 } 60 60 61 Optional<bool> VideoTrackPrivateWebM::defaultEnabled() const 62 { 63 if (m_track.is_enabled.is_present()) 64 return m_track.is_enabled.value(); 65 return WTF::nullopt; 66 } 67 61 68 AtomString VideoTrackPrivateWebM::label() const 62 69 { -
trunk/Source/WebCore/platform/graphics/cocoa/VideoTrackPrivateWebM.h
r270841 r271194 43 43 int trackIndex() const final; 44 44 Optional<uint64_t> trackUID() const final; 45 Optional<bool> defaultEnabled() const final; 45 46 46 47 private: -
trunk/Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm
r270722 r271194 32 32 #import "Logging.h" 33 33 #import "MediaUtilities.h" 34 #import " RuntimeEnabledFeatures.h"34 #import "PlatformMediaSessionManager.h" 35 35 #import <AudioToolbox/AudioComponent.h> 36 36 #import <AudioToolbox/AudioFormat.h> … … 178 178 179 179 #if ENABLE(VORBIS) && PLATFORM(MAC) 180 if (! RuntimeEnabledFeatures::sharedFeatures().vorbisDecoderEnabled())180 if (!PlatformMediaSessionManager::vorbisDecoderEnabled()) 181 181 return false; 182 182 -
trunk/Source/WebKit/ChangeLog
r271193 r271194 1 2021-01-05 Eric Carlson <eric.carlson@apple.com> 2 3 [Cocoa] WebM format reader doesn't work with a url in a <source> element 4 https://bugs.webkit.org/show_bug.cgi?id=219961 5 <rdar://problem/72399014> 6 7 Reviewed by Andy Estes. 8 9 Only enable a WebM track when the it has FlagEnabled element, or when we see that 10 it has media samples. This is necessary because there are WebM files with empty tracks, 11 and CoreMedia won't play a file if any enabled track doesn't have samples. 12 13 * Shared/mac/MediaFormatReader/FormatReader.cpp: 14 (WebKit::FormatReader::didParseTracks): 15 * Shared/mac/MediaFormatReader/TrackReader.cpp: 16 (WebKit::TrackReader::create): 17 (WebKit::TrackReader::TrackReader): 18 (WebKit::TrackReader::finishParsing): 19 (WebKit::TrackReader::isEnabled const): 20 (WebKit::TrackReader::copyProperty): 21 * Shared/mac/MediaFormatReader/TrackReader.h: 22 * WebProcess/WebPage/WebPage.cpp: 23 (WebKit::WebPage::updatePreferences): 24 * WebProcess/cocoa/WebProcessCocoa.mm: 25 (WebKit::WebProcess::platformInitializeWebProcess): 26 1 27 2021-01-05 Wenson Hsieh <wenson_hsieh@apple.com> 2 28 -
trunk/Source/WebKit/Shared/mac/MediaFormatReader/FormatReader.cpp
r270841 r271194 145 145 146 146 for (auto& videoTrack : segment.videoTracks) { 147 if (auto trackReader = TrackReader::create(allocator(), *this, videoTrack.track.get())) 147 auto track = videoTrack.track.get(); 148 auto trackReader = TrackReader::create(allocator(), *this, kCMMediaType_Video, *track->trackUID(), track->defaultEnabled()); 149 if (!trackReader) 150 continue; 151 152 m_trackReaders.append(trackReader.releaseNonNull()); 153 } 154 155 for (auto& audioTrack : segment.audioTracks) { 156 auto track = audioTrack.track.get(); 157 auto trackReader = TrackReader::create(allocator(), *this, kCMMediaType_Audio, *track->trackUID(), track->defaultEnabled()); 158 if (!trackReader) 159 continue; 160 161 m_trackReaders.append(trackReader.releaseNonNull()); 162 } 163 164 for (auto& textTrack : segment.textTracks) { 165 auto track = textTrack.track.get(); 166 if (auto trackReader = TrackReader::create(allocator(), *this, kCMMediaType_Text, *track->trackUID(), track->defaultEnabled())) 148 167 m_trackReaders.append(trackReader.releaseNonNull()); 149 // FIXME: How do we know which tracks should be enabled? 150 if (m_trackReaders.size() == 1) 151 m_trackReaders[0]->setEnabled(true); 152 } 153 154 for (auto& audioTrack : segment.audioTracks) { 155 if (auto trackReader = TrackReader::create(allocator(), *this, audioTrack.track.get())) 156 m_trackReaders.append(trackReader.releaseNonNull()); 157 // FIXME: How do we know which tracks should be enabled? 158 if (m_trackReaders.size() == segment.videoTracks.size() + 1) 159 m_trackReaders[segment.videoTracks.size()]->setEnabled(true); 160 } 161 162 for (auto& textTrack : segment.textTracks) { 163 if (auto trackReader = TrackReader::create(allocator(), *this, textTrack.track.get())) 164 m_trackReaders.append(trackReader.releaseNonNull()); 165 } 166 168 } 169 167 170 m_parseTracksCondition.notifyAll(); 168 171 } -
trunk/Source/WebKit/Shared/mac/MediaFormatReader/TrackReader.cpp
r270876 r271194 145 145 } 146 146 147 RefPtr<TrackReader> TrackReader::create(Allocator&& allocator, const FormatReader& formatReader, const VideoTrackPrivate* track) 148 { 149 if (!track) 150 return nullptr; 151 return adoptRef(new (allocator) TrackReader(WTFMove(allocator), formatReader, kCMMediaType_Video, *track->trackUID())); 152 } 153 154 RefPtr<TrackReader> TrackReader::create(Allocator&& allocator, const FormatReader& formatReader, const AudioTrackPrivate* track) 155 { 156 if (!track) 157 return nullptr; 158 return adoptRef(new (allocator) TrackReader(WTFMove(allocator), formatReader, kCMMediaType_Audio, *track->trackUID())); 159 } 160 161 RefPtr<TrackReader> TrackReader::create(Allocator&& allocator, const FormatReader& formatReader, const InbandTextTrackPrivate* track) 162 { 163 if (!track) 164 return nullptr; 165 return adoptRef(new (allocator) TrackReader(WTFMove(allocator), formatReader, kCMMediaType_Text, *track->trackUID())); 147 RefPtr<TrackReader> TrackReader::create(Allocator&& allocator, const FormatReader& formatReader, CMMediaType mediaType, uint64_t trackID, Optional<bool> enabled) 148 { 149 return adoptRef(new (allocator) TrackReader(WTFMove(allocator), formatReader, mediaType, trackID, enabled)); 166 150 } 167 151 … … 172 156 } 173 157 174 TrackReader::TrackReader(Allocator&& allocator, const FormatReader& formatReader, CMMediaType mediaType, uint64_t trackID )158 TrackReader::TrackReader(Allocator&& allocator, const FormatReader& formatReader, CMMediaType mediaType, uint64_t trackID, Optional<bool> enabled) 175 159 : CoreMediaWrapped(WTFMove(allocator)) 176 160 , m_trackID(trackID) … … 179 163 { 180 164 ASSERT(!isMainThread()); 165 166 if (enabled) 167 m_isEnabled = enabled.value() ? Enabled::True : Enabled::False; 181 168 } 182 169 … … 217 204 m_sampleStorage = makeUnique<SampleStorage>(); 218 205 m_sampleStorage->hasAllSamples = true; 206 if (m_isEnabled == Enabled::Unknown) 207 m_isEnabled = m_sampleStorage->sampleMap.empty() ? Enabled::False : Enabled::True; 219 208 m_sampleStorageCondition.notifyAll(); 220 209 } … … 222 211 OSStatus TrackReader::copyProperty(CFStringRef key, CFAllocatorRef allocator, void* copiedValue) 223 212 { 224 if (CFEqual(key, PAL::get_MediaToolbox_kMTPluginTrackReaderProperty_Enabled())) { 225 *reinterpret_cast<CFBooleanRef*>(copiedValue) = retainPtr(m_isEnabled ? kCFBooleanTrue : kCFBooleanFalse).leakRef(); 213 // Don't block waiting for media if the we know the enabled state. 214 if (CFEqual(key, PAL::get_MediaToolbox_kMTPluginTrackReaderProperty_Enabled()) && m_isEnabled != Enabled::Unknown) { 215 *reinterpret_cast<CFBooleanRef*>(copiedValue) = retainPtr(m_isEnabled == Enabled::True ? kCFBooleanTrue : kCFBooleanFalse).leakRef(); 226 216 return noErr; 227 217 } … … 233 223 234 224 auto& sampleMap = m_sampleStorage->sampleMap; 225 226 if (CFEqual(key, PAL::get_MediaToolbox_kMTPluginTrackReaderProperty_Enabled())) { 227 if (m_isEnabled == Enabled::Unknown) 228 m_isEnabled = sampleMap.empty() ? Enabled::False : Enabled::True; 229 230 *reinterpret_cast<CFBooleanRef*>(copiedValue) = retainPtr(m_isEnabled == Enabled::True ? kCFBooleanTrue : kCFBooleanFalse).leakRef(); 231 return noErr; 232 } 233 235 234 if (sampleMap.empty()) 236 235 return kCMBaseObjectError_ValueNotAvailable; -
trunk/Source/WebKit/Shared/mac/MediaFormatReader/TrackReader.h
r270841 r271194 55 55 static CMBaseClassID wrapperClassID(); 56 56 static CoreMediaWrapped<TrackReader>* unwrap(CMBaseObjectRef); 57 static WTF::WorkQueue& storageQueue(); 57 58 58 static RefPtr<TrackReader> create(Allocator&&, const FormatReader&, const WebCore::VideoTrackPrivate*); 59 static RefPtr<TrackReader> create(Allocator&&, const FormatReader&, const WebCore::AudioTrackPrivate*); 60 static RefPtr<TrackReader> create(Allocator&&, const FormatReader&, const WebCore::InbandTextTrackPrivate*); 61 62 static WTF::WorkQueue& storageQueue(); 59 static RefPtr<TrackReader> create(Allocator&&, const FormatReader&, CMMediaType, uint64_t, Optional<bool>); 63 60 64 61 uint64_t trackID() const { return m_trackID; } … … 66 63 void waitForSample(Function<bool(WebCore::SampleMap&, bool)>&&) const; 67 64 68 bool isEnabled() const { return m_isEnabled; }69 void setEnabled(bool enabled) { m_isEnabled = enabled; }65 void setEnabled(bool enabled) { m_isEnabled = enabled ? Enabled::True : Enabled::False; } 66 CMMediaType mediaType() const { return m_mediaType; } 70 67 71 68 void finishParsing(); … … 74 71 using CoreMediaWrapped<TrackReader>::unwrap; 75 72 76 TrackReader(Allocator&&, const FormatReader&, CMMediaType, uint64_t );73 TrackReader(Allocator&&, const FormatReader&, CMMediaType, uint64_t, Optional<bool>); 77 74 78 75 // CMBaseClass … … 94 91 }; 95 92 93 enum Enabled : uint8_t { Unknown, False, True }; 94 96 95 const uint64_t m_trackID; 97 96 const CMMediaType m_mediaType; 98 97 const MediaTime m_duration; 99 std::atomic< bool> m_isEnabled { false};98 std::atomic<Enabled> m_isEnabled { Enabled::Unknown }; 100 99 mutable Condition m_sampleStorageCondition; 101 100 mutable Lock m_sampleStorageLock; -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r271171 r271194 3839 3839 } 3840 3840 #endif 3841 3842 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER) 3843 PlatformMediaSessionManager::setWebMFormatReaderEnabled(RuntimeEnabledFeatures::sharedFeatures().webMFormatReaderEnabled()); 3844 #endif 3845 3846 #if ENABLE(VORBIS) && PLATFORM(MAC) 3847 PlatformMediaSessionManager::setVorbisDecoderEnabled(RuntimeEnabledFeatures::sharedFeatures().vorbisDecoderEnabled()); 3848 #endif 3841 3849 } 3842 3850 -
trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
r271190 r271194 69 69 #import <WebCore/PerformanceLogging.h> 70 70 #import <WebCore/PictureInPictureSupport.h> 71 #import <WebCore/PlatformMediaSessionManager.h> 71 72 #import <WebCore/RuntimeApplicationChecks.h> 73 #import <WebCore/RuntimeEnabledFeatures.h> 72 74 #import <WebCore/SWContextManager.h> 73 75 #import <WebCore/SystemBattery.h> … … 329 331 #endif 330 332 333 #if ENABLE(MEDIA_SOURCE) && HAVE(MT_PLUGIN_FORMAT_READER) 334 PlatformMediaSessionManager::setWebMFormatReaderEnabled(RuntimeEnabledFeatures::sharedFeatures().webMFormatReaderEnabled()); 335 #endif 336 337 #if ENABLE(VORBIS) && PLATFORM(MAC) 338 PlatformMediaSessionManager::setVorbisDecoderEnabled(RuntimeEnabledFeatures::sharedFeatures().vorbisDecoderEnabled()); 339 #endif 340 331 341 if (!parameters.mediaMIMETypes.isEmpty()) 332 342 setMediaMIMETypes(parameters.mediaMIMETypes);
Note:
See TracChangeset
for help on using the changeset viewer.