| 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 437 |
| 438 void VideoCaptureDeviceMac::OnPhotoTaken(const uint8_t* image_data, | 438 void VideoCaptureDeviceMac::OnPhotoTaken(const uint8_t* image_data, |
| 439 size_t image_length, | 439 size_t image_length, |
| 440 const std::string& mime_type) { | 440 const std::string& mime_type) { |
| 441 DCHECK(photo_callback_); | 441 DCHECK(photo_callback_); |
| 442 if (!image_data || !image_length) { | 442 if (!image_data || !image_length) { |
| 443 OnPhotoError(); | 443 OnPhotoError(); |
| 444 return; | 444 return; |
| 445 } | 445 } |
| 446 | 446 |
| 447 photo_callback_->Run( | 447 mojom::BlobPtr blob = mojom::Blob::New(); |
| 448 mime_type, std::vector<uint8_t>(image_data, image_data + image_length)); | 448 blob->data.assign(image_data, image_data + image_length); |
| 449 blob->mime_type = mime_type; |
| 450 photo_callback_->Run(std::move(blob)); |
| 449 photo_callback_.reset(); | 451 photo_callback_.reset(); |
| 450 } | 452 } |
| 451 | 453 |
| 452 void VideoCaptureDeviceMac::OnPhotoError() { | 454 void VideoCaptureDeviceMac::OnPhotoError() { |
| 453 DLOG(ERROR) << __FUNCTION__ << " error taking picture"; | 455 DLOG(ERROR) << __FUNCTION__ << " error taking picture"; |
| 454 photo_callback_.reset(); | 456 photo_callback_.reset(); |
| 455 } | 457 } |
| 456 | 458 |
| 457 void VideoCaptureDeviceMac::ReceiveError( | 459 void VideoCaptureDeviceMac::ReceiveError( |
| 458 const tracked_objects::Location& from_here, | 460 const tracked_objects::Location& from_here, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 480 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() | 482 if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() |
| 481 width:capture_format_.frame_size.width() | 483 width:capture_format_.frame_size.width() |
| 482 frameRate:capture_format_.frame_rate]) { | 484 frameRate:capture_format_.frame_rate]) { |
| 483 ReceiveError(FROM_HERE, "Could not configure capture device."); | 485 ReceiveError(FROM_HERE, "Could not configure capture device."); |
| 484 return false; | 486 return false; |
| 485 } | 487 } |
| 486 return true; | 488 return true; |
| 487 } | 489 } |
| 488 | 490 |
| 489 } // namespace media | 491 } // namespace media |
| OLD | NEW |