Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: media/capture/video/video_capture_device_client.cc

Issue 2378943002: Let clients interact with VideoCaptureDeviceClient instead of VideoCaptureDevice (Closed)
Patch Set: mcasas comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/capture/video/video_capture_device_client.cc
diff --git a/media/capture/video/video_capture_device_client.cc b/media/capture/video/video_capture_device_client.cc
index 368af81f9ce73b41bba132c1f54cd4b23a8d0470..e24df379acb7c25a25eb286b67dcbee66b11ec15 100644
--- a/media/capture/video/video_capture_device_client.cc
+++ b/media/capture/video/video_capture_device_client.cc
@@ -53,6 +53,12 @@ class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer {
return buffer_handle_->AsPlatformFile();
}
#endif
+ bool IsBackedByVideoFrame() const override {
+ return buffer_handle_->IsBackedByVideoFrame();
+ }
+ scoped_refptr<VideoFrame> GetVideoFrame() override {
+ return buffer_handle_->GetVideoFrame();
+ }
private:
~AutoReleaseBuffer() override { pool_->RelinquishProducerReservation(id_); }
@@ -285,28 +291,36 @@ void VideoCaptureDeviceClient::OnIncomingCapturedBuffer(
DCHECK_EQ(media::PIXEL_FORMAT_I420, frame_format.pixel_format);
scoped_refptr<VideoFrame> frame;
- switch (frame_format.pixel_storage) {
- case media::PIXEL_STORAGE_GPUMEMORYBUFFER: {
- // Create a VideoFrame to set the correct storage_type and pixel_format.
- gfx::GpuMemoryBufferHandle handle;
- frame = VideoFrame::WrapExternalYuvGpuMemoryBuffers(
- media::PIXEL_FORMAT_I420, frame_format.frame_size,
- gfx::Rect(frame_format.frame_size), frame_format.frame_size, 0, 0, 0,
- reinterpret_cast<uint8_t*>(buffer->data(media::VideoFrame::kYPlane)),
- reinterpret_cast<uint8_t*>(buffer->data(media::VideoFrame::kUPlane)),
- reinterpret_cast<uint8_t*>(buffer->data(media::VideoFrame::kVPlane)),
- handle, handle, handle, timestamp);
- break;
+ if (buffer->IsBackedByVideoFrame()) {
+ frame = buffer->GetVideoFrame();
+ frame->set_timestamp(timestamp);
+ } else {
+ switch (frame_format.pixel_storage) {
+ case media::PIXEL_STORAGE_GPUMEMORYBUFFER: {
+ // Create a VideoFrame to set the correct storage_type and pixel_format.
+ gfx::GpuMemoryBufferHandle handle;
+ frame = VideoFrame::WrapExternalYuvGpuMemoryBuffers(
+ media::PIXEL_FORMAT_I420, frame_format.frame_size,
+ gfx::Rect(frame_format.frame_size), frame_format.frame_size, 0, 0,
+ 0, reinterpret_cast<uint8_t*>(
+ buffer->data(media::VideoFrame::kYPlane)),
+ reinterpret_cast<uint8_t*>(
+ buffer->data(media::VideoFrame::kUPlane)),
+ reinterpret_cast<uint8_t*>(
+ buffer->data(media::VideoFrame::kVPlane)),
+ handle, handle, handle, timestamp);
+ break;
+ }
+ case media::PIXEL_STORAGE_CPU:
+ frame = VideoFrame::WrapExternalSharedMemory(
+ media::PIXEL_FORMAT_I420, frame_format.frame_size,
+ gfx::Rect(frame_format.frame_size), frame_format.frame_size,
+ reinterpret_cast<uint8_t*>(buffer->data()),
+ VideoFrame::AllocationSize(media::PIXEL_FORMAT_I420,
+ frame_format.frame_size),
+ base::SharedMemory::NULLHandle(), 0u, timestamp);
+ break;
}
- case media::PIXEL_STORAGE_CPU:
- frame = VideoFrame::WrapExternalSharedMemory(
- media::PIXEL_FORMAT_I420, frame_format.frame_size,
- gfx::Rect(frame_format.frame_size), frame_format.frame_size,
- reinterpret_cast<uint8_t*>(buffer->data()),
- VideoFrame::AllocationSize(media::PIXEL_FORMAT_I420,
- frame_format.frame_size),
- base::SharedMemory::NULLHandle(), 0u, timestamp);
- break;
}
if (!frame)
return;

Powered by Google App Engine
This is Rietveld 408576698