| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_android.h" | 5 #include "media/capture/video/android/video_capture_device_android.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 if (state_ != kCapturing) | 144 if (state_ != kCapturing) |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 | 147 |
| 148 JNIEnv* env = AttachCurrentThread(); | 148 JNIEnv* env = AttachCurrentThread(); |
| 149 | 149 |
| 150 // Make copy on the heap so we can pass the pointer through JNI. | 150 // Make copy on the heap so we can pass the pointer through JNI. |
| 151 std::unique_ptr<TakePhotoCallback> heap_callback( | 151 std::unique_ptr<TakePhotoCallback> heap_callback( |
| 152 new TakePhotoCallback(std::move(callback))); | 152 new TakePhotoCallback(std::move(callback))); |
| 153 const intptr_t callback_id = reinterpret_cast<intptr_t>(heap_callback.get()); | 153 const intptr_t callback_id = reinterpret_cast<intptr_t>(heap_callback.get()); |
| 154 if (!Java_VideoCapture_takePhoto(env, j_capture_.obj(), callback_id)) | 154 if (!Java_VideoCapture_takePhoto(env, j_capture_.obj(), callback_id, |
| 155 next_photo_resolution_.width(), |
| 156 next_photo_resolution_.height())) |
| 155 return; | 157 return; |
| 156 | 158 |
| 157 { | 159 { |
| 158 base::AutoLock lock(photo_callbacks_lock_); | 160 base::AutoLock lock(photo_callbacks_lock_); |
| 159 photo_callbacks_.push_back(std::move(heap_callback)); | 161 photo_callbacks_.push_back(std::move(heap_callback)); |
| 160 } | 162 } |
| 161 } | 163 } |
| 162 | 164 |
| 163 void VideoCaptureDeviceAndroid::GetPhotoCapabilities( | 165 void VideoCaptureDeviceAndroid::GetPhotoCapabilities( |
| 164 GetPhotoCapabilitiesCallback callback) { | 166 GetPhotoCapabilitiesCallback callback) { |
| 165 JNIEnv* env = AttachCurrentThread(); | 167 JNIEnv* env = AttachCurrentThread(); |
| 166 | 168 |
| 167 PhotoCapabilities caps( | 169 PhotoCapabilities caps( |
| 168 Java_VideoCapture_getPhotoCapabilities(env, j_capture_.obj())); | 170 Java_VideoCapture_getPhotoCapabilities(env, j_capture_.obj())); |
| 169 | 171 |
| 170 // TODO(mcasas): Manual member copying sucks, consider adding typemapping from | 172 // TODO(mcasas): Manual member copying sucks, consider adding typemapping from |
| 171 // PhotoCapabilities to mojom::PhotoCapabilitiesPtr, https://crbug.com/622002. | 173 // PhotoCapabilities to mojom::PhotoCapabilitiesPtr, https://crbug.com/622002. |
| 172 mojom::PhotoCapabilitiesPtr photo_capabilities = | 174 mojom::PhotoCapabilitiesPtr photo_capabilities = |
| 173 mojom::PhotoCapabilities::New(); | 175 mojom::PhotoCapabilities::New(); |
| 176 photo_capabilities->iso = mojom::Range::New(); |
| 177 photo_capabilities->iso->current = caps.getCurrentIso(); |
| 178 photo_capabilities->iso->max = caps.getMaxIso(); |
| 179 photo_capabilities->iso->min = caps.getMinIso(); |
| 180 photo_capabilities->height = mojom::Range::New(); |
| 181 photo_capabilities->height->current = caps.getCurrentHeight(); |
| 182 photo_capabilities->height->max = caps.getMaxHeight(); |
| 183 photo_capabilities->height->min = caps.getMinHeight(); |
| 184 photo_capabilities->width = mojom::Range::New(); |
| 185 photo_capabilities->width->current = caps.getCurrentWidth(); |
| 186 photo_capabilities->width->max = caps.getMaxWidth(); |
| 187 photo_capabilities->width->min = caps.getMinWidth(); |
| 174 photo_capabilities->zoom = mojom::Range::New(); | 188 photo_capabilities->zoom = mojom::Range::New(); |
| 175 photo_capabilities->zoom->current = caps.getCurrentZoom(); | 189 photo_capabilities->zoom->current = caps.getCurrentZoom(); |
| 176 photo_capabilities->zoom->max = caps.getMaxZoom(); | 190 photo_capabilities->zoom->max = caps.getMaxZoom(); |
| 177 photo_capabilities->zoom->min = caps.getMinZoom(); | 191 photo_capabilities->zoom->min = caps.getMinZoom(); |
| 178 photo_capabilities->focus_mode = caps.getAutoFocusInUse() | 192 photo_capabilities->focus_mode = caps.getAutoFocusInUse() |
| 179 ? mojom::FocusMode::AUTO | 193 ? mojom::FocusMode::AUTO |
| 180 : mojom::FocusMode::MANUAL; | 194 : mojom::FocusMode::MANUAL; |
| 181 callback.Run(std::move(photo_capabilities)); | 195 callback.Run(std::move(photo_capabilities)); |
| 182 } | 196 } |
| 183 | 197 |
| 184 void VideoCaptureDeviceAndroid::SetPhotoOptions( | 198 void VideoCaptureDeviceAndroid::SetPhotoOptions( |
| 185 mojom::PhotoSettingsPtr settings, | 199 mojom::PhotoSettingsPtr settings, |
| 186 SetPhotoOptionsCallback callback) { | 200 SetPhotoOptionsCallback callback) { |
| 187 JNIEnv* env = AttachCurrentThread(); | 201 JNIEnv* env = AttachCurrentThread(); |
| 202 // |width| and/or |height| are kept for the next TakePhoto()s. |
| 203 if (settings->has_width || settings->has_height) |
| 204 next_photo_resolution_.SetSize(0, 0); |
| 205 if (settings->has_width) |
| 206 next_photo_resolution_.set_width(settings->width); |
| 207 if (settings->has_height) |
| 208 next_photo_resolution_.set_height(settings->height); |
| 209 |
| 188 if (settings->has_zoom) | 210 if (settings->has_zoom) |
| 189 Java_VideoCapture_setZoom(env, j_capture_.obj(), settings->zoom); | 211 Java_VideoCapture_setZoom(env, j_capture_.obj(), settings->zoom); |
| 190 callback.Run(true); | 212 callback.Run(true); |
| 191 } | 213 } |
| 192 | 214 |
| 193 void VideoCaptureDeviceAndroid::OnFrameAvailable( | 215 void VideoCaptureDeviceAndroid::OnFrameAvailable( |
| 194 JNIEnv* env, | 216 JNIEnv* env, |
| 195 const JavaParamRef<jobject>& obj, | 217 const JavaParamRef<jobject>& obj, |
| 196 const JavaParamRef<jbyteArray>& data, | 218 const JavaParamRef<jbyteArray>& data, |
| 197 jint length, | 219 jint length, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 const tracked_objects::Location& from_here, | 312 const tracked_objects::Location& from_here, |
| 291 const std::string& reason) { | 313 const std::string& reason) { |
| 292 { | 314 { |
| 293 base::AutoLock lock(lock_); | 315 base::AutoLock lock(lock_); |
| 294 state_ = kError; | 316 state_ = kError; |
| 295 } | 317 } |
| 296 client_->OnError(from_here, reason); | 318 client_->OnError(from_here, reason); |
| 297 } | 319 } |
| 298 | 320 |
| 299 } // namespace media | 321 } // namespace media |
| OLD | NEW |