⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 291744 in webkit


Ignore:
Timestamp:
Mar 23, 2022, 6:54:42 AM (5 years ago)
Author:
youenn@apple.com
Message:

VideoFrame does not need to inherit from MediaSample
​https://bugs.webkit.org/show_bug.cgi?id=238071

Reviewed by Eric Carlson.

Update MediaSample, MediaSampleAVFObjC and VideoFrame according the separation.
This is a refactoring, covered by existing tests.

  • SourcesCocoa.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/MediaSample.h:
  • platform/VideoFrame.cpp:
  • platform/VideoFrame.h:
  • platform/VideoFrame.mm: Added.
  • platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h:
  • platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
  • platform/graphics/gstreamer/VideoFrameGStreamer.cpp:
  • platform/graphics/gstreamer/VideoFrameGStreamer.h:
Location:
trunk/Source/WebCore
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r291743 r291744  
     12022-03-23  Youenn Fablet  <youenn@apple.com>
     2
     3        VideoFrame does not need to inherit from MediaSample
     4        https://bugs.webkit.org/show_bug.cgi?id=238071
     5
     6        Reviewed by Eric Carlson.
     7
     8        Update MediaSample, MediaSampleAVFObjC and VideoFrame according the separation.
     9        This is a refactoring, covered by existing tests.
     10
     11        * SourcesCocoa.txt:
     12        * WebCore.xcodeproj/project.pbxproj:
     13        * platform/MediaSample.h:
     14        * platform/VideoFrame.cpp:
     15        * platform/VideoFrame.h:
     16        * platform/VideoFrame.mm: Added.
     17        * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h:
     18        * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
     19        * platform/graphics/gstreamer/VideoFrameGStreamer.cpp:
     20        * platform/graphics/gstreamer/VideoFrameGStreamer.h:
     21
    1222022-03-23  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
    223
  • trunk/Source/WebCore/SourcesCocoa.txt

    r291564 r291744  
    233233page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm
    234234page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm
     235platform/VideoFrame.mm
    235236platform/audio/AudioSession.cpp
    236237platform/audio/cocoa/AudioDestinationCocoa.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r291725 r291744  
    10771077                4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F19B1A08245E5A001E9ABC /* WebCore.framework */; };
    10781078                41230913138C42FF00BCCFCA /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* JavaScriptCore.framework */; };
     1079                412827B227E4AC3C005ADDE2 /* VideoFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B5A3DAD27ABF8C4006C6F97 /* VideoFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10791080                4129C9971F59B963009D7403 /* FetchBodySource.h in Headers */ = {isa = PBXBuildFile; fileRef = 413015D61C7B570400091C6F /* FetchBodySource.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10801081                4129C9A91F59C56B009D7403 /* ReadableStreamDefaultController.h in Headers */ = {isa = PBXBuildFile; fileRef = 418C395F1C8F0AAB0051C8A3 /* ReadableStreamDefaultController.h */; settings = {ATTRIBUTES = (Private, ); }; };
    … …  
    24222423                7B10339E2549721700C8C1AC /* GraphicsContextGLCV.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */; settings = {ATTRIBUTES = (Private, ); }; };
    24232424                7B10339F2549721E00C8C1AC /* GraphicsContextGLCVCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339C2549720100C8C1AC /* GraphicsContextGLCVCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
    2424                 7B5A3DAF27ABF8C5006C6F97 /* VideoFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B5A3DAD27ABF8C4006C6F97 /* VideoFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
    24252425                7B6094DD270C44BD0064835C /* ANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* ANGLEUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
    24262426                7B6DC81925712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6DC81725712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h */; settings = {ATTRIBUTES = (Private, ); }; };
    … …  
    85918591                41209E95216EC34E00A73A12 /* LibWebRTCCertificateGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCCertificateGenerator.h; path = libwebrtc/LibWebRTCCertificateGenerator.h; sourceTree = "<group>"; };
    85928592                41209E96216EC34F00A73A12 /* LibWebRTCCertificateGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCCertificateGenerator.cpp; path = libwebrtc/LibWebRTCCertificateGenerator.cpp; sourceTree = "<group>"; };
     8593                412827B027E4A9C3005ADDE2 /* VideoFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoFrame.mm; sourceTree = "<group>"; };
    85938594                4129C9801F5861C7009D7403 /* ReadableStreamSink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamSink.h; sourceTree = "<group>"; };
    85948595                4129C9811F5861C7009D7403 /* ReadableStreamSink.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamSink.idl; sourceTree = "<group>"; };
    … …  
    3026030261                                7B5A3DAB27ABF8C4006C6F97 /* VideoFrame.cpp */,
    3026130262                                7B5A3DAD27ABF8C4006C6F97 /* VideoFrame.h */,
     30263                                412827B027E4A9C3005ADDE2 /* VideoFrame.mm */,
    3026230264                                41DEEFB42719BA1900CB8D74 /* VideoFrameMetadata.h */,
    3026330265                                416049312743B0E700A86FA0 /* VideoFrameTimeMetadata.h */,
    … …  
    3796737969                                BCA257151293C010007A263D /* VerticalPositionCache.h in Headers */,
    3796837970                                CD3EEF3B25799FA1006563BB /* VideoConfiguration.h in Headers */,
    37969                                 7B5A3DAF27ABF8C5006C6F97 /* VideoFrame.h in Headers */,
     37971                                412827B227E4AC3C005ADDE2 /* VideoFrame.h in Headers */,
    3797037972                                7BE37F8727BBB708007A6CD3 /* VideoFrameCV.h in Headers */,
    3797137973                                41EB797E27C3E45E001C3E3E /* VideoFrameLibWebRTC.h in Headers */,
  • trunk/Source/WebCore/platform/MediaSample.h

    r291611 r291744  
    3030#include "PlatformVideoColorSpace.h"
    3131#include "SharedBuffer.h"
    32 #include <JavaScriptCore/TypedArrays.h>
    3332#include <functional>
    3433#include <wtf/EnumTraits.h>
    3534#include <wtf/MediaTime.h>
     35#include <wtf/PrintStream.h>
    3636#include <wtf/ThreadSafeRefCounted.h>
    3737#include <wtf/text/AtomString.h>
    … …  
    5757        CMSampleBufferType,
    5858        GStreamerSampleType,
    59         ByteRangeSampleType,
    60         VideoFrameType, // FIXME: To be removed when VideoFrame is not MediaSample.
     59        ByteRangeSampleType
    6160    } type;
    6261    union {
    … …  
    9392    virtual Ref<MediaSample> createNonDisplayingCopy() const = 0;
    9493
    95     virtual RefPtr<JSC::Uint8ClampedArray> getRGBAImageData() const { return nullptr; }
    96 
    9794    enum SampleFlags {
    9895        None = 0,
    … …  
    112109    virtual std::optional<ByteRange> byteRange() const { return std::nullopt; }
    113110
    114     enum class VideoRotation {
    115         None = 0,
    116         UpsideDown = 180,
    117         Right = 90,
    118         Left = 270,
    119     };
    120     virtual VideoRotation rotation() const { return VideoRotation::None; }
    121     virtual bool isMirrored() const { return false; }
    122     virtual uint32_t pixelFormat() const { return 0; }
    123 #if PLATFORM(COCOA)
    124     virtual CVPixelBufferRef pixelBuffer() const { return nullptr; };
    125 #endif
    126     virtual void setOwnershipIdentity(const ProcessIdentity&) { }
    127 
    128111    bool isSync() const { return flags() & IsSync; }
    129112    bool isNonDisplaying() const { return flags() & IsNonDisplaying; }
    … …  
    192175    uint8_t bitDepth { 8 };
    193176    PlatformVideoColorSpace colorSpace;
    194     MediaSample::VideoRotation rotation { MediaSample::VideoRotation::None };
    195177
    196178    RefPtr<SharedBuffer> atomData;
    … …  
    202184    {
    203185        auto& other = downcast<const VideoInfo>(otherVideoInfo);
    204         return size == other.size && displaySize == other.displaySize && bitDepth == other.bitDepth && colorSpace == other.colorSpace && rotation == other.rotation && ((!atomData && !other.atomData) || (atomData && other.atomData && *atomData == *other.atomData));
     186        return size == other.size && displaySize == other.displaySize && bitDepth == other.bitDepth && colorSpace == other.colorSpace && ((!atomData && !other.atomData) || (atomData && other.atomData && *atomData == *other.atomData));
    205187    }
    206188};
    … …  
    277259namespace WTF {
    278260
    279 template<> struct EnumTraits<WebCore::MediaSample::VideoRotation> {
    280     using values = EnumValues<
    281         WebCore::MediaSample::VideoRotation,
    282         WebCore::MediaSample::VideoRotation::None,
    283         WebCore::MediaSample::VideoRotation::UpsideDown,
    284         WebCore::MediaSample::VideoRotation::Right,
    285         WebCore::MediaSample::VideoRotation::Left
    286     >;
    287 };
    288 
    289261template<typename Type> struct LogArgument;
    290262template <>
  • trunk/Source/WebCore/platform/VideoFrame.cpp

    r291611 r291744  
    2727#include "VideoFrame.h"
    2828
    29 #if PLATFORM(COCOA)
    30 #include "VideoFrameCV.h"
     29#if ENABLE(VIDEO)
     30
     31#if USE(GSTREAMER)
     32#include "VideoFrameGStreamer.h"
    3133#endif
    32 
    33 #if ENABLE(VIDEO)
    3434
    3535namespace WebCore {
    3636
    37 VideoFrame::VideoFrame(MediaTime presentationTime, bool isMirrored, VideoRotation rotation)
     37VideoFrame::VideoFrame(MediaTime presentationTime, bool isMirrored, Rotation rotation)
    3838    : m_presentationTime(presentationTime)
    3939    , m_isMirrored(isMirrored)
    … …  
    4242}
    4343
    44 VideoFrame::~VideoFrame() = default;
    45 
    46 MediaTime VideoFrame::presentationTime() const
    47 {
    48     return m_presentationTime;
    49 }
    50 
    51 VideoFrame::Rotation VideoFrame::rotation() const
    52 {
    53     return m_rotation;
    54 }
    55 
    56 bool VideoFrame::isMirrored() const
    57 {
    58     return m_isMirrored;
    59 }
    60 
    61 WebCore::PlatformSample VideoFrame::platformSample() const
    62 {
    63     return { WebCore::PlatformSample::VideoFrameType, { } };
    64 }
    65 
    66 PlatformSample::Type VideoFrame::platformSampleType() const
    67 {
    68     return WebCore::PlatformSample::VideoFrameType;
    69 }
    70 
    71 MediaTime VideoFrame::decodeTime() const
    72 {
    73     ASSERT_NOT_REACHED();
    74     return { };
    75 }
    76 
    77 MediaTime VideoFrame::duration() const
    78 {
    79     ASSERT_NOT_REACHED();
    80     return { };
    81 }
    82 
    83 AtomString VideoFrame::trackID() const
    84 {
    85     ASSERT_NOT_REACHED();
    86     return { };
    87 }
    88 
    89 size_t VideoFrame::sizeInBytes() const
    90 {
    91     ASSERT_NOT_REACHED();
    92     return 0;
    93 }
    94 
    95 void VideoFrame::offsetTimestampsBy(const MediaTime&)
    96 {
    97     ASSERT_NOT_REACHED();
    98 }
    99 
    100 void VideoFrame::setTimestamps(const MediaTime&, const MediaTime&)
    101 {
    102     ASSERT_NOT_REACHED();
    103 }
    104 
    105 Ref<WebCore::MediaSample> VideoFrame::createNonDisplayingCopy() const
    106 {
    107     CRASH();
    108 }
    109 
    110 MediaSample::SampleFlags VideoFrame::flags() const
    111 {
    112     return MediaSample::SampleFlags::None;
    113 }
    114 
    115 void VideoFrame::dump(PrintStream&) const
    116 {
    117 }
    118 
    119 void VideoFrame::initializeCharacteristics(MediaTime presentationTime, bool isMirrored, VideoRotation rotation)
     44void VideoFrame::initializeCharacteristics(MediaTime presentationTime, bool isMirrored, Rotation rotation)
    12045{
    12146    const_cast<MediaTime&>(m_presentationTime) = presentationTime;
    12247    const_cast<bool&>(m_isMirrored) = isMirrored;
    123     const_cast<VideoRotation&>(m_rotation) = rotation;
     48    const_cast<Rotation&>(m_rotation) = rotation;
    12449}
    12550
    126 #if PLATFORM(COCOA)
    127 RefPtr<VideoFrameCV> VideoFrame::asVideoFrameCV()
     51#if !PLATFORM(COCOA)
     52RefPtr<JSC::Uint8ClampedArray> VideoFrame::getRGBAImageData() const
    12853{
    129     auto buffer = pixelBuffer();
    130     if (!buffer)
    131         return nullptr;
    132 
    133     return VideoFrameCV::create(presentationTime(), isMirrored(), rotation(), buffer);
     54#if USE(GSTREAMER)
     55    if (isGStreamer())
     56        return static_cast<const VideoFrameGStreamer*>(this)->computeRGBAImageData();
     57#endif
     58    // FIXME: Add support.
     59    return nullptr;
    13460}
    13561#endif
    … …  
    13763}
    13864
    139 #endif
     65#endif // ENABLE(VIDEO)
  • trunk/Source/WebCore/platform/VideoFrame.h

    r291611 r291744  
    2828#if ENABLE(VIDEO)
    2929
    30 #include "MediaSample.h"
     30#include "FloatSize.h"
     31#include <JavaScriptCore/TypedArrays.h>
     32#include <wtf/MediaTime.h>
     33#include <wtf/ThreadSafeRefCounted.h>
     34
     35typedef struct __CVBuffer *CVPixelBufferRef;
    3136
    3237namespace WebCore {
    3338
     39class ProcessIdentity;
    3440#if USE(AVFOUNDATION) && PLATFORM(COCOA)
    3541class VideoFrameCV;
    … …  
    3743
    3844// A class representing a video frame from a decoder, capture source, or similar.
    39 // FIXME: Currently for implementation purposes inherts from MediaSample until capture code
    40 // stops referring to MediaSample
    41 class VideoFrame : public MediaSample {
     45class VideoFrame : public ThreadSafeRefCounted<VideoFrame> {
    4246public:
    43     WEBCORE_EXPORT ~VideoFrame();
     47    virtual ~VideoFrame() = default;
    4448
    45     using Rotation = MediaSample::VideoRotation;
     49    enum class Rotation {
     50        None = 0,
     51        UpsideDown = 180,
     52        Right = 90,
     53        Left = 270,
     54    };
    4655
    47     // WebCore::MediaSample overrides.
    48     WEBCORE_EXPORT MediaTime presentationTime() const final;
    49     WEBCORE_EXPORT Rotation rotation() const final;
    50     WEBCORE_EXPORT bool isMirrored() const final;
    51     // FIXME: When VideoFrame is not MediaSample, these will not be needed.
    52     WEBCORE_EXPORT WebCore::PlatformSample platformSample() const final;
    53     WEBCORE_EXPORT PlatformSample::Type platformSampleType() const final;
     56    MediaTime presentationTime() const { return m_presentationTime; }
     57    Rotation rotation() const { return m_rotation; }
     58    bool isMirrored() const { return m_isMirrored; }
     59
     60#if PLATFORM(COCOA) && USE(AVFOUNDATION)
     61    WEBCORE_EXPORT RefPtr<VideoFrameCV> asVideoFrameCV();
     62#endif
     63    WEBCORE_EXPORT RefPtr<JSC::Uint8ClampedArray> getRGBAImageData() const;
     64
     65    virtual FloatSize presentationSize() const = 0;
     66    virtual uint32_t pixelFormat() const = 0;
    5467
    5568    virtual bool isRemoteProxy() const { return false; }
    5669    virtual bool isLibWebRTC() const { return false; }
    57 #if USE(AVFOUNDATION)
    5870    virtual bool isCV() const { return false; }
     71#if USE(GSTREAMER)
     72    virtual bool isGStreamer() const { return false; }
     73#endif
    5974#if PLATFORM(COCOA)
    60     WEBCORE_EXPORT virtual RefPtr<VideoFrameCV> asVideoFrameCV();
     75    virtual CVPixelBufferRef pixelBuffer() const { return nullptr; };
    6176#endif
    62 #endif
     77    WEBCORE_EXPORT virtual void setOwnershipIdentity(const ProcessIdentity&) { }
    6378
    64     void initializeCharacteristics(MediaTime presentationTime, bool isMirrored, VideoRotation);
     79    void initializeCharacteristics(MediaTime presentationTime, bool isMirrored, Rotation);
    6580
    6681protected:
    67     WEBCORE_EXPORT VideoFrame(MediaTime presentationTime, bool isMirrored, VideoRotation);
     82    WEBCORE_EXPORT VideoFrame(MediaTime presentationTime, bool isMirrored, Rotation);
     83
     84private:
    6885    const MediaTime m_presentationTime;
    6986    const bool m_isMirrored;
    70     const VideoRotation m_rotation;
    71 
    72 private:
    73     // FIXME: These are not intended to be used for these objects.
    74     // WebCore::MediaSample overrides.
    75     WEBCORE_EXPORT MediaTime decodeTime() const final;
    76     WEBCORE_EXPORT MediaTime duration() const final;
    77     WEBCORE_EXPORT AtomString trackID() const final;
    78     WEBCORE_EXPORT size_t sizeInBytes() const final;
    79     WEBCORE_EXPORT void offsetTimestampsBy(const MediaTime&) final;
    80     WEBCORE_EXPORT void setTimestamps(const MediaTime&, const MediaTime&) final;
    81     WEBCORE_EXPORT Ref<WebCore::MediaSample> createNonDisplayingCopy() const final;
    82     WEBCORE_EXPORT SampleFlags flags() const final;
    83     WEBCORE_EXPORT void dump(PrintStream&) const final;
     87    const Rotation m_rotation;
    8488};
    8589
    8690}
    8791
    88 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::VideoFrame)
    89     static bool isType(const WebCore::MediaSample& mediaSample) { return mediaSample.platformSampleType() == WebCore::PlatformSample::VideoFrameType; }
    90 SPECIALIZE_TYPE_TRAITS_END()
    91 #endif
     92namespace WTF {
     93
     94template<> struct EnumTraits<WebCore::VideoFrame::Rotation> {
     95    using values = EnumValues<
     96        WebCore::VideoFrame::Rotation,
     97        WebCore::VideoFrame::Rotation::None,
     98        WebCore::VideoFrame::Rotation::UpsideDown,
     99        WebCore::VideoFrame::Rotation::Right,
     100        WebCore::VideoFrame::Rotation::Left
     101    >;
     102};
     103
     104}
     105
     106#endif // ENABLE(VIDEO)
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h

    r291611 r291744  
    4444    static Ref<MediaSampleAVFObjC> create(CMSampleBufferRef sample, uint64_t trackID) { return adoptRef(*new MediaSampleAVFObjC(sample, trackID)); }
    4545    static Ref<MediaSampleAVFObjC> create(CMSampleBufferRef sample, AtomString trackID) { return adoptRef(*new MediaSampleAVFObjC(sample, trackID)); }
    46     static Ref<MediaSampleAVFObjC> create(CMSampleBufferRef sample, VideoRotation rotation = VideoRotation::None, bool mirrored = false) { return adoptRef(*new MediaSampleAVFObjC(sample, rotation, mirrored)); }
    47 
    48     WEBCORE_EXPORT RefPtr<JSC::Uint8ClampedArray> getRGBAImageData() const override;
    4946
    5047    MediaTime presentationTime() const override;
    … …  
    6663    WEBCORE_EXPORT Ref<MediaSample> createNonDisplayingCopy() const override;
    6764
    68     VideoRotation rotation() const override { return m_rotation; }
    69     bool isMirrored() const override { return m_mirrored; }
    70     WEBCORE_EXPORT uint32_t pixelFormat() const final;
    71     WEBCORE_EXPORT CVPixelBufferRef pixelBuffer() const final;
    72     WEBCORE_EXPORT void setOwnershipIdentity(const ProcessIdentity&) final;
    73 
    7465    CMSampleBufferRef sampleBuffer() const { return m_sample.get(); }
    7566
    … …  
    8475#endif
    8576
    86     // FIXME: To be removed once VideoFrame is not a MediaSample.
    87     WEBCORE_EXPORT RefPtr<VideoFrameCV> videoFrame() const;
    8877protected:
    8978    WEBCORE_EXPORT MediaSampleAVFObjC(RetainPtr<CMSampleBufferRef>&&);
    … …  
    9180    WEBCORE_EXPORT MediaSampleAVFObjC(CMSampleBufferRef, AtomString trackID);
    9281    WEBCORE_EXPORT MediaSampleAVFObjC(CMSampleBufferRef, uint64_t trackID);
    93     WEBCORE_EXPORT MediaSampleAVFObjC(CMSampleBufferRef, VideoRotation, bool mirrored);
    9482    WEBCORE_EXPORT virtual ~MediaSampleAVFObjC();
    9583
    9684    RetainPtr<CMSampleBufferRef> m_sample;
    9785    AtomString m_id;
    98     VideoRotation m_rotation { VideoRotation::None };
    99     bool m_mirrored { false };
    10086
    10187#if ENABLE(ENCRYPTED_MEDIA) && HAVE(AVCONTENTKEYSESSION)
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm

    r291611 r291744  
    6767{
    6868}
    69 MediaSampleAVFObjC::MediaSampleAVFObjC(CMSampleBufferRef sample, VideoRotation rotation, bool mirrored)
    70     : m_sample(sample)
    71     , m_rotation(rotation)
    72     , m_mirrored(mirrored)
    73 {
    74 }
    7569
    7670MediaSampleAVFObjC::~MediaSampleAVFObjC() = default;
    … …  
    109103    PlatformSample sample = { PlatformSample::CMSampleBufferType, { .cmSampleBuffer = m_sample.get() } };
    110104    return sample;
    111 }
    112 
    113 uint32_t MediaSampleAVFObjC::pixelFormat() const
    114 {
    115     auto pixelBuffer = static_cast<CVPixelBufferRef>(PAL::CMSampleBufferGetImageBuffer(m_sample.get()));
    116     return CVPixelBufferGetPixelFormatType(pixelBuffer);
    117 }
    118 
    119 RefPtr<VideoFrameCV> MediaSampleAVFObjC::videoFrame() const
    120 {
    121     if (!m_sample)
    122         return nullptr;
    123     auto pixelBuffer = static_cast<CVPixelBufferRef>(PAL::CMSampleBufferGetImageBuffer(m_sample.get()));
    124     if (!pixelBuffer)
    125         return nullptr;
    126     return VideoFrameCV::create(presentationTime(), m_mirrored, m_rotation, RetainPtr { pixelBuffer });
    127105}
    128106
    … …  
    313291}
    314292
    315 RefPtr<JSC::Uint8ClampedArray> MediaSampleAVFObjC::getRGBAImageData() const
    316 {
    317     const OSType imageFormat = kCVPixelFormatType_32RGBA;
    318     RetainPtr<CFNumberRef> imageFormatNumber = adoptCF(CFNumberCreate(nullptr,  kCFNumberIntType,  &imageFormat));
    319 
    320     RetainPtr<CFMutableDictionaryRef> conformerOptions = adoptCF(CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
    321     CFDictionarySetValue(conformerOptions.get(), kCVPixelBufferPixelFormatTypeKey, imageFormatNumber.get());
    322     PixelBufferConformerCV pixelBufferConformer(conformerOptions.get());
    323 
    324     auto pixelBuffer = static_cast<CVPixelBufferRef>(PAL::CMSampleBufferGetImageBuffer(m_sample.get()));
    325     auto rgbaPixelBuffer = pixelBufferConformer.convert(pixelBuffer);
    326     auto status = CVPixelBufferLockBaseAddress(rgbaPixelBuffer.get(), kCVPixelBufferLock_ReadOnly);
    327     ASSERT_UNUSED(status, status == noErr);
    328 
    329     void* data = CVPixelBufferGetBaseAddressOfPlane(rgbaPixelBuffer.get(), 0);
    330     size_t byteLength = CVPixelBufferGetHeight(pixelBuffer) * CVPixelBufferGetWidth(pixelBuffer) * 4;
    331     auto result = JSC::Uint8ClampedArray::tryCreate(JSC::ArrayBuffer::create(data, byteLength), 0, byteLength);
    332 
    333     status = CVPixelBufferUnlockBaseAddress(rgbaPixelBuffer.get(), kCVPixelBufferLock_ReadOnly);
    334     ASSERT(status == noErr);
    335 
    336     return result;
    337 }
    338 
    339 static inline void setSampleBufferAsDisplayImmediately(CMSampleBufferRef sampleBuffer)
    340 {
    341     CFArrayRef attachmentsArray = PAL::CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, true);
    342     for (CFIndex i = 0; i < CFArrayGetCount(attachmentsArray); ++i) {
    343         CFMutableDictionaryRef attachments = checked_cf_cast<CFMutableDictionaryRef>(CFArrayGetValueAtIndex(attachmentsArray, i));
    344         CFDictionarySetValue(attachments, PAL::kCMSampleAttachmentKey_DisplayImmediately, kCFBooleanTrue);
    345     }
    346 }
    347 
    348293bool MediaSampleAVFObjC::isHomogeneous() const
    349294{
    … …  
    416361}
    417362
    418 CVPixelBufferRef MediaSampleAVFObjC::pixelBuffer() const
    419 {
    420     return static_cast<CVPixelBufferRef>(PAL::CMSampleBufferGetImageBuffer(m_sample.get()));
    421 }
    422 
    423 void MediaSampleAVFObjC::setOwnershipIdentity(const ProcessIdentity& resourceOwner)
    424 {
    425     ASSERT(resourceOwner);
    426     auto buffer = pixelBuffer();
    427     ASSERT(buffer);
    428     setOwnershipIdentityForCVPixelBuffer(buffer, resourceOwner);
    429 }
    430 
    431 }
     363}
  • trunk/Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp

    r291611 r291744  
    105105}
    106106
    107 RefPtr<JSC::Uint8ClampedArray> VideoFrameGStreamer::getRGBAImageData() const
     107RefPtr<JSC::Uint8ClampedArray> VideoFrameGStreamer::computeRGBAImageData() const
    108108{
    109109    auto* caps = gst_sample_get_caps(m_sample.get());
  • trunk/Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.h

    r291611 r291744  
    2424#include "VideoFrame.h"
    2525#include "VideoFrameMetadataGStreamer.h"
     26#include <wtf/glib/GRefPtr.h>
     27
     28typedef struct _GstSample GstSample;
    2629
    2730namespace WebCore {
    … …  
    4447
    4548    GstSample* sample() const { return m_sample.get(); }
     49    RefPtr<JSC::Uint8ClampedArray> computeRGBAImageData() const;
    4650
    4751private:
    … …  
    5054
    5155    FloatSize presentationSize() const final { return m_presentationSize; }
    52     RefPtr<JSC::Uint8ClampedArray> getRGBAImageData() const final;
    5356    uint32_t pixelFormat() const final { return 0; }
     57    bool isGStreamer() const final { return true; }
    5458
    5559    GRefPtr<GstSample> m_sample;
  • trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeIncomingVideoSourceGStreamer.cpp

    r291611 r291744  
    2323#include "RealtimeIncomingVideoSourceGStreamer.h"
    2424
     25#include "GStreamerCommon.h"
    2526#include "VideoFrameGStreamer.h"
    2627#include "VideoFrameMetadataGStreamer.h"
Note: See TracChangeset for help on using the changeset viewer.