| 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/video/capture/android/video_capture_device_factory_android.h" | 5 #include "media/video/capture/android/video_capture_device_factory_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 return scoped_ptr<VideoCaptureDevice>(); | 51 return scoped_ptr<VideoCaptureDevice>(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void VideoCaptureDeviceFactoryAndroid::GetDeviceNames( | 54 void VideoCaptureDeviceFactoryAndroid::GetDeviceNames( |
| 55 VideoCaptureDevice::Names* device_names) { | 55 VideoCaptureDevice::Names* device_names) { |
| 56 DCHECK(thread_checker_.CalledOnValidThread()); | 56 DCHECK(thread_checker_.CalledOnValidThread()); |
| 57 device_names->clear(); | 57 device_names->clear(); |
| 58 | 58 |
| 59 JNIEnv* env = AttachCurrentThread(); | 59 JNIEnv* env = AttachCurrentThread(); |
| 60 | 60 |
| 61 int num_cameras = Java_ChromiumCameraInfo_getNumberOfCameras( | 61 int num_cameras = Java_VideoCaptureFactory_getNumberOfCameras( |
| 62 env, base::android::GetApplicationContext()); | 62 env, base::android::GetApplicationContext()); |
| 63 DVLOG(1) << "VideoCaptureDevice::GetDeviceNames: num_cameras=" << num_cameras; | 63 DVLOG(1) << "VideoCaptureDevice::GetDeviceNames: num_cameras=" << num_cameras; |
| 64 if (num_cameras <= 0) | 64 if (num_cameras <= 0) |
| 65 return; | 65 return; |
| 66 | 66 |
| 67 for (int camera_id = num_cameras - 1; camera_id >= 0; --camera_id) { | 67 for (int camera_id = num_cameras - 1; camera_id >= 0; --camera_id) { |
| 68 ScopedJavaLocalRef<jobject> ci = | |
| 69 Java_ChromiumCameraInfo_getAt(env, camera_id); | |
| 70 | |
| 71 VideoCaptureDevice::Name name( | 68 VideoCaptureDevice::Name name( |
| 72 base::android::ConvertJavaStringToUTF8( | 69 base::android::ConvertJavaStringToUTF8( |
| 73 Java_ChromiumCameraInfo_getDeviceName(env, ci.obj())), | 70 Java_VideoCaptureFactory_getDeviceName(env, camera_id)), |
| 74 base::StringPrintf("%d", Java_ChromiumCameraInfo_getId(env, ci.obj()))); | 71 base::android::ConvertJavaStringToUTF8( |
| 72 Java_VideoCaptureFactory_getDeviceId(env, camera_id))); |
| 75 device_names->push_back(name); | 73 device_names->push_back(name); |
| 76 | 74 |
| 77 DVLOG(1) << "VideoCaptureDeviceFactoryAndroid::GetDeviceNames: camera" | 75 DVLOG(1) << "VideoCaptureDeviceFactoryAndroid::GetDeviceNames: camera " |
| 78 << "device_name=" << name.name() << ", unique_id=" << name.id() | 76 << "device_name=" << name.name() << ", unique_id=" << name.id(); |
| 79 << ", orientation " | |
| 80 << Java_ChromiumCameraInfo_getOrientation(env, ci.obj()); | |
| 81 } | 77 } |
| 82 } | 78 } |
| 83 | 79 |
| 84 void VideoCaptureDeviceFactoryAndroid::GetDeviceSupportedFormats( | 80 void VideoCaptureDeviceFactoryAndroid::GetDeviceSupportedFormats( |
| 85 const VideoCaptureDevice::Name& device, | 81 const VideoCaptureDevice::Name& device, |
| 86 VideoCaptureFormats* capture_formats) { | 82 VideoCaptureFormats* capture_formats) { |
| 87 DCHECK(thread_checker_.CalledOnValidThread()); | 83 DCHECK(thread_checker_.CalledOnValidThread()); |
| 88 int id; | 84 int id; |
| 89 if (!base::StringToInt(device.id(), &id)) | 85 if (!base::StringToInt(device.id(), &id)) |
| 90 return; | 86 return; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 118 format.obj())), | 114 format.obj())), |
| 119 media::Java_VideoCaptureFactory_getCaptureFormatFramerate(env, | 115 media::Java_VideoCaptureFactory_getCaptureFormatFramerate(env, |
| 120 format.obj()), | 116 format.obj()), |
| 121 pixel_format); | 117 pixel_format); |
| 122 capture_formats->push_back(capture_format); | 118 capture_formats->push_back(capture_format); |
| 123 DVLOG(1) << device.name() << " " << capture_format.ToString(); | 119 DVLOG(1) << device.name() << " " << capture_format.ToString(); |
| 124 } | 120 } |
| 125 } | 121 } |
| 126 | 122 |
| 127 } // namespace media | 123 } // namespace media |
| OLD | NEW |