Title: [270722] trunk/Source
Revision
270722
Author
[email protected]
Date
2020-12-11 17:18:17 -0800 (Fri, 11 Dec 2020)

Log Message

[Cocoa] Add Experimental Vorbis support
https://bugs.webkit.org/show_bug.cgi?id=219810
<rdar://problem/72242614>

Patch by Eric Carlson <[email protected]> on 2020-12-11
Reviewed by Jer Noble.

Source/WebCore:

* page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setVorbisDecoderEnabled):
(WebCore::RuntimeEnabledFeatures::vorbisDecoderEnabled const):

* platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::AudioTrackData::consumeFrameData): Support being
called with more than one sample.

* platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm:
(WebCore::isVorbisDecoderAvailable): Check the runtime settings.

Source/WTF:

* Scripts/Preferences/WebPreferencesExperimental.yaml: Added an experimental web
preference.
* wtf/PlatformEnableCocoa.h: Define ENABLE_VORBIS.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (270721 => 270722)


--- trunk/Source/WTF/ChangeLog	2020-12-12 00:58:40 UTC (rev 270721)
+++ trunk/Source/WTF/ChangeLog	2020-12-12 01:18:17 UTC (rev 270722)
@@ -1,3 +1,15 @@
+2020-12-11  Eric Carlson  <[email protected]>
+
+        [Cocoa] Add Experimental Vorbis support
+        https://bugs.webkit.org/show_bug.cgi?id=219810
+        <rdar://problem/72242614>
+
+        Reviewed by Jer Noble.
+
+        * Scripts/Preferences/WebPreferencesExperimental.yaml: Added an experimental web
+        preference.
+        * wtf/PlatformEnableCocoa.h: Define ENABLE_VORBIS.
+
 2020-12-11  Jer Noble  <[email protected]>
 
         [Cocoa] Add Experimental VP8 support

Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (270721 => 270722)


--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml	2020-12-12 00:58:40 UTC (rev 270721)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml	2020-12-12 01:18:17 UTC (rev 270722)
@@ -902,6 +902,18 @@
     WebCore:
       default: false
 
+VorbisDecoderEnabled:
+  type: bool
+  humanReadableName: "Vorbis audio decoder"
+  humanReadableDescription: "Enable Vorbis audio decoder"
+  condition: ENABLE(VORBIS)
+  webcoreBinding: RuntimeEnabledFeatures
+  defaultValue:
+    WebKitLegacy:
+      default: true
+    WebKit:
+      default: true
+
 # FIXME: This is enabled when ENABLE(EXPERIMENTAL_FEATURES) is true in WebKit2. Perhaps we should consider using that for WebKitLegacy as well.
 WebAnimationsCompositeOperationsEnabled:
   type: bool

Modified: trunk/Source/WTF/wtf/PlatformEnableCocoa.h (270721 => 270722)


--- trunk/Source/WTF/wtf/PlatformEnableCocoa.h	2020-12-12 00:58:40 UTC (rev 270721)
+++ trunk/Source/WTF/wtf/PlatformEnableCocoa.h	2020-12-12 01:18:17 UTC (rev 270722)
@@ -630,6 +630,10 @@
 #define ENABLE_WKPDFVIEW 1
 #endif
 
+#if !defined(ENABLE_VORBIS) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 110300
+#define ENABLE_VORBIS 1
+#endif
+
 #if !defined(ENABLE_SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 120000
 #define ENABLE_SET_WEBCONTENT_PROCESS_INFORMATION_IN_NETWORK_PROCESS 1
 #endif

Modified: trunk/Source/WebCore/ChangeLog (270721 => 270722)


--- trunk/Source/WebCore/ChangeLog	2020-12-12 00:58:40 UTC (rev 270721)
+++ trunk/Source/WebCore/ChangeLog	2020-12-12 01:18:17 UTC (rev 270722)
@@ -1,3 +1,22 @@
+2020-12-11  Eric Carlson  <[email protected]>
+
+        [Cocoa] Add Experimental Vorbis support
+        https://bugs.webkit.org/show_bug.cgi?id=219810
+        <rdar://problem/72242614>
+
+        Reviewed by Jer Noble.
+
+        * page/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setVorbisDecoderEnabled):
+        (WebCore::RuntimeEnabledFeatures::vorbisDecoderEnabled const):
+
+        * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
+        (WebCore::SourceBufferParserWebM::AudioTrackData::consumeFrameData): Support being
+        called with more than one sample.
+
+        * platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm:
+        (WebCore::isVorbisDecoderAvailable): Check the runtime settings.
+
 2020-12-11  Jer Noble  <[email protected]>
 
         [Cocoa] Add Experimental VP8 support

Modified: trunk/Source/WebCore/page/RuntimeEnabledFeatures.h (270721 => 270722)


--- trunk/Source/WebCore/page/RuntimeEnabledFeatures.h	2020-12-12 00:58:40 UTC (rev 270721)
+++ trunk/Source/WebCore/page/RuntimeEnabledFeatures.h	2020-12-12 01:18:17 UTC (rev 270722)
@@ -255,6 +255,11 @@
     bool disableMediaExperiencePIDInheritance() const { return m_disableMediaExperiencePIDInheritance; }
 #endif
 
+#if ENABLE(VORBIS)
+    void setVorbisDecoderEnabled(bool isEnabled) { m_vorbisDecoderEnabled = isEnabled; }
+    bool vorbisDecoderEnabled() const { return m_vorbisDecoderEnabled; }
+#endif
+
 #if ENABLE(WEB_AUTHN)
     void setWebAuthenticationModernEnabled(bool areEnabled) { m_areWebAuthenticationModernEnabled = areEnabled; }
     bool webAuthenticationModernEnabled() const { return m_areWebAuthenticationModernEnabled; }
@@ -390,6 +395,10 @@
     bool m_disableMediaExperiencePIDInheritance { false };
 #endif
 
+#if ENABLE(VORBIS)
+    bool m_vorbisDecoderEnabled { false };
+#endif
+
 #if ENABLE(WEB_AUTHN)
     bool m_areWebAuthenticationModernEnabled { false };
 #endif

Modified: trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp (270721 => 270722)


--- trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp	2020-12-12 00:58:40 UTC (rev 270721)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp	2020-12-12 01:18:17 UTC (rev 270722)
@@ -1085,7 +1085,7 @@
 
 webm::Status SourceBufferParserWebM::AudioTrackData::consumeFrameData(webm::Reader& reader, const FrameMetadata& metadata, uint64_t* bytesRemaining, const CMTime& presentationTime, int sampleCount)
 {
-    ASSERT_UNUSED(sampleCount, sampleCount == 1);
+    ASSERT(sampleCount);
 
     if (!formatDescription()) {
         if (!track().codec_private.is_present()) {
@@ -1115,13 +1115,13 @@
         setFormatDescription(WTFMove(formatDescription));
     }
 
-    if (m_packetData.isEmpty()) {
-        m_packetData.resize(metadata.size);
+    if (m_packetDescriptions.isEmpty()) {
         m_packetBytesRead = 0;
         m_byteOffset = metadata.position;
         m_samplePresentationTime = presentationTime;
     }
 
+    m_packetData.resize(m_packetBytesRead + metadata.size);
     size_t packetDataOffset = m_packetBytesRead;
     size_t bytesToRead = metadata.size;
     while (bytesToRead) {
@@ -1137,7 +1137,7 @@
     }
 
     m_packetDescriptions.append({ static_cast<int64_t>(packetDataOffset), 0, static_cast<UInt32>(metadata.size) });
-    auto sampleDuration = CMTimeGetSeconds(CMTimeSubtract(presentationTime, m_samplePresentationTime)) + CMTimeGetSeconds(m_packetDuration);
+    auto sampleDuration = CMTimeGetSeconds(CMTimeSubtract(presentationTime, m_samplePresentationTime)) + CMTimeGetSeconds(m_packetDuration) * sampleCount;
     if (sampleDuration >= m_minimumSampleDuration)
         createSampleBuffer();
 

Modified: trunk/Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm (270721 => 270722)


--- trunk/Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm	2020-12-12 00:58:40 UTC (rev 270721)
+++ trunk/Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm	2020-12-12 01:18:17 UTC (rev 270722)
@@ -31,6 +31,7 @@
 #import "CAAudioStreamDescription.h"
 #import "Logging.h"
 #import "MediaUtilities.h"
+#import "RuntimeEnabledFeatures.h"
 #import <AudioToolbox/AudioComponent.h>
 #import <AudioToolbox/AudioFormat.h>
 #import <CoreMedia/CMFormatDescription.h>
@@ -176,6 +177,9 @@
     static bool available;
 
 #if ENABLE(VORBIS) && PLATFORM(MAC)
+    if (!RuntimeEnabledFeatures::sharedFeatures().vorbisDecoderEnabled())
+        return false;
+
     static dispatch_once_t onceToken;
     dispatch_once(&onceToken, ^{
         available = registerDecoderFactory("ACVorbisDecoderFactory", 'vorb');
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to