Index: media/video/capture/mac/video_capture_device_mac.mm |
diff --git a/media/video/capture/mac/video_capture_device_mac.mm b/media/video/capture/mac/video_capture_device_mac.mm |
index b353b1257728d663f0272538ffd4b6e68a112e7c..9ef29d231b8d8d0581383c1de2c48ce359e49770 100644 |
--- a/media/video/capture/mac/video_capture_device_mac.mm |
+++ b/media/video/capture/mac/video_capture_device_mac.mm |
@@ -134,15 +134,15 @@ VideoCaptureDeviceMac::~VideoCaptureDeviceMac() { |
} |
void VideoCaptureDeviceMac::AllocateAndStart( |
- const VideoCaptureCapability& capture_format, |
+ const VideoCaptureParams& params, |
scoped_ptr<VideoCaptureDevice::Client> client) { |
DCHECK_EQ(loop_proxy_, base::MessageLoopProxy::current()); |
if (state_ != kIdle) { |
return; |
} |
- int width = capture_format.width; |
- int height = capture_format.height; |
- int frame_rate = capture_format.frame_rate; |
+ int width = params.requested_format.frame_size.width(); |
+ int height = params.requested_format.frame_size.height(); |
+ int frame_rate = params.requested_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,10 +164,9 @@ void VideoCaptureDeviceMac::AllocateAndStart( |
else if (frame_rate > kMaxFrameRate) |
frame_rate = kMaxFrameRate; |
- current_settings_.color = PIXEL_FORMAT_UYVY; |
- current_settings_.width = width; |
- current_settings_.height = height; |
- current_settings_.frame_rate = frame_rate; |
+ capture_format_.frame_size.SetSize(width, height); |
+ capture_format_.frame_rate = frame_rate; |
+ capture_format_.pixel_format = PIXEL_FORMAT_UYVY; |
if (width <= kVGA.width || height <= kVGA.height) { |
// If the resolution is VGA or QVGA, set the capture resolution to the |
@@ -226,7 +225,7 @@ bool VideoCaptureDeviceMac::Init() { |
void VideoCaptureDeviceMac::ReceiveFrame( |
const uint8* video_frame, |
int video_frame_length, |
- const VideoCaptureCapability& frame_info, |
+ const VideoCaptureFormat& frame_format, |
int aspect_numerator, |
int aspect_denominator) { |
// This method is safe to call from a device capture thread, |
@@ -234,23 +233,24 @@ void VideoCaptureDeviceMac::ReceiveFrame( |
if (!sent_frame_info_) { |
// Final resolution has not yet been selected. |
- if (current_settings_.width > kVGA.width || |
- current_settings_.height > kVGA.height) { |
+ if (capture_format_.frame_size.width() > kVGA.width || |
+ capture_format_.frame_size.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_info.width < current_settings_.width || |
- frame_info.height < current_settings_.height) { |
+ if (frame_format.frame_size.width() < |
+ capture_format_.frame_size.width() || |
+ frame_format.frame_size.height() < |
+ capture_format_.frame_size.height()) { |
// These are the default capture settings, not yet configured to match |
- // |current_settings_|. |
- DCHECK(frame_info.frame_rate == 0); |
+ // |capture_format_|. |
+ DCHECK(frame_format.frame_rate == 0); |
DVLOG(1) << "Switching to VGA because the default resolution is " << |
- frame_info.width << "x" << frame_info.height; |
+ frame_format.frame_size.ToString(); |
change_to_vga = true; |
} |
- if (frame_info.width == current_settings_.width && |
- frame_info.height == current_settings_.height && |
+ if (capture_format_.frame_size == frame_format.frame_size && |
aspect_numerator != aspect_denominator) { |
DVLOG(1) << "Switching to VGA because HD has nonsquare pixel " << |
"aspect ratio " << aspect_numerator << ":" << aspect_denominator; |
@@ -258,33 +258,29 @@ void VideoCaptureDeviceMac::ReceiveFrame( |
} |
if (change_to_vga) { |
- current_settings_.width = kVGA.width; |
- current_settings_.height = kVGA.height; |
+ capture_format_.frame_size.SetSize(kVGA.width, kVGA.height); |
} |
} |
- if (current_settings_.width == frame_info.width && |
- current_settings_.height == frame_info.height && |
+ if (capture_format_.frame_size == frame_format.frame_size && |
!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 = current_settings_.width; |
- int new_height = current_settings_.height; |
+ int new_width = capture_format_.frame_size.width(); |
+ int new_height = capture_format_.frame_size.height(); |
if (aspect_numerator < aspect_denominator) { |
new_width = (new_width * aspect_numerator) / aspect_denominator; |
} else { |
new_height = (new_height * aspect_denominator) / aspect_numerator; |
} |
- current_settings_.width = new_width; |
- current_settings_.height = new_height; |
+ capture_format_.frame_size.SetSize(new_width, new_height); |
tried_to_square_pixels_ = true; |
} |
- if (current_settings_.width == frame_info.width && |
- current_settings_.height == frame_info.height) { |
+ if (capture_format_.frame_size == frame_format.frame_size) { |
sent_frame_info_ = true; |
} else { |
UpdateCaptureResolution(); |
@@ -294,8 +290,10 @@ void VideoCaptureDeviceMac::ReceiveFrame( |
} |
} |
- DCHECK(current_settings_.width == frame_info.width && |
- current_settings_.height == frame_info.height); |
+ DCHECK_EQ(capture_format_.frame_size.width(), |
+ frame_format.frame_size.width()); |
+ DCHECK_EQ(capture_format_.frame_size.height(), |
+ frame_format.frame_size.height()); |
client_->OnIncomingCapturedFrame(video_frame, |
video_frame_length, |
@@ -303,7 +301,7 @@ void VideoCaptureDeviceMac::ReceiveFrame( |
0, |
false, |
false, |
- current_settings_); |
+ capture_format_); |
} |
void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) { |
@@ -320,9 +318,9 @@ void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) { |
} |
bool VideoCaptureDeviceMac::UpdateCaptureResolution() { |
- if (![capture_device_ setCaptureHeight:current_settings_.height |
- width:current_settings_.width |
- frameRate:current_settings_.frame_rate]) { |
+ if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
+ width:capture_format_.frame_size.width() |
+ frameRate:capture_format_.frame_rate]) { |
ReceiveError("Could not configure capture device."); |
return false; |
} |