| OLD | NEW |
| 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" |
| 11 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
| 12 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "jni/VideoCapture_jni.h" | 14 #include "jni/VideoCapture_jni.h" |
| 15 #include "media/capture/video/android/photo_capabilities.h" | 15 #include "media/capture/video/android/photo_capabilities.h" |
| 16 #include "media/capture/video/android/video_capture_device_factory_android.h" | 16 #include "media/capture/video/android/video_capture_device_factory_android.h" |
| 17 #include "mojo/public/cpp/bindings/string.h" | |
| 18 | 17 |
| 19 using base::android::AttachCurrentThread; | 18 using base::android::AttachCurrentThread; |
| 20 using base::android::CheckException; | 19 using base::android::CheckException; |
| 21 using base::android::GetClass; | 20 using base::android::GetClass; |
| 22 using base::android::MethodID; | 21 using base::android::MethodID; |
| 23 using base::android::JavaRef; | 22 using base::android::JavaRef; |
| 24 using base::android::ScopedJavaLocalRef; | 23 using base::android::ScopedJavaLocalRef; |
| 25 | 24 |
| 26 namespace media { | 25 namespace media { |
| 27 | 26 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 return callback.get() == cb; | 255 return callback.get() == cb; |
| 257 }); | 256 }); |
| 258 if (reference_it == photo_callbacks_.end()) { | 257 if (reference_it == photo_callbacks_.end()) { |
| 259 NOTREACHED() << "|callback_id| not found."; | 258 NOTREACHED() << "|callback_id| not found."; |
| 260 return; | 259 return; |
| 261 } | 260 } |
| 262 | 261 |
| 263 std::vector<uint8_t> native_data; | 262 std::vector<uint8_t> native_data; |
| 264 base::android::JavaByteArrayToByteVector(env, data.obj(), &native_data); | 263 base::android::JavaByteArrayToByteVector(env, data.obj(), &native_data); |
| 265 | 264 |
| 266 cb->Run(mojo::String::From(native_data.empty() ? "" : "image/jpeg"), | 265 cb->Run(std::string(native_data.empty() ? "" : "image/jpeg"), native_data); |
| 267 mojo::Array<uint8_t>::From(native_data)); | |
| 268 | 266 |
| 269 photo_callbacks_.erase(reference_it); | 267 photo_callbacks_.erase(reference_it); |
| 270 } | 268 } |
| 271 | 269 |
| 272 VideoPixelFormat VideoCaptureDeviceAndroid::GetColorspace() { | 270 VideoPixelFormat VideoCaptureDeviceAndroid::GetColorspace() { |
| 273 JNIEnv* env = AttachCurrentThread(); | 271 JNIEnv* env = AttachCurrentThread(); |
| 274 const int current_capture_colorspace = | 272 const int current_capture_colorspace = |
| 275 Java_VideoCapture_getColorspace(env, j_capture_.obj()); | 273 Java_VideoCapture_getColorspace(env, j_capture_.obj()); |
| 276 switch (current_capture_colorspace) { | 274 switch (current_capture_colorspace) { |
| 277 case ANDROID_IMAGE_FORMAT_YV12: | 275 case ANDROID_IMAGE_FORMAT_YV12: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 290 const tracked_objects::Location& from_here, | 288 const tracked_objects::Location& from_here, |
| 291 const std::string& reason) { | 289 const std::string& reason) { |
| 292 { | 290 { |
| 293 base::AutoLock lock(lock_); | 291 base::AutoLock lock(lock_); |
| 294 state_ = kError; | 292 state_ = kError; |
| 295 } | 293 } |
| 296 client_->OnError(from_here, reason); | 294 client_->OnError(from_here, reason); |
| 297 } | 295 } |
| 298 | 296 |
| 299 } // namespace media | 297 } // namespace media |
| OLD | NEW |