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

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: 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) 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 const auto reference_it = 252 const auto reference_it =
253 std::find_if(photo_callbacks_.begin(), photo_callbacks_.end(), 253 std::find_if(photo_callbacks_.begin(), photo_callbacks_.end(),
254 [cb](const std::unique_ptr<TakePhotoCallback>& callback) { 254 [cb](const std::unique_ptr<TakePhotoCallback>& callback) {
255 return callback.get() == cb; 255 return callback.get() == cb;
256 }); 256 });
257 if (reference_it == photo_callbacks_.end()) { 257 if (reference_it == photo_callbacks_.end()) {
258 NOTREACHED() << "|callback_id| not found."; 258 NOTREACHED() << "|callback_id| not found.";
259 return; 259 return;
260 } 260 }
261 261
262 std::vector<uint8_t> native_data; 262 mojom::BlobPtr blob = mojom::Blob::New();
263 base::android::JavaByteArrayToByteVector(env, data.obj(), &native_data); 263 base::android::JavaByteArrayToByteVector(env, data.obj(), &blob->data);
264 264 blob->mime_type = blob->data.empty() ? "" : "image/jpeg";
265 cb->Run(std::string(native_data.empty() ? "" : "image/jpeg"), native_data); 265 cb->Run(std::move(blob));
266 266
267 photo_callbacks_.erase(reference_it); 267 photo_callbacks_.erase(reference_it);
268 } 268 }
269 269
270 VideoPixelFormat VideoCaptureDeviceAndroid::GetColorspace() { 270 VideoPixelFormat VideoCaptureDeviceAndroid::GetColorspace() {
271 JNIEnv* env = AttachCurrentThread(); 271 JNIEnv* env = AttachCurrentThread();
272 const int current_capture_colorspace = 272 const int current_capture_colorspace =
273 Java_VideoCapture_getColorspace(env, j_capture_.obj()); 273 Java_VideoCapture_getColorspace(env, j_capture_.obj());
274 switch (current_capture_colorspace) { 274 switch (current_capture_colorspace) {
275 case ANDROID_IMAGE_FORMAT_YV12: 275 case ANDROID_IMAGE_FORMAT_YV12:
(...skipping 12 matching lines...) Expand all
288 const tracked_objects::Location& from_here, 288 const tracked_objects::Location& from_here,
289 const std::string& reason) { 289 const std::string& reason) {
290 { 290 {
291 base::AutoLock lock(lock_); 291 base::AutoLock lock(lock_);
292 state_ = kError; 292 state_ = kError;
293 } 293 }
294 client_->OnError(from_here, reason); 294 client_->OnError(from_here, reason);
295 } 295 }
296 296
297 } // namespace media 297 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698