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

Unified Diff: content/browser/media/capture/content_video_capture_device_core.cc

Issue 1179323002: Video Capture: extract storage info from pixel format in VideoCaptureFormat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hubbe@s comments and minor rebase Created 5 years, 6 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: content/browser/media/capture/content_video_capture_device_core.cc
diff --git a/content/browser/media/capture/content_video_capture_device_core.cc b/content/browser/media/capture/content_video_capture_device_core.cc
index 336bcd63a7f578d4e757b8de39a5c5d7688dff55..776dea457bfa75eaa85dcfd4589061ff1cbbe66f 100644
--- a/content/browser/media/capture/content_video_capture_device_core.cc
+++ b/content/browser/media/capture/content_video_capture_device_core.cc
@@ -74,8 +74,12 @@ bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
(visible_size.height() + 15) & ~15);
scoped_ptr<media::VideoCaptureDevice::Client::Buffer> output_buffer(
- client_->ReserveOutputBuffer(params_.requested_format.pixel_format,
- coded_size));
+ client_->ReserveOutputBuffer(coded_size,
+ (params_.requested_format.pixel_storage !=
+ media::PIXEL_STORAGE_TEXTURE)
+ ? media::PIXEL_FORMAT_I420
+ : media::PIXEL_FORMAT_ARGB,
+ params_.requested_format.pixel_storage));
// TODO(miu): Use current buffer pool utilization to drive automatic video
// resolution changes. http://crbug.com/156767.
VLOG(2) << "Current buffer pool utilization is "
@@ -119,9 +123,9 @@ bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
TRACE_EVENT_ASYNC_BEGIN2("gpu.capture", "Capture", output_buffer.get(),
"frame_number", frame_number,
"trigger", event_name);
- // NATIVE_TEXTURE frames wrap a texture mailbox, which we don't have at the
- // moment. We do not construct those frames.
- if (params_.requested_format.pixel_format != media::PIXEL_FORMAT_TEXTURE) {
+ // Texture frames wrap a texture mailbox, which we don't have at the moment.
+ // We do not construct those frames.
+ if (params_.requested_format.pixel_storage != media::PIXEL_STORAGE_TEXTURE) {
*storage = media::VideoFrame::WrapExternalData(
media::VideoFrame::I420,
coded_size,
@@ -231,28 +235,31 @@ void ContentVideoCaptureDeviceCore::AllocateAndStart(
return;
}
- if (params.requested_format.frame_rate <= 0) {
- std::string error_msg("Invalid frame_rate: ");
- error_msg += base::DoubleToString(params.requested_format.frame_rate);
- DVLOG(1) << error_msg;
+ if (params.requested_format.frame_rate <= 0.0f) {
+ const std::string error_msg = base::StringPrintf(
+ "Invalid frame_rate: %.3f", params.requested_format.frame_rate);
client->OnError(error_msg);
return;
}
- if (params.requested_format.pixel_format != media::PIXEL_FORMAT_I420 &&
- params.requested_format.pixel_format != media::PIXEL_FORMAT_TEXTURE) {
- std::string error_msg = base::StringPrintf(
- "unsupported format: %d", params.requested_format.pixel_format);
- DVLOG(1) << error_msg;
+ if (!(params.requested_format.pixel_storage == media::PIXEL_STORAGE_CPU &&
+ params.requested_format.pixel_format == media::PIXEL_FORMAT_I420) &&
+ !(params.requested_format.pixel_storage == media::PIXEL_STORAGE_TEXTURE &&
+ params.requested_format.pixel_format == media::PIXEL_FORMAT_ARGB)) {
+ const std::string error_msg =
+ base::StringPrintf("unsupported format %s and storage %s combination.",
+ media::VideoCaptureFormat::PixelFormatToString(
+ params.requested_format.pixel_format)
+ .c_str(),
+ media::VideoCaptureFormat::PixelStorageToString(
+ params.requested_format.pixel_storage)
+ .c_str());
client->OnError(error_msg);
return;
}
if (params.requested_format.frame_size.IsEmpty()) {
- std::string error_msg =
- "invalid frame size: " + params.requested_format.frame_size.ToString();
- DVLOG(1) << error_msg;
- client->OnError(error_msg);
+ client->OnError("invalid empty frame size");
return;
}

Powered by Google App Engine
This is Rietveld 408576698