Title: [186945] branches/safari-601.1-branch/Source/WebCore

Diff

Modified: branches/safari-601.1-branch/Source/WebCore/AVFoundationSupport.py (186944 => 186945)


--- branches/safari-601.1-branch/Source/WebCore/AVFoundationSupport.py	2015-07-17 05:33:22 UTC (rev 186944)
+++ branches/safari-601.1-branch/Source/WebCore/AVFoundationSupport.py	2015-07-17 06:15:19 UTC (rev 186945)
@@ -57,3 +57,7 @@
     regexp = re.compile("CACFLayerSetContentsScale")
     if fileContains("/include/QuartzCore/CACFLayer.h", regexp):
         print "#define HAVE_CACFLAYER_SETCONTENTSSCALE 1"
+if lookFor("/include/AVFoundationCF/AVCFPlayerItemLegibleOutput.h"):
+    regexp = re.compile("kAVCFPlayerItemLegibleOutput_CallbacksVersion_2")
+    if fileContains("/include/AVFoundationCF/AVCFPlayerItemLegibleOutput.h", regexp):
+        print "#define HAVE_AVCFPLAYERITEM_CALLBACK_VERSION_2 1"

Modified: branches/safari-601.1-branch/Source/WebCore/ChangeLog (186944 => 186945)


--- branches/safari-601.1-branch/Source/WebCore/ChangeLog	2015-07-17 05:33:22 UTC (rev 186944)
+++ branches/safari-601.1-branch/Source/WebCore/ChangeLog	2015-07-17 06:15:19 UTC (rev 186945)
@@ -1,5 +1,36 @@
 2015-07-16  Matthew Hanson  <[email protected]>
 
+        Merge r186798. rdar://problem/20542574
+
+    2015-07-13  Brent Fulgham  <[email protected]>
+
+            [Win] Update Media Player logic for new Legible Output API
+            https://bugs.webkit.org/show_bug.cgi?id=146922
+            <rdar://problem/20542574>
+
+            Reviewed by Eric Carlson.
+
+            * AVFoundationSupport.py: Check for updated AVFCF feature.
+            * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+            (WebCore::InbandTextTrackPrivateAVF::processNativeSamples): Update to call the
+            new 'readNativeSampleBuffer' method.
+            (WebCore::InbandTextTrackPrivateAVF::readNativeSampleBuffer): Added. This is a no-op
+            on Windows if it has the new AVCF API. Otherwise, it contains the same implementation
+            that has always been used in 'processNativeSamples'.
+            * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h:
+            * platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp:
+            (WebCore::InbandTextTrackPrivateAVCF::readNativeSampleBuffer): Added. Use the new
+            Legible Output API instead of the old CoreMedia solution if it is available.
+            * platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h:
+            (WebCore::InbandTextTrackPrivateAVCF::mediaSelectionOption):
+            * platform/graphics/avfoundation/cf/InbandTextTrackPrivateLegacyAVCF.cpp:
+            (WebCore::InbandTextTrackPrivateLegacyAVCF::readNativeSampleBuffer): Add a stub implementation.
+            * platform/graphics/avfoundation/cf/InbandTextTrackPrivateLegacyAVCF.h:
+            * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+            (WebCore::AVFWrapper::createPlayerItem): Use the new Legible Output API if it is available.
+
+2015-07-16  Matthew Hanson  <[email protected]>
+
         Merge r186911. rdar://problem/21822541
 
     2015-07-16  Simon Fraser  <[email protected]>

Modified: branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp (186944 => 186945)


--- branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp	2015-07-17 05:33:22 UTC (rev 186944)
+++ branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp	2015-07-17 06:15:19 UTC (rev 186945)
@@ -489,30 +489,12 @@
     LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples - %li sample buffers at time %.2f\n", count, presentationTime.toDouble());
 
     for (CFIndex i = 0; i < count; i++) {
-
-        CMSampleBufferRef sampleBuffer = (CMSampleBufferRef)CFArrayGetValueAtIndex(nativeSamples, i);
-        if (!sampleBuffer)
+        RefPtr<ArrayBuffer> buffer;
+        MediaTime duration;
+        CMFormatDescriptionRef formatDescription;
+        if (!readNativeSampleBuffer(nativeSamples, i, buffer, duration, formatDescription))
             continue;
 
-        CMSampleTimingInfo timingInfo;
-        OSStatus status = CMSampleBufferGetSampleTimingInfo(sampleBuffer, i, &timingInfo);
-        if (status) {
-            LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - CMSampleBufferGetSampleTimingInfo returned error %x for sample %li", this, static_cast<int>(status), i);
-            continue;
-        }
-
-        CMBlockBufferRef blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer);
-        size_t bufferLength = CMBlockBufferGetDataLength(blockBuffer);
-        if (bufferLength < ISOBox::boxHeaderSize()) {
-            LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - ERROR: CMSampleBuffer size length unexpectedly small (%zu)!!", this, bufferLength);
-            continue;
-        }
-
-        m_sampleInputBuffer.resize(m_sampleInputBuffer.size() + bufferLength);
-        CMBlockBufferCopyDataBytes(blockBuffer, 0, bufferLength, m_sampleInputBuffer.data() + m_sampleInputBuffer.size() - bufferLength);
-
-        RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(m_sampleInputBuffer.data(), m_sampleInputBuffer.size());
-
         String type = ISOBox::peekType(buffer.get());
         size_t boxLength = ISOBox::peekLength(buffer.get());
         if (boxLength > buffer->byteLength()) {
@@ -523,7 +505,7 @@
         LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - chunk type = '%s', size = %zu", this, type.utf8().data(), boxLength);
 
         if (type == ISOWebVTTCue::boxType()) {
-            ISOWebVTTCue cueData = ISOWebVTTCue(presentationTime, toMediaTime(timingInfo.duration), buffer.get());
+            ISOWebVTTCue cueData = ISOWebVTTCue(presentationTime, duration, buffer.get());
             LOG(Media, "    sample presentation time = %.2f, duration = %.2f", cueData.presentationTime().toDouble(), cueData.duration().toDouble());
             LOG(Media, "    id = \"%s\", settings = \"%s\", cue text = \"%s\"", cueData.id().utf8().data(), cueData.settings().utf8().data(), cueData.cueText().utf8().data());
             LOG(Media, "    sourceID = \"%s\", originalStartTime = \"%s\"", cueData.sourceID().utf8().data(), cueData.originalStartTime().utf8().data());
@@ -535,7 +517,6 @@
             if (m_haveReportedVTTHeader)
                 break;
 
-            CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer);
             if (!formatDescription)
                 break;
 
@@ -570,6 +551,42 @@
     }
 }
 
+bool InbandTextTrackPrivateAVF::readNativeSampleBuffer(CFArrayRef nativeSamples, CFIndex index, RefPtr<ArrayBuffer>& buffer, MediaTime& duration, CMFormatDescriptionRef& formatDescription)
+{
+#if OS(WINDOWS) && HAVE(AVCFPLAYERITEM_CALLBACK_VERSION_2)
+    return false;
+#else
+    CMSampleBufferRef const sampleBuffer = reinterpret_cast<CMSampleBufferRef>(const_cast<void*>(CFArrayGetValueAtIndex(nativeSamples, index)));
+    if (!sampleBuffer)
+        return false;
+
+    CMSampleTimingInfo timingInfo;
+    OSStatus status = CMSampleBufferGetSampleTimingInfo(sampleBuffer, index, &timingInfo);
+    if (status) {
+        LOG(Media, "InbandTextTrackPrivateAVF::readNativeSampleBuffer(%p) - CMSampleBufferGetSampleTimingInfo returned error %x for sample %li", this, static_cast<int>(status), index);
+        return false;
+    }
+
+    duration = toMediaTime(timingInfo.duration);
+
+    CMBlockBufferRef blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer);
+    size_t bufferLength = CMBlockBufferGetDataLength(blockBuffer);
+    if (bufferLength < ISOBox::boxHeaderSize()) {
+        LOG(Media, "InbandTextTrackPrivateAVF::readNativeSampleBuffer(%p) - ERROR: CMSampleBuffer size length unexpectedly small (%zu)!!", this, bufferLength);
+        return false;
+    }
+
+    m_sampleInputBuffer.resize(m_sampleInputBuffer.size() + bufferLength);
+    CMBlockBufferCopyDataBytes(blockBuffer, 0, bufferLength, m_sampleInputBuffer.data() + m_sampleInputBuffer.size() - bufferLength);
+
+    buffer = ArrayBuffer::create(m_sampleInputBuffer.data(), m_sampleInputBuffer.size());
+
+    formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer);
+
+    return true;
+#endif
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(VIDEO) && (USE(AVFOUNDATION) || PLATFORM(IOS))

Modified: branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h (186944 => 186945)


--- branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h	2015-07-17 05:33:22 UTC (rev 186944)
+++ branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h	2015-07-17 06:15:19 UTC (rev 186945)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,6 +32,12 @@
 #include "InbandTextTrackPrivateClient.h"
 #include <wtf/text/StringBuilder.h>
 
+typedef const struct opaqueCMFormatDescription* CMFormatDescriptionRef;
+
+namespace JSC {
+class ArrayBuffer;
+}
+
 namespace WebCore {
 
 class AVFInbandTrackParent {
@@ -70,6 +76,8 @@
     virtual Category textTrackCategory() const = 0;
     
     virtual MediaTime startTimeVariance() const override { return MediaTime(1, 4); }
+
+    virtual bool readNativeSampleBuffer(CFArrayRef nativeSamples, CFIndex, RefPtr<JSC::ArrayBuffer>&, MediaTime&, CMFormatDescriptionRef&);
     
 protected:
     InbandTextTrackPrivateAVF(AVFInbandTrackParent*, CueFormat);

Modified: branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp (186944 => 186945)


--- branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp	2015-07-17 05:33:22 UTC (rev 186944)
+++ branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp	2015-07-17 06:15:19 UTC (rev 186945)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,10 +30,13 @@
 #include "InbandTextTrackPrivateAVCF.h"
 
 #include "FloatConversion.h"
+#include "ISOVTTCue.h"
 #include "InbandTextTrackPrivate.h"
 #include "InbandTextTrackPrivateAVF.h"
 #include "Logging.h"
+#include "MediaTimeAVFoundation.h"
 #include "SoftLinking.h"
+#include <_javascript_Core/ArrayBuffer.h>
 
 #include <AVFoundationCF/AVCFPlayerItemLegibleOutput.h>
 #include <AVFoundationCF/AVFoundationCF.h>
@@ -184,6 +187,29 @@
     return false;
 }
 
+bool InbandTextTrackPrivateAVCF::readNativeSampleBuffer(CFArrayRef nativeSamples, CFIndex index, RefPtr<ArrayBuffer>& buffer, MediaTime& duration, CMFormatDescriptionRef& formatDescription)
+{
+    const AVCFPlayerItemLegibleOutputSample* sampleBuffer = reinterpret_cast<const AVCFPlayerItemLegibleOutputSample*>(CFArrayGetValueAtIndex(nativeSamples, index));
+    if (!sampleBuffer)
+        return false;
+
+    duration = toMediaTime(sampleBuffer->duration);
+    formatDescription = sampleBuffer->formatDescription;
+
+    size_t bufferLength = CFDataGetLength(sampleBuffer->buffer);
+    if (bufferLength < ISOBox::boxHeaderSize()) {
+        LOG(Media, "InbandTextTrackPrivateLegacyAVCF::readNativeSampleBuffer(%p) - ERROR: CFBuffer size length unexpectedly small (%zu)!!", this, bufferLength);
+        return false;
+    }
+
+    m_sampleInputBuffer.resize(m_sampleInputBuffer.size() + bufferLength);
+    CFDataGetBytes(sampleBuffer->buffer, CFRangeMake(0, bufferLength), reinterpret_cast<UInt8*>(m_sampleInputBuffer.data()) + m_sampleInputBuffer.size() - bufferLength);
+
+    buffer = ArrayBuffer::create(m_sampleInputBuffer.data(), m_sampleInputBuffer.size());
+
+    return true;
+}
+
 } // namespace WebCore
 
 #endif

Modified: branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h (186944 => 186945)


--- branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h	2015-07-17 05:33:22 UTC (rev 186944)
+++ branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h	2015-07-17 06:15:19 UTC (rev 186945)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -55,7 +55,8 @@
 
     virtual void disconnect() override;
 
-    virtual Category textTrackCategory() const override { return InBand; }
+    Category textTrackCategory() const override { return InBand; }
+    bool readNativeSampleBuffer(CFArrayRef nativeSamples, CFIndex, RefPtr<JSC::ArrayBuffer>&, MediaTime&, CMFormatDescriptionRef&) override;
 
     AVCFMediaSelectionOptionRef mediaSelectionOption() const { return m_mediaSelectionOption.get(); }
 

Modified: branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (186944 => 186945)


--- branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2015-07-17 05:33:22 UTC (rev 186944)
+++ branches/safari-601.1-branch/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2015-07-17 06:15:19 UTC (rev 186945)
@@ -1616,7 +1616,11 @@
     AVCFPlayerItemOutputSetSuppressPlayerRendering(m_legibleOutput.get(), TRUE);
 
     AVCFPlayerItemLegibleOutputCallbacks callbackInfo;
+#if HAVE(AVCFPLAYERITEM_CALLBACK_VERSION_2)
+    callbackInfo.version = kAVCFPlayerItemLegibleOutput_CallbacksVersion_2;
+#else
     callbackInfo.version = kAVCFPlayerItemLegibleOutput_CallbacksVersion_1;
+#endif
     ASSERT(callbackContext());
     callbackInfo.context = callbackContext();
     callbackInfo.legibleOutputCallback = AVFWrapper::legibleOutputCallback;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to