Chromium Code Reviews| Index: media/capture/video/android/video_capture_device_android.cc |
| diff --git a/media/capture/video/android/video_capture_device_android.cc b/media/capture/video/android/video_capture_device_android.cc |
| index 8df6ca9226053c4bc5c180c10ae00ddeee220222..ae32f9a6d47e401a8ae8ea69854fb788f5c4d789 100644 |
| --- a/media/capture/video/android/video_capture_device_android.cc |
| +++ b/media/capture/video/android/video_capture_device_android.cc |
| @@ -389,9 +389,7 @@ void VideoCaptureDeviceAndroid::DoTakePhoto(TakePhotoCallback callback) { |
| std::unique_ptr<TakePhotoCallback> heap_callback( |
| new TakePhotoCallback(std::move(callback))); |
| const intptr_t callback_id = reinterpret_cast<intptr_t>(heap_callback.get()); |
| - if (!Java_VideoCapture_takePhoto(env, j_capture_.obj(), callback_id, |
| - next_photo_resolution_.width(), |
| - next_photo_resolution_.height())) |
| + if (!Java_VideoCapture_takePhoto(env, j_capture_.obj(), callback_id)) |
| return; |
| { |
| @@ -435,9 +433,22 @@ void VideoCaptureDeviceAndroid::DoGetPhotoCapabilities( |
| photo_capabilities->zoom->current = caps.getCurrentZoom(); |
| photo_capabilities->zoom->max = caps.getMaxZoom(); |
| photo_capabilities->zoom->min = caps.getMinZoom(); |
| - photo_capabilities->focus_mode = caps.getAutoFocusInUse() |
| - ? mojom::FocusMode::AUTO |
| - : mojom::FocusMode::MANUAL; |
| + switch (caps.getFocusMode()) { |
| + case PhotoCapabilities::ANDROID_FOCUS_MODE_UNAVAILABLE: |
| + photo_capabilities->focus_mode = mojom::FocusMode::UNAVAILABLE; |
| + break; |
| + case PhotoCapabilities::ANDROID_FOCUS_MODE_FIXED: |
| + photo_capabilities->focus_mode = mojom::FocusMode::MANUAL; |
| + break; |
| + case PhotoCapabilities::ANDROID_FOCUS_MODE_SINGLE_SHOT: |
| + photo_capabilities->focus_mode = mojom::FocusMode::SINGLE_SHOT; |
| + break; |
| + case PhotoCapabilities::ANDROID_FOCUS_MODE_CONTINUOUS: |
| + photo_capabilities->focus_mode = mojom::FocusMode::CONTINUOUS; |
| + break; |
| + default: |
|
Reilly Grant (use Gerrit)
2016/08/15 20:28:18
Use an enum class and you won't need a default cas
mcasas
2016/08/15 21:08:54
Done.
|
| + NOTREACHED(); |
| + } |
| callback.Run(std::move(photo_capabilities)); |
| } |
| @@ -454,20 +465,33 @@ void VideoCaptureDeviceAndroid::DoSetPhotoOptions( |
| #endif |
| JNIEnv* env = AttachCurrentThread(); |
| - // |width| and/or |height| are kept for the next TakePhoto()s. |
| - if (settings->has_width || settings->has_height) |
| - next_photo_resolution_.SetSize(0, 0); |
| - if (settings->has_width) { |
| - next_photo_resolution_.set_width( |
| - base::saturated_cast<int>(settings->width)); |
| - } |
| - if (settings->has_height) { |
| - next_photo_resolution_.set_height( |
| - base::saturated_cast<int>(settings->height)); |
| + const int width = settings->has_width ? settings->width : 0; |
| + const int height = settings->has_height ? settings->height : 0; |
| + const int zoom = settings->has_zoom ? settings->zoom : 0; |
| + |
| + PhotoCapabilities::AndroidFocusMode focus_mode = |
| + PhotoCapabilities::ANDROID_FOCUS_MODE_UNAVAILABLE; |
| + if (settings->has_focus_mode) { |
| + switch (settings->focus_mode) { |
| + case mojom::FocusMode::MANUAL: |
| + focus_mode = PhotoCapabilities::ANDROID_FOCUS_MODE_FIXED; |
| + break; |
| + case mojom::FocusMode::SINGLE_SHOT: |
| + focus_mode = PhotoCapabilities::ANDROID_FOCUS_MODE_SINGLE_SHOT; |
| + break; |
| + case mojom::FocusMode::CONTINUOUS: |
| + focus_mode = PhotoCapabilities::ANDROID_FOCUS_MODE_CONTINUOUS; |
| + break; |
| + case mojom::FocusMode::UNAVAILABLE: |
| + focus_mode = PhotoCapabilities::ANDROID_FOCUS_MODE_UNAVAILABLE; |
| + break; |
| + default: |
| + NOTREACHED(); |
| + } |
| } |
| - if (settings->has_zoom) |
| - Java_VideoCapture_setZoom(env, j_capture_.obj(), settings->zoom); |
| + Java_VideoCapture_setPhotoOptions(env, j_capture_.obj(), zoom, focus_mode, |
| + width, height); |
| callback.Run(true); |
| } |