- Revision
- 258314
- Author
- [email protected]
- Date
- 2020-03-11 21:57:31 -0700 (Wed, 11 Mar 2020)
Log Message
Adopt AVSampleBufferVideoOutput
https://bugs.webkit.org/show_bug.cgi?id=208951
Reviewed by Eric Carlson.
Source/WebCore:
Adopt AVSampleBufferVideoOutput, used for extracting decoded samples from an AVSampleBufferDisplayLayer.
Rather than use a separate decompression session when we need to, e.g., paint samples into WebGL, we will
add a AVSBVO to the AVSBDL and use it to extract CVPixelBuffers when asked.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateLastPixelBuffer):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isVideoOutputAvailable const):
Source/WebCore/PAL:
* pal/cocoa/AVFoundationSoftLink.h:
* pal/cocoa/AVFoundationSoftLink.mm:
* pal/spi/cocoa/AVFoundationSPI.h:
Source/WTF:
* wtf/PlatformHave.h:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (258313 => 258314)
--- trunk/Source/WTF/ChangeLog 2020-03-12 04:25:11 UTC (rev 258313)
+++ trunk/Source/WTF/ChangeLog 2020-03-12 04:57:31 UTC (rev 258314)
@@ -1,5 +1,14 @@
2020-03-11 Jer Noble <[email protected]>
+ Adopt AVSampleBufferVideoOutput
+ https://bugs.webkit.org/show_bug.cgi?id=208951
+
+ Reviewed by Eric Carlson.
+
+ * wtf/PlatformHave.h:
+
+2020-03-11 Jer Noble <[email protected]>
+
[EME] Issue an "encrypted" event when a new encrypted initialization segment is encountered
https://bugs.webkit.org/show_bug.cgi?id=208923
Modified: trunk/Source/WTF/wtf/PlatformHave.h (258313 => 258314)
--- trunk/Source/WTF/wtf/PlatformHave.h 2020-03-12 04:25:11 UTC (rev 258313)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2020-03-12 04:57:31 UTC (rev 258314)
@@ -600,6 +600,7 @@
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
#define HAVE_WEBP 1
+#define HAVE_AVSAMPLEBUFFERVIDEOOUTPUT 1
#endif
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600)
Modified: trunk/Source/WebCore/ChangeLog (258313 => 258314)
--- trunk/Source/WebCore/ChangeLog 2020-03-12 04:25:11 UTC (rev 258313)
+++ trunk/Source/WebCore/ChangeLog 2020-03-12 04:57:31 UTC (rev 258314)
@@ -1,3 +1,22 @@
+2020-03-11 Jer Noble <[email protected]>
+
+ Adopt AVSampleBufferVideoOutput
+ https://bugs.webkit.org/show_bug.cgi?id=208951
+
+ Reviewed by Eric Carlson.
+
+ Adopt AVSampleBufferVideoOutput, used for extracting decoded samples from an AVSampleBufferDisplayLayer.
+
+ Rather than use a separate decompression session when we need to, e.g., paint samples into WebGL, we will
+ add a AVSBVO to the AVSBDL and use it to extract CVPixelBuffers when asked.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateLastPixelBuffer):
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged):
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isVideoOutputAvailable const):
+
2020-03-11 Andres Gonzalez <[email protected]>
Removed unused textElements member from AccessibilityText structure.
Modified: trunk/Source/WebCore/PAL/ChangeLog (258313 => 258314)
--- trunk/Source/WebCore/PAL/ChangeLog 2020-03-12 04:25:11 UTC (rev 258313)
+++ trunk/Source/WebCore/PAL/ChangeLog 2020-03-12 04:57:31 UTC (rev 258314)
@@ -1,5 +1,16 @@
2020-03-11 Jer Noble <[email protected]>
+ Adopt AVSampleBufferVideoOutput
+ https://bugs.webkit.org/show_bug.cgi?id=208951
+
+ Reviewed by Eric Carlson.
+
+ * pal/cocoa/AVFoundationSoftLink.h:
+ * pal/cocoa/AVFoundationSoftLink.mm:
+ * pal/spi/cocoa/AVFoundationSPI.h:
+
+2020-03-11 Jer Noble <[email protected]>
+
[EME] Issue an "encrypted" event when a new encrypted initialization segment is encountered
https://bugs.webkit.org/show_bug.cgi?id=208923
Modified: trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h (258313 => 258314)
--- trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h 2020-03-12 04:25:11 UTC (rev 258313)
+++ trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h 2020-03-12 04:57:31 UTC (rev 258314)
@@ -62,6 +62,7 @@
SOFT_LINK_CLASS_FOR_HEADER(PAL, AVSampleBufferAudioRenderer)
SOFT_LINK_CLASS_FOR_HEADER(PAL, AVSampleBufferDisplayLayer)
SOFT_LINK_CLASS_FOR_HEADER(PAL, AVSampleBufferRenderSynchronizer)
+SOFT_LINK_CLASS_FOR_HEADER(PAL, AVSampleBufferVideoOutput)
SOFT_LINK_CLASS_FOR_HEADER(PAL, AVStreamDataParser)
SOFT_LINK_CLASS_FOR_HEADER(PAL, AVURLAsset)
Modified: trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm (258313 => 258314)
--- trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm 2020-03-12 04:25:11 UTC (rev 258313)
+++ trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm 2020-03-12 04:57:31 UTC (rev 258314)
@@ -89,6 +89,7 @@
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, AVFoundation, AVSampleBufferAudioRenderer, PAL_EXPORT)
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, AVFoundation, AVSampleBufferDisplayLayer, PAL_EXPORT)
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, AVFoundation, AVSampleBufferRenderSynchronizer, PAL_EXPORT)
+SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, AVFoundation, AVSampleBufferVideoOutput, PAL_EXPORT)
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, AVFoundation, AVStreamDataParser, PAL_EXPORT)
#if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h (258313 => 258314)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h 2020-03-12 04:25:11 UTC (rev 258313)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h 2020-03-12 04:57:31 UTC (rev 258314)
@@ -355,3 +355,17 @@
@end
#endif
+
+#if HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
+#if USE(APPLE_INTERNAL_SDK)
+#include <AVFoundation/AVSampleBufferVideoOutput.h>
+#else
+@interface AVSampleBufferVideoOutput : NSObject
+- (CVPixelBufferRef)copyPixelBufferForSourceTime:(CMTime)sourceTime sourceTimeForDisplay:(nullable CMTime *)outSourceTimeForDisplay;
+@end
+
+@interface AVSampleBufferDisplayLayer (VideoOutput)
+@property (nonatomic, nullable) AVSampleBufferVideoOutput *output;
+@end
+#endif
+#endif
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (258313 => 258314)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2020-03-12 04:25:11 UTC (rev 258313)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2020-03-12 04:57:31 UTC (rev 258314)
@@ -41,6 +41,7 @@
OBJC_CLASS AVSampleBufferAudioRenderer;
OBJC_CLASS AVSampleBufferDisplayLayer;
OBJC_CLASS AVSampleBufferRenderSynchronizer;
+OBJC_CLASS AVSampleBufferVideoOutput;
OBJC_CLASS AVStreamSession;
typedef struct OpaqueCMTimebase* CMTimebaseRef;
@@ -261,6 +262,8 @@
bool shouldBePlaying() const;
+ bool isVideoOutputAvailable() const;
+
friend class MediaSourcePrivateAVFObjC;
struct PendingSeek {
@@ -282,6 +285,9 @@
RefPtr<MediaSourcePrivateAVFObjC> m_mediaSourcePrivate;
RetainPtr<AVAsset> m_asset;
RetainPtr<AVSampleBufferDisplayLayer> m_sampleBufferDisplayLayer;
+#if HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
+ RetainPtr<AVSampleBufferVideoOutput> m_videoOutput;
+#endif
struct AudioRendererProperties {
bool hasAudibleSample { false };
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (258313 => 258314)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2020-03-12 04:25:11 UTC (rev 258313)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2020-03-12 04:57:31 UTC (rev 258314)
@@ -585,6 +585,17 @@
bool MediaPlayerPrivateMediaSourceAVFObjC::updateLastPixelBuffer()
{
+#if HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
+ if (m_videoOutput) {
+ CMTime outputTime;
+ if (auto pixelBuffer = [m_videoOutput copyPixelBufferForSourceTime:toCMTime(currentMediaTime()) sourceTimeForDisplay:&outputTime]) {
+ INFO_LOG(LOGIDENTIFIER, "new pixelbuffer found for time ", toMediaTime(outputTime));
+ m_lastPixelBuffer = WTFMove(pixelBuffer);
+ return true;
+ }
+ }
+#endif
+
if (m_sampleBufferDisplayLayer || !m_decompressionSession)
return false;
@@ -670,7 +681,7 @@
void MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged()
{
- if (!m_hasBeenAskedToPaintGL) {
+ if (!m_hasBeenAskedToPaintGL || isVideoOutputAvailable()) {
destroyDecompressionSession();
ensureLayer();
} else {
@@ -755,6 +766,15 @@
[m_sampleBufferDisplayLayer setName:@"MediaPlayerPrivateMediaSource AVSampleBufferDisplayLayer"];
#endif
+#if HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
+ ASSERT(!m_videoOutput);
+ if (isVideoOutputAvailable()) {
+ m_videoOutput = adoptNS([PAL::allocAVSampleBufferVideoOutputInstance() init]);
+ ASSERT(m_videoOutput);
+ [m_sampleBufferDisplayLayer setOutput:m_videoOutput.get()];
+ }
+#endif
+
ASSERT(m_sampleBufferDisplayLayer);
if (!m_sampleBufferDisplayLayer) {
ERROR_LOG(LOGIDENTIFIER, "Failed to create AVSampleBufferDisplayLayer");
@@ -822,6 +842,15 @@
return m_playing && !seeking() && allRenderersHaveAvailableSamples() && m_readyState >= MediaPlayer::ReadyState::HaveFutureData;
}
+bool MediaPlayerPrivateMediaSourceAVFObjC::isVideoOutputAvailable() const
+{
+#if HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
+ return PAL::getAVSampleBufferVideoOutputClass;
+#else
+ return false;
+#endif
+}
+
void MediaPlayerPrivateMediaSourceAVFObjC::setHasAvailableVideoFrame(bool flag)
{
if (m_hasAvailableVideoFrame == flag)