Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: media/capture/video/android/video_capture_device_android.cc

Issue 2239583002: ImageCapture: support enhanced FocusMode getting/setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reillyg@ comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 DCHECK_EQ(kConfigured, state_); 382 DCHECK_EQ(kConfigured, state_);
383 DCHECK(got_first_frame_); 383 DCHECK(got_first_frame_);
384 } 384 }
385 #endif 385 #endif
386 JNIEnv* env = AttachCurrentThread(); 386 JNIEnv* env = AttachCurrentThread();
387 387
388 // Make copy on the heap so we can pass the pointer through JNI. 388 // Make copy on the heap so we can pass the pointer through JNI.
389 std::unique_ptr<TakePhotoCallback> heap_callback( 389 std::unique_ptr<TakePhotoCallback> heap_callback(
390 new TakePhotoCallback(std::move(callback))); 390 new TakePhotoCallback(std::move(callback)));
391 const intptr_t callback_id = reinterpret_cast<intptr_t>(heap_callback.get()); 391 const intptr_t callback_id = reinterpret_cast<intptr_t>(heap_callback.get());
392 if (!Java_VideoCapture_takePhoto(env, j_capture_.obj(), callback_id, 392 if (!Java_VideoCapture_takePhoto(env, j_capture_.obj(), callback_id))
393 next_photo_resolution_.width(),
394 next_photo_resolution_.height()))
395 return; 393 return;
396 394
397 { 395 {
398 base::AutoLock lock(photo_callbacks_lock_); 396 base::AutoLock lock(photo_callbacks_lock_);
399 photo_callbacks_.push_back(std::move(heap_callback)); 397 photo_callbacks_.push_back(std::move(heap_callback));
400 } 398 }
401 } 399 }
402 400
403 void VideoCaptureDeviceAndroid::DoGetPhotoCapabilities( 401 void VideoCaptureDeviceAndroid::DoGetPhotoCapabilities(
404 GetPhotoCapabilitiesCallback callback) { 402 GetPhotoCapabilitiesCallback callback) {
(...skipping 23 matching lines...) Expand all
428 photo_capabilities->height->max = caps.getMaxHeight(); 426 photo_capabilities->height->max = caps.getMaxHeight();
429 photo_capabilities->height->min = caps.getMinHeight(); 427 photo_capabilities->height->min = caps.getMinHeight();
430 photo_capabilities->width = mojom::Range::New(); 428 photo_capabilities->width = mojom::Range::New();
431 photo_capabilities->width->current = caps.getCurrentWidth(); 429 photo_capabilities->width->current = caps.getCurrentWidth();
432 photo_capabilities->width->max = caps.getMaxWidth(); 430 photo_capabilities->width->max = caps.getMaxWidth();
433 photo_capabilities->width->min = caps.getMinWidth(); 431 photo_capabilities->width->min = caps.getMinWidth();
434 photo_capabilities->zoom = mojom::Range::New(); 432 photo_capabilities->zoom = mojom::Range::New();
435 photo_capabilities->zoom->current = caps.getCurrentZoom(); 433 photo_capabilities->zoom->current = caps.getCurrentZoom();
436 photo_capabilities->zoom->max = caps.getMaxZoom(); 434 photo_capabilities->zoom->max = caps.getMaxZoom();
437 photo_capabilities->zoom->min = caps.getMinZoom(); 435 photo_capabilities->zoom->min = caps.getMinZoom();
438 photo_capabilities->focus_mode = caps.getAutoFocusInUse() 436 switch (caps.getFocusMode()) {
439 ? mojom::FocusMode::AUTO 437 case PhotoCapabilities::AndroidFocusMode::UNAVAILABLE:
440 : mojom::FocusMode::MANUAL; 438 photo_capabilities->focus_mode = mojom::FocusMode::UNAVAILABLE;
439 break;
440 case PhotoCapabilities::AndroidFocusMode::FIXED:
441 photo_capabilities->focus_mode = mojom::FocusMode::MANUAL;
442 break;
443 case PhotoCapabilities::AndroidFocusMode::SINGLE_SHOT:
444 photo_capabilities->focus_mode = mojom::FocusMode::SINGLE_SHOT;
445 break;
446 case PhotoCapabilities::AndroidFocusMode::CONTINUOUS:
447 photo_capabilities->focus_mode = mojom::FocusMode::CONTINUOUS;
448 break;
449 }
441 callback.Run(std::move(photo_capabilities)); 450 callback.Run(std::move(photo_capabilities));
442 } 451 }
443 452
444 void VideoCaptureDeviceAndroid::DoSetPhotoOptions( 453 void VideoCaptureDeviceAndroid::DoSetPhotoOptions(
445 mojom::PhotoSettingsPtr settings, 454 mojom::PhotoSettingsPtr settings,
446 SetPhotoOptionsCallback callback) { 455 SetPhotoOptionsCallback callback) {
447 DCHECK(main_task_runner_->BelongsToCurrentThread()); 456 DCHECK(main_task_runner_->BelongsToCurrentThread());
448 #if DCHECK_IS_ON() 457 #if DCHECK_IS_ON()
449 { 458 {
450 base::AutoLock lock(lock_); 459 base::AutoLock lock(lock_);
451 DCHECK_EQ(kConfigured, state_); 460 DCHECK_EQ(kConfigured, state_);
452 DCHECK(got_first_frame_); 461 DCHECK(got_first_frame_);
453 } 462 }
454 #endif 463 #endif
455 JNIEnv* env = AttachCurrentThread(); 464 JNIEnv* env = AttachCurrentThread();
456 465
457 // |width| and/or |height| are kept for the next TakePhoto()s. 466 const int width = settings->has_width ? settings->width : 0;
458 if (settings->has_width || settings->has_height) 467 const int height = settings->has_height ? settings->height : 0;
459 next_photo_resolution_.SetSize(0, 0); 468 const int zoom = settings->has_zoom ? settings->zoom : 0;
460 if (settings->has_width) { 469
461 next_photo_resolution_.set_width( 470 PhotoCapabilities::AndroidFocusMode focus_mode =
462 base::saturated_cast<int>(settings->width)); 471 PhotoCapabilities::AndroidFocusMode::UNAVAILABLE;
463 } 472 if (settings->has_focus_mode) {
464 if (settings->has_height) { 473 switch (settings->focus_mode) {
465 next_photo_resolution_.set_height( 474 case mojom::FocusMode::MANUAL:
466 base::saturated_cast<int>(settings->height)); 475 focus_mode = PhotoCapabilities::AndroidFocusMode::FIXED;
476 break;
477 case mojom::FocusMode::SINGLE_SHOT:
478 focus_mode = PhotoCapabilities::AndroidFocusMode::SINGLE_SHOT;
479 break;
480 case mojom::FocusMode::CONTINUOUS:
481 focus_mode = PhotoCapabilities::AndroidFocusMode::CONTINUOUS;
482 break;
483 case mojom::FocusMode::UNAVAILABLE:
484 focus_mode = PhotoCapabilities::AndroidFocusMode::UNAVAILABLE;
485 break;
486 }
467 } 487 }
468 488
469 if (settings->has_zoom) 489 Java_VideoCapture_setPhotoOptions(
470 Java_VideoCapture_setZoom(env, j_capture_.obj(), settings->zoom); 490 env, j_capture_.obj(), zoom, static_cast<int>(focus_mode), width, height);
471 491
472 callback.Run(true); 492 callback.Run(true);
473 } 493 }
474 494
475 } // namespace media 495 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698