Changeset 258314 in webkit


Ignore:
Timestamp:
Mar 11, 2020 9:57:31 PM (4 years ago)
Author:
jer.noble@apple.com
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:
Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r258295 r258314  
     12020-03-11  Jer Noble  <jer.noble@apple.com>
     2
     3        Adopt AVSampleBufferVideoOutput
     4        https://bugs.webkit.org/show_bug.cgi?id=208951
     5
     6        Reviewed by Eric Carlson.
     7
     8        * wtf/PlatformHave.h:
     9
    1102020-03-11  Jer Noble  <jer.noble@apple.com>
    211
  • trunk/Source/WTF/wtf/PlatformHave.h

    r258283 r258314  
    601601#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
    602602#define HAVE_WEBP 1
     603#define HAVE_AVSAMPLEBUFFERVIDEOOUTPUT 1
    603604#endif
    604605
  • trunk/Source/WebCore/ChangeLog

    r258313 r258314  
     12020-03-11  Jer Noble  <jer.noble@apple.com>
     2
     3        Adopt AVSampleBufferVideoOutput
     4        https://bugs.webkit.org/show_bug.cgi?id=208951
     5
     6        Reviewed by Eric Carlson.
     7
     8        Adopt AVSampleBufferVideoOutput, used for extracting decoded samples from an AVSampleBufferDisplayLayer.
     9
     10        Rather than use a separate decompression session when we need to, e.g., paint samples into WebGL, we will
     11        add a AVSBVO to the AVSBDL and use it to extract CVPixelBuffers when asked.
     12
     13        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
     14        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     15        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateLastPixelBuffer):
     16        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged):
     17        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
     18        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isVideoOutputAvailable const):
     19
    1202020-03-11  Andres Gonzalez  <andresg_22@apple.com>
    221
  • trunk/Source/WebCore/PAL/ChangeLog

    r258295 r258314  
     12020-03-11  Jer Noble  <jer.noble@apple.com>
     2
     3        Adopt AVSampleBufferVideoOutput
     4        https://bugs.webkit.org/show_bug.cgi?id=208951
     5
     6        Reviewed by Eric Carlson.
     7
     8        * pal/cocoa/AVFoundationSoftLink.h:
     9        * pal/cocoa/AVFoundationSoftLink.mm:
     10        * pal/spi/cocoa/AVFoundationSPI.h:
     11
    1122020-03-11  Jer Noble  <jer.noble@apple.com>
    213
  • trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h

    r254257 r258314  
    6363SOFT_LINK_CLASS_FOR_HEADER(PAL, AVSampleBufferDisplayLayer)
    6464SOFT_LINK_CLASS_FOR_HEADER(PAL, AVSampleBufferRenderSynchronizer)
     65SOFT_LINK_CLASS_FOR_HEADER(PAL, AVSampleBufferVideoOutput)
    6566SOFT_LINK_CLASS_FOR_HEADER(PAL, AVStreamDataParser)
    6667SOFT_LINK_CLASS_FOR_HEADER(PAL, AVURLAsset)
  • trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm

    r255455 r258314  
    9090SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, AVFoundation, AVSampleBufferDisplayLayer, PAL_EXPORT)
    9191SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, AVFoundation, AVSampleBufferRenderSynchronizer, PAL_EXPORT)
     92SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, AVFoundation, AVSampleBufferVideoOutput, PAL_EXPORT)
    9293SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, AVFoundation, AVStreamDataParser, PAL_EXPORT)
    9394
  • trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h

    r258295 r258314  
    356356@end
    357357#endif
     358
     359#if HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
     360#if USE(APPLE_INTERNAL_SDK)
     361#include <AVFoundation/AVSampleBufferVideoOutput.h>
     362#else
     363@interface AVSampleBufferVideoOutput : NSObject
     364- (CVPixelBufferRef)copyPixelBufferForSourceTime:(CMTime)sourceTime sourceTimeForDisplay:(nullable CMTime *)outSourceTimeForDisplay;
     365@end
     366
     367@interface AVSampleBufferDisplayLayer (VideoOutput)
     368@property (nonatomic, nullable) AVSampleBufferVideoOutput *output;
     369@end
     370#endif
     371#endif
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

    r258082 r258314  
    4242OBJC_CLASS AVSampleBufferDisplayLayer;
    4343OBJC_CLASS AVSampleBufferRenderSynchronizer;
     44OBJC_CLASS AVSampleBufferVideoOutput;
    4445OBJC_CLASS AVStreamSession;
    4546
     
    261262
    262263    bool shouldBePlaying() const;
     264
     265    bool isVideoOutputAvailable() const;
    263266
    264267    friend class MediaSourcePrivateAVFObjC;
     
    283286    RetainPtr<AVAsset> m_asset;
    284287    RetainPtr<AVSampleBufferDisplayLayer> m_sampleBufferDisplayLayer;
     288#if HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
     289    RetainPtr<AVSampleBufferVideoOutput> m_videoOutput;
     290#endif
    285291
    286292    struct AudioRendererProperties {
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r258082 r258314  
    586586bool MediaPlayerPrivateMediaSourceAVFObjC::updateLastPixelBuffer()
    587587{
     588#if HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
     589    if (m_videoOutput) {
     590        CMTime outputTime;
     591        if (auto pixelBuffer = [m_videoOutput copyPixelBufferForSourceTime:toCMTime(currentMediaTime()) sourceTimeForDisplay:&outputTime]) {
     592            INFO_LOG(LOGIDENTIFIER, "new pixelbuffer found for time ", toMediaTime(outputTime));
     593            m_lastPixelBuffer = WTFMove(pixelBuffer);
     594            return true;
     595        }
     596    }
     597#endif
     598
    588599    if (m_sampleBufferDisplayLayer || !m_decompressionSession)
    589600        return false;
     
    671682void MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged()
    672683{
    673     if (!m_hasBeenAskedToPaintGL) {
     684    if (!m_hasBeenAskedToPaintGL || isVideoOutputAvailable()) {
    674685        destroyDecompressionSession();
    675686        ensureLayer();
     
    756767#endif
    757768
     769#if HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
     770    ASSERT(!m_videoOutput);
     771    if (isVideoOutputAvailable()) {
     772        m_videoOutput = adoptNS([PAL::allocAVSampleBufferVideoOutputInstance() init]);
     773        ASSERT(m_videoOutput);
     774        [m_sampleBufferDisplayLayer setOutput:m_videoOutput.get()];
     775    }
     776#endif
     777
    758778    ASSERT(m_sampleBufferDisplayLayer);
    759779    if (!m_sampleBufferDisplayLayer) {
     
    821841{
    822842    return m_playing && !seeking() && allRenderersHaveAvailableSamples() && m_readyState >= MediaPlayer::ReadyState::HaveFutureData;
     843}
     844
     845bool MediaPlayerPrivateMediaSourceAVFObjC::isVideoOutputAvailable() const
     846{
     847#if HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)
     848    return PAL::getAVSampleBufferVideoOutputClass;
     849#else
     850    return false;
     851#endif
    823852}
    824853
Note: See TracChangeset for help on using the changeset viewer.