Changeset 291744 in webkit
- Timestamp:
- Mar 23, 2022, 6:54:42 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 11 edited
-
ChangeLog (modified) (1 diff)
-
SourcesCocoa.txt (modified) (1 diff)
-
WebCore.xcodeproj/project.pbxproj (modified) (5 diffs)
-
platform/MediaSample.h (modified) (7 diffs)
-
platform/VideoFrame.cpp (modified) (3 diffs)
-
platform/VideoFrame.h (modified) (2 diffs)
-
platform/VideoFrame.mm (added)
-
platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h (modified) (4 diffs)
-
platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm (modified) (4 diffs)
-
platform/graphics/gstreamer/VideoFrameGStreamer.cpp (modified) (1 diff)
-
platform/graphics/gstreamer/VideoFrameGStreamer.h (modified) (3 diffs)
-
platform/mediastream/gstreamer/RealtimeIncomingVideoSourceGStreamer.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r291743 r291744 1 2022-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 1 22 2022-03-23 Víctor Manuel Jáquez Leal <vjaquez@igalia.com> 2 23 -
trunk/Source/WebCore/SourcesCocoa.txt
r291564 r291744 233 233 page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm 234 234 page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm 235 platform/VideoFrame.mm 235 236 platform/audio/AudioSession.cpp 236 237 platform/audio/cocoa/AudioDestinationCocoa.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r291725 r291744 1077 1077 4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F19B1A08245E5A001E9ABC /* WebCore.framework */; }; 1078 1078 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, ); }; }; 1079 1080 4129C9971F59B963009D7403 /* FetchBodySource.h in Headers */ = {isa = PBXBuildFile; fileRef = 413015D61C7B570400091C6F /* FetchBodySource.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1080 1081 4129C9A91F59C56B009D7403 /* ReadableStreamDefaultController.h in Headers */ = {isa = PBXBuildFile; fileRef = 418C395F1C8F0AAB0051C8A3 /* ReadableStreamDefaultController.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 2422 2423 7B10339E2549721700C8C1AC /* GraphicsContextGLCV.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B10339D2549720100C8C1AC /* GraphicsContextGLCV.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2423 2424 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, ); }; };2425 2425 7B6094DD270C44BD0064835C /* ANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* ANGLEUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2426 2426 7B6DC81925712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6DC81725712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 8591 8591 41209E95216EC34E00A73A12 /* LibWebRTCCertificateGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCCertificateGenerator.h; path = libwebrtc/LibWebRTCCertificateGenerator.h; sourceTree = "<group>"; }; 8592 8592 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>"; }; 8593 8594 4129C9801F5861C7009D7403 /* ReadableStreamSink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamSink.h; sourceTree = "<group>"; }; 8594 8595 4129C9811F5861C7009D7403 /* ReadableStreamSink.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamSink.idl; sourceTree = "<group>"; }; … … 30260 30261 7B5A3DAB27ABF8C4006C6F97 /* VideoFrame.cpp */, 30261 30262 7B5A3DAD27ABF8C4006C6F97 /* VideoFrame.h */, 30263 412827B027E4A9C3005ADDE2 /* VideoFrame.mm */, 30262 30264 41DEEFB42719BA1900CB8D74 /* VideoFrameMetadata.h */, 30263 30265 416049312743B0E700A86FA0 /* VideoFrameTimeMetadata.h */, … … 37967 37969 BCA257151293C010007A263D /* VerticalPositionCache.h in Headers */, 37968 37970 CD3EEF3B25799FA1006563BB /* VideoConfiguration.h in Headers */, 37969 7B5A3DAF27ABF8C5006C6F97/* VideoFrame.h in Headers */,37971 412827B227E4AC3C005ADDE2 /* VideoFrame.h in Headers */, 37970 37972 7BE37F8727BBB708007A6CD3 /* VideoFrameCV.h in Headers */, 37971 37973 41EB797E27C3E45E001C3E3E /* VideoFrameLibWebRTC.h in Headers */, -
trunk/Source/WebCore/platform/MediaSample.h
r291611 r291744 30 30 #include "PlatformVideoColorSpace.h" 31 31 #include "SharedBuffer.h" 32 #include <JavaScriptCore/TypedArrays.h>33 32 #include <functional> 34 33 #include <wtf/EnumTraits.h> 35 34 #include <wtf/MediaTime.h> 35 #include <wtf/PrintStream.h> 36 36 #include <wtf/ThreadSafeRefCounted.h> 37 37 #include <wtf/text/AtomString.h> … … 57 57 CMSampleBufferType, 58 58 GStreamerSampleType, 59 ByteRangeSampleType, 60 VideoFrameType, // FIXME: To be removed when VideoFrame is not MediaSample. 59 ByteRangeSampleType 61 60 } type; 62 61 union { … … 93 92 virtual Ref<MediaSample> createNonDisplayingCopy() const = 0; 94 93 95 virtual RefPtr<JSC::Uint8ClampedArray> getRGBAImageData() const { return nullptr; }96 97 94 enum SampleFlags { 98 95 None = 0, … … 112 109 virtual std::optional<ByteRange> byteRange() const { return std::nullopt; } 113 110 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 #endif126 virtual void setOwnershipIdentity(const ProcessIdentity&) { }127 128 111 bool isSync() const { return flags() & IsSync; } 129 112 bool isNonDisplaying() const { return flags() & IsNonDisplaying; } … … 192 175 uint8_t bitDepth { 8 }; 193 176 PlatformVideoColorSpace colorSpace; 194 MediaSample::VideoRotation rotation { MediaSample::VideoRotation::None };195 177 196 178 RefPtr<SharedBuffer> atomData; … … 202 184 { 203 185 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)); 205 187 } 206 188 }; … … 277 259 namespace WTF { 278 260 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::Left286 >;287 };288 289 261 template<typename Type> struct LogArgument; 290 262 template <> -
trunk/Source/WebCore/platform/VideoFrame.cpp
r291611 r291744 27 27 #include "VideoFrame.h" 28 28 29 #if PLATFORM(COCOA) 30 #include "VideoFrameCV.h" 29 #if ENABLE(VIDEO) 30 31 #if USE(GSTREAMER) 32 #include "VideoFrameGStreamer.h" 31 33 #endif 32 33 #if ENABLE(VIDEO)34 34 35 35 namespace WebCore { 36 36 37 VideoFrame::VideoFrame(MediaTime presentationTime, bool isMirrored, VideoRotation rotation)37 VideoFrame::VideoFrame(MediaTime presentationTime, bool isMirrored, Rotation rotation) 38 38 : m_presentationTime(presentationTime) 39 39 , m_isMirrored(isMirrored) … … 42 42 } 43 43 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) 44 void VideoFrame::initializeCharacteristics(MediaTime presentationTime, bool isMirrored, Rotation rotation) 120 45 { 121 46 const_cast<MediaTime&>(m_presentationTime) = presentationTime; 122 47 const_cast<bool&>(m_isMirrored) = isMirrored; 123 const_cast< VideoRotation&>(m_rotation) = rotation;48 const_cast<Rotation&>(m_rotation) = rotation; 124 49 } 125 50 126 #if PLATFORM(COCOA)127 RefPtr< VideoFrameCV> VideoFrame::asVideoFrameCV()51 #if !PLATFORM(COCOA) 52 RefPtr<JSC::Uint8ClampedArray> VideoFrame::getRGBAImageData() const 128 53 { 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; 134 60 } 135 61 #endif … … 137 63 } 138 64 139 #endif 65 #endif // ENABLE(VIDEO) -
trunk/Source/WebCore/platform/VideoFrame.h
r291611 r291744 28 28 #if ENABLE(VIDEO) 29 29 30 #include "MediaSample.h" 30 #include "FloatSize.h" 31 #include <JavaScriptCore/TypedArrays.h> 32 #include <wtf/MediaTime.h> 33 #include <wtf/ThreadSafeRefCounted.h> 34 35 typedef struct __CVBuffer *CVPixelBufferRef; 31 36 32 37 namespace WebCore { 33 38 39 class ProcessIdentity; 34 40 #if USE(AVFOUNDATION) && PLATFORM(COCOA) 35 41 class VideoFrameCV; … … 37 43 38 44 // 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 { 45 class VideoFrame : public ThreadSafeRefCounted<VideoFrame> { 42 46 public: 43 WEBCORE_EXPORT ~VideoFrame();47 virtual ~VideoFrame() = default; 44 48 45 using Rotation = MediaSample::VideoRotation; 49 enum class Rotation { 50 None = 0, 51 UpsideDown = 180, 52 Right = 90, 53 Left = 270, 54 }; 46 55 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; 54 67 55 68 virtual bool isRemoteProxy() const { return false; } 56 69 virtual bool isLibWebRTC() const { return false; } 57 #if USE(AVFOUNDATION)58 70 virtual bool isCV() const { return false; } 71 #if USE(GSTREAMER) 72 virtual bool isGStreamer() const { return false; } 73 #endif 59 74 #if PLATFORM(COCOA) 60 WEBCORE_EXPORT virtual RefPtr<VideoFrameCV> asVideoFrameCV();75 virtual CVPixelBufferRef pixelBuffer() const { return nullptr; }; 61 76 #endif 62 #endif 77 WEBCORE_EXPORT virtual void setOwnershipIdentity(const ProcessIdentity&) { } 63 78 64 void initializeCharacteristics(MediaTime presentationTime, bool isMirrored, VideoRotation);79 void initializeCharacteristics(MediaTime presentationTime, bool isMirrored, Rotation); 65 80 66 81 protected: 67 WEBCORE_EXPORT VideoFrame(MediaTime presentationTime, bool isMirrored, VideoRotation); 82 WEBCORE_EXPORT VideoFrame(MediaTime presentationTime, bool isMirrored, Rotation); 83 84 private: 68 85 const MediaTime m_presentationTime; 69 86 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; 84 88 }; 85 89 86 90 } 87 91 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 92 namespace WTF { 93 94 template<> 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 44 44 static Ref<MediaSampleAVFObjC> create(CMSampleBufferRef sample, uint64_t trackID) { return adoptRef(*new MediaSampleAVFObjC(sample, trackID)); } 45 45 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;49 46 50 47 MediaTime presentationTime() const override; … … 66 63 WEBCORE_EXPORT Ref<MediaSample> createNonDisplayingCopy() const override; 67 64 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 74 65 CMSampleBufferRef sampleBuffer() const { return m_sample.get(); } 75 66 … … 84 75 #endif 85 76 86 // FIXME: To be removed once VideoFrame is not a MediaSample.87 WEBCORE_EXPORT RefPtr<VideoFrameCV> videoFrame() const;88 77 protected: 89 78 WEBCORE_EXPORT MediaSampleAVFObjC(RetainPtr<CMSampleBufferRef>&&); … … 91 80 WEBCORE_EXPORT MediaSampleAVFObjC(CMSampleBufferRef, AtomString trackID); 92 81 WEBCORE_EXPORT MediaSampleAVFObjC(CMSampleBufferRef, uint64_t trackID); 93 WEBCORE_EXPORT MediaSampleAVFObjC(CMSampleBufferRef, VideoRotation, bool mirrored);94 82 WEBCORE_EXPORT virtual ~MediaSampleAVFObjC(); 95 83 96 84 RetainPtr<CMSampleBufferRef> m_sample; 97 85 AtomString m_id; 98 VideoRotation m_rotation { VideoRotation::None };99 bool m_mirrored { false };100 86 101 87 #if ENABLE(ENCRYPTED_MEDIA) && HAVE(AVCONTENTKEYSESSION) -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm
r291611 r291744 67 67 { 68 68 } 69 MediaSampleAVFObjC::MediaSampleAVFObjC(CMSampleBufferRef sample, VideoRotation rotation, bool mirrored)70 : m_sample(sample)71 , m_rotation(rotation)72 , m_mirrored(mirrored)73 {74 }75 69 76 70 MediaSampleAVFObjC::~MediaSampleAVFObjC() = default; … … 109 103 PlatformSample sample = { PlatformSample::CMSampleBufferType, { .cmSampleBuffer = m_sample.get() } }; 110 104 return sample; 111 }112 113 uint32_t MediaSampleAVFObjC::pixelFormat() const114 {115 auto pixelBuffer = static_cast<CVPixelBufferRef>(PAL::CMSampleBufferGetImageBuffer(m_sample.get()));116 return CVPixelBufferGetPixelFormatType(pixelBuffer);117 }118 119 RefPtr<VideoFrameCV> MediaSampleAVFObjC::videoFrame() const120 {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 });127 105 } 128 106 … … 313 291 } 314 292 315 RefPtr<JSC::Uint8ClampedArray> MediaSampleAVFObjC::getRGBAImageData() const316 {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 348 293 bool MediaSampleAVFObjC::isHomogeneous() const 349 294 { … … 416 361 } 417 362 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 105 105 } 106 106 107 RefPtr<JSC::Uint8ClampedArray> VideoFrameGStreamer:: getRGBAImageData() const107 RefPtr<JSC::Uint8ClampedArray> VideoFrameGStreamer::computeRGBAImageData() const 108 108 { 109 109 auto* caps = gst_sample_get_caps(m_sample.get()); -
trunk/Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.h
r291611 r291744 24 24 #include "VideoFrame.h" 25 25 #include "VideoFrameMetadataGStreamer.h" 26 #include <wtf/glib/GRefPtr.h> 27 28 typedef struct _GstSample GstSample; 26 29 27 30 namespace WebCore { … … 44 47 45 48 GstSample* sample() const { return m_sample.get(); } 49 RefPtr<JSC::Uint8ClampedArray> computeRGBAImageData() const; 46 50 47 51 private: … … 50 54 51 55 FloatSize presentationSize() const final { return m_presentationSize; } 52 RefPtr<JSC::Uint8ClampedArray> getRGBAImageData() const final;53 56 uint32_t pixelFormat() const final { return 0; } 57 bool isGStreamer() const final { return true; } 54 58 55 59 GRefPtr<GstSample> m_sample; -
trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeIncomingVideoSourceGStreamer.cpp
r291611 r291744 23 23 #include "RealtimeIncomingVideoSourceGStreamer.h" 24 24 25 #include "GStreamerCommon.h" 25 26 #include "VideoFrameGStreamer.h" 26 27 #include "VideoFrameMetadataGStreamer.h"
Note:
See TracChangeset
for help on using the changeset viewer.