Chromium Code Reviews| 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/capture/video/mac/video_capture_device_mac.h" | 5 #include "media/capture/video/mac/video_capture_device_mac.h" |
| 6 | 6 |
| 7 #include <IOKit/IOCFPlugIn.h> | 7 #include <IOKit/IOCFPlugIn.h> |
| 8 #include <IOKit/usb/IOUSBLib.h> | 8 #include <IOKit/usb/IOUSBLib.h> |
| 9 #include <IOKit/usb/USBSpec.h> | 9 #include <IOKit/usb/USBSpec.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 SetAntiFlickerInUsbDevice(vendor_id_as_int, model_id_as_int, | 352 SetAntiFlickerInUsbDevice(vendor_id_as_int, model_id_as_int, |
| 353 GetPowerLineFrequency(params)); | 353 GetPowerLineFrequency(params)); |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 | 356 |
| 357 if (![capture_device_ startCapture]) { | 357 if (![capture_device_ startCapture]) { |
| 358 SetErrorState(FROM_HERE, "Could not start capture device."); | 358 SetErrorState(FROM_HERE, "Could not start capture device."); |
| 359 return; | 359 return; |
| 360 } | 360 } |
| 361 | 361 |
| 362 client_->OnStarted(); | |
| 362 state_ = kCapturing; | 363 state_ = kCapturing; |
| 363 } | 364 } |
| 364 | 365 |
| 365 void VideoCaptureDeviceMac::StopAndDeAllocate() { | 366 void VideoCaptureDeviceMac::StopAndDeAllocate() { |
| 366 DCHECK(task_runner_->BelongsToCurrentThread()); | 367 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 367 DCHECK(state_ == kCapturing || state_ == kError) << state_; | 368 DCHECK(state_ == kCapturing || state_ == kError) << state_; |
| 368 | 369 |
| 369 [capture_device_ setCaptureDevice:nil]; | 370 [capture_device_ setCaptureDevice:nil]; |
| 370 [capture_device_ setFrameReceiver:nil]; | 371 [capture_device_ setFrameReceiver:nil]; |
| 371 client_.reset(); | 372 client_.reset(); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 399 state_ = kIdle; | 400 state_ = kIdle; |
| 400 return true; | 401 return true; |
| 401 } | 402 } |
| 402 | 403 |
| 403 void VideoCaptureDeviceMac::ReceiveFrame(const uint8_t* video_frame, | 404 void VideoCaptureDeviceMac::ReceiveFrame(const uint8_t* video_frame, |
| 404 int video_frame_length, | 405 int video_frame_length, |
| 405 const VideoCaptureFormat& frame_format, | 406 const VideoCaptureFormat& frame_format, |
| 406 int aspect_numerator, | 407 int aspect_numerator, |
| 407 int aspect_denominator, | 408 int aspect_denominator, |
| 408 base::TimeDelta timestamp) { | 409 base::TimeDelta timestamp) { |
| 410 if (state_ != kCapturing) | |
|
chfremer
2017/02/17 23:51:15
Unless this runs on the same thread as AllocateAnd
braveyao
2017/02/22 18:06:44
Done.
Tried to apply std::atomic<> to all other pl
| |
| 411 return; | |
| 412 | |
| 409 if (capture_format_.frame_size != frame_format.frame_size) { | 413 if (capture_format_.frame_size != frame_format.frame_size) { |
| 410 ReceiveError(FROM_HERE, | 414 ReceiveError(FROM_HERE, |
| 411 "Captured resolution " + frame_format.frame_size.ToString() + | 415 "Captured resolution " + frame_format.frame_size.ToString() + |
| 412 ", and expected " + capture_format_.frame_size.ToString()); | 416 ", and expected " + capture_format_.frame_size.ToString()); |
| 413 return; | 417 return; |
| 414 } | 418 } |
| 415 | 419 |
| 416 client_->OnIncomingCapturedData(video_frame, video_frame_length, frame_format, | 420 client_->OnIncomingCapturedData(video_frame, video_frame_length, frame_format, |
| 417 0, base::TimeTicks::Now(), timestamp); | 421 0, base::TimeTicks::Now(), timestamp); |
| 418 } | 422 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 492 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
| 489 width:capture_format_.frame_size.width() | 493 width:capture_format_.frame_size.width() |
| 490 frameRate:capture_format_.frame_rate]) { | 494 frameRate:capture_format_.frame_rate]) { |
| 491 ReceiveError(FROM_HERE, "Could not configure capture device."); | 495 ReceiveError(FROM_HERE, "Could not configure capture device."); |
| 492 return false; | 496 return false; |
| 493 } | 497 } |
| 494 return true; | 498 return true; |
| 495 } | 499 } |
| 496 | 500 |
| 497 } // namespace media | 501 } // namespace media |
| OLD | NEW |