| 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 "device/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/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "device/capture/video/android/video_capture_device_android.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 | 15 |
| 16 using base::android::AttachCurrentThread; | 16 using base::android::AttachCurrentThread; |
| 17 using base::android::ScopedJavaLocalRef; | 17 using base::android::ScopedJavaLocalRef; |
| 18 | 18 |
| 19 namespace media { | 19 namespace device { |
| 20 | 20 |
| 21 // static | 21 // static |
| 22 ScopedJavaLocalRef<jobject> | 22 ScopedJavaLocalRef<jobject> |
| 23 VideoCaptureDeviceFactoryAndroid::createVideoCaptureAndroid( | 23 VideoCaptureDeviceFactoryAndroid::createVideoCaptureAndroid( |
| 24 int id, | 24 int id, |
| 25 jlong nativeVideoCaptureDeviceAndroid) { | 25 jlong nativeVideoCaptureDeviceAndroid) { |
| 26 return (Java_VideoCaptureFactory_createVideoCapture( | 26 return (Java_VideoCaptureFactory_createVideoCapture( |
| 27 AttachCurrentThread(), base::android::GetApplicationContext(), id, | 27 AttachCurrentThread(), base::android::GetApplicationContext(), id, |
| 28 nativeVideoCaptureDeviceAndroid)); | 28 nativeVideoCaptureDeviceAndroid)); |
| 29 } | 29 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 if (collected_formats.is_null()) | 98 if (collected_formats.is_null()) |
| 99 return; | 99 return; |
| 100 | 100 |
| 101 jsize num_formats = env->GetArrayLength(collected_formats.obj()); | 101 jsize num_formats = env->GetArrayLength(collected_formats.obj()); |
| 102 for (int i = 0; i < num_formats; ++i) { | 102 for (int i = 0; i < num_formats; ++i) { |
| 103 base::android::ScopedJavaLocalRef<jobject> format( | 103 base::android::ScopedJavaLocalRef<jobject> format( |
| 104 env, env->GetObjectArrayElement(collected_formats.obj(), i)); | 104 env, env->GetObjectArrayElement(collected_formats.obj(), i)); |
| 105 | 105 |
| 106 VideoPixelFormat pixel_format = | 106 VideoPixelFormat pixel_format = |
| 107 media::PIXEL_FORMAT_UNKNOWN; | 107 media::PIXEL_FORMAT_UNKNOWN; |
| 108 switch (media::Java_VideoCaptureFactory_getCaptureFormatPixelFormat( | 108 switch (Java_VideoCaptureFactory_getCaptureFormatPixelFormat( |
| 109 env, format.obj())) { | 109 env, format.obj())) { |
| 110 case VideoCaptureDeviceAndroid::ANDROID_IMAGE_FORMAT_YV12: | 110 case VideoCaptureDeviceAndroid::ANDROID_IMAGE_FORMAT_YV12: |
| 111 pixel_format = media::PIXEL_FORMAT_YV12; | 111 pixel_format = media::PIXEL_FORMAT_YV12; |
| 112 break; | 112 break; |
| 113 case VideoCaptureDeviceAndroid::ANDROID_IMAGE_FORMAT_NV21: | 113 case VideoCaptureDeviceAndroid::ANDROID_IMAGE_FORMAT_NV21: |
| 114 pixel_format = media::PIXEL_FORMAT_NV21; | 114 pixel_format = media::PIXEL_FORMAT_NV21; |
| 115 break; | 115 break; |
| 116 default: | 116 default: |
| 117 continue; | 117 continue; |
| 118 } | 118 } |
| 119 VideoCaptureFormat capture_format( | 119 VideoCaptureFormat capture_format( |
| 120 gfx::Size(media::Java_VideoCaptureFactory_getCaptureFormatWidth( | 120 gfx::Size( |
| 121 env, format.obj()), | 121 Java_VideoCaptureFactory_getCaptureFormatWidth(env, format.obj()), |
| 122 media::Java_VideoCaptureFactory_getCaptureFormatHeight( | 122 Java_VideoCaptureFactory_getCaptureFormatHeight(env, format.obj())), |
| 123 env, format.obj())), | 123 Java_VideoCaptureFactory_getCaptureFormatFramerate(env, format.obj()), |
| 124 media::Java_VideoCaptureFactory_getCaptureFormatFramerate(env, | |
| 125 format.obj()), | |
| 126 pixel_format); | 124 pixel_format); |
| 127 capture_formats->push_back(capture_format); | 125 capture_formats->push_back(capture_format); |
| 128 DVLOG(1) << device.display_name << " " | 126 DVLOG(1) << device.display_name << " " |
| 129 << VideoCaptureFormat::ToString(capture_format); | 127 << VideoCaptureFormat::ToString(capture_format); |
| 130 } | 128 } |
| 131 } | 129 } |
| 132 | 130 |
| 133 // static | 131 // static |
| 134 VideoCaptureDeviceFactory* | 132 VideoCaptureDeviceFactory* |
| 135 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( | 133 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory( |
| 136 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 134 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 137 return new VideoCaptureDeviceFactoryAndroid(); | 135 return new VideoCaptureDeviceFactoryAndroid(); |
| 138 } | 136 } |
| 139 | 137 |
| 140 } // namespace media | 138 } // namespace device |
| OLD | NEW |