Changeset 291611 in webkit
- Timestamp:
- Mar 22, 2022, 3:36:52 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 91 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp (modified) (1 diff)
-
WebCore/html/canvas/WebGLRenderingContextBase.cpp (modified) (1 diff)
-
WebCore/platform/MediaSample.h (modified) (1 diff)
-
WebCore/platform/VideoFrame.cpp (modified) (2 diffs)
-
WebCore/platform/VideoFrame.h (modified) (1 diff)
-
WebCore/platform/graphics/avfoundation/SampleBufferDisplayLayer.h (modified) (4 diffs)
-
WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h (modified) (5 diffs)
-
WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm (modified) (12 diffs)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (modified) (1 diff)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (modified) (1 diff)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (modified) (7 diffs)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (modified) (22 diffs)
-
WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h (modified) (1 diff)
-
WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm (modified) (1 diff)
-
WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm (modified) (1 diff)
-
WebCore/platform/graphics/cv/ImageRotationSessionVT.h (modified) (2 diffs)
-
WebCore/platform/graphics/cv/ImageRotationSessionVT.mm (modified) (2 diffs)
-
WebCore/platform/graphics/cv/ImageTransferSessionVT.h (modified) (1 diff)
-
WebCore/platform/graphics/cv/ImageTransferSessionVT.mm (modified) (4 diffs)
-
WebCore/platform/graphics/cv/VideoFrameCV.h (modified) (6 diffs)
-
WebCore/platform/graphics/cv/VideoFrameCV.mm (modified) (5 diffs)
-
WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp (modified) (3 diffs)
-
WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.h (modified) (1 diff)
-
WebCore/platform/mediarecorder/MediaRecorderPrivate.h (modified) (3 diffs)
-
WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp (modified) (2 diffs)
-
WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.h (modified) (1 diff)
-
WebCore/platform/mediarecorder/MediaRecorderPrivateGStreamer.h (modified) (1 diff)
-
WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp (modified) (1 diff)
-
WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h (modified) (1 diff)
-
WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h (modified) (1 diff)
-
WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm (modified) (5 diffs)
-
WebCore/platform/mediastream/RealtimeMediaSource.cpp (modified) (3 diffs)
-
WebCore/platform/mediastream/RealtimeMediaSource.h (modified) (5 diffs)
-
WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp (modified) (3 diffs)
-
WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h (modified) (2 diffs)
-
WebCore/platform/mediastream/RealtimeVideoCaptureSource.cpp (modified) (2 diffs)
-
WebCore/platform/mediastream/RealtimeVideoCaptureSource.h (modified) (3 diffs)
-
WebCore/platform/mediastream/RealtimeVideoSource.cpp (modified) (8 diffs)
-
WebCore/platform/mediastream/RealtimeVideoSource.h (modified) (2 diffs)
-
WebCore/platform/mediastream/VideoPreset.h (modified) (1 diff)
-
WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.cpp (modified) (2 diffs)
-
WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.h (modified) (2 diffs)
-
WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp (modified) (7 diffs)
-
WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp (modified) (1 diff)
-
WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp (modified) (4 diffs)
-
WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.h (modified) (2 diffs)
-
WebCore/platform/mediastream/gstreamer/RealtimeIncomingVideoSourceGStreamer.cpp (modified) (1 diff)
-
WebCore/platform/mediastream/ios/ReplayKitCaptureSource.mm (modified) (1 diff)
-
WebCore/platform/mediastream/libwebrtc/VideoFrameLibWebRTC.cpp (modified) (1 diff)
-
WebCore/platform/mediastream/libwebrtc/VideoFrameLibWebRTC.h (modified) (2 diffs)
-
WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeIncomingVideoSourceLibWebRTC.cpp (modified) (1 diff)
-
WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.cpp (modified) (1 diff)
-
WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.h (modified) (1 diff)
-
WebCore/platform/mediastream/mac/AVVideoCaptureSource.h (modified) (4 diffs)
-
WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (modified) (4 diffs)
-
WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm (modified) (1 diff)
-
WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h (modified) (1 diff)
-
WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm (modified) (3 diffs)
-
WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp (modified) (4 diffs)
-
WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h (modified) (1 diff)
-
WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.mm (modified) (1 diff)
-
WebCore/platform/mock/MockRealtimeVideoSource.cpp (modified) (2 diffs)
-
WebCore/platform/mock/MockRealtimeVideoSource.h (modified) (2 diffs)
-
WebCore/testing/Internals.cpp (modified) (4 diffs)
-
WebCore/testing/Internals.h (modified) (2 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp (modified) (1 diff)
-
WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.cpp (modified) (2 diffs)
-
WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.h (modified) (3 diffs)
-
WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm (modified) (2 diffs)
-
WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp (modified) (1 diff)
-
WebKit/GPUProcess/webrtc/RemoteMediaRecorder.h (modified) (1 diff)
-
WebKit/GPUProcess/webrtc/RemoteMediaRecorder.messages.in (modified) (1 diff)
-
WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp (modified) (2 diffs)
-
WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.h (modified) (1 diff)
-
WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.messages.in (modified) (1 diff)
-
WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp (modified) (7 diffs)
-
WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.cpp (modified) (2 diffs)
-
WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.h (modified) (5 diffs)
-
WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp (modified) (2 diffs)
-
WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp (modified) (1 diff)
-
WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h (modified) (1 diff)
-
WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp (modified) (3 diffs)
-
WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.h (modified) (1 diff)
-
WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp (modified) (1 diff)
-
WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h (modified) (3 diffs)
-
WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp (modified) (2 diffs)
-
WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.h (modified) (1 diff)
-
WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.messages.in (modified) (1 diff)
-
WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r291610 r291611 1 2022-03-22 Youenn Fablet <youenn@apple.com> 2 3 Move RealtimeMediaSource::VideoSampleObserver::videoSampleAvailable to VideoFrame 4 https://bugs.webkit.org/show_bug.cgi?id=237884 5 6 Reviewed by Eric Carlson. 7 8 Refactoring to do the following: 9 - Renaming of VideoSampleObserver to VideoFrameObserver, videoSampleAvailable to videoFrameAvailable... 10 - videoFrameAvailable takes a VideoFrame instead of a MediaSample 11 - Use VideoFrame::rotation and VideoFrame::isMirrored. 12 - Use VideoFrame::Rotation instead of MediaSample::VideoRotation 13 Update code according this renaming. 14 Move from using MediaSample to VideoFrame where it makes sense. 15 16 Prepare for removal of MediaSample as parent class of VideoFrame. 17 18 * Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp: 19 * html/canvas/WebGLRenderingContextBase.cpp: 20 * platform/MediaSample.h: 21 * platform/VideoFrame.cpp: 22 * platform/VideoFrame.h: 23 * platform/graphics/avfoundation/SampleBufferDisplayLayer.h: 24 * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h: 25 * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm: 26 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 27 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: 28 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: 29 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: 30 * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h: 31 * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: 32 * platform/graphics/cocoa/GraphicsContextGLCocoa.mm: 33 * platform/graphics/cv/ImageRotationSessionVT.h: 34 * platform/graphics/cv/ImageRotationSessionVT.mm: 35 * platform/graphics/cv/ImageTransferSessionVT.h: 36 * platform/graphics/cv/ImageTransferSessionVT.mm: 37 * platform/graphics/cv/VideoFrameCV.h: 38 * platform/graphics/cv/VideoFrameCV.mm: 39 * platform/graphics/gstreamer/VideoFrameGStreamer.cpp: 40 * platform/graphics/gstreamer/VideoFrameGStreamer.h: 41 * platform/mediarecorder/MediaRecorderPrivate.h: 42 * platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp: 43 * platform/mediarecorder/MediaRecorderPrivateAVFImpl.h: 44 * platform/mediarecorder/MediaRecorderPrivateMock.cpp: 45 * platform/mediarecorder/MediaRecorderPrivateMock.h: 46 * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h: 47 * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm: 48 * platform/mediastream/RealtimeMediaSource.cpp: 49 * platform/mediastream/RealtimeMediaSource.h: 50 * platform/mediastream/RealtimeOutgoingVideoSource.cpp: 51 * platform/mediastream/RealtimeOutgoingVideoSource.h: 52 * platform/mediastream/RealtimeVideoCaptureSource.cpp: 53 * platform/mediastream/RealtimeVideoCaptureSource.h: 54 * platform/mediastream/RealtimeVideoSource.cpp: 55 * platform/mediastream/RealtimeVideoSource.h: 56 * platform/mediastream/VideoPreset.h: 57 * platform/mediastream/cocoa/DisplayCaptureSourceCocoa.cpp: 58 * platform/mediastream/cocoa/DisplayCaptureSourceCocoa.h: 59 * platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp: 60 * platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp: 61 * platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.h: 62 * platform/mediastream/ios/ReplayKitCaptureSource.mm: 63 * platform/mediastream/libwebrtc/VideoFrameLibWebRTC.cpp: 64 * platform/mediastream/libwebrtc/VideoFrameLibWebRTC.h: 65 * platform/mediastream/libwebrtc/gstreamer/RealtimeIncomingVideoSourceLibWebRTC.cpp: 66 * platform/mediastream/libwebrtc/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.cpp: 67 * platform/mediastream/libwebrtc/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.h: 68 * platform/mediastream/mac/AVVideoCaptureSource.h: 69 * platform/mediastream/mac/AVVideoCaptureSource.mm: 70 * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: 71 * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h: 72 * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm: 73 * platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp: 74 * platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h: 75 * platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.mm: 76 * platform/mock/MockRealtimeVideoSource.cpp: 77 * platform/mock/MockRealtimeVideoSource.h: 78 * testing/Internals.cpp: 79 * testing/Internals.h: 80 1 81 2022-03-22 Zan Dobersek <zdobersek@igalia.com> 2 82 -
trunk/Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp
r291468 r291611 200 200 VideoFrameTimeMetadata metadata; 201 201 metadata.captureTime = MonotonicTime::now().secondsSinceEpoch(); 202 video SampleAvailable(*videoFrame, metadata);202 videoFrameAvailable(*videoFrame, metadata); 203 203 } 204 204 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
r291477 r291611 136 136 #if ENABLE(OFFSCREEN_CANVAS) 137 137 #include "OffscreenCanvas.h" 138 #endif139 140 #if ENABLE(MEDIA_STREAM)141 #include "MediaSample.h"142 138 #endif 143 139 -
trunk/Source/WebCore/platform/MediaSample.h
r291216 r291611 118 118 Left = 270, 119 119 }; 120 virtual VideoRotation videoRotation() const { return VideoRotation::None; }121 virtual bool videoMirrored() const { return false; }122 virtual uint32_t videoPixelFormat() const { return 0; }120 virtual VideoRotation rotation() const { return VideoRotation::None; } 121 virtual bool isMirrored() const { return false; } 122 virtual uint32_t pixelFormat() const { return 0; } 123 123 #if PLATFORM(COCOA) 124 124 virtual CVPixelBufferRef pixelBuffer() const { return nullptr; }; -
trunk/Source/WebCore/platform/VideoFrame.cpp
r291078 r291611 49 49 } 50 50 51 MediaSample::VideoRotation VideoFrame::videoRotation() const51 VideoFrame::Rotation VideoFrame::rotation() const 52 52 { 53 53 return m_rotation; 54 54 } 55 55 56 bool VideoFrame:: videoMirrored() const56 bool VideoFrame::isMirrored() const 57 57 { 58 58 return m_isMirrored; … … 131 131 return nullptr; 132 132 133 return VideoFrameCV::create(presentationTime(), videoMirrored(), videoRotation(), buffer);133 return VideoFrameCV::create(presentationTime(), isMirrored(), rotation(), buffer); 134 134 } 135 135 #endif -
trunk/Source/WebCore/platform/VideoFrame.h
r291078 r291611 43 43 WEBCORE_EXPORT ~VideoFrame(); 44 44 45 using Rotation = MediaSample::VideoRotation; 46 45 47 // WebCore::MediaSample overrides. 46 48 WEBCORE_EXPORT MediaTime presentationTime() const final; 47 WEBCORE_EXPORT VideoRotation videoRotation() const final;48 WEBCORE_EXPORT bool videoMirrored() const final;49 WEBCORE_EXPORT Rotation rotation() const final; 50 WEBCORE_EXPORT bool isMirrored() const final; 49 51 // FIXME: When VideoFrame is not MediaSample, these will not be needed. 50 52 WEBCORE_EXPORT WebCore::PlatformSample platformSample() const final; -
trunk/Source/WebCore/platform/graphics/avfoundation/SampleBufferDisplayLayer.h
r284093 r291611 26 26 #pragma once 27 27 28 #include "MediaSample.h"29 28 #include "PlatformLayer.h" 29 #include "VideoFrame.h" 30 30 #include <wtf/CompletionHandler.h> 31 31 #include <wtf/WeakPtr.h> … … 37 37 namespace WebCore { 38 38 class IntSize; 39 class MediaSample;39 class VideoFrame; 40 40 41 41 class SampleBufferDisplayLayer { … … 62 62 63 63 virtual void updateAffineTransform(CGAffineTransform) = 0; 64 virtual void updateBoundsAndPosition(CGRect, MediaSample::VideoRotation) = 0;64 virtual void updateBoundsAndPosition(CGRect, VideoFrame::Rotation) = 0; 65 65 66 66 virtual void flush() = 0; … … 70 70 virtual void pause() = 0; 71 71 72 virtual void enqueue Sample(MediaSample&) = 0;73 virtual void clear EnqueuedSamples() = 0;72 virtual void enqueueVideoFrame(VideoFrame&) = 0; 73 virtual void clearVideoFrames() = 0; 74 74 75 75 virtual PlatformLayer* rootLayer() = 0; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.h
r291421 r291611 48 48 ~LocalSampleBufferDisplayLayer(); 49 49 50 void enqueueBuffer(CVPixelBufferRef, MediaTime); 51 50 52 // API used by WebAVSampleBufferStatusChangeListener 51 53 void layerStatusDidChange(); … … 57 59 PlatformLayer* displayLayer(); 58 60 59 PlatformLayer* rootLayer() final;60 61 61 enum class ShouldUpdateRootLayer { No, Yes }; 62 void updateRootLayerBoundsAndPosition(CGRect, MediaSample::VideoRotation, ShouldUpdateRootLayer);62 void updateRootLayerBoundsAndPosition(CGRect, VideoFrame::Rotation, ShouldUpdateRootLayer); 63 63 void updateRootLayerAffineTransform(CGAffineTransform); 64 64 65 // SampleBufferDisplayLayer. 66 PlatformLayer* rootLayer() final; 65 67 void initialize(bool hideRootLayer, IntSize, CompletionHandler<void(bool didSucceed)>&&) final; 66 68 #if !RELEASE_LOG_DISABLED … … 72 74 73 75 void updateAffineTransform(CGAffineTransform) final; 74 void updateBoundsAndPosition(CGRect, MediaSample::VideoRotation) final;76 void updateBoundsAndPosition(CGRect, VideoFrame::Rotation) final; 75 77 76 78 void flush() final; … … 80 82 void pause() final; 81 83 82 void enqueue(CVPixelBufferRef, MediaTime); 83 void enqueueSample(MediaSample&) final; 84 void clearEnqueuedSamples() final; 84 void enqueueVideoFrame(VideoFrame&) final; 85 void clearVideoFrames() final; 85 86 void setRenderPolicy(RenderPolicy) final; 86 87 87 88 private: 88 void removeOldSamplesFromPendingQueue(); 89 void addSampleToPendingQueue(MediaSample&); 89 90 void removeOldVideoFramesFromPendingQueue(); 91 void addVideoFrameToPendingQueue(Ref<VideoFrame>&&); 90 92 void requestNotificationWhenReadyForVideoData(); 91 void enqueueSampleBuffer(MediaSample&); 92 void setRootLayerBoundsAndPositions(CGRect, MediaSample::VideoRotation); 93 void setRootLayerBoundsAndPositions(CGRect, VideoFrame::Rotation); 93 94 94 95 #if !RELEASE_LOG_DISABLED … … 105 106 106 107 // Only accessed through m_processingQueue or if m_processingQueue is null. 107 using PendingSampleQueue = Deque<Ref< MediaSample>>;108 PendingSampleQueue m_pendingVideo SampleQueue;108 using PendingSampleQueue = Deque<Ref<VideoFrame>>; 109 PendingSampleQueue m_pendingVideoFrameQueue; 109 110 110 111 bool m_paused { false }; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm
r291421 r291611 32 32 #import "IntSize.h" 33 33 #import "Logging.h" 34 #import "MediaSampleAVFObjC.h"35 34 #import "MediaUtilities.h" 36 35 … … 43 42 #import <wtf/cf/TypeCastsCF.h> 44 43 44 #import <pal/avfoundation/MediaTimeAVFoundation.h> 45 45 #import <pal/spi/cocoa/AVFoundationSPI.h> 46 46 #import <pal/cf/CoreMediaSoftLink.h> 47 47 #import <pal/cocoa/AVFoundationSoftLink.h> 48 48 … … 199 199 [m_statusChangeListener stop]; 200 200 201 m_pendingVideo SampleQueue.clear();201 m_pendingVideoFrameQueue.clear(); 202 202 203 203 [m_sampleBufferDisplayLayer stopRequestingMediaData]; … … 266 266 } 267 267 268 void LocalSampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, MediaSample::VideoRotation rotation)268 void LocalSampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, VideoFrame::Rotation rotation) 269 269 { 270 270 updateRootLayerBoundsAndPosition(bounds, rotation, ShouldUpdateRootLayer::No); 271 271 } 272 272 273 void LocalSampleBufferDisplayLayer::setRootLayerBoundsAndPositions(CGRect bounds, MediaSample::VideoRotation rotation)273 void LocalSampleBufferDisplayLayer::setRootLayerBoundsAndPositions(CGRect bounds, VideoFrame::Rotation rotation) 274 274 { 275 275 CGPoint position = { bounds.size.width / 2, bounds.size.height / 2}; 276 if (rotation == MediaSample::VideoRotation::Right || rotation == MediaSample::VideoRotation::Left)276 if (rotation == VideoFrame::Rotation::Right || rotation == VideoFrame::Rotation::Left) 277 277 std::swap(bounds.size.width, bounds.size.height); 278 278 … … 281 281 } 282 282 283 void LocalSampleBufferDisplayLayer::updateRootLayerBoundsAndPosition(CGRect bounds, MediaSample::VideoRotation rotation, ShouldUpdateRootLayer shouldUpdateRootLayer)283 void LocalSampleBufferDisplayLayer::updateRootLayerBoundsAndPosition(CGRect bounds, VideoFrame::Rotation rotation, ShouldUpdateRootLayer shouldUpdateRootLayer) 284 284 { 285 285 runWithoutAnimations([&] { … … 287 287 setRootLayerBoundsAndPositions(bounds, rotation); 288 288 289 if (rotation == MediaSample::VideoRotation::Right || rotation == MediaSample::VideoRotation::Left)289 if (rotation == VideoFrame::Rotation::Right || rotation == VideoFrame::Rotation::Left) 290 290 std::swap(bounds.size.width, bounds.size.height); 291 291 … … 313 313 static const double rendererLatency = 0.02; 314 314 315 void LocalSampleBufferDisplayLayer::enqueue Sample(MediaSample& sample)315 void LocalSampleBufferDisplayLayer::enqueueVideoFrame(VideoFrame& videoFrame) 316 316 { 317 317 if (m_paused) { … … 322 322 } 323 323 324 m_processingQueue->dispatch([this, sample = Ref { sample }]{324 m_processingQueue->dispatch([this, videoFrame = Ref { videoFrame }]() mutable { 325 325 if (![m_sampleBufferDisplayLayer isReadyForMoreMediaData]) { 326 326 RELEASE_LOG(WebRTC, "LocalSampleBufferDisplayLayer::enqueueSample (%{public}s) not ready for more media data", m_logIdentifier.utf8().data()); 327 add SampleToPendingQueue(sample);327 addVideoFrameToPendingQueue(WTFMove(videoFrame)); 328 328 requestNotificationWhenReadyForVideoData(); 329 329 return; 330 330 } 331 enqueueSampleBuffer(sample); 332 }); 333 } 334 335 void LocalSampleBufferDisplayLayer::enqueueSampleBuffer(MediaSample& sample) 336 { 337 enqueue(sample.pixelBuffer(), sample.presentationTime()); 331 enqueueBuffer(videoFrame->pixelBuffer(), videoFrame->presentationTime()); 332 }); 338 333 } 339 334 … … 347 342 } 348 343 349 void LocalSampleBufferDisplayLayer::enqueue (CVPixelBufferRef pixelBuffer, MediaTime presentationTime)344 void LocalSampleBufferDisplayLayer::enqueueBuffer(CVPixelBufferRef pixelBuffer, MediaTime presentationTime) 350 345 { 351 346 ASSERT(!isMainThread()); … … 362 357 if (!(m_frameRateMonitor.frameCount() % frameCountPerLog)) { 363 358 if (auto* metrics = [m_sampleBufferDisplayLayer videoPerformanceMetrics]) 364 RELEASE_LOG(WebRTC, "LocalSampleBufferDisplayLayer (%{public}s) metrics, total=%lu, dropped=%lu, corrupted=%lu, display-composited=%lu, non-display-composited=%lu (pending=%lu)", m_logIdentifier.utf8().data(), metrics.totalNumberOfVideoFrames, metrics.numberOfDroppedVideoFrames, metrics.numberOfCorruptedVideoFrames, metrics.numberOfDisplayCompositedVideoFrames, metrics.numberOfNonDisplayCompositedVideoFrames, m_pendingVideo SampleQueue.size());359 RELEASE_LOG(WebRTC, "LocalSampleBufferDisplayLayer (%{public}s) metrics, total=%lu, dropped=%lu, corrupted=%lu, display-composited=%lu, non-display-composited=%lu (pending=%lu)", m_logIdentifier.utf8().data(), metrics.totalNumberOfVideoFrames, metrics.numberOfDroppedVideoFrames, metrics.numberOfCorruptedVideoFrames, metrics.numberOfDisplayCompositedVideoFrames, metrics.numberOfNonDisplayCompositedVideoFrames, m_pendingVideoFrameQueue.size()); 365 360 } 366 361 m_frameRateMonitor.update(); … … 374 369 if (!weakThis) 375 370 return; 376 RELEASE_LOG(WebRTC, "LocalSampleBufferDisplayLayer::enqueue SampleBuffer(%{public}s) at %f, previous frame was at %f, observed frame rate is %f, delay since last frame is %f ms, frame count is %lu", weakThis->m_logIdentifier.utf8().data(), frameTime, lastFrameTime, observedFrameRate, (frameTime - lastFrameTime) * 1000, frameCount);377 }); 378 } 379 #endif 380 381 void LocalSampleBufferDisplayLayer::removeOld SamplesFromPendingQueue()371 RELEASE_LOG(WebRTC, "LocalSampleBufferDisplayLayer::enqueueVideoFrame (%{public}s) at %f, previous frame was at %f, observed frame rate is %f, delay since last frame is %f ms, frame count is %lu", weakThis->m_logIdentifier.utf8().data(), frameTime, lastFrameTime, observedFrameRate, (frameTime - lastFrameTime) * 1000, frameCount); 372 }); 373 } 374 #endif 375 376 void LocalSampleBufferDisplayLayer::removeOldVideoFramesFromPendingQueue() 382 377 { 383 378 ASSERT(!isMainThread()); 384 379 385 if (m_pendingVideo SampleQueue.isEmpty())380 if (m_pendingVideoFrameQueue.isEmpty()) 386 381 return; 387 382 388 383 if (m_renderPolicy == RenderPolicy::Immediately) { 389 m_pendingVideo SampleQueue.clear();384 m_pendingVideoFrameQueue.clear(); 390 385 return; 391 386 } 392 387 393 388 auto now = MediaTime::createWithDouble(MonotonicTime::now().secondsSinceEpoch().value()); 394 while (!m_pendingVideo SampleQueue.isEmpty()) {395 auto presentationTime = m_pendingVideo SampleQueue.first()->presentationTime();389 while (!m_pendingVideoFrameQueue.isEmpty()) { 390 auto presentationTime = m_pendingVideoFrameQueue.first()->presentationTime(); 396 391 if (presentationTime.isValid() && presentationTime > now) 397 392 break; 398 m_pendingVideo SampleQueue.removeFirst();399 } 400 } 401 402 void LocalSampleBufferDisplayLayer::add SampleToPendingQueue(MediaSample& sample)393 m_pendingVideoFrameQueue.removeFirst(); 394 } 395 } 396 397 void LocalSampleBufferDisplayLayer::addVideoFrameToPendingQueue(Ref<VideoFrame>&& videoFrame) 403 398 { 404 399 ASSERT(!isMainThread()); 405 400 406 removeOld SamplesFromPendingQueue();407 m_pendingVideo SampleQueue.append(sample);408 } 409 410 void LocalSampleBufferDisplayLayer::clear EnqueuedSamples()401 removeOldVideoFramesFromPendingQueue(); 402 m_pendingVideoFrameQueue.append(WTFMove(videoFrame)); 403 } 404 405 void LocalSampleBufferDisplayLayer::clearVideoFrames() 411 406 { 412 407 m_processingQueue->dispatch([this] { 413 m_pendingVideo SampleQueue.clear();408 m_pendingVideoFrameQueue.clear(); 414 409 }); 415 410 } … … 425 420 [m_sampleBufferDisplayLayer stopRequestingMediaData]; 426 421 427 while (!m_pendingVideo SampleQueue.isEmpty()) {422 while (!m_pendingVideoFrameQueue.isEmpty()) { 428 423 if (![m_sampleBufferDisplayLayer isReadyForMoreMediaData]) { 429 424 requestNotificationWhenReadyForVideoData(); 430 425 return; 431 426 } 432 auto sample = m_pendingVideoSampleQueue.takeFirst();433 enqueue SampleBuffer(sample);427 auto videoFrame = m_pendingVideoFrameQueue.takeFirst(); 428 enqueueBuffer(videoFrame->pixelBuffer(), videoFrame->presentationTime()); 434 429 } 435 430 }); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r291326 r291611 2755 2755 if (!m_lastPixelBuffer) 2756 2756 return nullptr; 2757 return VideoFrameCV::create(currentMediaTime(), false, VideoFrame CV::VideoRotation::None, RetainPtr { m_lastPixelBuffer });2757 return VideoFrameCV::create(currentMediaTime(), false, VideoFrame::Rotation::None, RetainPtr { m_lastPixelBuffer }); 2758 2758 } 2759 2759 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
r290590 r291611 748 748 if (!m_lastPixelBuffer) 749 749 return nullptr; 750 return VideoFrameCV::create(currentMediaTime(), false, VideoFrame CV::VideoRotation::None, RetainPtr { m_lastPixelBuffer });750 return VideoFrameCV::create(currentMediaTime(), false, VideoFrame::Rotation::None, RetainPtr { m_lastPixelBuffer }); 751 751 } 752 752 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h
r291269 r291611 29 29 30 30 #include "MediaPlayerPrivate.h" 31 #include "MediaSample.h"32 31 #include "MediaStreamPrivate.h" 33 32 #include "SampleBufferDisplayLayer.h" 33 #include "VideoFrame.h" 34 34 #include <wtf/Deque.h> 35 35 #include <wtf/Forward.h> … … 53 53 , private MediaStreamPrivate::Observer 54 54 , public MediaStreamTrackPrivate::Observer 55 , public RealtimeMediaSource::Video SampleObserver55 , public RealtimeMediaSource::VideoFrameObserver 56 56 , public SampleBufferDisplayLayer::Client 57 57 , private LoggerHelper … … 137 137 void flushRenderers(); 138 138 139 void processNewVideo Sample(MediaSample&, VideoFrameTimeMetadata, Seconds);140 void enqueueVideo Sample(MediaSample&);141 void reenqueueCurrentVideo SampleIfNeeded();139 void processNewVideoFrame(VideoFrame&, VideoFrameTimeMetadata, Seconds); 140 void enqueueVideoFrame(VideoFrame&); 141 void reenqueueCurrentVideoFrameIfNeeded(); 142 142 void requestNotificationWhenReadyForVideoData(); 143 143 … … 212 212 void readyStateChanged(MediaStreamTrackPrivate&) override; 213 213 214 // RealtimeMediaSouce::Video SampleObserver215 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) final;214 // RealtimeMediaSouce::VideoFrameObserver 215 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) final; 216 216 217 217 RetainPtr<PlatformLayer> createVideoFullscreenLayer() override; … … 239 239 240 240 RefPtr<NativeImage> cgImage; 241 RefPtr< MediaSample> mediaSample;241 RefPtr<VideoFrame> videoFrame; 242 242 std::unique_ptr<PixelBufferConformerCV> pixelBufferConformer; 243 243 }; … … 261 261 bool m_canEnqueueDisplayLayer { false }; 262 262 // Used on sample thread. 263 MediaSample::VideoRotation m_videoRotation { MediaSample::VideoRotation::None };263 VideoFrame::Rotation m_videoRotation { VideoFrame::Rotation::None }; 264 264 bool m_videoMirrored { false }; 265 265 … … 273 273 RetainPtr<WebRootSampleBufferBoundsChangeListener> m_boundsChangeListener; 274 274 275 Lock m_currentVideo SampleLock;276 RefPtr< MediaSample> m_currentVideoSample WTF_GUARDED_BY_LOCK(m_currentVideoSampleLock);275 Lock m_currentVideoFrameLock; 276 RefPtr<VideoFrame> m_currentVideoFrame WTF_GUARDED_BY_LOCK(m_currentVideoFrameLock); 277 277 278 278 bool m_playing { false }; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
r291269 r291611 34 34 #import "Logging.h" 35 35 #import "MediaPlayer.h" 36 #import "MediaSampleAVFObjC.h"37 36 #import "MediaSessionManagerCocoa.h" 38 37 #import "MediaStreamPrivate.h" … … 161 160 162 161 if (m_activeVideoTrack) 163 m_activeVideoTrack->streamTrack().source().removeVideo SampleObserver(*this);162 m_activeVideoTrack->streamTrack().source().removeVideoFrameObserver(*this); 164 163 165 164 [m_boundsChangeListener invalidate]; … … 230 229 #pragma mark AVSampleBuffer Methods 231 230 232 static inline CGAffineTransform videoTransformationMatrix( MediaSample& sample)233 { 234 auto size = sample.presentationSize();231 static inline CGAffineTransform videoTransformationMatrix(VideoFrame& videoFrame) 232 { 233 auto size = videoFrame.presentationSize(); 235 234 size_t width = static_cast<size_t>(size.width()); 236 235 size_t height = static_cast<size_t>(size.height()); … … 238 237 return CGAffineTransformIdentity; 239 238 240 auto videoTransform = CGAffineTransformMakeRotation(static_cast<int>( sample.videoRotation()) * M_PI / 180);241 if ( sample.videoMirrored())239 auto videoTransform = CGAffineTransformMakeRotation(static_cast<int>(videoFrame.rotation()) * M_PI / 180); 240 if (videoFrame.isMirrored()) 242 241 videoTransform = CGAffineTransformScale(videoTransform, -1, 1); 243 242 … … 245 244 } 246 245 247 void MediaPlayerPrivateMediaStreamAVFObjC::video SampleAvailable(MediaSample& sample, VideoFrameTimeMetadata metadata)246 void MediaPlayerPrivateMediaStreamAVFObjC::videoFrameAvailable(VideoFrame& videoFrame, VideoFrameTimeMetadata metadata) 248 247 { 249 248 auto presentationTime = MonotonicTime::now().secondsSinceEpoch(); 250 processNewVideo Sample(sample, metadata, presentationTime);251 enqueueVideo Sample(sample);252 } 253 254 void MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideo Sample(MediaSample& sample)249 processNewVideoFrame(videoFrame, metadata, presentationTime); 250 enqueueVideoFrame(videoFrame); 251 } 252 253 void MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoFrame(VideoFrame& videoFrame) 255 254 { 256 255 if (!m_isPageVisible || !m_isVisibleInViewPort) … … 264 263 return; 265 264 266 if ( sample.videoRotation() != m_videoRotation || sample.videoMirrored() != m_videoMirrored) {267 m_videoRotation = sample.videoRotation();268 m_videoMirrored = sample.videoMirrored();265 if (videoFrame.rotation() != m_videoRotation || videoFrame.isMirrored() != m_videoMirrored) { 266 m_videoRotation = videoFrame.rotation(); 267 m_videoMirrored = videoFrame.isMirrored(); 269 268 m_shouldUpdateDisplayLayer = true; 270 269 } 271 270 if (m_shouldUpdateDisplayLayer) { 272 m_sampleBufferDisplayLayer->updateAffineTransform(videoTransformationMatrix( sample));271 m_sampleBufferDisplayLayer->updateAffineTransform(videoTransformationMatrix(videoFrame)); 273 272 m_sampleBufferDisplayLayer->updateBoundsAndPosition(m_sampleBufferDisplayLayer->rootLayer().bounds, m_videoRotation); 274 273 m_shouldUpdateDisplayLayer = false; 275 274 } 276 275 277 m_sampleBufferDisplayLayer->enqueue Sample(sample);278 } 279 280 void MediaPlayerPrivateMediaStreamAVFObjC::reenqueueCurrentVideo SampleIfNeeded()281 { 282 if (!m_currentVideo SampleLock.tryLock())283 return; 284 Locker locker { AdoptLock, m_currentVideo SampleLock };285 286 if (!m_currentVideo Sample && !m_imagePainter.mediaSample)287 return; 288 289 enqueueVideo Sample(m_currentVideoSample ? *m_currentVideoSample : *m_imagePainter.mediaSample);290 } 291 292 void MediaPlayerPrivateMediaStreamAVFObjC::processNewVideo Sample(MediaSample& sample, VideoFrameTimeMetadata metadata, Seconds presentationTime)276 m_sampleBufferDisplayLayer->enqueueVideoFrame(videoFrame); 277 } 278 279 void MediaPlayerPrivateMediaStreamAVFObjC::reenqueueCurrentVideoFrameIfNeeded() 280 { 281 if (!m_currentVideoFrameLock.tryLock()) 282 return; 283 Locker locker { AdoptLock, m_currentVideoFrameLock }; 284 285 if (!m_currentVideoFrame && !m_imagePainter.videoFrame) 286 return; 287 288 enqueueVideoFrame(m_currentVideoFrame ? *m_currentVideoFrame : *m_imagePainter.videoFrame); 289 } 290 291 void MediaPlayerPrivateMediaStreamAVFObjC::processNewVideoFrame(VideoFrame& videoFrame, VideoFrameTimeMetadata metadata, Seconds presentationTime) 293 292 { 294 293 if (!isMainThread()) { 295 294 { 296 Locker locker { m_currentVideo SampleLock };297 m_currentVideo Sample = &sample;295 Locker locker { m_currentVideoFrameLock }; 296 m_currentVideoFrame = &videoFrame; 298 297 } 299 298 callOnMainThread([weakThis = WeakPtr { *this }, metadata, presentationTime]() mutable { … … 301 300 return; 302 301 303 RefPtr< MediaSample> sample;302 RefPtr<VideoFrame> videoFrame; 304 303 { 305 Locker locker { weakThis->m_currentVideo SampleLock };306 sample = WTFMove(weakThis->m_currentVideoSample);304 Locker locker { weakThis->m_currentVideoFrameLock }; 305 videoFrame = WTFMove(weakThis->m_currentVideoFrame); 307 306 } 308 if (! sample)307 if (!videoFrame) 309 308 return; 310 309 311 weakThis->processNewVideo Sample(*sample, metadata, presentationTime);310 weakThis->processNewVideoFrame(*videoFrame, metadata, presentationTime); 312 311 }); 313 312 return; … … 317 316 return; 318 317 319 if (!m_imagePainter. mediaSample || m_displayMode != PausedImage) {320 m_imagePainter. mediaSample = &sample;318 if (!m_imagePainter.videoFrame || m_displayMode != PausedImage) { 319 m_imagePainter.videoFrame = &videoFrame; 321 320 m_imagePainter.cgImage = nullptr; 322 321 if (m_readyState < MediaPlayer::ReadyState::HaveEnoughData) … … 325 324 326 325 m_presentationTime = presentationTime; 327 m_videoFrameSize = sample.presentationSize();328 if ( sample.videoRotation() == MediaSample::VideoRotation::Left || sample.videoRotation() == MediaSample::VideoRotation::Right)326 m_videoFrameSize = videoFrame.presentationSize(); 327 if (videoFrame.rotation() == VideoFrame::Rotation::Left || videoFrame.rotation() == VideoFrame::Rotation::Right) 329 328 m_videoFrameSize = { m_videoFrameSize.height(), m_videoFrameSize.width() }; 330 329 m_sampleMetadata = metadata; … … 361 360 if (m_sampleBufferDisplayLayer && m_sampleBufferDisplayLayer->didFail()) { 362 361 flushRenderers(); 363 if (m_imagePainter. mediaSample)364 enqueueVideo Sample(*m_imagePainter.mediaSample);362 if (m_imagePainter.videoFrame) 363 enqueueVideoFrame(*m_imagePainter.videoFrame); 365 364 updateDisplayMode(); 366 365 } … … 570 569 m_sampleBufferDisplayLayer->play(); 571 570 updateDisplayMode(); 572 reenqueueCurrentVideo SampleIfNeeded();571 reenqueueCurrentVideoFrameIfNeeded(); 573 572 574 573 scheduleDeferredTask([this] { … … 642 641 m_isPageVisible = isVisible; 643 642 flushRenderers(); 644 reenqueueCurrentVideo SampleIfNeeded();643 reenqueueCurrentVideoFrameIfNeeded(); 645 644 } 646 645 … … 682 681 return MediaPlayer::ReadyState::HaveNothing; 683 682 684 bool waitingForImage = activeVideoTrack() && !m_imagePainter. mediaSample;683 bool waitingForImage = activeVideoTrack() && !m_imagePainter.videoFrame; 685 684 if (waitingForImage && (!m_haveSeenMetadata || m_waitingForFirstImage)) 686 685 return MediaPlayer::ReadyState::HaveNothing; … … 741 740 if (m_player) 742 741 m_player->renderingModeChanged(); 743 reenqueueCurrentVideo SampleIfNeeded();742 reenqueueCurrentVideoFrameIfNeeded(); 744 743 }); 745 744 } … … 895 894 if (m_sampleBufferDisplayLayer) { 896 895 if (!m_activeVideoTrack) 897 m_sampleBufferDisplayLayer->clear EnqueuedSamples();896 m_sampleBufferDisplayLayer->clearVideoFrames(); 898 897 m_sampleBufferDisplayLayer->updateDisplayMode(hideVideoLayer || m_displayMode < PausedImage, hideRootLayer()); 899 898 } … … 903 902 if (oldVideoTrack != m_activeVideoTrack) { 904 903 if (oldVideoTrack) 905 oldVideoTrack->streamTrack().source().removeVideo SampleObserver(*this);904 oldVideoTrack->streamTrack().source().removeVideoFrameObserver(*this); 906 905 if (m_activeVideoTrack) { 907 906 if (m_sampleBufferDisplayLayer && m_activeVideoTrack->streamTrack().source().isCaptureSource()) 908 907 m_sampleBufferDisplayLayer->setRenderPolicy(SampleBufferDisplayLayer::RenderPolicy::Immediately); 909 m_activeVideoTrack->streamTrack().source().addVideo SampleObserver(*this);908 m_activeVideoTrack->streamTrack().source().addVideoFrameObserver(*this); 910 909 ALWAYS_LOG(LOGIDENTIFIER, "observing video source ", m_activeVideoTrack->streamTrack().logIdentifier()); 911 910 } … … 988 987 void MediaPlayerPrivateMediaStreamAVFObjC::updateCurrentFrameImage() 989 988 { 990 if (m_imagePainter.cgImage || !m_imagePainter. mediaSample)989 if (m_imagePainter.cgImage || !m_imagePainter.videoFrame) 991 990 return; 992 991 … … 998 997 return; 999 998 1000 if (auto pixelBuffer = m_imagePainter. mediaSample->pixelBuffer())999 if (auto pixelBuffer = m_imagePainter.videoFrame->pixelBuffer()) 1001 1000 m_imagePainter.cgImage = NativeImage::create(m_imagePainter.pixelBufferConformer->createImageFromPixelBuffer(pixelBuffer)); 1002 1001 } … … 1007 1006 return; 1008 1007 1009 if (m_displayMode != PaintItBlack && m_imagePainter. mediaSample)1008 if (m_displayMode != PaintItBlack && m_imagePainter.videoFrame) 1010 1009 updateCurrentFrameImage(); 1011 1010 … … 1016 1015 } 1017 1016 1018 if (!m_imagePainter.cgImage || !m_imagePainter. mediaSample)1017 if (!m_imagePainter.cgImage || !m_imagePainter.videoFrame) 1019 1018 return; 1020 1019 1021 1020 auto& image = m_imagePainter.cgImage; 1022 1021 FloatRect imageRect { FloatPoint::zero(), image->size() }; 1023 AffineTransform videoTransform = videoTransformationMatrix(*m_imagePainter. mediaSample);1022 AffineTransform videoTransform = videoTransformationMatrix(*m_imagePainter.videoFrame); 1024 1023 FloatRect transformedDestRect = valueOrDefault(videoTransform.inverse()).mapRect(destRect); 1025 1024 context.concatCTM(videoTransform); … … 1033 1032 if (m_displayMode == PaintItBlack) 1034 1033 return nullptr; 1035 if (!m_imagePainter.mediaSample) 1036 return nullptr; 1037 if (is<VideoFrame>(*m_imagePainter.mediaSample)) 1038 return &downcast<VideoFrame>(*m_imagePainter.mediaSample); 1039 ASSERT(is<MediaSampleAVFObjC>(*m_imagePainter.mediaSample)); 1040 return downcast<MediaSampleAVFObjC>(*m_imagePainter.mediaSample).videoFrame(); 1034 return m_imagePainter.videoFrame; 1041 1035 } 1042 1036 … … 1112 1106 { 1113 1107 cgImage = nullptr; 1114 mediaSample = nullptr;1108 videoFrame = nullptr; 1115 1109 pixelBufferConformer = nullptr; 1116 1110 } -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h
r291550 r291611 66 66 WEBCORE_EXPORT Ref<MediaSample> createNonDisplayingCopy() const override; 67 67 68 VideoRotation videoRotation() const override { return m_rotation; }69 bool videoMirrored() const override { return m_mirrored; }70 WEBCORE_EXPORT uint32_t videoPixelFormat() const final;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 71 WEBCORE_EXPORT CVPixelBufferRef pixelBuffer() const final; 72 72 WEBCORE_EXPORT void setOwnershipIdentity(const ProcessIdentity&) final; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm
r291550 r291611 111 111 } 112 112 113 uint32_t MediaSampleAVFObjC:: videoPixelFormat() const113 uint32_t MediaSampleAVFObjC::pixelFormat() const 114 114 { 115 115 auto pixelBuffer = static_cast<CVPixelBufferRef>(PAL::CMSampleBufferGetImageBuffer(m_sample.get())); -
trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm
r291566 r291611 802 802 if (m_resourceOwner) 803 803 setOwnershipIdentityForCVPixelBuffer(mediaSamplePixelBuffer.get(), m_resourceOwner); 804 return VideoFrameCV::create({ }, false, VideoFrame:: VideoRotation::None, WTFMove(mediaSamplePixelBuffer));804 return VideoFrameCV::create({ }, false, VideoFrame::Rotation::None, WTFMove(mediaSamplePixelBuffer)); 805 805 } 806 806 #endif -
trunk/Source/WebCore/platform/graphics/cv/ImageRotationSessionVT.h
r289365 r291611 35 35 namespace WebCore { 36 36 37 class MediaSample;37 class VideoFrame; 38 38 39 39 class ImageRotationSessionVT final { … … 61 61 62 62 RetainPtr<CVPixelBufferRef> rotate(CVPixelBufferRef); 63 WEBCORE_EXPORT RetainPtr<CVPixelBufferRef> rotate( MediaSample&, const RotationProperties&, IsCGImageCompatible);63 WEBCORE_EXPORT RetainPtr<CVPixelBufferRef> rotate(VideoFrame&, const RotationProperties&, IsCGImageCompatible); 64 64 65 65 private: -
trunk/Source/WebCore/platform/graphics/cv/ImageRotationSessionVT.mm
r291550 r291611 30 30 #import "CVUtilities.h" 31 31 #import "Logging.h" 32 #import " MediaSample.h"32 #import "VideoFrame.h" 33 33 34 34 #import "CoreVideoSoftLink.h" … … 128 128 } 129 129 130 RetainPtr<CVPixelBufferRef> ImageRotationSessionVT::rotate( MediaSample& videoFrame, const RotationProperties& rotation, IsCGImageCompatible cgImageCompatible)130 RetainPtr<CVPixelBufferRef> ImageRotationSessionVT::rotate(VideoFrame& videoFrame, const RotationProperties& rotation, IsCGImageCompatible cgImageCompatible) 131 131 { 132 132 auto pixelBuffer = videoFrame.pixelBuffer(); -
trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.h
r291550 r291611 46 46 } 47 47 48 RefPtr< MediaSample> convertVideoFrame(MediaSample&, const IntSize&);49 RefPtr< MediaSample> createMediaSample(CGImageRef, const MediaTime&, const IntSize&, MediaSample::VideoRotation = MediaSample::VideoRotation::None, bool mirrored = false);50 RefPtr< MediaSample> createMediaSample(CMSampleBufferRef, const MediaTime&, const IntSize&, MediaSample::VideoRotation = MediaSample::VideoRotation::None, bool mirrored = false);48 RefPtr<VideoFrame> convertVideoFrame(VideoFrame&, const IntSize&); 49 RefPtr<VideoFrame> createVideoFrame(CGImageRef, const MediaTime&, const IntSize&, VideoFrame::Rotation = VideoFrame::Rotation::None, bool mirrored = false); 50 RefPtr<VideoFrame> createVideoFrame(CMSampleBufferRef, const MediaTime&, const IntSize&, VideoFrame::Rotation = VideoFrame::Rotation::None, bool mirrored = false); 51 51 52 52 #if !PLATFORM(MACCATALYST) 53 WEBCORE_EXPORT RefPtr< MediaSample> createMediaSample(IOSurfaceRef, const MediaTime&, const IntSize&, MediaSample::VideoRotation = MediaSample::VideoRotation::None, bool mirrored = false);53 WEBCORE_EXPORT RefPtr<VideoFrame> createVideoFrame(IOSurfaceRef, const MediaTime&, const IntSize&, VideoFrame::Rotation = VideoFrame::Rotation::None, bool mirrored = false); 54 54 #endif 55 55 -
trunk/Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.mm
r291550 r291611 256 256 #endif 257 257 258 RefPtr< MediaSample> ImageTransferSessionVT::convertVideoFrame(MediaSample& videoFrame, const IntSize& size)258 RefPtr<VideoFrame> ImageTransferSessionVT::convertVideoFrame(VideoFrame& videoFrame, const IntSize& size) 259 259 { 260 260 if (size == expandedIntSize(videoFrame.presentationSize())) … … 265 265 return nullptr; 266 266 267 return VideoFrameCV::create(videoFrame.presentationTime(), videoFrame. videoMirrored(), videoFrame.videoRotation(), WTFMove(resizedBuffer));267 return VideoFrameCV::create(videoFrame.presentationTime(), videoFrame.isMirrored(), videoFrame.rotation(), WTFMove(resizedBuffer)); 268 268 } 269 269 270 270 #if !PLATFORM(MACCATALYST) 271 RefPtr< MediaSample> ImageTransferSessionVT::createMediaSample(IOSurfaceRef surface, const MediaTime& sampleTime, const IntSize& size, MediaSample::VideoRotation rotation, bool mirrored)271 RefPtr<VideoFrame> ImageTransferSessionVT::createVideoFrame(IOSurfaceRef surface, const MediaTime& sampleTime, const IntSize& size, VideoFrame::Rotation rotation, bool mirrored) 272 272 { 273 273 auto sampleBuffer = createCMSampleBuffer(surface, sampleTime, size); … … 279 279 #endif 280 280 281 RefPtr< MediaSample> ImageTransferSessionVT::createMediaSample(CGImageRef image, const MediaTime& sampleTime, const IntSize& size, MediaSample::VideoRotation rotation, bool mirrored)281 RefPtr<VideoFrame> ImageTransferSessionVT::createVideoFrame(CGImageRef image, const MediaTime& sampleTime, const IntSize& size, VideoFrame::Rotation rotation, bool mirrored) 282 282 { 283 283 auto sampleBuffer = createCMSampleBuffer(image, sampleTime, size); … … 288 288 } 289 289 290 RefPtr< MediaSample> ImageTransferSessionVT::createMediaSample(CMSampleBufferRef buffer, const MediaTime& sampleTime, const IntSize& size, MediaSample::VideoRotation rotation, bool mirrored)290 RefPtr<VideoFrame> ImageTransferSessionVT::createVideoFrame(CMSampleBufferRef buffer, const MediaTime& sampleTime, const IntSize& size, VideoFrame::Rotation rotation, bool mirrored) 291 291 { 292 292 auto sampleBuffer = convertCMSampleBuffer(buffer, size, &sampleTime); -
trunk/Source/WebCore/platform/graphics/cv/VideoFrameCV.h
r291550 r291611 32 32 #include <wtf/RetainPtr.h> 33 33 34 using C VPixelBufferRef = struct __CVBuffer*;34 using CMSampleBufferRef = struct opaqueCMSampleBuffer*; 35 35 36 36 namespace WebCore { … … 40 40 class VideoFrameCV : public VideoFrame { 41 41 public: 42 WEBCORE_EXPORT static Ref<VideoFrameCV> create(MediaTime presentationTime, bool isMirrored, VideoRotation, RetainPtr<CVPixelBufferRef>&&);43 WEBCORE_EXPORT static Ref<VideoFrameCV> create(CMSampleBufferRef, bool isMirrored, VideoRotation);42 WEBCORE_EXPORT static Ref<VideoFrameCV> create(MediaTime presentationTime, bool isMirrored, Rotation, RetainPtr<CVPixelBufferRef>&&); 43 WEBCORE_EXPORT static Ref<VideoFrameCV> create(CMSampleBufferRef, bool isMirrored, Rotation); 44 44 static RefPtr<VideoFrameCV> createFromPixelBuffer(PixelBuffer&&); 45 45 WEBCORE_EXPORT ~VideoFrameCV(); … … 53 53 // VideoFrame overrides. 54 54 WEBCORE_EXPORT WebCore::FloatSize presentationSize() const final; 55 WEBCORE_EXPORT uint32_t videoPixelFormat() const final;55 WEBCORE_EXPORT uint32_t pixelFormat() const final; 56 56 WEBCORE_EXPORT void setOwnershipIdentity(const ProcessIdentity&) final; 57 57 bool isCV() const final { return true; } 58 WEBCORE_EXPORT RefPtr<WebCore::VideoFrameCV> asVideoFrameCV() final;59 58 60 59 private: 61 WEBCORE_EXPORT VideoFrameCV(MediaTime presentationTime, bool isMirrored, VideoRotation, RetainPtr<CVPixelBufferRef>&&);60 WEBCORE_EXPORT VideoFrameCV(MediaTime presentationTime, bool isMirrored, Rotation, RetainPtr<CVPixelBufferRef>&&); 62 61 63 62 const RetainPtr<CVPixelBufferRef> m_pixelBuffer; … … 66 65 template<typename Encoder> void VideoFrameCV::encode(Encoder& encoder) const 67 66 { 68 encoder << m_presentationTime << m_isMirrored << m_rotation<< m_pixelBuffer;67 encoder << presentationTime() << isMirrored() << rotation() << m_pixelBuffer; 69 68 } 70 69 … … 73 72 auto presentationTime = decoder.template decode<MediaTime>(); 74 73 auto isMirrored = decoder.template decode<bool>(); 75 auto rotation = decoder.template decode< VideoRotation>();74 auto rotation = decoder.template decode<Rotation>(); 76 75 auto pixelBuffer = decoder.template decode<RetainPtr<CVPixelBufferRef>>(); 77 76 if (!decoder.isValid() || !*pixelBuffer) … … 84 83 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::VideoFrameCV) 85 84 static bool isType(const WebCore::VideoFrame& videoFrame) { return videoFrame.isCV(); } 86 static bool isType(const WebCore::MediaSample& mediaSample) { return is<WebCore::VideoFrame>(mediaSample) && is<WebCore::VideoFrameCV>(downcast<WebCore::VideoFrame>(mediaSample)); }87 85 SPECIALIZE_TYPE_TRAITS_END() 88 86 -
trunk/Source/WebCore/platform/graphics/cv/VideoFrameCV.mm
r291550 r291611 35 35 namespace WebCore { 36 36 37 Ref<VideoFrameCV> VideoFrameCV::create(CMSampleBufferRef sampleBuffer, bool isMirrored, VideoRotation rotation)37 Ref<VideoFrameCV> VideoFrameCV::create(CMSampleBufferRef sampleBuffer, bool isMirrored, Rotation rotation) 38 38 { 39 39 auto pixelBuffer = static_cast<CVPixelBufferRef>(PAL::CMSampleBufferGetImageBuffer(sampleBuffer)); … … 45 45 } 46 46 47 Ref<VideoFrameCV> VideoFrameCV::create(MediaTime presentationTime, bool isMirrored, VideoRotation rotation, RetainPtr<CVPixelBufferRef>&& pixelBuffer)47 Ref<VideoFrameCV> VideoFrameCV::create(MediaTime presentationTime, bool isMirrored, Rotation rotation, RetainPtr<CVPixelBufferRef>&& pixelBuffer) 48 48 { 49 49 ASSERT(pixelBuffer); … … 74 74 } 75 75 ASSERT_UNUSED(status, !status); 76 return create({ }, false, VideoRotation::None, WTFMove(cvPixelBuffer));76 return create({ }, false, Rotation::None, WTFMove(cvPixelBuffer)); 77 77 } 78 78 79 VideoFrameCV::VideoFrameCV(MediaTime presentationTime, bool isMirrored, VideoRotation rotation, RetainPtr<CVPixelBufferRef>&& pixelBuffer)79 VideoFrameCV::VideoFrameCV(MediaTime presentationTime, bool isMirrored, Rotation rotation, RetainPtr<CVPixelBufferRef>&& pixelBuffer) 80 80 : VideoFrame(presentationTime, isMirrored, rotation) 81 81 , m_pixelBuffer(WTFMove(pixelBuffer)) … … 90 90 } 91 91 92 uint32_t VideoFrameCV:: videoPixelFormat() const92 uint32_t VideoFrameCV::pixelFormat() const 93 93 { 94 94 return CVPixelBufferGetPixelFormatType(m_pixelBuffer.get()); … … 103 103 } 104 104 105 RefPtr<WebCore::VideoFrameCV> VideoFrameCV::asVideoFrameCV()106 {107 return this;108 }109 110 105 ImageOrientation VideoFrameCV::orientation() const 111 106 { 112 107 // Sample transform first flips x-coordinates, then rotates. 113 switch ( m_rotation) {114 case MediaSample::VideoRotation::None:115 return m_isMirrored? ImageOrientation::OriginTopRight : ImageOrientation::OriginTopLeft;116 case MediaSample::VideoRotation::Right:117 return m_isMirrored? ImageOrientation::OriginRightBottom : ImageOrientation::OriginRightTop;118 case MediaSample::VideoRotation::UpsideDown:119 return m_isMirrored? ImageOrientation::OriginBottomLeft : ImageOrientation::OriginBottomRight;120 case MediaSample::VideoRotation::Left:121 return m_isMirrored? ImageOrientation::OriginLeftTop : ImageOrientation::OriginLeftBottom;108 switch (rotation()) { 109 case VideoFrame::Rotation::None: 110 return isMirrored() ? ImageOrientation::OriginTopRight : ImageOrientation::OriginTopLeft; 111 case VideoFrame::Rotation::Right: 112 return isMirrored() ? ImageOrientation::OriginRightBottom : ImageOrientation::OriginRightTop; 113 case VideoFrame::Rotation::UpsideDown: 114 return isMirrored() ? ImageOrientation::OriginBottomLeft : ImageOrientation::OriginBottomRight; 115 case VideoFrame::Rotation::Left: 116 return isMirrored() ? ImageOrientation::OriginLeftTop : ImageOrientation::OriginLeftBottom; 122 117 } 123 118 } -
trunk/Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp
r291357 r291611 31 31 namespace WebCore { 32 32 33 Ref<VideoFrameGStreamer> VideoFrameGStreamer::createFromPixelBuffer(PixelBuffer&& pixelBuffer, const MediaTime& presentationTime, const IntSize& destinationSize, double frameRate, VideoRotation videoRotation, bool videoMirrored, std::optional<VideoFrameTimeMetadata>&& metadata)33 Ref<VideoFrameGStreamer> VideoFrameGStreamer::createFromPixelBuffer(PixelBuffer&& pixelBuffer, const MediaTime& presentationTime, const IntSize& destinationSize, double frameRate, Rotation videoRotation, bool videoMirrored, std::optional<VideoFrameTimeMetadata>&& metadata) 34 34 { 35 35 ensureGStreamerInitialized(); … … 86 86 } 87 87 88 VideoFrameGStreamer::VideoFrameGStreamer(GRefPtr<GstSample>&& sample, const FloatSize& presentationSize, const MediaTime& presentationTime, VideoRotation videoRotation, bool videoMirrored, std::optional<VideoFrameTimeMetadata>&& metadata)88 VideoFrameGStreamer::VideoFrameGStreamer(GRefPtr<GstSample>&& sample, const FloatSize& presentationSize, const MediaTime& presentationTime, Rotation videoRotation, bool videoMirrored, std::optional<VideoFrameTimeMetadata>&& metadata) 89 89 : VideoFrame(presentationTime, videoMirrored, videoRotation) 90 90 , m_sample(WTFMove(sample)) … … 99 99 } 100 100 101 VideoFrameGStreamer::VideoFrameGStreamer(const GRefPtr<GstSample>& sample, const MediaTime& presentationTime, VideoRotation videoRotation)101 VideoFrameGStreamer::VideoFrameGStreamer(const GRefPtr<GstSample>& sample, const MediaTime& presentationTime, Rotation videoRotation) 102 102 : VideoFrame(presentationTime, false, videoRotation) 103 103 , m_sample(sample) -
trunk/Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.h
r291357 r291611 31 31 class VideoFrameGStreamer final : public VideoFrame { 32 32 public: 33 static Ref<VideoFrameGStreamer> create(GRefPtr<GstSample>&& sample, const FloatSize& presentationSize, const MediaTime& presentationTime = MediaTime::invalidTime(), VideoRotation videoRotation = VideoRotation::None, bool videoMirrored = false, std::optional<VideoFrameTimeMetadata>&& metadata = std::nullopt)33 static Ref<VideoFrameGStreamer> create(GRefPtr<GstSample>&& sample, const FloatSize& presentationSize, const MediaTime& presentationTime = MediaTime::invalidTime(), Rotation videoRotation = Rotation::None, bool videoMirrored = false, std::optional<VideoFrameTimeMetadata>&& metadata = std::nullopt) 34 34 { 35 35 return adoptRef(*new VideoFrameGStreamer(WTFMove(sample), presentationSize, presentationTime, videoRotation, videoMirrored, WTFMove(metadata))); 36 36 } 37 37 38 static Ref<VideoFrameGStreamer> createWrappedSample(const GRefPtr<GstSample>& sample, const MediaTime& presentationTime, VideoRotation videoRotation = VideoRotation::None)38 static Ref<VideoFrameGStreamer> createWrappedSample(const GRefPtr<GstSample>& sample, const MediaTime& presentationTime, Rotation videoRotation = Rotation::None) 39 39 { 40 40 return adoptRef(*new VideoFrameGStreamer(sample, presentationTime, videoRotation)); 41 41 } 42 42 43 static Ref<VideoFrameGStreamer> createFromPixelBuffer(PixelBuffer&&, const MediaTime& presentationTime = MediaTime::invalidTime(), const IntSize& destinationSize = { }, double frameRate = 1, VideoRotation videoRotation = VideoRotation::None, bool videoMirrored = false, std::optional<VideoFrameTimeMetadata>&& metadata = std::nullopt);43 static Ref<VideoFrameGStreamer> createFromPixelBuffer(PixelBuffer&&, const MediaTime& presentationTime = MediaTime::invalidTime(), const IntSize& destinationSize = { }, double frameRate = 1, Rotation videoRotation = Rotation::None, bool videoMirrored = false, std::optional<VideoFrameTimeMetadata>&& metadata = std::nullopt); 44 44 45 45 GstSample* sample() const { return m_sample.get(); } 46 46 47 47 private: 48 VideoFrameGStreamer(GRefPtr<GstSample>&&, const FloatSize& presentationSize, const MediaTime& presentationTime = MediaTime::invalidTime(), VideoRotation = VideoRotation::None, bool videoMirrored = false, std::optional<VideoFrameTimeMetadata>&& = std::nullopt);49 VideoFrameGStreamer(const GRefPtr<GstSample>&, const MediaTime& presentationTime, VideoRotation = VideoRotation::None);48 VideoFrameGStreamer(GRefPtr<GstSample>&&, const FloatSize& presentationSize, const MediaTime& presentationTime = MediaTime::invalidTime(), Rotation = Rotation::None, bool videoMirrored = false, std::optional<VideoFrameTimeMetadata>&& = std::nullopt); 49 VideoFrameGStreamer(const GRefPtr<GstSample>&, const MediaTime& presentationTime, Rotation = Rotation::None); 50 50 51 51 FloatSize presentationSize() const final { return m_presentationSize; } 52 52 RefPtr<JSC::Uint8ClampedArray> getRGBAImageData() const final; 53 uint32_t pixelFormat() const final { return 0; } 53 54 54 55 GRefPtr<GstSample> m_sample; -
trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h
r289894 r291611 50 50 class MediaRecorderPrivate 51 51 : public RealtimeMediaSource::AudioSampleObserver 52 , public RealtimeMediaSource::Video SampleObserver {52 , public RealtimeMediaSource::VideoFrameObserver { 53 53 public: 54 54 ~MediaRecorderPrivate(); … … 117 117 { 118 118 if (m_videoSource) 119 m_videoSource->removeVideo SampleObserver(*this);119 m_videoSource->removeVideoFrameObserver(*this); 120 120 121 121 m_videoSource = WTFMove(videoSource); 122 122 123 123 if (m_videoSource) 124 m_videoSource->addVideo SampleObserver(*this);124 m_videoSource->addVideoFrameObserver(*this); 125 125 } 126 126 … … 133 133 m_audioSource->removeAudioSampleObserver(*this); 134 134 if (m_videoSource) 135 m_videoSource->removeVideo SampleObserver(*this);135 m_videoSource->removeVideoFrameObserver(*this); 136 136 } 137 137 -
trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp
r291421 r291611 84 84 } 85 85 86 void MediaRecorderPrivateAVFImpl::video SampleAvailable(MediaSample& sample, VideoFrameTimeMetadata)86 void MediaRecorderPrivateAVFImpl::videoFrameAvailable(VideoFrame& videoFrame, VideoFrameTimeMetadata) 87 87 { 88 88 if (shouldMuteVideo()) { 89 89 if (!m_blackFrame) { 90 auto size = sample.presentationSize();91 m_blackFrame = VideoFrameCV::create( sample.presentationTime(), sample.videoMirrored(), sample.videoRotation(), createBlackPixelBuffer(size.width(), size.height()));90 auto size = videoFrame.presentationSize(); 91 m_blackFrame = VideoFrameCV::create(videoFrame.presentationTime(), videoFrame.isMirrored(), videoFrame.rotation(), createBlackPixelBuffer(size.width(), size.height())); 92 92 } 93 93 m_writer->appendVideoFrame(*m_blackFrame); … … 96 96 97 97 m_blackFrame = nullptr; 98 m_writer->appendVideoFrame( VideoFrameCV::create(sample.presentationTime(), sample.videoMirrored(), sample.videoRotation(), sample.pixelBuffer()));98 m_writer->appendVideoFrame(videoFrame); 99 99 } 100 100 -
trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateAVFImpl.h
r291421 r291611 50 50 51 51 // MediaRecorderPrivate 52 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) final;52 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) final; 53 53 void fetchData(FetchDataCallback&&) final; 54 54 void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final; -
trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateGStreamer.h
r291269 r291611 52 52 53 53 private: 54 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) final { };54 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) final { }; 55 55 void audioSamplesAvailable(const WTF::MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { }; 56 56 -
trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp
r291269 r291611 68 68 } 69 69 70 void MediaRecorderPrivateMock::video SampleAvailable(MediaSample&, VideoFrameTimeMetadata)70 void MediaRecorderPrivateMock::videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) 71 71 { 72 72 Locker locker { m_bufferLock }; -
trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h
r291269 r291611 43 43 private: 44 44 // MediaRecorderPrivate 45 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) final;45 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) final; 46 46 void fetchData(FetchDataCallback&&) final; 47 47 void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final; -
trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h
r291421 r291611 133 133 134 134 RetainPtr<WebAVAssetWriterDelegate> m_writerDelegate; 135 Deque<RetainPtr<CMSampleBufferRef>> m_pendingVideo SampleQueue;135 Deque<RetainPtr<CMSampleBufferRef>> m_pendingVideoFrameQueue; 136 136 Deque<RetainPtr<CMSampleBufferRef>> m_pendingAudioSampleQueue; 137 137 -
trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm
r291421 r291611 133 133 { 134 134 m_pendingAudioSampleQueue.clear(); 135 m_pendingVideo SampleQueue.clear();135 m_pendingVideoFrameQueue.clear(); 136 136 if (m_writer) { 137 137 [m_writer cancelWriting]; … … 284 284 285 285 if (m_isFlushingSamples) { 286 m_pendingVideo SampleQueue.append(WTFMove(buffer));286 m_pendingVideoFrameQueue.append(WTFMove(buffer)); 287 287 return true; 288 288 } 289 289 290 while (!m_pendingVideo SampleQueue.isEmpty() && [m_videoAssetWriterInput isReadyForMoreMediaData])291 appendCompressedVideoSampleBuffer(m_pendingVideo SampleQueue.takeFirst().get());290 while (!m_pendingVideoFrameQueue.isEmpty() && [m_videoAssetWriterInput isReadyForMoreMediaData]) 291 appendCompressedVideoSampleBuffer(m_pendingVideoFrameQueue.takeFirst().get()); 292 292 293 293 if (![m_videoAssetWriterInput isReadyForMoreMediaData]) { 294 m_pendingVideo SampleQueue.append(WTFMove(buffer));294 m_pendingVideoFrameQueue.append(WTFMove(buffer)); 295 295 return true; 296 296 } … … 335 335 { 336 336 bool hasPendingAudioSamples = !m_pendingAudioSampleQueue.isEmpty(); 337 bool hasPendingVideoSamples = !m_pendingVideo SampleQueue.isEmpty();337 bool hasPendingVideoSamples = !m_pendingVideoFrameQueue.isEmpty(); 338 338 339 339 if (m_hasEncodedVideoSamples) { … … 350 350 ASSERT(!m_isFlushingSamples); 351 351 m_isFlushingSamples = true; 352 auto block = makeBlockPtr([this, weakThis = WeakPtr { *this }, hasPendingAudioSamples, hasPendingVideoSamples, audioSampleQueue = WTFMove(m_pendingAudioSampleQueue), videoSampleQueue = WTFMove(m_pendingVideo SampleQueue), callback = WTFMove(callback)]() mutable {352 auto block = makeBlockPtr([this, weakThis = WeakPtr { *this }, hasPendingAudioSamples, hasPendingVideoSamples, audioSampleQueue = WTFMove(m_pendingAudioSampleQueue), videoSampleQueue = WTFMove(m_pendingVideoFrameQueue), callback = WTFMove(callback)]() mutable { 353 353 if (!weakThis) { 354 354 callback(); … … 387 387 m_firstVideoFrame = true; 388 388 m_resumedVideoTime = PAL::CMClockGetTime(PAL::CMClockGetHostTimeClock()); 389 if (frame. videoRotation() != MediaSample::VideoRotation::None || frame.videoMirrored()) {390 m_videoTransform = CGAffineTransformMakeRotation(static_cast<int>(frame. videoRotation()) * M_PI / 180);391 if (frame. videoMirrored())389 if (frame.rotation() != VideoFrame::Rotation::None || frame.isMirrored()) { 390 m_videoTransform = CGAffineTransformMakeRotation(static_cast<int>(frame.rotation()) * M_PI / 180); 391 if (frame.isMirrored()) 392 392 m_videoTransform = CGAffineTransformScale(*m_videoTransform, -1, 1); 393 393 } -
trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
r291269 r291611 76 76 } 77 77 78 void RealtimeMediaSource::addVideo SampleObserver(VideoSampleObserver& observer)78 void RealtimeMediaSource::addVideoFrameObserver(VideoFrameObserver& observer) 79 79 { 80 80 ASSERT(isMainThread()); 81 Locker locker { m_ videoSampleObserversLock };82 m_ videoSampleObservers.add(&observer);83 } 84 85 void RealtimeMediaSource::removeVideo SampleObserver(VideoSampleObserver& observer)81 Locker locker { m_VideoFrameObserversLock }; 82 m_VideoFrameObservers.add(&observer); 83 } 84 85 void RealtimeMediaSource::removeVideoFrameObserver(VideoFrameObserver& observer) 86 86 { 87 87 ASSERT(isMainThread()); 88 Locker locker { m_ videoSampleObserversLock };89 m_ videoSampleObservers.remove(&observer);88 Locker locker { m_VideoFrameObserversLock }; 89 m_VideoFrameObservers.remove(&observer); 90 90 } 91 91 … … 193 193 } 194 194 195 void RealtimeMediaSource::video SampleAvailable(MediaSample& mediaSample, VideoFrameTimeMetadata metadata)195 void RealtimeMediaSource::videoFrameAvailable(VideoFrame& videoFrame, VideoFrameTimeMetadata metadata) 196 196 { 197 197 #if !RELEASE_LOG_DISABLED … … 211 211 updateHasStartedProducingData(); 212 212 213 Locker locker { m_ videoSampleObserversLock };214 for (auto* observer : m_ videoSampleObservers)215 observer->video SampleAvailable(mediaSample, metadata);213 Locker locker { m_VideoFrameObserversLock }; 214 for (auto* observer : m_VideoFrameObservers) 215 observer->videoFrameAvailable(videoFrame, metadata); 216 216 } 217 217 -
trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h
r291269 r291611 39 39 #include "Image.h" 40 40 #include "MediaConstraints.h" 41 #include "MediaSample.h"42 41 #include "PlatformLayer.h" 43 42 #include "RealtimeMediaSourceCapabilities.h" 44 43 #include "RealtimeMediaSourceFactory.h" 44 #include "VideoFrame.h" 45 45 #include "VideoFrameTimeMetadata.h" 46 46 #include <wtf/CompletionHandler.h> … … 99 99 virtual void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t /*numberOfFrames*/) = 0; 100 100 }; 101 class Video SampleObserver {101 class VideoFrameObserver { 102 102 public: 103 virtual ~Video SampleObserver() = default;103 virtual ~VideoFrameObserver() = default; 104 104 105 105 // May be called on a background thread. 106 virtual void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) = 0;106 virtual void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) = 0; 107 107 }; 108 108 … … 148 148 WEBCORE_EXPORT void removeAudioSampleObserver(AudioSampleObserver&); 149 149 150 WEBCORE_EXPORT void addVideo SampleObserver(VideoSampleObserver&);151 WEBCORE_EXPORT void removeVideo SampleObserver(VideoSampleObserver&);150 WEBCORE_EXPORT void addVideoFrameObserver(VideoFrameObserver&); 151 WEBCORE_EXPORT void removeVideoFrameObserver(VideoFrameObserver&); 152 152 153 153 const IntSize size() const; … … 251 251 void initializeEchoCancellation(bool echoCancellation) { m_echoCancellation = echoCancellation; } 252 252 253 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata);253 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata); 254 254 void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t); 255 255 … … 290 290 HashSet<AudioSampleObserver*> m_audioSampleObservers WTF_GUARDED_BY_LOCK(m_audioSampleObserversLock); 291 291 292 mutable Lock m_ videoSampleObserversLock;293 HashSet<Video SampleObserver*> m_videoSampleObservers WTF_GUARDED_BY_LOCK(m_videoSampleObserversLock);292 mutable Lock m_VideoFrameObserversLock; 293 HashSet<VideoFrameObserver*> m_VideoFrameObservers WTF_GUARDED_BY_LOCK(m_VideoFrameObserversLock); 294 294 295 295 // Set on the main thread from constraints. -
trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp
r286644 r291611 76 76 { 77 77 m_videoSource->removeObserver(*this); 78 m_videoSource->source().removeVideo SampleObserver(*this);78 m_videoSource->source().removeVideoFrameObserver(*this); 79 79 } 80 80 … … 115 115 { 116 116 if (!m_muted && m_enabled) { 117 m_videoSource->source().addVideo SampleObserver(*this);117 m_videoSource->source().addVideoFrameObserver(*this); 118 118 if (m_blackFrameTimer.isActive()) 119 119 m_blackFrameTimer.stop(); … … 121 121 } 122 122 123 m_videoSource->source().removeVideo SampleObserver(*this);123 m_videoSource->source().removeVideoFrameObserver(*this); 124 124 sendBlackFramesIfNeeded(); 125 125 } -
trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h
r291269 r291611 51 51 , public webrtc::VideoTrackSourceInterface 52 52 , private MediaStreamTrackPrivate::Observer 53 , private RealtimeMediaSource::Video SampleObserver53 , private RealtimeMediaSource::VideoFrameObserver 54 54 #if !RELEASE_LOG_DISABLED 55 55 , private LoggerHelper … … 135 135 void trackEnded(MediaStreamTrackPrivate&) final { } 136 136 137 // RealtimeMediaSource::Video SampleObserver API138 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) override { }137 // RealtimeMediaSource::VideoFrameObserver API 138 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) override { } 139 139 140 140 Ref<MediaStreamTrackPrivate> m_videoSource; -
trunk/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.cpp
r291269 r291611 366 366 } 367 367 368 void RealtimeVideoCaptureSource::dispatch MediaSampleToObservers(MediaSample& sample, WebCore::VideoFrameTimeMetadata metadata)369 { 370 MediaTime sampleTime = sample.presentationTime();368 void RealtimeVideoCaptureSource::dispatchVideoFrameToObservers(VideoFrame& videoFrame, WebCore::VideoFrameTimeMetadata metadata) 369 { 370 MediaTime sampleTime = videoFrame.presentationTime(); 371 371 372 372 auto frameTime = sampleTime.toDouble(); … … 380 380 m_observedFrameRate = (m_observedFrameTimeStamps.size() / interval); 381 381 382 video SampleAvailable(sample, metadata);382 videoFrameAvailable(videoFrame, metadata); 383 383 } 384 384 -
trunk/Source/WebCore/platform/mediastream/RealtimeVideoCaptureSource.h
r291269 r291611 29 29 30 30 #include "ImageBuffer.h" 31 #include "MediaSample.h"32 31 #include "RealtimeMediaSource.h" 33 32 #include "VideoPreset.h" … … 47 46 bool supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) override; 48 47 virtual void generatePresets() = 0; 49 virtual MediaSample::VideoRotation sampleRotation() const { return MediaSample::VideoRotation::None; }48 virtual VideoFrame::Rotation videoFrameRotation() const { return VideoFrame::Rotation::None; } 50 49 51 50 double observedFrameRate() const { return m_observedFrameRate; } … … 74 73 void updateCapabilities(RealtimeMediaSourceCapabilities&); 75 74 76 void dispatch MediaSampleToObservers(MediaSample&, WebCore::VideoFrameTimeMetadata);75 void dispatchVideoFrameToObservers(VideoFrame&, VideoFrameTimeMetadata); 77 76 78 77 static Span<const IntSize> standardVideoSizes(); -
trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.cpp
r291550 r291611 52 52 RealtimeVideoSource::~RealtimeVideoSource() 53 53 { 54 m_source->removeVideo SampleObserver(*this);54 m_source->removeVideoFrameObserver(*this); 55 55 m_source->removeObserver(*this); 56 56 } … … 70 70 { 71 71 m_source->start(); 72 m_source->addVideo SampleObserver(*this);72 m_source->addVideoFrameObserver(*this); 73 73 } 74 74 75 75 void RealtimeVideoSource::stopProducingData() 76 76 { 77 m_source->removeVideo SampleObserver(*this);77 m_source->removeVideoFrameObserver(*this); 78 78 m_source->stop(); 79 79 } … … 81 81 void RealtimeVideoSource::endProducingData() 82 82 { 83 m_source->removeVideo SampleObserver(*this);83 m_source->removeVideoFrameObserver(*this); 84 84 m_source->requestToEnd(*this); 85 85 } … … 126 126 void RealtimeVideoSource::sourceSettingsChanged() 127 127 { 128 auto rotation = m_source-> sampleRotation();128 auto rotation = m_source->videoFrameRotation(); 129 129 auto size = this->size(); 130 130 if (size.isEmpty()) 131 131 size = m_source->size(); 132 132 133 if (rotation == MediaSample::VideoRotation::Left || rotation == MediaSample::VideoRotation::Right)133 if (rotation == VideoFrame::Rotation::Left || rotation == VideoFrame::Rotation::Right) 134 134 size = size.transposedSize(); 135 135 … … 173 173 174 174 #if PLATFORM(COCOA) 175 RefPtr< MediaSample> RealtimeVideoSource::adaptVideoFrame(MediaSample& videoFrame)176 { 177 if (!m_imageTransferSession || m_imageTransferSession->pixelFormat() != videoFrame. videoPixelFormat())178 m_imageTransferSession = ImageTransferSessionVT::create(videoFrame. videoPixelFormat(), m_shouldUseIOSurface);175 RefPtr<VideoFrame> RealtimeVideoSource::adaptVideoFrame(VideoFrame& videoFrame) 176 { 177 if (!m_imageTransferSession || m_imageTransferSession->pixelFormat() != videoFrame.pixelFormat()) 178 m_imageTransferSession = ImageTransferSessionVT::create(videoFrame.pixelFormat(), m_shouldUseIOSurface); 179 179 180 180 ASSERT(m_imageTransferSession); … … 189 189 #endif 190 190 191 void RealtimeVideoSource::video SampleAvailable(MediaSample& videoFrame, VideoFrameTimeMetadata metadata)191 void RealtimeVideoSource::videoFrameAvailable(VideoFrame& videoFrame, VideoFrameTimeMetadata metadata) 192 192 { 193 193 if (m_frameDecimation > 1 && ++m_frameDecimationCounter % m_frameDecimation) … … 203 203 if (!size.isEmpty() && size != expandedIntSize(videoFrame.presentationSize())) { 204 204 if (auto newVideoFrame = adaptVideoFrame(videoFrame)) { 205 RealtimeMediaSource::video SampleAvailable(*newVideoFrame, metadata);205 RealtimeMediaSource::videoFrameAvailable(*newVideoFrame, metadata); 206 206 return; 207 207 } … … 209 209 #endif 210 210 211 RealtimeMediaSource::video SampleAvailable(videoFrame, metadata);211 RealtimeMediaSource::videoFrameAvailable(videoFrame, metadata); 212 212 } 213 213 -
trunk/Source/WebCore/platform/mediastream/RealtimeVideoSource.h
r291550 r291611 37 37 : public RealtimeMediaSource 38 38 , public RealtimeMediaSource::Observer 39 , public RealtimeMediaSource::Video SampleObserver {39 , public RealtimeMediaSource::VideoFrameObserver { 40 40 public: 41 41 static Ref<RealtimeVideoSource> create(Ref<RealtimeVideoCaptureSource>&& source, bool shouldUseIOSurface = true) { return adoptRef(*new RealtimeVideoSource(WTFMove(source), shouldUseIOSurface)); } … … 72 72 bool preventSourceFromStopping() final; 73 73 74 // RealtimeMediaSource::Video SampleObserver75 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) final;74 // RealtimeMediaSource::VideoFrameObserver 75 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) final; 76 76 77 77 #if PLATFORM(COCOA) 78 RefPtr< MediaSample> adaptVideoFrame(MediaSample&);78 RefPtr<VideoFrame> adaptVideoFrame(VideoFrame&); 79 79 #endif 80 80 -
trunk/Source/WebCore/platform/mediastream/VideoPreset.h
r278253 r291611 29 29 30 30 #include "ImageBuffer.h" 31 #include "MediaSample.h"32 31 #include "RealtimeMediaSource.h" 33 32 #include <wtf/Lock.h> -
trunk/Source/WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.cpp
r291269 r291611 294 294 } 295 295 296 auto sample = WTF::switchOn(frame,297 [this, sampleTime](RetainPtr<IOSurfaceRef>& surface) -> RefPtr< MediaSample> {296 auto videoFrame = WTF::switchOn(frame, 297 [this, sampleTime](RetainPtr<IOSurfaceRef>& surface) -> RefPtr<VideoFrame> { 298 298 if (!surface) 299 299 return nullptr; 300 300 301 return m_imageTransferSession->create MediaSample(surface.get(), sampleTime, size());301 return m_imageTransferSession->createVideoFrame(surface.get(), sampleTime, size()); 302 302 }, 303 [this, sampleTime](RefPtr<NativeImage>& image) -> RefPtr< MediaSample> {303 [this, sampleTime](RefPtr<NativeImage>& image) -> RefPtr<VideoFrame> { 304 304 if (!image) 305 305 return nullptr; 306 306 307 return m_imageTransferSession->create MediaSample(image->platformImage().get(), sampleTime, size());307 return m_imageTransferSession->createVideoFrame(image->platformImage().get(), sampleTime, size()); 308 308 }, 309 [this, sampleTime](RetainPtr<CMSampleBufferRef>& sample) -> RefPtr< MediaSample> {309 [this, sampleTime](RetainPtr<CMSampleBufferRef>& sample) -> RefPtr<VideoFrame> { 310 310 if (!sample) 311 311 return nullptr; 312 312 313 return m_imageTransferSession->create MediaSample(sample.get(), sampleTime, size());313 return m_imageTransferSession->createVideoFrame(sample.get(), sampleTime, size()); 314 314 } 315 315 ); 316 316 317 if (! sample) {317 if (!videoFrame) { 318 318 ASSERT_NOT_REACHED(); 319 319 return; … … 322 322 VideoFrameTimeMetadata metadata; 323 323 metadata.captureTime = MonotonicTime::now().secondsSinceEpoch(); 324 video SampleAvailable(*sample.get(), metadata);324 videoFrameAvailable(*videoFrame.get(), metadata); 325 325 } 326 326 -
trunk/Source/WebCore/platform/mediastream/cocoa/DisplayCaptureSourceCocoa.h
r291034 r291611 30 30 #include "CaptureDevice.h" 31 31 #include "RealtimeMediaSource.h" 32 #include "RealtimeMediaSourceSettings.h" 32 33 #include <wtf/Observer.h> 33 34 #include <wtf/RefCounted.h> … … 37 38 #include <wtf/text/WTFString.h> 38 39 39 40 typedef struct CGImage *CGImageRef;41 typedef struct __CVBuffer *CVPixelBufferRef;42 typedef struct __IOSurface *IOSurfaceRef;40 using CGImageRef = CGImage*; 41 using CVPixelBufferRef = struct __CVBuffer*; 42 using IOSurfaceRef = struct __IOSurface*; 43 using CMSampleBufferRef = struct opaqueCMSampleBuffer*; 43 44 44 45 namespace WTF { -
trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp
r291483 r291611 129 129 class InternalSource final : public MediaStreamTrackPrivate::Observer, 130 130 public RealtimeMediaSource::AudioSampleObserver, 131 public RealtimeMediaSource::Video SampleObserver {131 public RealtimeMediaSource::VideoFrameObserver { 132 132 WTF_MAKE_FAST_ALLOCATED; 133 133 public: … … 182 182 m_track.source().addAudioSampleObserver(*this); 183 183 else if (m_track.hasVideo()) 184 m_track.source().addVideo SampleObserver(*this);184 m_track.source().addVideoFrameObserver(*this); 185 185 m_isObserving = true; 186 186 } … … 197 197 m_track.source().removeAudioSampleObserver(*this); 198 198 else if (m_track.hasVideo()) 199 m_track.source().removeVideo SampleObserver(*this);199 m_track.source().removeVideoFrameObserver(*this); 200 200 m_track.removeObserver(*this); 201 201 } … … 273 273 } 274 274 275 void video SampleAvailable(MediaSample& sample, VideoFrameTimeMetadata) final275 void videoFrameAvailable(VideoFrame& videoFrame, VideoFrameTimeMetadata) final 276 276 { 277 277 if (!m_parent || !m_isObserving) 278 278 return; 279 279 280 auto sampleSize = sample.presentationSize();281 IntSize captureSize( sampleSize.width(), sampleSize.height());280 auto videoFrameSize = videoFrame.presentationSize(); 281 IntSize captureSize(videoFrameSize.width(), videoFrameSize.height()); 282 282 283 283 auto settings = m_track.settings(); … … 290 290 m_configuredSize.setHeight(captureSize.height()); 291 291 292 auto videoRotation = sample.videoRotation();293 bool videoMirrored = sample.videoMirrored();292 auto videoRotation = videoFrame.rotation(); 293 bool videoMirrored = videoFrame.isMirrored(); 294 294 if (m_videoRotation != videoRotation || m_videoMirrored != videoMirrored) { 295 295 m_videoRotation = videoRotation; … … 302 302 } 303 303 304 auto* videoFrame = static_cast<VideoFrameGStreamer*>(&sample); 305 auto* gstSample = videoFrame->sample(); 304 auto* gstSample = static_cast<VideoFrameGStreamer*>(&videoFrame)->sample(); 306 305 if (!m_configuredSize.isEmpty() && m_lastKnownSize != m_configuredSize) { 307 306 m_lastKnownSize = m_configuredSize; … … 385 384 IntSize m_lastKnownSize; 386 385 GRefPtr<GstSample> m_blackFrame; 387 MediaSample::VideoRotation m_videoRotation { MediaSample::VideoRotation::None };386 VideoFrame::Rotation m_videoRotation { VideoFrame::Rotation::None }; 388 387 bool m_videoMirrored { false }; 389 388 }; -
trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp
r291357 r291611 196 196 return; 197 197 198 dispatch MediaSampleToObservers(WTFMove(videoFrame), { });198 dispatchVideoFrameToObservers(WTFMove(videoFrame), { }); 199 199 } 200 200 -
trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp
r291357 r291611 70 70 , m_deviceType(deviceType) 71 71 { 72 m_source->addVideo SampleObserver(*this);72 m_source->addVideoFrameObserver(*this); 73 73 } 74 74 75 75 MockDisplayCaptureSourceGStreamer::~MockDisplayCaptureSourceGStreamer() 76 76 { 77 m_source->removeVideo SampleObserver(*this);77 m_source->removeVideoFrameObserver(*this); 78 78 } 79 79 80 80 void MockDisplayCaptureSourceGStreamer::stopProducingData() 81 81 { 82 m_source->removeVideo SampleObserver(*this);82 m_source->removeVideoFrameObserver(*this); 83 83 m_source->stop(); 84 84 } … … 87 87 { 88 88 RealtimeMediaSource::requestToEnd(callingObserver); 89 m_source->removeVideo SampleObserver(*this);89 m_source->removeVideoFrameObserver(*this); 90 90 m_source->requestToEnd(callingObserver); 91 91 } … … 97 97 } 98 98 99 void MockDisplayCaptureSourceGStreamer::video SampleAvailable(MediaSample& sample, VideoFrameTimeMetadata metadata)99 void MockDisplayCaptureSourceGStreamer::videoFrameAvailable(VideoFrame& videoFrame, VideoFrameTimeMetadata metadata) 100 100 { 101 RealtimeMediaSource::video SampleAvailable(sample, metadata);101 RealtimeMediaSource::videoFrameAvailable(videoFrame, metadata); 102 102 } 103 103 … … 166 166 metadata->captureTime = MonotonicTime::now().secondsSinceEpoch(); 167 167 auto presentationTime = MediaTime::createWithDouble((elapsedTime() + 100_ms).seconds()); 168 auto videoFrame = VideoFrameGStreamer::createFromPixelBuffer(WTFMove(*pixelBuffer), presentationTime, size(), frameRate(), sampleRotation(), false, WTFMove(metadata));169 dispatch MediaSampleToObservers(videoFrame.get(), { });168 auto videoFrame = VideoFrameGStreamer::createFromPixelBuffer(WTFMove(*pixelBuffer), presentationTime, size(), frameRate(), videoFrameRotation(), false, WTFMove(metadata)); 169 dispatchVideoFrameToObservers(videoFrame.get(), { }); 170 170 } 171 171 -
trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.h
r291269 r291611 41 41 }; 42 42 43 class MockDisplayCaptureSourceGStreamer final : public RealtimeMediaSource, RealtimeMediaSource::Video SampleObserver {43 class MockDisplayCaptureSourceGStreamer final : public RealtimeMediaSource, RealtimeMediaSource::VideoFrameObserver { 44 44 public: 45 45 static CaptureSourceOrError create(const CaptureDevice&, String&&, const MediaConstraints*); … … 50 50 51 51 protected: 52 // RealtimeMediaSource::Video SampleObserver53 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) final;52 // RealtimeMediaSource::VideoFrameObserver 53 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) final; 54 54 55 55 private: -
trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeIncomingVideoSourceGStreamer.cpp
r291483 r291611 101 101 { 102 102 auto* buffer = gst_sample_get_buffer(gstSample.get()); 103 video SampleAvailable(VideoFrameGStreamer::createWrappedSample(gstSample, fromGstClockTime(GST_BUFFER_PTS(buffer))), { });103 videoFrameAvailable(VideoFrameGStreamer::createWrappedSample(gstSample, fromGstClockTime(GST_BUFFER_PTS(buffer))), { }); 104 104 } 105 105 -
trunk/Source/WebCore/platform/mediastream/ios/ReplayKitCaptureSource.mm
r288950 r291611 157 157 158 158 auto completionHandler = makeBlockPtr([this, weakThis = WeakPtr { *this }, identifier](NSError * _Nullable error) { 159 // FIXME: It should be safe to call `video SampleAvailable` from any thread. Test this and get rid of this main thread hop.159 // FIXME: It should be safe to call `videoFrameAvailable` from any thread. Test this and get rid of this main thread hop. 160 160 RunLoop::main().dispatch([this, weakThis, error = retainPtr(error), identifier]() mutable { 161 161 if (!weakThis || !error) -
trunk/Source/WebCore/platform/mediastream/libwebrtc/VideoFrameLibWebRTC.cpp
r291051 r291611 34 34 namespace WebCore { 35 35 36 Ref<VideoFrameLibWebRTC> VideoFrameLibWebRTC::create(MediaTime presentationTime, bool isMirrored, VideoRotation rotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, ConversionCallback&& conversionCallback)36 Ref<VideoFrameLibWebRTC> VideoFrameLibWebRTC::create(MediaTime presentationTime, bool isMirrored, Rotation rotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, ConversionCallback&& conversionCallback) 37 37 { 38 38 return adoptRef(*new VideoFrameLibWebRTC(presentationTime, isMirrored, rotation, WTFMove(buffer), WTFMove(conversionCallback))); 39 39 } 40 40 41 VideoFrameLibWebRTC::VideoFrameLibWebRTC(MediaTime presentationTime, bool isMirrored, VideoRotation rotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, ConversionCallback&& conversionCallback)41 VideoFrameLibWebRTC::VideoFrameLibWebRTC(MediaTime presentationTime, bool isMirrored, Rotation rotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&& buffer, ConversionCallback&& conversionCallback) 42 42 : VideoFrame(presentationTime, isMirrored, rotation) 43 43 , m_buffer(WTFMove(buffer)) -
trunk/Source/WebCore/platform/mediastream/libwebrtc/VideoFrameLibWebRTC.h
r291051 r291611 43 43 public: 44 44 using ConversionCallback = Function<RetainPtr<CVPixelBufferRef>(webrtc::VideoFrameBuffer&)>; 45 static Ref<VideoFrameLibWebRTC> create(MediaTime, bool isMirrored, VideoRotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&&, ConversionCallback&&);45 static Ref<VideoFrameLibWebRTC> create(MediaTime, bool isMirrored, Rotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&&, ConversionCallback&&); 46 46 47 47 rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer() { return m_buffer; } 48 48 49 49 private: 50 VideoFrameLibWebRTC(MediaTime, bool isMirrored, VideoRotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&&, ConversionCallback&&);50 VideoFrameLibWebRTC(MediaTime, bool isMirrored, Rotation, rtc::scoped_refptr<webrtc::VideoFrameBuffer>&&, ConversionCallback&&); 51 51 52 52 // VideoFrame 53 53 FloatSize presentationSize() const final { return m_size; } 54 uint32_t videoPixelFormat() const final { return m_videoPixelFormat; }54 uint32_t pixelFormat() const final { return m_videoPixelFormat; } 55 55 CVPixelBufferRef pixelBuffer() const final; 56 56 … … 68 68 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::VideoFrameLibWebRTC) 69 69 static bool isType(const WebCore::VideoFrame& videoFrame) { return videoFrame.isLibWebRTC(); } 70 static bool isType(const WebCore::MediaSample& mediaSample) { return is<WebCore::VideoFrame>(mediaSample) && is<WebCore::VideoFrameLibWebRTC>(downcast<WebCore::VideoFrame>(mediaSample)); }71 70 SPECIALIZE_TYPE_TRAITS_END() 72 71 -
trunk/Source/WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeIncomingVideoSourceLibWebRTC.cpp
r291357 r291611 62 62 if (frame.video_frame_buffer()->type() == webrtc::VideoFrameBuffer::Type::kNative) { 63 63 auto* framebuffer = static_cast<GStreamerVideoFrameLibWebRTC*>(frame.video_frame_buffer().get()); 64 video SampleAvailable(VideoFrameGStreamer::createWrappedSample(framebuffer->getSample(), presentationTime, static_cast<MediaSample::VideoRotation>(frame.rotation())), { });64 videoFrameeAvailable(VideoFrameGStreamer::createWrappedSample(framebuffer->getSample(), presentationTime, static_cast<VideoFrame::Rotation>(frame.rotation())), { }); 65 65 } else { 66 66 auto gstSample = convertLibWebRTCVideoFrameToGStreamerSample(frame); 67 67 auto metadata = std::make_optional(metadataFromVideoFrame(frame)); 68 video SampleAvailable(VideoFrameGStreamer::create(WTFMove(gstSample), { }, presentationTime, static_cast<MediaSample::VideoRotation>(frame.rotation()), false, WTFMove(metadata)), { });68 videoFrameAvailable(VideoFrameGStreamer::create(WTFMove(gstSample), { }, presentationTime, static_cast<VideoFrame::Rotation>(frame.rotation()), false, WTFMove(metadata)), { }); 69 69 } 70 70 } -
trunk/Source/WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.cpp
r291357 r291611 51 51 } 52 52 53 void RealtimeOutgoingVideoSourceLibWebRTC::video SampleAvailable(MediaSample& sample, VideoFrameTimeMetadata)53 void RealtimeOutgoingVideoSourceLibWebRTC::videoFrameAvailable(VideoFrame& videoFrame, VideoFrameTimeMetadata) 54 54 { 55 switch ( sample.videoRotation()) {56 case MediaSample::VideoRotation::None:55 switch (videoFrame.rotation()) { 56 case VideoFrame::Rotation::None: 57 57 m_currentRotation = webrtc::kVideoRotation_0; 58 58 break; 59 case MediaSample::VideoRotation::UpsideDown:59 case VideoFrame::Rotation::UpsideDown: 60 60 m_currentRotation = webrtc::kVideoRotation_180; 61 61 break; 62 case MediaSample::VideoRotation::Right:62 case VideoFrame::Rotation::Right: 63 63 m_currentRotation = webrtc::kVideoRotation_90; 64 64 break; 65 case MediaSample::VideoRotation::Left:65 case VideoFrame::Rotation::Left: 66 66 m_currentRotation = webrtc::kVideoRotation_270; 67 67 break; -
trunk/Source/WebCore/platform/mediastream/libwebrtc/gstreamer/RealtimeOutgoingVideoSourceLibWebRTC.h
r291269 r291611 42 42 rtc::scoped_refptr<webrtc::VideoFrameBuffer> createBlackFrame(size_t, size_t) final; 43 43 44 // RealtimeMediaSource::Video SampleObserver API45 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) final;44 // RealtimeMediaSource::VideoFrameObserver API 45 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) final; 46 46 }; 47 47 -
trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h
r291034 r291611 92 92 bool interrupted() const final; 93 93 94 MediaSample::VideoRotation sampleRotation() const final { return m_sampleRotation; }94 VideoFrame::Rotation videoFrameRotation() const final { return m_videoFrameRotation; } 95 95 void setFrameRateWithPreset(double, RefPtr<VideoPreset>) final; 96 96 bool prefersPreset(VideoPreset&) final; … … 100 100 void setSessionSizeAndFrameRate(); 101 101 bool setPreset(NSString*); 102 void compute SampleRotation();102 void computeVideoFrameRotation(); 103 103 AVFrameRateRange* frameDurationForFrameRate(double); 104 104 … … 119 119 void verifyIsCapturing(); 120 120 121 RefPtr< MediaSample> m_buffer;121 RefPtr<VideoFrame> m_buffer; 122 122 RetainPtr<AVCaptureVideoDataOutput> m_videoOutput; 123 123 std::unique_ptr<ImageTransferSessionVT> m_imageTransferSession; … … 125 125 int m_sensorOrientation { 0 }; 126 126 int m_deviceOrientation { 0 }; 127 MediaSample::VideoRotation m_sampleRotation { MediaSample::VideoRotation::None };127 VideoFrame::Rotation m_videoFrameRotation { VideoFrame::Rotation::None }; 128 128 129 129 std::optional<RealtimeMediaSourceSettings> m_currentSettings; -
trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
r291550 r291611 252 252 253 253 auto size = this->size(); 254 if (m_ sampleRotation == MediaSample::VideoRotation::Left || m_sampleRotation == MediaSample::VideoRotation::Right)254 if (m_videoFrameRotation == VideoFrame::Rotation::Left || m_videoFrameRotation == VideoFrame::Rotation::Right) 255 255 size = size.transposedSize(); 256 256 … … 497 497 498 498 m_sensorOrientation = sensorOrientationFromVideoOutput(m_videoOutput.get()); 499 compute SampleRotation();499 computeVideoFrameRotation(); 500 500 501 501 return true; … … 522 522 ASSERT(orientation == 0 || orientation == 90 || orientation == -90 || orientation == 180); 523 523 m_deviceOrientation = orientation; 524 compute SampleRotation();525 ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, "rotation = ", m_ sampleRotation, ", orientation = ", m_deviceOrientation);526 } 527 528 void AVVideoCaptureSource::compute SampleRotation()524 computeVideoFrameRotation(); 525 ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, "rotation = ", m_videoFrameRotation, ", orientation = ", m_deviceOrientation); 526 } 527 528 void AVVideoCaptureSource::computeVideoFrameRotation() 529 529 { 530 530 bool frontCamera = [device() position] == AVCaptureDevicePositionFront; 531 MediaSample::VideoRotation sampleRotation;531 VideoFrame::Rotation videoFrameRotation; 532 532 switch (m_sensorOrientation - m_deviceOrientation) { 533 533 case 0: 534 sampleRotation = MediaSample::VideoRotation::None;534 videoFrameRotation = VideoFrame::Rotation::None; 535 535 break; 536 536 case 180: 537 537 case -180: 538 sampleRotation = MediaSample::VideoRotation::UpsideDown;538 videoFrameRotation = VideoFrame::Rotation::UpsideDown; 539 539 break; 540 540 case 90: 541 541 case -270: 542 sampleRotation = frontCamera ? MediaSample::VideoRotation::Left : MediaSample::VideoRotation::Right;542 videoFrameRotation = frontCamera ? VideoFrame::Rotation::Left : VideoFrame::Rotation::Right; 543 543 break; 544 544 case -90: 545 545 case 270: 546 sampleRotation = frontCamera ? MediaSample::VideoRotation::Right : MediaSample::VideoRotation::Left;546 videoFrameRotation = frontCamera ? VideoFrame::Rotation::Right : VideoFrame::Rotation::Left; 547 547 break; 548 548 default: 549 549 ASSERT_NOT_REACHED(); 550 sampleRotation = MediaSample::VideoRotation::None;551 } 552 if ( sampleRotation == m_sampleRotation)553 return; 554 555 m_ sampleRotation = sampleRotation;550 videoFrameRotation = VideoFrame::Rotation::None; 551 } 552 if (videoFrameRotation == m_videoFrameRotation) 553 return; 554 555 m_videoFrameRotation = videoFrameRotation; 556 556 notifySettingsDidChangeObservers({ RealtimeMediaSourceSettings::Flag::Width, RealtimeMediaSourceSettings::Flag::Height }); 557 557 } … … 562 562 return; 563 563 564 auto videoFrame = VideoFrameCV::create(sampleBuffer, [captureConnection isVideoMirrored], m_ sampleRotation);564 auto videoFrame = VideoFrameCV::create(sampleBuffer, [captureConnection isVideoMirrored], m_videoFrameRotation); 565 565 m_buffer = &videoFrame.get(); 566 566 setIntrinsicSize(expandedIntSize(videoFrame->presentationSize())); 567 567 VideoFrameTimeMetadata metadata; 568 568 metadata.captureTime = MonotonicTime::now().secondsSinceEpoch(); 569 dispatch MediaSampleToObservers(WTFMove(videoFrame), metadata);569 dispatchVideoFrameToObservers(WTFMove(videoFrame), metadata); 570 570 } 571 571 -
trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm
r291550 r291611 94 94 platformImage = nativeImage->platformImage(); 95 95 96 auto sampleTime = MediaTime::createWithDouble((elapsedTime() + 100_ms).seconds());97 auto sampleBuffer = m_imageTransferSession->createMediaSample(platformImage.get(), sampleTime, size(), sampleRotation());98 if (! sampleBuffer)96 auto presentationTime = MediaTime::createWithDouble((elapsedTime() + 100_ms).seconds()); 97 auto videoFrame = m_imageTransferSession->createVideoFrame(platformImage.get(), presentationTime, size(), videoFrameRotation()); 98 if (!videoFrame) 99 99 return; 100 100 101 101 auto captureTime = MonotonicTime::now().secondsSinceEpoch(); 102 m_workQueue->dispatch([this, protectedThis = Ref { *this }, sampleBuffer = WTFMove(sampleBuffer), captureTime]() mutable {102 m_workQueue->dispatch([this, protectedThis = Ref { *this }, videoFrame = WTFMove(videoFrame), captureTime]() mutable { 103 103 VideoFrameTimeMetadata metadata; 104 104 metadata.captureTime = captureTime; 105 dispatch MediaSampleToObservers(*sampleBuffer, metadata);105 dispatchVideoFrameToObservers(*videoFrame, metadata); 106 106 }); 107 107 } -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.h
r291550 r291611 50 50 RetainPtr<CVPixelBufferRef> pixelBufferFromVideoFrame(const webrtc::VideoFrame&); 51 51 CVPixelBufferPoolRef pixelBufferPool(size_t width, size_t height, webrtc::BufferType); 52 RefPtr<VideoFrame> toVideoFrame(const webrtc::VideoFrame&, MediaSample::VideoRotation);53 Ref<VideoFrame> createVideoSampleFromCVPixelBuffer(CVPixelBufferRef, MediaSample::VideoRotation, int64_t);52 RefPtr<VideoFrame> toVideoFrame(const webrtc::VideoFrame&, VideoFrame::Rotation); 53 Ref<VideoFrame> createVideoSampleFromCVPixelBuffer(CVPixelBufferRef, VideoFrame::Rotation, int64_t); 54 54 55 55 // rtc::VideoSinkInterface -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm
r291550 r291611 92 92 } 93 93 94 Ref<VideoFrame> RealtimeIncomingVideoSourceCocoa::createVideoSampleFromCVPixelBuffer(CVPixelBufferRef pixelBuffer, MediaSample::VideoRotation rotation, int64_t timeStamp)94 Ref<VideoFrame> RealtimeIncomingVideoSourceCocoa::createVideoSampleFromCVPixelBuffer(CVPixelBufferRef pixelBuffer, VideoFrame::Rotation rotation, int64_t timeStamp) 95 95 { 96 96 return VideoFrameCV::create(MediaTime(timeStamp, 1000000), false, rotation, pixelBuffer); 97 97 } 98 98 99 RefPtr<VideoFrame> RealtimeIncomingVideoSourceCocoa::toVideoFrame(const webrtc::VideoFrame& frame, MediaSample::VideoRotation rotation)99 RefPtr<VideoFrame> RealtimeIncomingVideoSourceCocoa::toVideoFrame(const webrtc::VideoFrame& frame, VideoFrame::Rotation rotation) 100 100 { 101 101 if (muted()) { … … 145 145 unsigned height = webrtcVideoFrame.height(); 146 146 147 MediaSample::VideoRotation rotation;147 VideoFrame::Rotation rotation; 148 148 switch (webrtcVideoFrame.rotation()) { 149 149 case webrtc::kVideoRotation_0: 150 rotation = MediaSample::VideoRotation::None;150 rotation = VideoFrame::Rotation::None; 151 151 break; 152 152 case webrtc::kVideoRotation_180: 153 rotation = MediaSample::VideoRotation::UpsideDown;153 rotation = VideoFrame::Rotation::UpsideDown; 154 154 break; 155 155 case webrtc::kVideoRotation_90: 156 rotation = MediaSample::VideoRotation::Right;156 rotation = VideoFrame::Rotation::Right; 157 157 std::swap(width, height); 158 158 break; 159 159 case webrtc::kVideoRotation_270: 160 rotation = MediaSample::VideoRotation::Left;160 rotation = VideoFrame::Rotation::Left; 161 161 std::swap(width, height); 162 162 break; … … 172 172 173 173 setIntrinsicSize(IntSize(width, height)); 174 video SampleAvailable(*videoFrame, metadataFromVideoFrame(webrtcVideoFrame));174 videoFrameAvailable(*videoFrame, metadataFromVideoFrame(webrtcVideoFrame)); 175 175 } 176 176 -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp
r291269 r291611 64 64 } 65 65 66 void RealtimeOutgoingVideoSourceCocoa::video SampleAvailable(MediaSample& sample, VideoFrameTimeMetadata)66 void RealtimeOutgoingVideoSourceCocoa::videoFrameAvailable(VideoFrame& videoFrame, VideoFrameTimeMetadata) 67 67 { 68 68 #if !RELEASE_LOG_DISABLED … … 71 71 #endif 72 72 73 switch ( sample.videoRotation()) {74 case MediaSample::VideoRotation::None:73 switch (videoFrame.rotation()) { 74 case VideoFrame::Rotation::None: 75 75 m_currentRotation = webrtc::kVideoRotation_0; 76 76 break; 77 case MediaSample::VideoRotation::UpsideDown:77 case VideoFrame::Rotation::UpsideDown: 78 78 m_currentRotation = webrtc::kVideoRotation_180; 79 79 break; 80 case MediaSample::VideoRotation::Right:80 case VideoFrame::Rotation::Right: 81 81 m_currentRotation = webrtc::kVideoRotation_90; 82 82 break; 83 case MediaSample::VideoRotation::Left:83 case VideoFrame::Rotation::Left: 84 84 m_currentRotation = webrtc::kVideoRotation_270; 85 85 break; … … 87 87 88 88 bool shouldApplyRotation = m_shouldApplyRotation && m_currentRotation != webrtc::kVideoRotation_0; 89 if (!shouldApplyRotation && is<VideoFrame>(sample)) {90 if ( downcast<VideoFrame>(sample).isRemoteProxy()) {91 Ref videoFrame { downcast<VideoFrame>(sample)};92 auto size = sample.presentationSize();93 sendFrame(webrtc::toWebRTCVideoFrameBuffer(& videoFrame.leakRef(),89 if (!shouldApplyRotation) { 90 if (videoFrame.isRemoteProxy()) { 91 Ref remoteVideoFrame { videoFrame }; 92 auto size = videoFrame.presentationSize(); 93 sendFrame(webrtc::toWebRTCVideoFrameBuffer(&remoteVideoFrame.leakRef(), 94 94 [](auto* pointer) { return static_cast<VideoFrame*>(pointer)->pixelBuffer(); }, 95 95 [](auto* pointer) { static_cast<VideoFrame*>(pointer)->deref(); }, … … 97 97 return; 98 98 } 99 if ( downcast<VideoFrame>(sample).isLibWebRTC()) {100 sendFrame(downcast<VideoFrameLibWebRTC>( sample).buffer());99 if (videoFrame.isLibWebRTC()) { 100 sendFrame(downcast<VideoFrameLibWebRTC>(videoFrame).buffer()); 101 101 return; 102 102 } 103 103 } 104 104 105 auto pixelBuffer = sample.pixelBuffer();105 auto pixelBuffer = videoFrame.pixelBuffer(); 106 106 auto pixelFormatType = CVPixelBufferGetPixelFormatType(pixelBuffer); 107 107 -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h
r291269 r291611 45 45 rtc::scoped_refptr<webrtc::VideoFrameBuffer> createBlackFrame(size_t width, size_t height) final; 46 46 47 // RealtimeMediaSource::Video SampleObserver API48 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) final;47 // RealtimeMediaSource::VideoFrameObserver API 48 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) final; 49 49 50 50 RetainPtr<CVPixelBufferRef> convertToYUV(CVPixelBufferRef); -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.mm
r289365 r291611 32 32 #import "ImageRotationSessionVT.h" 33 33 #import "Logging.h" 34 #import "MediaSample.h"35 34 #import "PixelBufferConformerCV.h" 36 35 #import "RealtimeVideoUtilities.h" -
trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp
r291034 r291611 181 181 auto size = this->size(); 182 182 if (mockCamera()) { 183 if (m_deviceOrientation == MediaSample::VideoRotation::Left || m_deviceOrientation == MediaSample::VideoRotation::Right)183 if (m_deviceOrientation == VideoFrame::Rotation::Left || m_deviceOrientation == VideoFrame::Rotation::Right) 184 184 size = size.transposedSize(); 185 185 } … … 497 497 switch (orientation) { 498 498 case 0: 499 m_deviceOrientation = MediaSample::VideoRotation::None;499 m_deviceOrientation = VideoFrame::Rotation::None; 500 500 break; 501 501 case 90: 502 m_deviceOrientation = MediaSample::VideoRotation::Right;502 m_deviceOrientation = VideoFrame::Rotation::Right; 503 503 break; 504 504 case -90: 505 m_deviceOrientation = MediaSample::VideoRotation::Left;505 m_deviceOrientation = VideoFrame::Rotation::Left; 506 506 break; 507 507 case 180: 508 m_deviceOrientation = MediaSample::VideoRotation::UpsideDown;508 m_deviceOrientation = VideoFrame::Rotation::UpsideDown; 509 509 break; 510 510 default: -
trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h
r291034 r291611 63 63 Seconds elapsedTime(); 64 64 void settingsDidChange(OptionSet<RealtimeMediaSourceSettings::Flag>) override; 65 MediaSample::VideoRotation sampleRotation() const final { return m_deviceOrientation; }65 VideoFrame::Rotation videoFrameRotation() const final { return m_deviceOrientation; } 66 66 void generatePresets() override; 67 67 … … 123 123 MockMediaDevice m_device; 124 124 RefPtr<VideoPreset> m_preset; 125 MediaSample::VideoRotation m_deviceOrientation { MediaSample::VideoRotation::None };125 VideoFrame::Rotation m_deviceOrientation { VideoFrame::Rotation::None }; 126 126 }; 127 127 -
trunk/Source/WebCore/testing/Internals.cpp
r291517 r291611 5526 5526 case RealtimeMediaSource::Type::Screen: 5527 5527 case RealtimeMediaSource::Type::Window: 5528 m_trackSource->removeVideo SampleObserver(*this);5528 m_trackSource->removeVideoFrameObserver(*this); 5529 5529 break; 5530 5530 case RealtimeMediaSource::Type::None: … … 5553 5553 case RealtimeMediaSource::Type::Screen: 5554 5554 case RealtimeMediaSource::Type::Window: 5555 m_trackSource->addVideo SampleObserver(*this);5555 m_trackSource->addVideoFrameObserver(*this); 5556 5556 break; 5557 5557 case RealtimeMediaSource::Type::None: … … 5570 5570 } 5571 5571 5572 void Internals::video SampleAvailable(MediaSample& sample, VideoFrameTimeMetadata)5573 { 5574 callOnMainThread([this, weakThis = WeakPtr { *this }, sample = Ref { sample }] {5572 void Internals::videoFrameAvailable(VideoFrame& videoFrame, VideoFrameTimeMetadata) 5573 { 5574 callOnMainThread([this, weakThis = WeakPtr { *this }, videoFrame = Ref { videoFrame }] { 5575 5575 if (!weakThis) 5576 5576 return; 5577 5577 m_trackVideoSampleCount++; 5578 m_trackVideoRotation = static_cast<int>( sample->videoRotation());5578 m_trackVideoRotation = static_cast<int>(videoFrame->rotation()); 5579 5579 if (!m_nextTrackFramePromise) 5580 5580 return; … … 5584 5584 return; 5585 5585 5586 auto rgba = sample->getRGBAImageData();5586 auto rgba = videoFrame->getRGBAImageData(); 5587 5587 if (!rgba) 5588 5588 return; -
trunk/Source/WebCore/testing/Internals.h
r291517 r291611 166 166 , public RealtimeMediaSource::Observer 167 167 , private RealtimeMediaSource::AudioSampleObserver 168 , private RealtimeMediaSource::Video SampleObserver168 , private RealtimeMediaSource::VideoFrameObserver 169 169 #endif 170 170 { … … 1297 1297 #if ENABLE(MEDIA_STREAM) 1298 1298 // RealtimeMediaSource::Observer API 1299 void video SampleAvailable(MediaSample&, VideoFrameTimeMetadata) final;1299 void videoFrameAvailable(VideoFrame&, VideoFrameTimeMetadata) final; 1300 1300 // RealtimeMediaSource::AudioSampleObserver API 1301 1301 void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final { m_trackAudioSampleCount++; } -
trunk/Source/WebKit/ChangeLog
r291608 r291611 1 2022-03-22 Youenn Fablet <youenn@apple.com> 2 3 Move RealtimeMediaSource::VideoSampleObserver::videoSampleAvailable to VideoFrame 4 https://bugs.webkit.org/show_bug.cgi?id=237884 5 6 Reviewed by Eric Carlson. 7 8 Move from using MediaSample to VideoFrame directly. 9 10 * GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp: 11 * GPUProcess/media/RemoteVideoFrameObjectHeap.cpp: 12 * GPUProcess/media/RemoteVideoFrameObjectHeap.h: 13 * GPUProcess/webrtc/LibWebRTCCodecsProxy.mm: 14 * GPUProcess/webrtc/RemoteMediaRecorder.cpp: 15 * GPUProcess/webrtc/RemoteMediaRecorder.h: 16 * GPUProcess/webrtc/RemoteMediaRecorder.messages.in: 17 * GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp: 18 * GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.h: 19 * GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.messages.in: 20 * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: 21 * WebProcess/GPU/media/RemoteVideoFrameProxy.cpp: 22 * WebProcess/GPU/media/RemoteVideoFrameProxy.h: 23 * WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp: 24 * WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp: 25 * WebProcess/GPU/webrtc/MediaRecorderPrivate.h: 26 * WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp: 27 * WebProcess/GPU/webrtc/SampleBufferDisplayLayer.h: 28 * WebProcess/GPU/webrtc/SharedVideoFrame.cpp: 29 * WebProcess/GPU/webrtc/SharedVideoFrame.h: 30 * WebProcess/cocoa/RemoteCaptureSampleManager.cpp: 31 * WebProcess/cocoa/RemoteCaptureSampleManager.h: 32 * WebProcess/cocoa/RemoteCaptureSampleManager.messages.in: 33 * WebProcess/cocoa/RemoteRealtimeVideoSource.h: 34 1 35 2022-03-22 Diego Pino Garcia <dpino@igalia.com> 2 36 -
trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp
r290513 r291611 57 57 return; 58 58 } 59 // Note: This extra casting is needed since VideoFrames are still MediaSamples. 60 RefPtr<WebCore::VideoFrameCV> videoFrameCV; 61 if (is<WebCore::VideoFrameCV>(*videoFrame)) 62 videoFrameCV = &downcast<WebCore::VideoFrameCV>(*videoFrame); 63 else if (is<WebCore::MediaSampleAVFObjC>(*videoFrame)) 64 videoFrameCV = downcast<WebCore::MediaSampleAVFObjC>(*videoFrame).videoFrame(); 65 else { 59 60 auto videoFrameCV = videoFrame->asVideoFrameCV(); 61 if (!videoFrameCV) { 66 62 ASSERT_NOT_REACHED(); // Programming error, not a IPC attack. 67 63 completionHandler(false); -
trunk/Source/WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.cpp
r290824 r291611 34 34 35 35 #if PLATFORM(COCOA) 36 #include <WebCore/MediaSampleAVFObjC.h>37 36 #include <WebCore/VideoFrameCV.h> 38 37 #include <pal/cf/CoreMediaSoftLink.h> … … 85 84 } 86 85 87 RemoteVideoFrameProxy::Properties RemoteVideoFrameObjectHeap::add(Ref<WebCore:: MediaSample>&& frame)86 RemoteVideoFrameProxy::Properties RemoteVideoFrameObjectHeap::add(Ref<WebCore::VideoFrame>&& frame) 88 87 { 89 88 auto write = RemoteVideoFrameWriteReference::generateForAdd(); -
trunk/Source/WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.h
r290824 r291611 30 30 #include "RemoteVideoFrameProxy.h" 31 31 #include "ThreadSafeObjectHeap.h" 32 #include <WebCore/ MediaSample.h>32 #include <WebCore/VideoFrame.h> 33 33 34 34 #if PLATFORM(COCOA) … … 45 45 46 46 void close(); 47 RemoteVideoFrameProxy::Properties add(Ref<WebCore:: MediaSample>&&);48 RefPtr<WebCore:: MediaSample> get(RemoteVideoFrameReadReference&& read) { return m_heap.retire(WTFMove(read), 0_s); }47 RemoteVideoFrameProxy::Properties add(Ref<WebCore::VideoFrame>&&); 48 RefPtr<WebCore::VideoFrame> get(RemoteVideoFrameReadReference&& read) { return m_heap.retire(WTFMove(read), 0_s); } 49 49 50 50 void stopListeningForIPC(Ref<RemoteVideoFrameObjectHeap>&&) { close(); } … … 65 65 66 66 const Ref<IPC::Connection> m_connection; 67 ThreadSafeObjectHeap<RemoteVideoFrameIdentifier, RefPtr<WebCore:: MediaSample>> m_heap;67 ThreadSafeObjectHeap<RemoteVideoFrameIdentifier, RefPtr<WebCore::VideoFrame>> m_heap; 68 68 #if PLATFORM(COCOA) 69 69 SharedVideoFrameWriter m_sharedVideoFrameWriter; -
trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm
r291550 r291611 98 98 videoFrameObjectHeap = m_videoFrameObjectHeap.ptr(); 99 99 return [identifier, connection = m_connection, resourceOwner = m_resourceOwner, videoFrameObjectHeap = WTFMove(videoFrameObjectHeap)] (CVPixelBufferRef pixelBuffer, uint32_t timeStampNs, uint32_t timeStamp) mutable { 100 auto videoFrame = WebCore::VideoFrameCV::create(MediaTime(timeStampNs, 1), false, WebCore:: MediaSample::VideoRotation::None, pixelBuffer);100 auto videoFrame = WebCore::VideoFrameCV::create(MediaTime(timeStampNs, 1), false, WebCore::VideoFrame::Rotation::None, pixelBuffer); 101 101 if (resourceOwner) 102 102 videoFrame->setOwnershipIdentity(resourceOwner); … … 216 216 } 217 217 218 static inline webrtc::VideoRotation toWebRTCVideoRotation(WebCore:: MediaSample::VideoRotation rotation)218 static inline webrtc::VideoRotation toWebRTCVideoRotation(WebCore::VideoFrame::Rotation rotation) 219 219 { 220 220 switch (rotation) { 221 case WebCore:: MediaSample::VideoRotation::None:221 case WebCore::VideoFrame::Rotation::None: 222 222 return webrtc::kVideoRotation_0; 223 case WebCore:: MediaSample::VideoRotation::UpsideDown:223 case WebCore::VideoFrame::Rotation::UpsideDown: 224 224 return webrtc::kVideoRotation_180; 225 case WebCore:: MediaSample::VideoRotation::Right:225 case WebCore::VideoFrame::Rotation::Right: 226 226 return webrtc::kVideoRotation_90; 227 case WebCore:: MediaSample::VideoRotation::Left:227 case WebCore::VideoFrame::Rotation::Left: 228 228 return webrtc::kVideoRotation_270; 229 229 } -
trunk/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp
r291550 r291611 87 87 } 88 88 89 void RemoteMediaRecorder::video SampleAvailable(SharedVideoFrame&& sharedVideoFrame)89 void RemoteMediaRecorder::videoFrameAvailable(SharedVideoFrame&& sharedVideoFrame) 90 90 { 91 91 if (auto frame = m_sharedVideoFrameReader.read(WTFMove(sharedVideoFrame))) -
trunk/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.h
r290721 r291611 72 72 void audioSamplesStorageChanged(const SharedMemory::IPCHandle&, const WebCore::CAAudioStreamDescription&, uint64_t numberOfFrames); 73 73 void audioSamplesAvailable(MediaTime, uint64_t numberOfFrames); 74 void video SampleAvailable(SharedVideoFrame&&);74 void videoFrameAvailable(SharedVideoFrame&&); 75 75 void fetchData(CompletionHandler<void(IPC::DataReference&&, double)>&&); 76 76 void stopRecording(CompletionHandler<void()>&&); -
trunk/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.messages.in
r290903 r291611 27 27 AudioSamplesStorageChanged(WebKit::SharedMemory::IPCHandle storageHandle, WebCore::CAAudioStreamDescription description, uint64_t numberOfFrames) 28 28 AudioSamplesAvailable(MediaTime time, uint64_t numberOfFrames) 29 Video SampleAvailable(struct WebKit::SharedVideoFrame frame)29 VideoFrameAvailable(struct WebKit::SharedVideoFrame frame) 30 30 FetchData() -> (IPC::DataReference buffer, double timeCode) 31 31 StopRecording() -> () -
trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.cpp
r291550 r291611 92 92 } 93 93 94 void RemoteSampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, WebCore:: MediaSample::VideoRotation rotation)94 void RemoteSampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, WebCore::VideoFrame::Rotation rotation) 95 95 { 96 96 m_sampleBufferDisplayLayer->updateRootLayerBoundsAndPosition(bounds, rotation, LocalSampleBufferDisplayLayer::ShouldUpdateRootLayer::Yes); … … 117 117 } 118 118 119 void RemoteSampleBufferDisplayLayer::enqueue (SharedVideoFrame&& frame)119 void RemoteSampleBufferDisplayLayer::enqueueVideoFrame(SharedVideoFrame&& frame) 120 120 { 121 121 if (auto videoFrame = m_sharedVideoFrameReader.read(WTFMove(frame))) 122 m_sampleBufferDisplayLayer->enqueue (videoFrame->pixelBuffer(), videoFrame->presentationTime());122 m_sampleBufferDisplayLayer->enqueueBuffer(videoFrame->pixelBuffer(), videoFrame->presentationTime()); 123 123 } 124 124 125 void RemoteSampleBufferDisplayLayer::clear EnqueuedSamples()125 void RemoteSampleBufferDisplayLayer::clearVideoFrames() 126 126 { 127 m_sampleBufferDisplayLayer->clear EnqueuedSamples();127 m_sampleBufferDisplayLayer->clearVideoFrames(); 128 128 } 129 129 -
trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.h
r290721 r291611 71 71 void updateDisplayMode(bool hideDisplayLayer, bool hideRootLayer); 72 72 void updateAffineTransform(CGAffineTransform); 73 void updateBoundsAndPosition(CGRect, WebCore:: MediaSample::VideoRotation);73 void updateBoundsAndPosition(CGRect, WebCore::VideoFrame::Rotation); 74 74 void flush(); 75 75 void flushAndRemoveImage(); 76 76 void play(); 77 77 void pause(); 78 void enqueue (SharedVideoFrame&&);79 void clear EnqueuedSamples();78 void enqueueVideoFrame(SharedVideoFrame&&); 79 void clearVideoFrames(); 80 80 void setSharedVideoFrameSemaphore(IPC::Semaphore&&); 81 81 void setSharedVideoFrameMemory(const SharedMemory::IPCHandle&); -
trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayer.messages.in
r290358 r291611 30 30 UpdateDisplayMode(bool hideDisplayLayer, bool hideRootLayer) 31 31 UpdateAffineTransform(CGAffineTransform transform) 32 UpdateBoundsAndPosition(CGRect bounds, WebCore:: MediaSample::VideoRotation rotation)32 UpdateBoundsAndPosition(CGRect bounds, WebCore::VideoFrame::Rotation rotation) 33 33 Flush() 34 34 FlushAndRemoveImage() 35 Enqueue (struct WebKit::SharedVideoFrame frame)36 Clear EnqueuedSamples()35 EnqueueVideoFrame(struct WebKit::SharedVideoFrame frame) 36 ClearVideoFrames() 37 37 Play() 38 38 Pause() -
trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp
r291550 r291611 56 56 : private RealtimeMediaSource::Observer 57 57 , private RealtimeMediaSource::AudioSampleObserver 58 , private RealtimeMediaSource::Video SampleObserver {58 , private RealtimeMediaSource::VideoFrameObserver { 59 59 WTF_MAKE_FAST_ALLOCATED; 60 60 public: … … 75 75 case RealtimeMediaSource::Type::Screen: 76 76 case RealtimeMediaSource::Type::Window: 77 m_source->addVideo SampleObserver(*this);77 m_source->addVideoFrameObserver(*this); 78 78 break; 79 79 case RealtimeMediaSource::Type::None: … … 92 92 case RealtimeMediaSource::Type::Screen: 93 93 case RealtimeMediaSource::Type::Window: 94 m_source->removeVideo SampleObserver(*this);94 m_source->removeVideoFrameObserver(*this); 95 95 break; 96 96 case RealtimeMediaSource::Type::None: … … 179 179 } 180 180 181 RefPtr< MediaSample> rotateVideoFrameIfNeeded(MediaSample& sample)182 { 183 if (m_shouldApplyRotation && sample.videoRotation() != MediaSample::VideoRotation::None) {184 auto pixelBuffer = rotatePixelBuffer( sample);185 return VideoFrameCV::create( sample.presentationTime(), sample.videoMirrored(), MediaSample::VideoRotation::None, WTFMove(pixelBuffer));186 } 187 return & sample;188 } 189 190 void video SampleAvailable(MediaSample& frame, VideoFrameTimeMetadata metadata) final181 RefPtr<VideoFrame> rotateVideoFrameIfNeeded(VideoFrame& frame) 182 { 183 if (m_shouldApplyRotation && frame.rotation() != VideoFrame::Rotation::None) { 184 auto pixelBuffer = rotatePixelBuffer(frame); 185 return VideoFrameCV::create(frame.presentationTime(), frame.isMirrored(), VideoFrame::Rotation::None, WTFMove(pixelBuffer)); 186 } 187 return &frame; 188 } 189 190 void videoFrameAvailable(VideoFrame& frame, VideoFrameTimeMetadata metadata) final 191 191 { 192 192 auto videoFrame = rotateVideoFrameIfNeeded(frame); … … 196 196 videoFrame->setOwnershipIdentity(m_resourceOwner); 197 197 if (!m_videoFrameObjectHeap) { 198 m_connection->send(Messages::RemoteCaptureSampleManager::VideoFrameAvailableCV(m_id, videoFrame->pixelBuffer(), videoFrame-> videoRotation(), videoFrame->videoMirrored(), videoFrame->presentationTime(), metadata), 0);198 m_connection->send(Messages::RemoteCaptureSampleManager::VideoFrameAvailableCV(m_id, videoFrame->pixelBuffer(), videoFrame->rotation(), videoFrame->isMirrored(), videoFrame->presentationTime(), metadata), 0); 199 199 return; 200 200 } … … 203 203 } 204 204 205 RetainPtr<CVPixelBufferRef> rotatePixelBuffer( MediaSample& sample)205 RetainPtr<CVPixelBufferRef> rotatePixelBuffer(VideoFrame& videoFrame) 206 206 { 207 207 if (!m_rotationSession) … … 209 209 210 210 ImageRotationSessionVT::RotationProperties rotation; 211 switch ( sample.videoRotation()) {212 case MediaSample::VideoRotation::None:211 switch (videoFrame.rotation()) { 212 case VideoFrame::Rotation::None: 213 213 ASSERT_NOT_REACHED(); 214 214 rotation.angle = 0; 215 215 break; 216 case MediaSample::VideoRotation::UpsideDown:216 case VideoFrame::Rotation::UpsideDown: 217 217 rotation.angle = 180; 218 218 break; 219 case MediaSample::VideoRotation::Right:219 case VideoFrame::Rotation::Right: 220 220 rotation.angle = 90; 221 221 break; 222 case MediaSample::VideoRotation::Left:222 case VideoFrame::Rotation::Left: 223 223 rotation.angle = 270; 224 224 break; 225 225 } 226 return m_rotationSession->rotate( sample, rotation, ImageRotationSessionVT::IsCGImageCompatible::No);226 return m_rotationSession->rotate(videoFrame, rotation, ImageRotationSessionVT::IsCGImageCompatible::No); 227 227 } 228 228 -
trunk/Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.cpp
r291051 r291611 43 43 namespace WebKit { 44 44 45 RemoteVideoFrameProxy::Properties RemoteVideoFrameProxy::properties(WebKit::RemoteVideoFrameReference&& reference, const WebCore:: MediaSample& mediaSample)45 RemoteVideoFrameProxy::Properties RemoteVideoFrameProxy::properties(WebKit::RemoteVideoFrameReference&& reference, const WebCore::VideoFrame& videoFrame) 46 46 { 47 47 return { 48 48 WTFMove(reference), 49 mediaSample.presentationTime(),50 mediaSample.videoMirrored(),51 mediaSample.videoRotation(),52 expandedIntSize( mediaSample.presentationSize()),53 mediaSample.videoPixelFormat()49 videoFrame.presentationTime(), 50 videoFrame.isMirrored(), 51 videoFrame.rotation(), 52 expandedIntSize(videoFrame.presentationSize()), 53 videoFrame.pixelFormat() 54 54 }; 55 55 } … … 95 95 } 96 96 97 uint32_t RemoteVideoFrameProxy:: videoPixelFormat() const97 uint32_t RemoteVideoFrameProxy::pixelFormat() const 98 98 { 99 99 return m_pixelFormat; -
trunk/Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.h
r291051 r291611 60 60 MediaTime presentationTime; 61 61 bool isMirrored { false }; 62 VideoRotation rotation { VideoRotation::None };62 Rotation rotation { Rotation::None }; 63 63 WebCore::IntSize size; 64 64 uint32_t pixelFormat { 0 }; … … 68 68 }; 69 69 70 static Properties properties(WebKit::RemoteVideoFrameReference&&, const WebCore:: MediaSample&);70 static Properties properties(WebKit::RemoteVideoFrameReference&&, const WebCore::VideoFrame&); 71 71 72 72 static Ref<RemoteVideoFrameProxy> create(IPC::Connection&, RemoteVideoFrameObjectHeapProxy&, Properties&&); … … 85 85 // WebCore::VideoFrame overrides. 86 86 WebCore::FloatSize presentationSize() const final { return m_size; } 87 uint32_t videoPixelFormat() const final;87 uint32_t pixelFormat() const final; 88 88 bool isRemoteProxy() const final { return true; } 89 89 #if PLATFORM(COCOA) … … 117 117 auto presentationTime = decoder.template decode<MediaTime>(); 118 118 auto isMirrored = decoder.template decode<bool>(); 119 auto videoRotation = decoder.template decode<VideoRotation>();119 auto rotation = decoder.template decode<Rotation>(); 120 120 auto size = decoder.template decode<WebCore::IntSize>(); 121 121 auto pixelFormat = decoder.template decode<uint32_t>(); 122 122 if (!decoder.isValid()) 123 123 return std::nullopt; 124 return Properties { WTFMove(*reference), WTFMove(*presentationTime), *isMirrored, * videoRotation, *size, *pixelFormat };124 return Properties { WTFMove(*reference), WTFMove(*presentationTime), *isMirrored, *rotation, *size, *pixelFormat }; 125 125 } 126 126 … … 130 130 131 131 SPECIALIZE_TYPE_TRAITS_BEGIN(WebKit::RemoteVideoFrameProxy) 132 static bool isType(const WebCore:: MediaSample& mediaSample) { return is<WebCore::VideoFrame>(mediaSample) && downcast<WebCore::VideoFrame>(mediaSample).isRemoteProxy(); }132 static bool isType(const WebCore::VideoFrame& videoFrame) { return videoFrame.isRemoteProxy(); } 133 133 SPECIALIZE_TYPE_TRAITS_END() 134 134 -
trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp
r291095 r291611 103 103 } 104 104 105 static inline MediaSample::VideoRotation toMediaSampleVideoRotation(webrtc::VideoRotation rotation)105 static inline VideoFrame::Rotation toVideoRotation(webrtc::VideoRotation rotation) 106 106 { 107 107 switch (rotation) { 108 108 case webrtc::kVideoRotation_0: 109 return MediaSample::VideoRotation::None;109 return VideoFrame::Rotation::None; 110 110 case webrtc::kVideoRotation_180: 111 return MediaSample::VideoRotation::UpsideDown;111 return VideoFrame::Rotation::UpsideDown; 112 112 case webrtc::kVideoRotation_90: 113 return MediaSample::VideoRotation::Right;113 return VideoFrame::Rotation::Right; 114 114 case webrtc::kVideoRotation_270: 115 return MediaSample::VideoRotation::Left;115 return VideoFrame::Rotation::Left; 116 116 } 117 117 ASSERT_NOT_REACHED(); 118 return MediaSample::VideoRotation::None;118 return VideoFrame::Rotation::None; 119 119 } 120 120 … … 495 495 return WEBRTC_VIDEO_CODEC_ERROR; 496 496 497 SharedVideoFrame sharedVideoFrame { MediaTime(frame.timestamp_us() * 1000, 1000000), false, to MediaSampleVideoRotation(frame.rotation()), WTFMove(*buffer) };497 SharedVideoFrame sharedVideoFrame { MediaTime(frame.timestamp_us() * 1000, 1000000), false, toVideoRotation(frame.rotation()), WTFMove(*buffer) }; 498 498 encoder.connection->send(Messages::LibWebRTCCodecsProxy::EncodeFrame { encoder.identifier, sharedVideoFrame, frame.timestamp(), shouldEncodeAsKeyFrame }, 0); 499 499 return WEBRTC_VIDEO_CODEC_OK; -
trunk/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp
r291269 r291611 93 93 } 94 94 95 void MediaRecorderPrivate::video SampleAvailable(MediaSample& sample, VideoFrameTimeMetadata)95 void MediaRecorderPrivate::videoFrameAvailable(VideoFrame& videoFrame, VideoFrameTimeMetadata) 96 96 { 97 97 if (shouldMuteVideo()) { 98 98 if (!m_blackFrameSize) { 99 auto size = sample.presentationSize();99 auto size = videoFrame.presentationSize(); 100 100 m_blackFrameSize = WebCore::IntSize { static_cast<int>(size.width()), static_cast<int>(size.height()) }; 101 101 } 102 SharedVideoFrame sharedVideoFrame { sample.presentationTime(), sample.videoMirrored(), sample.videoRotation(), *m_blackFrameSize };103 m_connection->send(Messages::RemoteMediaRecorder::Video SampleAvailable { sharedVideoFrame }, m_identifier);102 SharedVideoFrame sharedVideoFrame { videoFrame.presentationTime(), videoFrame.isMirrored(), videoFrame.rotation(), *m_blackFrameSize }; 103 m_connection->send(Messages::RemoteMediaRecorder::VideoFrameAvailable { sharedVideoFrame }, m_identifier); 104 104 return; 105 105 } 106 106 107 107 m_blackFrameSize = { }; 108 auto sharedVideoFrame = m_sharedVideoFrameWriter.write( sample,108 auto sharedVideoFrame = m_sharedVideoFrameWriter.write(videoFrame, 109 109 [this](auto& semaphore) { m_connection->send(Messages::RemoteMediaRecorder::SetSharedVideoFrameSemaphore { semaphore }, m_identifier); }, 110 110 [this](auto& handle) { m_connection->send(Messages::RemoteMediaRecorder::SetSharedVideoFrameMemory { handle }, m_identifier); } 111 111 ); 112 112 if (sharedVideoFrame) 113 m_connection->send(Messages::RemoteMediaRecorder::Video SampleAvailable { WTFMove(*sharedVideoFrame) }, m_identifier);113 m_connection->send(Messages::RemoteMediaRecorder::VideoFrameAvailable { WTFMove(*sharedVideoFrame) }, m_identifier); 114 114 } 115 115 -
trunk/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h
r291269 r291611 57 57 private: 58 58 // WebCore::MediaRecorderPrivate 59 void video SampleAvailable(WebCore::MediaSample&, WebCore::VideoFrameTimeMetadata) final;59 void videoFrameAvailable(WebCore::VideoFrame&, WebCore::VideoFrameTimeMetadata) final; 60 60 void fetchData(CompletionHandler<void(RefPtr<WebCore::FragmentedSharedBuffer>&&, const String& mimeType, double)>&&) final; 61 61 void stopRecording(CompletionHandler<void()>&&) final; -
trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.cpp
r290721 r291611 101 101 } 102 102 103 void SampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, MediaSample::VideoRotation rotation)103 void SampleBufferDisplayLayer::updateBoundsAndPosition(CGRect bounds, VideoFrame::Rotation rotation) 104 104 { 105 105 m_connection->send(Messages::RemoteSampleBufferDisplayLayer::UpdateBoundsAndPosition { bounds, rotation }, m_identifier); … … 128 128 } 129 129 130 void SampleBufferDisplayLayer::enqueue Sample(MediaSample& sample)130 void SampleBufferDisplayLayer::enqueueVideoFrame(VideoFrame& videoFrame) 131 131 { 132 132 if (m_paused) 133 133 return; 134 134 135 auto sharedVideoFrame = m_sharedVideoFrameWriter.write( sample,135 auto sharedVideoFrame = m_sharedVideoFrameWriter.write(videoFrame, 136 136 [this](auto& semaphore) { m_connection->send(Messages::RemoteSampleBufferDisplayLayer::SetSharedVideoFrameSemaphore { semaphore }, m_identifier); }, 137 137 [this](auto& handle) { m_connection->send(Messages::RemoteSampleBufferDisplayLayer::SetSharedVideoFrameMemory { handle }, m_identifier); } … … 140 140 return; 141 141 142 m_connection->send(Messages::RemoteSampleBufferDisplayLayer::Enqueue { *sharedVideoFrame }, m_identifier);142 m_connection->send(Messages::RemoteSampleBufferDisplayLayer::EnqueueVideoFrame { *sharedVideoFrame }, m_identifier); 143 143 } 144 144 145 void SampleBufferDisplayLayer::clear EnqueuedSamples()145 void SampleBufferDisplayLayer::clearVideoFrames() 146 146 { 147 m_connection->send(Messages::RemoteSampleBufferDisplayLayer::Clear EnqueuedSamples { }, m_identifier);147 m_connection->send(Messages::RemoteSampleBufferDisplayLayer::ClearVideoFrames { }, m_identifier); 148 148 } 149 149 -
trunk/Source/WebKit/WebProcess/GPU/webrtc/SampleBufferDisplayLayer.h
r290358 r291611 63 63 void updateDisplayMode(bool hideDisplayLayer, bool hideRootLayer) final; 64 64 void updateAffineTransform(CGAffineTransform) final; 65 void updateBoundsAndPosition(CGRect, WebCore:: MediaSample::VideoRotation) final;65 void updateBoundsAndPosition(CGRect, WebCore::VideoFrame::Rotation) final; 66 66 void flush() final; 67 67 void flushAndRemoveImage() final; 68 68 void play() final; 69 69 void pause() final; 70 void enqueue Sample(WebCore::MediaSample&) final;71 void clear EnqueuedSamples() final;70 void enqueueVideoFrame(WebCore::VideoFrame&) final; 71 void clearVideoFrames() final; 72 72 PlatformLayer* rootLayer() final; 73 73 -
trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp
r291421 r291611 94 94 } 95 95 96 std::optional<SharedVideoFrame> SharedVideoFrameWriter::write( MediaSample& frame, const Function<void(IPC::Semaphore&)>& newSemaphoreCallback, const Function<void(const SharedMemory::IPCHandle&)>& newMemoryCallback)96 std::optional<SharedVideoFrame> SharedVideoFrameWriter::write(VideoFrame& frame, const Function<void(IPC::Semaphore&)>& newSemaphoreCallback, const Function<void(const SharedMemory::IPCHandle&)>& newMemoryCallback) 97 97 { 98 98 auto buffer = writeBuffer(frame, newSemaphoreCallback, newMemoryCallback); 99 99 if (!buffer) 100 100 return { }; 101 return SharedVideoFrame { frame.presentationTime(), frame. videoMirrored(), frame.videoRotation(), WTFMove(*buffer) };102 } 103 104 std::optional<SharedVideoFrame::Buffer> SharedVideoFrameWriter::writeBuffer( MediaSample& frame, const Function<void(IPC::Semaphore&)>& newSemaphoreCallback, const Function<void(const SharedMemory::IPCHandle&)>& newMemoryCallback)101 return SharedVideoFrame { frame.presentationTime(), frame.isMirrored(), frame.rotation(), WTFMove(*buffer) }; 102 } 103 104 std::optional<SharedVideoFrame::Buffer> SharedVideoFrameWriter::writeBuffer(VideoFrame& frame, const Function<void(IPC::Semaphore&)>& newSemaphoreCallback, const Function<void(const SharedMemory::IPCHandle&)>& newMemoryCallback) 105 105 { 106 106 if (is<RemoteVideoFrameProxy>(frame)) -
trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h
r291421 r291611 56 56 MediaTime time; 57 57 bool mirrored { false }; 58 WebCore:: MediaSample::VideoRotation rotation { WebCore::MediaSample::VideoRotation::None };58 WebCore::VideoFrame::Rotation rotation { WebCore::VideoFrame::Rotation::None }; 59 59 using Buffer = std::variant<std::nullptr_t, RemoteVideoFrameReadReference, MachSendRight, WebCore::IntSize>; 60 60 Buffer buffer; … … 69 69 SharedVideoFrameWriter(); 70 70 71 std::optional<SharedVideoFrame> write(WebCore:: MediaSample&, const Function<void(IPC::Semaphore&)>&, const Function<void(const SharedMemory::IPCHandle&)>&);71 std::optional<SharedVideoFrame> write(WebCore::VideoFrame&, const Function<void(IPC::Semaphore&)>&, const Function<void(const SharedMemory::IPCHandle&)>&); 72 72 std::optional<SharedVideoFrame::Buffer> writeBuffer(CVPixelBufferRef, const Function<void(IPC::Semaphore&)>&, const Function<void(const SharedMemory::IPCHandle&)>&, bool canSendIOSurface = true); 73 73 #if USE(LIBWEBRTC) … … 81 81 bool prepareWriting(const WebCore::SharedVideoFrameInfo&, const Function<void(IPC::Semaphore&)>&, const Function<void(const SharedMemory::IPCHandle&)>&); 82 82 83 std::optional<SharedVideoFrame::Buffer> writeBuffer(WebCore:: MediaSample&, const Function<void(IPC::Semaphore&)>&, const Function<void(const SharedMemory::IPCHandle&)>&);83 std::optional<SharedVideoFrame::Buffer> writeBuffer(WebCore::VideoFrame&, const Function<void(IPC::Semaphore&)>&, const Function<void(const SharedMemory::IPCHandle&)>&); 84 84 #if USE(LIBWEBRTC) 85 85 std::optional<SharedVideoFrame::Buffer> writeBuffer(webrtc::VideoFrameBuffer&, const Function<void(IPC::Semaphore&)>&, const Function<void(const SharedMemory::IPCHandle&)>&); -
trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.cpp
r291269 r291611 160 160 return; 161 161 } 162 auto videoFrameSize = videoFrame->size(); 163 iterator->value->videoFrameAvailable(WTFMove(videoFrame), videoFrameSize, metadata); 164 } 165 166 void RemoteCaptureSampleManager::videoFrameAvailableCV(RealtimeMediaSourceIdentifier identifier, RetainPtr<CVPixelBufferRef>&& pixelBuffer, WebCore::MediaSample::VideoRotation rotation, bool mirrored, MediaTime presentationTime, WebCore::VideoFrameTimeMetadata metadata) 162 iterator->value->remoteVideoFrameAvailable(WTFMove(videoFrame), metadata); 163 } 164 165 void RemoteCaptureSampleManager::videoFrameAvailableCV(RealtimeMediaSourceIdentifier identifier, RetainPtr<CVPixelBufferRef>&& pixelBuffer, WebCore::VideoFrame::Rotation rotation, bool mirrored, MediaTime presentationTime, WebCore::VideoFrameTimeMetadata metadata) 167 166 { 168 167 ASSERT(!WTF::isMainRunLoop()); … … 174 173 175 174 auto videoFrame = VideoFrameCV::create(presentationTime, mirrored, rotation, WTFMove(pixelBuffer)); 176 auto size = videoFrame->presentationSize(); 177 iterator->value->videoFrameAvailable(videoFrame.get(), { static_cast<int>(size.width()), static_cast<int>(size.height()) }, metadata); 175 iterator->value->remoteVideoFrameAvailable(videoFrame.get(), metadata); 178 176 } 179 177 -
trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.h
r291269 r291611 75 75 void videoFrameAvailable(WebCore::RealtimeMediaSourceIdentifier, RemoteVideoFrameProxy::Properties&&, WebCore::VideoFrameTimeMetadata); 76 76 // FIXME: Will be removed once RemoteVideoFrameProxy providers are the only ones sending data. 77 void videoFrameAvailableCV(WebCore::RealtimeMediaSourceIdentifier, RetainPtr<CVPixelBufferRef>&&, WebCore:: MediaSample::VideoRotation, bool mirrored, MediaTime, WebCore::VideoFrameTimeMetadata);77 void videoFrameAvailableCV(WebCore::RealtimeMediaSourceIdentifier, RetainPtr<CVPixelBufferRef>&&, WebCore::VideoFrame::Rotation, bool mirrored, MediaTime, WebCore::VideoFrameTimeMetadata); 78 78 79 79 void setConnection(IPC::Connection*); -
trunk/Source/WebKit/WebProcess/cocoa/RemoteCaptureSampleManager.messages.in
r291269 r291611 27 27 AudioStorageChanged(WebCore::RealtimeMediaSourceIdentifier id, WebKit::SharedMemory::IPCHandle storageHandle, WebCore::CAAudioStreamDescription description, uint64_t numberOfFrames, IPC::Semaphore captureSemaphore, MediaTime mediaTime, size_t frameChunkSize); 28 28 VideoFrameAvailable(WebCore::RealtimeMediaSourceIdentifier id, WebKit::RemoteVideoFrameProxy::Properties sample, struct WebCore::VideoFrameTimeMetadata metadata) 29 VideoFrameAvailableCV(WebCore::RealtimeMediaSourceIdentifier id, RetainPtr<CVPixelBufferRef> pixelBuffer, WebCore:: MediaSample::VideoRotation rotation, bool mirrored, MediaTime presentationTime, struct WebCore::VideoFrameTimeMetadata metadata)29 VideoFrameAvailableCV(WebCore::RealtimeMediaSourceIdentifier id, RetainPtr<CVPixelBufferRef> pixelBuffer, WebCore::VideoFrame::Rotation rotation, bool mirrored, MediaTime presentationTime, struct WebCore::VideoFrameTimeMetadata metadata) 30 30 31 31 } -
trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeVideoSource.h
r291269 r291611 59 59 void captureStopped(bool didFail); 60 60 61 void videoFrameAvailable(WebCore::VideoFrame& frame, WebCore::IntSize, WebCore::VideoFrameTimeMetadata metadata) { videoSampleAvailable(frame, metadata); }61 void remoteVideoFrameAvailable(WebCore::VideoFrame& frame, WebCore::VideoFrameTimeMetadata metadata) { videoFrameAvailable(frame, metadata); } 62 62 void sourceMutedChanged(bool value, bool interrupted); 63 63
Note:
See TracChangeset
for help on using the changeset viewer.