| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_factory_android.h" | 5 #include "media/capture/video/android/video_capture_device_factory_android.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "jni/VideoCaptureFactory_jni.h" | 14 #include "jni/VideoCaptureFactory_jni.h" |
| 15 #include "media/capture/video/android/video_capture_device_android.h" | 15 #include "media/capture/video/android/video_capture_device_android.h" |
| 16 #include "media/capture/video/android/video_capture_device_tango_android.h" |
| 16 | 17 |
| 17 using base::android::AttachCurrentThread; | 18 using base::android::AttachCurrentThread; |
| 18 using base::android::JavaRef; | 19 using base::android::JavaRef; |
| 19 using base::android::ScopedJavaLocalRef; | 20 using base::android::ScopedJavaLocalRef; |
| 20 | 21 |
| 21 namespace media { | 22 namespace media { |
| 22 | 23 |
| 23 // static | 24 // static |
| 24 ScopedJavaLocalRef<jobject> | 25 ScopedJavaLocalRef<jobject> |
| 25 VideoCaptureDeviceFactoryAndroid::createVideoCaptureAndroid( | 26 VideoCaptureDeviceFactoryAndroid::createVideoCaptureAndroid( |
| 26 int id, | 27 int id, |
| 27 jlong nativeVideoCaptureDeviceAndroid) { | 28 jlong nativeVideoCaptureDeviceAndroid) { |
| 28 return (Java_VideoCaptureFactory_createVideoCapture( | 29 return (Java_VideoCaptureFactory_createVideoCapture( |
| 29 AttachCurrentThread(), id, nativeVideoCaptureDeviceAndroid)); | 30 AttachCurrentThread(), id, nativeVideoCaptureDeviceAndroid)); |
| 30 } | 31 } |
| 31 | 32 |
| 32 std::unique_ptr<VideoCaptureDevice> | 33 std::unique_ptr<VideoCaptureDevice> |
| 33 VideoCaptureDeviceFactoryAndroid::CreateDevice( | 34 VideoCaptureDeviceFactoryAndroid::CreateDevice( |
| 34 const VideoCaptureDeviceDescriptor& device_descriptor) { | 35 const VideoCaptureDeviceDescriptor& device_descriptor) { |
| 35 DCHECK(thread_checker_.CalledOnValidThread()); | 36 DCHECK(thread_checker_.CalledOnValidThread()); |
| 36 int id; | 37 int id; |
| 37 if (!base::StringToInt(device_descriptor.device_id, &id)) | 38 if (!base::StringToInt(device_descriptor.device_id, &id)) |
| 38 return std::unique_ptr<VideoCaptureDevice>(); | 39 return std::unique_ptr<VideoCaptureDevice>(); |
| 39 | 40 |
| 40 std::unique_ptr<VideoCaptureDeviceAndroid> video_capture_device( | 41 std::unique_ptr<VideoCaptureDeviceAndroid> video_capture_device( |
| 41 new VideoCaptureDeviceAndroid(device_descriptor)); | 42 (device_descriptor.capture_api == VideoCaptureApi::ANDROID_TANGO) |
| 43 ? new VideoCaptureDeviceTangoAndroid(device_descriptor) |
| 44 : new VideoCaptureDeviceAndroid(device_descriptor)); |
| 42 | 45 |
| 43 if (video_capture_device->Init()) { | 46 if (video_capture_device->Init()) { |
| 44 if (test_mode_) | 47 if (test_mode_) |
| 45 video_capture_device->ConfigureForTesting(); | 48 video_capture_device->ConfigureForTesting(); |
| 46 return std::move(video_capture_device); | 49 return std::move(video_capture_device); |
| 47 } | 50 } |
| 48 | 51 |
| 49 DLOG(ERROR) << "Error creating Video Capture Device."; | 52 DLOG(ERROR) << "Error creating Video Capture Device."; |
| 50 return nullptr; | 53 return nullptr; |
| 51 } | 54 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 145 } |
| 143 | 146 |
| 144 // static | 147 // static |
| 145 VideoCaptureDeviceFactory* | 148 VideoCaptureDeviceFactory* |
| 146 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( | 149 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( |
| 147 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 150 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 148 return new VideoCaptureDeviceFactoryAndroid(); | 151 return new VideoCaptureDeviceFactoryAndroid(); |
| 149 } | 152 } |
| 150 | 153 |
| 151 } // namespace media | 154 } // namespace media |
| OLD | NEW |