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/context_utils.h" | 9 #include "base/android/context_utils.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/android/scoped_java_ref.h" |
11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "jni/VideoCaptureFactory_jni.h" | 14 #include "jni/VideoCaptureFactory_jni.h" |
14 #include "media/capture/video/android/video_capture_device_android.h" | 15 #include "media/capture/video/android/video_capture_device_android.h" |
15 | 16 |
16 using base::android::AttachCurrentThread; | 17 using base::android::AttachCurrentThread; |
| 18 using base::android::JavaRef; |
17 using base::android::ScopedJavaLocalRef; | 19 using base::android::ScopedJavaLocalRef; |
18 | 20 |
19 namespace media { | 21 namespace media { |
20 | 22 |
21 // static | 23 // static |
22 ScopedJavaLocalRef<jobject> | 24 ScopedJavaLocalRef<jobject> |
23 VideoCaptureDeviceFactoryAndroid::createVideoCaptureAndroid( | 25 VideoCaptureDeviceFactoryAndroid::createVideoCaptureAndroid( |
24 int id, | 26 int id, |
25 jlong nativeVideoCaptureDeviceAndroid) { | 27 jlong nativeVideoCaptureDeviceAndroid) { |
26 return (Java_VideoCaptureFactory_createVideoCapture( | 28 return (Java_VideoCaptureFactory_createVideoCapture( |
(...skipping 19 matching lines...) Expand all Loading... |
46 return std::unique_ptr<VideoCaptureDevice>(); | 48 return std::unique_ptr<VideoCaptureDevice>(); |
47 } | 49 } |
48 | 50 |
49 void VideoCaptureDeviceFactoryAndroid::GetDeviceDescriptors( | 51 void VideoCaptureDeviceFactoryAndroid::GetDeviceDescriptors( |
50 VideoCaptureDeviceDescriptors* device_descriptors) { | 52 VideoCaptureDeviceDescriptors* device_descriptors) { |
51 DCHECK(thread_checker_.CalledOnValidThread()); | 53 DCHECK(thread_checker_.CalledOnValidThread()); |
52 device_descriptors->clear(); | 54 device_descriptors->clear(); |
53 | 55 |
54 JNIEnv* env = AttachCurrentThread(); | 56 JNIEnv* env = AttachCurrentThread(); |
55 | 57 |
56 const jobject context = base::android::GetApplicationContext(); | 58 const JavaRef<jobject>& context = base::android::GetApplicationContext(); |
57 const int num_cameras = | 59 const int num_cameras = |
58 Java_VideoCaptureFactory_getNumberOfCameras(env, context); | 60 Java_VideoCaptureFactory_getNumberOfCameras(env, context); |
59 DVLOG(1) << __FUNCTION__ << ": num_cameras=" << num_cameras; | 61 DVLOG(1) << __FUNCTION__ << ": num_cameras=" << num_cameras; |
60 if (num_cameras <= 0) | 62 if (num_cameras <= 0) |
61 return; | 63 return; |
62 | 64 |
63 for (int camera_id = num_cameras - 1; camera_id >= 0; --camera_id) { | 65 for (int camera_id = num_cameras - 1; camera_id >= 0; --camera_id) { |
64 base::android::ScopedJavaLocalRef<jstring> device_name = | 66 base::android::ScopedJavaLocalRef<jstring> device_name = |
65 Java_VideoCaptureFactory_getDeviceName(env, camera_id, context); | 67 Java_VideoCaptureFactory_getDeviceName(env, camera_id, context); |
66 if (device_name.obj() == NULL) | 68 if (device_name.obj() == NULL) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 133 } |
132 | 134 |
133 // static | 135 // static |
134 VideoCaptureDeviceFactory* | 136 VideoCaptureDeviceFactory* |
135 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( | 137 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( |
136 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 138 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
137 return new VideoCaptureDeviceFactoryAndroid(); | 139 return new VideoCaptureDeviceFactoryAndroid(); |
138 } | 140 } |
139 | 141 |
140 } // namespace media | 142 } // namespace media |
OLD | NEW |