Chromium Code Reviews| Index: media/video/capture/android/video_capture_device_android.cc |
| diff --git a/media/video/capture/android/video_capture_device_android.cc b/media/video/capture/android/video_capture_device_android.cc |
| index d8b3796155dd7d087fc45511e9d1ad348da116eb..34a6a9feb567c36328d88dfc858627689fb48970 100644 |
| --- a/media/video/capture/android/video_capture_device_android.cc |
| +++ b/media/video/capture/android/video_capture_device_android.cc |
| @@ -57,7 +57,42 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) { |
| // static |
| void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device, |
| VideoCaptureFormats* formats) { |
| - NOTIMPLEMENTED(); |
| + JNIEnv* env = AttachCurrentThread(); |
|
bulach
2014/02/13 14:08:23
nit: could move this after the StringToInt..
mcasas
2014/02/14 11:28:39
Done.
|
| + int id; |
| + if (!base::StringToInt(device.id(), &id)) |
| + return; |
| + base::android::ScopedJavaLocalRef<jobjectArray> collected_formats = |
| + Java_VideoCapture_getDeviceSupportedFormats(env, id); |
| + if (collected_formats.is_null()) |
| + return; |
| + |
| + jsize num_formats = env->GetArrayLength(collected_formats.obj()); |
| + for (int i = 0; i < num_formats; ++i) { |
| + base::android::ScopedJavaLocalRef<jobject> format( |
| + env, env->GetObjectArrayElement(collected_formats.obj(), i)); |
| + |
| + VideoPixelFormat pixel_format = media::PIXEL_FORMAT_UNKNOWN; |
| + switch (media::Java_CaptureFormat_getPixelFormat(env, format.obj())) { |
| + case VideoCaptureDeviceAndroid::ANDROID_IMAGEFORMAT_YV12: |
| + pixel_format = media::PIXEL_FORMAT_YV12; |
| + break; |
| + case VideoCaptureDeviceAndroid::ANDROID_IMAGEFORMAT_NV21: |
| + pixel_format = media::PIXEL_FORMAT_NV21; |
| + break; |
| + default: |
| + break; |
| + } |
| + formats->push_back(VideoCaptureFormat( |
| + gfx::Size(media::Java_CaptureFormat_getWidth(env, format.obj()), |
| + media::Java_CaptureFormat_getHeight(env, format.obj())), |
| + media::Java_CaptureFormat_getFramerate(env, format.obj()), |
| + pixel_format)); |
| + |
| + VideoCaptureFormat& last_format = formats->back(); |
|
bulach
2014/02/13 14:08:23
nit: maybe clang would complain since this will be
mcasas
2014/02/14 11:28:39
Done.
|
| + DVLOG(1) << device.name() << " resolution: " << |
| + last_format.frame_size.ToString() << ", fps: " << last_format.frame_rate |
| + << ", pixel format: " << last_format.pixel_format; |
| + } |
| } |
| const std::string VideoCaptureDevice::Name::GetModel() const { |