| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/video/capture/mac/video_capture_device_mac.h" | 5 #include "media/video/capture/mac/video_capture_device_mac.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 new_height = (new_height * aspect_denominator) / aspect_numerator; | 293 new_height = (new_height * aspect_denominator) / aspect_numerator; |
| 294 } | 294 } |
| 295 capture_format_.frame_size.SetSize(new_width, new_height); | 295 capture_format_.frame_size.SetSize(new_width, new_height); |
| 296 tried_to_square_pixels_ = true; | 296 tried_to_square_pixels_ = true; |
| 297 } | 297 } |
| 298 | 298 |
| 299 if (capture_format_.frame_size == frame_format.frame_size) { | 299 if (capture_format_.frame_size == frame_format.frame_size) { |
| 300 sent_frame_info_ = true; | 300 sent_frame_info_ = true; |
| 301 } else { | 301 } else { |
| 302 UpdateCaptureResolution(); | 302 UpdateCaptureResolution(); |
| 303 // OnFrameInfo has not yet been called. OnIncomingCapturedFrame must | 303 // OnFrameInfo has not yet been called. OnIncomingCapturedData must |
| 304 // not be called until after OnFrameInfo, so we return early. | 304 // not be called until after OnFrameInfo, so we return early. |
| 305 return; | 305 return; |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 | 308 |
| 309 DCHECK_EQ(capture_format_.frame_size.width(), | 309 DCHECK_EQ(capture_format_.frame_size.width(), |
| 310 frame_format.frame_size.width()); | 310 frame_format.frame_size.width()); |
| 311 DCHECK_EQ(capture_format_.frame_size.height(), | 311 DCHECK_EQ(capture_format_.frame_size.height(), |
| 312 frame_format.frame_size.height()); | 312 frame_format.frame_size.height()); |
| 313 | 313 |
| 314 client_->OnIncomingCapturedFrame(video_frame, | 314 client_->OnIncomingCapturedData(video_frame, |
| 315 video_frame_length, | 315 video_frame_length, |
| 316 base::TimeTicks::Now(), | 316 capture_format_, |
| 317 0, | 317 0, |
| 318 capture_format_); | 318 base::TimeTicks::Now()); |
| 319 } | 319 } |
| 320 | 320 |
| 321 void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) { | 321 void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) { |
| 322 task_runner_->PostTask(FROM_HERE, | 322 task_runner_->PostTask(FROM_HERE, |
| 323 base::Bind(&VideoCaptureDeviceMac::SetErrorState, weak_this_, | 323 base::Bind(&VideoCaptureDeviceMac::SetErrorState, weak_this_, |
| 324 reason)); | 324 reason)); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) { | 327 void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) { |
| 328 DCHECK(task_runner_->BelongsToCurrentThread()); | 328 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 329 DLOG(ERROR) << reason; | 329 DLOG(ERROR) << reason; |
| 330 state_ = kError; | 330 state_ = kError; |
| 331 client_->OnError(reason); | 331 client_->OnError(reason); |
| 332 } | 332 } |
| 333 | 333 |
| 334 bool VideoCaptureDeviceMac::UpdateCaptureResolution() { | 334 bool VideoCaptureDeviceMac::UpdateCaptureResolution() { |
| 335 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 335 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
| 336 width:capture_format_.frame_size.width() | 336 width:capture_format_.frame_size.width() |
| 337 frameRate:capture_format_.frame_rate]) { | 337 frameRate:capture_format_.frame_rate]) { |
| 338 ReceiveError("Could not configure capture device."); | 338 ReceiveError("Could not configure capture device."); |
| 339 return false; | 339 return false; |
| 340 } | 340 } |
| 341 return true; | 341 return true; |
| 342 } | 342 } |
| 343 | 343 |
| 344 } // namespace media | 344 } // namespace media |
| OLD | NEW |