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

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

Issue 2621743002: Reland2 [Mojo Video Capture] Replace method OnIncomingCapturedVideoFrame() with OnIncomingCapturedBu (Closed)
Patch Set: Fix for shared memory handle not closed. Created 3 years, 11 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 3321633b610852d5e5be905e54e489b912f4b6fc..857e714e5af3e3a40de73d91c82148880bb5d278 100644
--- a/media/capture/video/video_capture_device_client.cc
+++ b/media/capture/video/video_capture_device_client.cc
@@ -21,6 +21,7 @@
#include "media/capture/video/video_capture_jpeg_decoder.h"
#include "media/capture/video/video_frame_receiver.h"
#include "media/capture/video_capture_types.h"
+#include "mojo/public/cpp/system/platform_handle.h"
#include "third_party/libyuv/include/libyuv.h"
using media::VideoCaptureFormat;
@@ -295,32 +296,35 @@ void VideoCaptureDeviceClient::OnIncomingCapturedBuffer(
const VideoCaptureFormat& format,
base::TimeTicks reference_time,
base::TimeDelta timestamp) {
- DCHECK(IsFormatSupported(format.pixel_format));
- DCHECK_EQ(media::PIXEL_STORAGE_CPU, format.pixel_storage);
+ OnIncomingCapturedBufferExt(std::move(buffer), format, reference_time,
+ timestamp, gfx::Rect(format.frame_size),
+ VideoFrameMetadata());
+}
- scoped_refptr<VideoFrame> frame;
- if (buffer->IsBackedByVideoFrame()) {
- frame = buffer->GetVideoFrame();
- frame->set_timestamp(timestamp);
- } else {
- frame = VideoFrame::WrapExternalSharedMemory(
- format.pixel_format, format.frame_size, gfx::Rect(format.frame_size),
- format.frame_size, reinterpret_cast<uint8_t*>(buffer->data()),
- VideoFrame::AllocationSize(format.pixel_format, format.frame_size),
- base::SharedMemory::NULLHandle(), 0u, timestamp);
- }
- if (!frame)
- return;
+void VideoCaptureDeviceClient::OnIncomingCapturedBufferExt(
+ std::unique_ptr<Buffer> buffer,
+ const VideoCaptureFormat& format,
+ base::TimeTicks reference_time,
+ base::TimeDelta timestamp,
+ gfx::Rect visible_rect,
+ const VideoFrameMetadata& additional_metadata) {
+ scoped_refptr<media::VideoFrame> frame =
+ media::VideoFrame::WrapExternalSharedMemory(
+ format.pixel_format, // format
+ format.frame_size, // coded_size
+ visible_rect, // visible_rect
+ format.frame_size, // natural_size
+ static_cast<uint8_t*>(buffer->data()), // data
+ buffer->mapped_size(), // data_size
+ base::SharedMemory::NULLHandle(), // handle
miu 2017/01/10 23:32:19 This could either be great or not: Great in that
chfremer 2017/01/10 23:45:29 In this case, I think it is okay to not attach a r
+ 0u, // shared_memory_offset
+ timestamp); // timestamp
+ frame->metadata()->MergeMetadataFrom(&additional_metadata);
frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE,
format.frame_rate);
frame->metadata()->SetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME,
reference_time);
- OnIncomingCapturedVideoFrame(std::move(buffer), std::move(frame));
-}
-void VideoCaptureDeviceClient::OnIncomingCapturedVideoFrame(
- std::unique_ptr<Buffer> buffer,
- scoped_refptr<VideoFrame> frame) {
receiver_->OnIncomingCapturedVideoFrame(std::move(buffer), std::move(frame));
}
« no previous file with comments | « media/capture/video/video_capture_device_client.h ('k') | media/capture/video/video_capture_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698