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

Side by Side Diff: media/capture/video/mac/video_capture_device_mac.mm

Issue 2167313002: ImageCapture: introduce image_capture Blob to allow move-only semantics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: foolip comments and rebase Created 4 years, 5 months 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 unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « media/capture/video/fake_video_capture_device_unittest.cc ('k') | media/capture/video/video_capture_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698