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

Unified Diff: trunk/src/media/video/capture/mac/video_capture_device_mac.mm

Issue 84393002: Revert 236927 "Reorganize media::VideoCapture* types" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month 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: trunk/src/media/video/capture/mac/video_capture_device_mac.mm
===================================================================
--- trunk/src/media/video/capture/mac/video_capture_device_mac.mm (revision 236934)
+++ trunk/src/media/video/capture/mac/video_capture_device_mac.mm (working copy)
@@ -134,15 +134,15 @@
}
void VideoCaptureDeviceMac::AllocateAndStart(
- const VideoCaptureParams& params,
+ const VideoCaptureCapability& capture_format,
scoped_ptr<VideoCaptureDevice::Client> client) {
DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current());
if (state_ != kIdle) {
return;
}
- int width = params.requested_format.frame_size.width();
- int height = params.requested_format.frame_size.height();
- int frame_rate = params.requested_format.frame_rate;
+ int width = capture_format.width;
+ int height = capture_format.height;
+ int frame_rate = capture_format.frame_rate;
// The OS API can scale captured frame to any size requested, which would lead
// to undesired aspect ratio change. Try to open the camera with a natively
@@ -164,9 +164,10 @@
else if (frame_rate > kMaxFrameRate)
frame_rate = kMaxFrameRate;
- capture_format_.frame_size.SetSize(width, height);
- capture_format_.frame_rate = frame_rate;
- capture_format_.pixel_format = PIXEL_FORMAT_UYVY;
+ current_settings_.color = PIXEL_FORMAT_UYVY;
+ current_settings_.width = width;
+ current_settings_.height = height;
+ current_settings_.frame_rate = frame_rate;
if (width <= kVGA.width || height <= kVGA.height) {
// If the resolution is VGA or QVGA, set the capture resolution to the
@@ -225,7 +226,7 @@
void VideoCaptureDeviceMac::ReceiveFrame(
const uint8* video_frame,
int video_frame_length,
- const VideoCaptureFormat& frame_format,
+ const VideoCaptureCapability& frame_info,
int aspect_numerator,
int aspect_denominator) {
// This method is safe to call from a device capture thread,
@@ -233,24 +234,23 @@
if (!sent_frame_info_) {
// Final resolution has not yet been selected.
- if (capture_format_.frame_size.width() > kVGA.width ||
- capture_format_.frame_size.height() > kVGA.height) {
+ if (current_settings_.width > kVGA.width ||
+ current_settings_.height > kVGA.height) {
// We are requesting HD. Make sure that the picture is good, otherwise
// drop down to VGA.
bool change_to_vga = false;
- if (frame_format.frame_size.width() <
- capture_format_.frame_size.width() ||
- frame_format.frame_size.height() <
- capture_format_.frame_size.height()) {
+ if (frame_info.width < current_settings_.width ||
+ frame_info.height < current_settings_.height) {
// These are the default capture settings, not yet configured to match
- // |capture_format_|.
- DCHECK(frame_format.frame_rate == 0);
+ // |current_settings_|.
+ DCHECK(frame_info.frame_rate == 0);
DVLOG(1) << "Switching to VGA because the default resolution is " <<
- frame_format.frame_size.ToString();
+ frame_info.width << "x" << frame_info.height;
change_to_vga = true;
}
- if (capture_format_.frame_size == frame_format.frame_size &&
+ if (frame_info.width == current_settings_.width &&
+ frame_info.height == current_settings_.height &&
aspect_numerator != aspect_denominator) {
DVLOG(1) << "Switching to VGA because HD has nonsquare pixel " <<
"aspect ratio " << aspect_numerator << ":" << aspect_denominator;
@@ -258,29 +258,33 @@
}
if (change_to_vga) {
- capture_format_.frame_size.SetSize(kVGA.width, kVGA.height);
+ current_settings_.width = kVGA.width;
+ current_settings_.height = kVGA.height;
}
}
- if (capture_format_.frame_size == frame_format.frame_size &&
+ if (current_settings_.width == frame_info.width &&
+ current_settings_.height == frame_info.height &&
!tried_to_square_pixels_ &&
(aspect_numerator > kMaxPixelAspectRatio * aspect_denominator ||
aspect_denominator > kMaxPixelAspectRatio * aspect_numerator)) {
// The requested size results in non-square PAR.
// Shrink the frame to 1:1 PAR (assuming QTKit selects the same input
// mode, which is not guaranteed).
- int new_width = capture_format_.frame_size.width();
- int new_height = capture_format_.frame_size.height();
+ int new_width = current_settings_.width;
+ int new_height = current_settings_.height;
if (aspect_numerator < aspect_denominator) {
new_width = (new_width * aspect_numerator) / aspect_denominator;
} else {
new_height = (new_height * aspect_denominator) / aspect_numerator;
}
- capture_format_.frame_size.SetSize(new_width, new_height);
+ current_settings_.width = new_width;
+ current_settings_.height = new_height;
tried_to_square_pixels_ = true;
}
- if (capture_format_.frame_size == frame_format.frame_size) {
+ if (current_settings_.width == frame_info.width &&
+ current_settings_.height == frame_info.height) {
sent_frame_info_ = true;
} else {
UpdateCaptureResolution();
@@ -290,10 +294,8 @@
}
}
- DCHECK_EQ(capture_format_.frame_size.width(),
- frame_format.frame_size.width());
- DCHECK_EQ(capture_format_.frame_size.height(),
- frame_format.frame_size.height());
+ DCHECK(current_settings_.width == frame_info.width &&
+ current_settings_.height == frame_info.height);
client_->OnIncomingCapturedFrame(video_frame,
video_frame_length,
@@ -301,7 +303,7 @@
0,
false,
false,
- capture_format_);
+ current_settings_);
}
void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) {
@@ -318,9 +320,9 @@
}
bool VideoCaptureDeviceMac::UpdateCaptureResolution() {
- if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height()
- width:capture_format_.frame_size.width()
- frameRate:capture_format_.frame_rate]) {
+ if (![capture_device_ setCaptureHeight:current_settings_.height
+ width:current_settings_.width
+ frameRate:current_settings_.frame_rate]) {
ReceiveError("Could not configure capture device.");
return false;
}

Powered by Google App Engine
This is Rietveld 408576698