Title: [291421] trunk/Source
Revision
291421
Author
[email protected]
Date
2022-03-17 11:08:53 -0700 (Thu, 17 Mar 2022)

Log Message

Make SharedVideoFrameReader use VideoFrameCV instead of MediaSample
https://bugs.webkit.org/show_bug.cgi?id=237596

Reviewed by Eric Carlson.

Source/WebCore:

Update media recorder and display layer to use pixel buffers instead of MediaSample.
This allows migrating to VideoFrameCV.
No change of behavior.

* platform/cocoa/MediaUtilities.cpp:
* platform/cocoa/MediaUtilities.h:
* platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h:
* platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm:
* platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
* platform/mediarecorder/MediaRecorderPrivateAVFImpl.h:
* platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
* platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:

Source/WebKit:

* GPUProcess/webrtc/RemoteMediaRecorder.cpp:
* GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp:
* WebProcess/GPU/webrtc/SharedVideoFrame.cpp:
* WebProcess/GPU/webrtc/SharedVideoFrame.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291420 => 291421)


--- trunk/Source/WebCore/ChangeLog	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebCore/ChangeLog	2022-03-17 18:08:53 UTC (rev 291421)
@@ -1,3 +1,23 @@
+2022-03-17  Youenn Fablet  <[email protected]>
+
+        Make SharedVideoFrameReader use VideoFrameCV instead of MediaSample
+        https://bugs.webkit.org/show_bug.cgi?id=237596
+
+        Reviewed by Eric Carlson.
+
+        Update media recorder and display layer to use pixel buffers instead of MediaSample.
+        This allows migrating to VideoFrameCV.
+        No change of behavior.
+
+        * platform/cocoa/MediaUtilities.cpp:
+        * platform/cocoa/MediaUtilities.h:
+        * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h:
+        * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm:
+        * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
+        * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h:
+        * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+        * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+
 2022-03-17  Antoine Quint  <[email protected]>
 
         REGRESSION (iOS 15.4 / r287669): Mobile app stopped working due to CSS / angular animation

Modified: trunk/Source/WebCore/platform/cocoa/MediaUtilities.cpp (291420 => 291421)


--- trunk/Source/WebCore/platform/cocoa/MediaUtilities.cpp	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebCore/platform/cocoa/MediaUtilities.cpp	2022-03-17 18:08:53 UTC (rev 291421)
@@ -68,4 +68,21 @@
     return buffer;
 }
 
+RetainPtr<CMSampleBufferRef> createVideoSampleBuffer(CVPixelBufferRef pixelBuffer, CMTime presentationTime)
+{
+    CMVideoFormatDescriptionRef formatDescription = nullptr;
+    auto status = PAL::CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, pixelBuffer, &formatDescription);
+    if (status)
+        return nullptr;
+    auto retainedFormatDescription = adoptCF(formatDescription);
+
+    CMSampleTimingInfo timingInfo { PAL::kCMTimeInvalid, presentationTime, PAL::kCMTimeInvalid };
+    CMSampleBufferRef sampleBuffer;
+    status = PAL::CMSampleBufferCreateReadyWithImageBuffer(kCFAllocatorDefault, pixelBuffer, formatDescription, &timingInfo, &sampleBuffer);
+    if (status)
+        return nullptr;
+
+    return adoptCF(sampleBuffer);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/cocoa/MediaUtilities.h (291420 => 291421)


--- trunk/Source/WebCore/platform/cocoa/MediaUtilities.h	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebCore/platform/cocoa/MediaUtilities.h	2022-03-17 18:08:53 UTC (rev 291421)
@@ -30,6 +30,7 @@
 
 typedef const struct opaqueCMFormatDescription* CMFormatDescriptionRef;
 typedef struct opaqueCMSampleBuffer* CMSampleBufferRef;
+typedef struct __CVBuffer *CVPixelBufferRef;
 
 namespace WebCore {
 
@@ -38,5 +39,6 @@
 
 RetainPtr<CMFormatDescriptionRef> createAudioFormatDescription(const AudioStreamDescription&, size_t magicCookieSize = 0, const void* magicCookie = nullptr);
 RetainPtr<CMSampleBufferRef> createAudioSampleBuffer(const PlatformAudioData&, const AudioStreamDescription&, CMTime, size_t sampleCount);
+RetainPtr<CMSampleBufferRef> createVideoSampleBuffer(CVPixelBufferRef, CMTime);
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h (291420 => 291421)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h	2022-03-17 18:08:53 UTC (rev 291421)
@@ -79,6 +79,7 @@
     void play() final;
     void pause() final;
 
+    void enqueue(CVPixelBufferRef, MediaTime);
     void enqueueSample(MediaSample&) final;
     void clearEnqueuedSamples() final;
     void setRenderPolicy(RenderPolicy) final;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm (291420 => 291421)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm	2022-03-17 18:08:53 UTC (rev 291421)
@@ -32,6 +32,7 @@
 #import "IntSize.h"
 #import "Logging.h"
 #import "MediaSampleAVFObjC.h"
+#import "MediaUtilities.h"
 
 #import <AVFoundation/AVSampleBufferDisplayLayer.h>
 #import <QuartzCore/CALayer.h>
@@ -333,24 +334,29 @@
 
 void LocalSampleBufferDisplayLayer::enqueueSampleBuffer(MediaSample& sample)
 {
+    enqueue(sample.pixelBuffer(), sample.presentationTime());
+}
+
+static void setSampleBufferAsDisplayImmediately(CMSampleBufferRef sampleBuffer)
+{
+    CFArrayRef attachmentsArray = PAL::CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, true);
+    for (CFIndex i = 0; i < CFArrayGetCount(attachmentsArray); ++i) {
+        CFMutableDictionaryRef attachments = checked_cf_cast<CFMutableDictionaryRef>(CFArrayGetValueAtIndex(attachmentsArray, i));
+        CFDictionarySetValue(attachments, PAL::kCMSampleAttachmentKey_DisplayImmediately, kCFBooleanTrue);
+    }
+}
+
+void LocalSampleBufferDisplayLayer::enqueue(CVPixelBufferRef pixelBuffer, MediaTime presentationTime)
+{
     ASSERT(!isMainThread());
-    // FIXME: Local playback of RemoteVideoFrameProxy is not implemented.
-    if (!is<MediaSampleAVFObjC>(sample))
-        return;
 
-    auto sampleToEnqueue = sample.platformSample().sample.cmSampleBuffer;
+    auto sampleBuffer = createVideoSampleBuffer(pixelBuffer, PAL::toCMTime(presentationTime));
     auto now = MediaTime::createWithDouble(MonotonicTime::now().secondsSinceEpoch().value() + rendererLatency);
+    if (m_renderPolicy == RenderPolicy::Immediately || now >= presentationTime)
+        setSampleBufferAsDisplayImmediately(sampleBuffer.get());
 
-    // If needed, we set the sample buffer to kCMSampleAttachmentKey_DisplayImmediately as a workaround to rdar://problem/49274083.
-    // We clone the sample buffer as modifying the attachments of a sample buffer used elsewhere (encoding e.g.) may not be thread safe.
-    RetainPtr<CMSampleBufferRef> newSampleBuffer;
-    if (m_renderPolicy == RenderPolicy::Immediately || now >= sample.presentationTime()) {
-        newSampleBuffer = MediaSampleAVFObjC::cloneSampleBufferAndSetAsDisplayImmediately(sampleToEnqueue);
-        sampleToEnqueue = newSampleBuffer.get();
-    }
+    [m_sampleBufferDisplayLayer enqueueSampleBuffer:sampleBuffer.get()];
 
-    [m_sampleBufferDisplayLayer enqueueSampleBuffer:sampleToEnqueue];
-
 #if !RELEASE_LOG_DISABLED
     constexpr size_t frameCountPerLog = 1800; // log every minute at 30 fps
     if (!(m_frameRateMonitor.frameCount() % frameCountPerLog)) {

Modified: trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp (291420 => 291421)


--- trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp	2022-03-17 18:08:53 UTC (rev 291421)
@@ -33,10 +33,10 @@
 #include "CVUtilities.h"
 #include "Logging.h"
 #include "MediaRecorderPrivateWriterCocoa.h"
-#include "MediaSampleAVFObjC.h"
 #include "MediaStreamPrivate.h"
 #include "RealtimeIncomingVideoSourceCocoa.h"
 #include "SharedBuffer.h"
+#include "VideoFrameCV.h"
 #include "WebAudioBufferList.h"
 
 #include "CoreVideoSoftLink.h"
@@ -83,40 +83,19 @@
     callback(String(m_writer->mimeType()), m_writer->audioBitRate(), m_writer->videoBitRate());
 }
 
-void MediaRecorderPrivateAVFImpl::videoSampleAvailable(MediaSample& sampleBuffer, VideoFrameTimeMetadata)
+void MediaRecorderPrivateAVFImpl::videoSampleAvailable(MediaSample& sample, VideoFrameTimeMetadata)
 {
     if (shouldMuteVideo()) {
         if (!m_blackFrame) {
-            m_blackFrameDescription = PAL::CMSampleBufferGetFormatDescription(sampleBuffer.platformSample().sample.cmSampleBuffer);
-            auto dimensions = PAL::CMVideoFormatDescriptionGetDimensions(m_blackFrameDescription.get());
-            m_blackFrame = createBlackPixelBuffer(dimensions.width, dimensions.height);
-
-            CMVideoFormatDescriptionRef formatDescription = nullptr;
-            auto status = PAL::CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, m_blackFrame.get(), &formatDescription);
-            if (status != noErr) {
-                RELEASE_LOG_ERROR(Media, "MediaRecorderPrivateAVFImpl::videoSampleAvailable ::unable to create a black frame description: %d", static_cast<int>(status));
-                m_blackFrame = nullptr;
-                return;
-            }
-            m_blackFrameDescription = adoptCF(formatDescription);
+            auto size = sample.presentationSize();
+            m_blackFrame = VideoFrameCV::create(sample.presentationTime(), sample.videoMirrored(), sample.videoRotation(), createBlackPixelBuffer(size.width(), size.height()));
         }
-
-        CMSampleBufferRef sample = nullptr;
-        CMSampleTimingInfo timingInfo { PAL::kCMTimeInvalid, PAL::toCMTime(sampleBuffer.presentationTime()), PAL::toCMTime(sampleBuffer.decodeTime()) };
-        auto status = PAL::CMSampleBufferCreateReadyWithImageBuffer(kCFAllocatorDefault, (CVImageBufferRef)m_blackFrame.get(), m_blackFrameDescription.get(), &timingInfo, &sample);
-
-        if (status != noErr) {
-            RELEASE_LOG_ERROR(MediaStream, "MediaRecorderPrivateAVFImpl::videoSampleAvailable - unable to create a black frame: %d", static_cast<int>(status));
-            return;
-        }
-        auto newSample = adoptCF(sample);
-        m_writer->appendVideoSampleBuffer(MediaSampleAVFObjC::create(newSample.get(), sampleBuffer.videoRotation(), sampleBuffer.videoMirrored()));
+        m_writer->appendVideoFrame(*m_blackFrame);
         return;
     }
 
     m_blackFrame = nullptr;
-    m_blackFrameDescription = nullptr;
-    m_writer->appendVideoSampleBuffer(sampleBuffer);
+    m_writer->appendVideoFrame(VideoFrameCV::create(sample.presentationTime(), sample.videoMirrored(), sample.videoRotation(), sample.pixelBuffer()));
 }
 
 void MediaRecorderPrivateAVFImpl::audioSamplesAvailable(const MediaTime& mediaTime, const PlatformAudioData& data, const AudioStreamDescription& description, size_t sampleCount)

Modified: trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.h (291420 => 291421)


--- trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.h	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.h	2022-03-17 18:08:53 UTC (rev 291421)
@@ -60,8 +60,7 @@
     void resumeRecording(CompletionHandler<void()>&&) final;
 
     Ref<MediaRecorderPrivateWriter> m_writer;
-    RetainPtr<CVPixelBufferRef> m_blackFrame;
-    RetainPtr<CMFormatDescriptionRef> m_blackFrameDescription;
+    RefPtr<VideoFrame> m_blackFrame;
     CAAudioStreamDescription m_description;
     std::unique_ptr<WebAudioBufferList> m_audioBuffer;
 };

Modified: trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h (291420 => 291421)


--- trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h	2022-03-17 18:08:53 UTC (rev 291421)
@@ -56,9 +56,9 @@
 
 class AudioSampleBufferCompressor;
 class AudioStreamDescription;
-class MediaSample;
 class MediaStreamTrackPrivate;
 class PlatformAudioData;
+class VideoFrame;
 class VideoSampleBufferCompressor;
 struct MediaRecorderPrivateOptions;
 
@@ -67,7 +67,7 @@
     static RefPtr<MediaRecorderPrivateWriter> create(bool hasAudio, bool hasVideo, const MediaRecorderPrivateOptions&);
     ~MediaRecorderPrivateWriter();
 
-    void appendVideoSampleBuffer(MediaSample&);
+    void appendVideoFrame(VideoFrame&);
     void appendAudioSampleBuffer(const PlatformAudioData&, const AudioStreamDescription&, const WTF::MediaTime&, size_t);
     void stopRecording();
     void fetchData(CompletionHandler<void(RefPtr<FragmentedSharedBuffer>&&, double)>&&);

Modified: trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm (291420 => 291421)


--- trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm	2022-03-17 18:08:53 UTC (rev 291421)
@@ -35,6 +35,7 @@
 #include "MediaRecorderPrivateOptions.h"
 #include "MediaStreamTrackPrivate.h"
 #include "MediaUtilities.h"
+#include "VideoFrame.h"
 #include "VideoSampleBufferCompressor.h"
 #include "WebAudioBufferList.h"
 #include <AVFoundation/AVAssetWriter.h>
@@ -380,42 +381,21 @@
         [m_videoAssetWriterInput requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:block.get()];
 }
 
-static inline RetainPtr<CMSampleBufferRef> copySampleBufferWithCurrentTimeStamp(CMSampleBufferRef originalBuffer, CMTime startTime)
+void MediaRecorderPrivateWriter::appendVideoFrame(VideoFrame& frame)
 {
-    CMItemCount count = 0;
-    PAL::CMSampleBufferGetSampleTimingInfoArray(originalBuffer, 0, nil, &count);
-
-    Vector<CMSampleTimingInfo> timeInfo(count);
-    PAL::CMSampleBufferGetSampleTimingInfoArray(originalBuffer, count, timeInfo.data(), &count);
-
-    for (auto i = 0; i < count; i++) {
-        timeInfo[i].decodeTimeStamp = PAL::kCMTimeInvalid;
-        timeInfo[i].presentationTimeStamp = startTime;
-    }
-
-    CMSampleBufferRef newBuffer = nullptr;
-    if (auto error = PAL::CMSampleBufferCreateCopyWithNewTiming(kCFAllocatorDefault, originalBuffer, count, timeInfo.data(), &newBuffer)) {
-        RELEASE_LOG_ERROR(MediaStream, "MediaRecorderPrivateWriter CMSampleBufferCreateCopyWithNewTiming failed with %d", error);
-        return nullptr;
-    }
-    return adoptCF(newBuffer);
-}
-
-void MediaRecorderPrivateWriter::appendVideoSampleBuffer(MediaSample& sample)
-{
     if (!m_firstVideoFrame) {
         m_firstVideoFrame = true;
         m_resumedVideoTime = PAL::CMClockGetTime(PAL::CMClockGetHostTimeClock());
-        if (sample.videoRotation() != MediaSample::VideoRotation::None || sample.videoMirrored()) {
-            m_videoTransform = CGAffineTransformMakeRotation(static_cast<int>(sample.videoRotation()) * M_PI / 180);
-            if (sample.videoMirrored())
+        if (frame.videoRotation() != MediaSample::VideoRotation::None || frame.videoMirrored()) {
+            m_videoTransform = CGAffineTransformMakeRotation(static_cast<int>(frame.videoRotation()) * M_PI / 180);
+            if (frame.videoMirrored())
                 m_videoTransform = CGAffineTransformScale(*m_videoTransform, -1, 1);
         }
     }
 
-    auto sampleTime = PAL::CMTimeSubtract(PAL::CMClockGetTime(PAL::CMClockGetHostTimeClock()), m_resumedVideoTime);
-    sampleTime = PAL::CMTimeAdd(sampleTime, m_currentVideoDuration);
-    if (auto bufferWithCurrentTime = copySampleBufferWithCurrentTimeStamp(sample.platformSample().sample.cmSampleBuffer, sampleTime))
+    auto frameTime = PAL::CMTimeSubtract(PAL::CMClockGetTime(PAL::CMClockGetHostTimeClock()), m_resumedVideoTime);
+    frameTime = PAL::CMTimeAdd(frameTime, m_currentVideoDuration);
+    if (auto bufferWithCurrentTime = createVideoSampleBuffer(frame.pixelBuffer(), frameTime))
         m_videoCompressor->addSampleBuffer(bufferWithCurrentTime.get());
 }
 

Modified: trunk/Source/WebKit/ChangeLog (291420 => 291421)


--- trunk/Source/WebKit/ChangeLog	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebKit/ChangeLog	2022-03-17 18:08:53 UTC (rev 291421)
@@ -1,3 +1,15 @@
+2022-03-17  Youenn Fablet  <[email protected]>
+
+        Make SharedVideoFrameReader use VideoFrameCV instead of MediaSample
+        https://bugs.webkit.org/show_bug.cgi?id=237596
+
+        Reviewed by Eric Carlson.
+
+        * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
+        * GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp:
+        * WebProcess/GPU/webrtc/SharedVideoFrame.cpp:
+        * WebProcess/GPU/webrtc/SharedVideoFrame.h:
+
 2022-03-17  Ben Nham  <[email protected]>
 
         Allow push preference to be set programatically

Modified: trunk/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp (291420 => 291421)


--- trunk/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp	2022-03-17 18:08:53 UTC (rev 291421)
@@ -89,8 +89,8 @@
 
 void RemoteMediaRecorder::videoSampleAvailable(SharedVideoFrame&& sharedVideoFrame)
 {
-    if (auto sample = m_sharedVideoFrameReader.read(WTFMove(sharedVideoFrame)))
-        m_writer->appendVideoSampleBuffer(*sample);
+    if (auto frame = m_sharedVideoFrameReader.read(WTFMove(sharedVideoFrame)))
+        m_writer->appendVideoFrame(*frame);
 }
 
 void RemoteMediaRecorder::fetchData(CompletionHandler<void(IPC::DataReference&&, double)>&& completionHandler)

Modified: trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp (291420 => 291421)


--- trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp	2022-03-17 18:08:53 UTC (rev 291421)
@@ -119,12 +119,8 @@
 
 void RemoteSampleBufferDisplayLayer::enqueue(SharedVideoFrame&& frame)
 {
-    auto sample = m_sharedVideoFrameReader.read(WTFMove(frame));
-    if (!sample)
-        return;
-
-    MediaSampleAVFObjC::setAsDisplayImmediately(*sample);
-    m_sampleBufferDisplayLayer->enqueueSample(*sample);
+    if (auto videoFrame = m_sharedVideoFrameReader.read(WTFMove(frame)))
+        m_sampleBufferDisplayLayer->enqueue(videoFrame->pixelBuffer(), videoFrame->presentationTime());
 }
 
 void RemoteSampleBufferDisplayLayer::clearEnqueuedSamples()

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp (291420 => 291421)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp	2022-03-17 18:08:53 UTC (rev 291421)
@@ -33,8 +33,8 @@
 #include "RemoteVideoFrameProxy.h"
 #include <WebCore/CVUtilities.h>
 #include <WebCore/IOSurface.h>
-#include <WebCore/MediaSampleAVFObjC.h>
 #include <WebCore/SharedVideoFrameInfo.h>
+#include <WebCore/VideoFrameCV.h>
 #include <WebCore/VideoFrameLibWebRTC.h>
 #include <wtf/Scope.h>
 
@@ -229,13 +229,13 @@
     });
 }
 
-RefPtr<MediaSample> SharedVideoFrameReader::read(SharedVideoFrame&& sharedVideoFrame)
+RefPtr<VideoFrame> SharedVideoFrameReader::read(SharedVideoFrame&& sharedVideoFrame)
 {
     auto pixelBuffer = readBuffer(WTFMove(sharedVideoFrame.buffer));
     if (!pixelBuffer)
         return nullptr;
 
-    return MediaSampleAVFObjC::createFromPixelBuffer(WTFMove(pixelBuffer), sharedVideoFrame.rotation, sharedVideoFrame.mirrored, sharedVideoFrame.time);
+    return VideoFrameCV::create(sharedVideoFrame.time, sharedVideoFrame.mirrored, sharedVideoFrame.rotation, WTFMove(pixelBuffer));
 }
 
 CVPixelBufferPoolRef SharedVideoFrameReader::pixelBufferPool(const SharedVideoFrameInfo& info)

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h (291420 => 291421)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h	2022-03-17 17:44:42 UTC (rev 291420)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h	2022-03-17 18:08:53 UTC (rev 291421)
@@ -30,8 +30,8 @@
 #include "IPCSemaphore.h"
 #include "RemoteVideoFrameIdentifier.h"
 #include "SharedMemory.h"
-#include <WebCore/MediaSample.h>
 #include <WebCore/ProcessIdentity.h>
+#include <WebCore/VideoFrame.h>
 #include <wtf/RefPtr.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/UniqueRef.h>
@@ -101,7 +101,7 @@
     void setSemaphore(IPC::Semaphore&& semaphore) { m_semaphore = WTFMove(semaphore); }
     bool setSharedMemory(const SharedMemory::IPCHandle&);
 
-    RefPtr<WebCore::MediaSample> read(SharedVideoFrame&&);
+    RefPtr<WebCore::VideoFrame> read(SharedVideoFrame&&);
     RetainPtr<CVPixelBufferRef> readBuffer(SharedVideoFrame::Buffer&&);
 
 private:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to