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

Side by Side Diff: media/capture/video/android/video_capture_device_android.cc

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, 4 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/android/video_capture_device_android.h" 5 #include "media/capture/video/android/video_capture_device_android.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 const auto reference_it = 332 const auto reference_it =
333 std::find_if(photo_callbacks_.begin(), photo_callbacks_.end(), 333 std::find_if(photo_callbacks_.begin(), photo_callbacks_.end(),
334 [cb](const std::unique_ptr<TakePhotoCallback>& callback) { 334 [cb](const std::unique_ptr<TakePhotoCallback>& callback) {
335 return callback.get() == cb; 335 return callback.get() == cb;
336 }); 336 });
337 if (reference_it == photo_callbacks_.end()) { 337 if (reference_it == photo_callbacks_.end()) {
338 NOTREACHED() << "|callback_id| not found."; 338 NOTREACHED() << "|callback_id| not found.";
339 return; 339 return;
340 } 340 }
341 341
342 std::vector<uint8_t> native_data; 342 mojom::BlobPtr blob = mojom::Blob::New();
343 base::android::JavaByteArrayToByteVector(env, data.obj(), &native_data); 343 base::android::JavaByteArrayToByteVector(env, data.obj(), &blob->data);
344 344 blob->mime_type = blob->data.empty() ? "" : "image/jpeg";
345 cb->Run(std::string(native_data.empty() ? "" : "image/jpeg"), native_data); 345 cb->Run(std::move(blob));
346 346
347 photo_callbacks_.erase(reference_it); 347 photo_callbacks_.erase(reference_it);
348 } 348 }
349 349
350 VideoPixelFormat VideoCaptureDeviceAndroid::GetColorspace() { 350 VideoPixelFormat VideoCaptureDeviceAndroid::GetColorspace() {
351 JNIEnv* env = AttachCurrentThread(); 351 JNIEnv* env = AttachCurrentThread();
352 const int current_capture_colorspace = 352 const int current_capture_colorspace =
353 Java_VideoCapture_getColorspace(env, j_capture_.obj()); 353 Java_VideoCapture_getColorspace(env, j_capture_.obj());
354 switch (current_capture_colorspace) { 354 switch (current_capture_colorspace) {
355 case ANDROID_IMAGE_FORMAT_YV12: 355 case ANDROID_IMAGE_FORMAT_YV12:
(...skipping 12 matching lines...) Expand all
368 const tracked_objects::Location& from_here, 368 const tracked_objects::Location& from_here,
369 const std::string& reason) { 369 const std::string& reason) {
370 { 370 {
371 base::AutoLock lock(lock_); 371 base::AutoLock lock(lock_);
372 state_ = kError; 372 state_ = kError;
373 } 373 }
374 client_->OnError(from_here, reason); 374 client_->OnError(from_here, reason);
375 } 375 }
376 376
377 } // namespace media 377 } // namespace media
OLDNEW
« no previous file with comments | « content/browser/media/capture/image_capture_impl.cc ('k') | media/capture/video/fake_video_capture_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698