Commit 18a0e912 authored by Moja Hsu's avatar Moja Hsu Committed by Chromium LUCI CQ

camera: Support iso control

This CL adds iso MediaTrackCapabilities.

Bug: b:151048287
Test: Tested on kukui.
Change-Id: Icf05d4666f5d6fbe31f1cb768730c9f7e5444a0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2374467Reviewed-by: default avatarWei Lee <wtlee@chromium.org>
Commit-Queue: Hsu Wei-Cheng <mojahsu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839078}
parent 4418438f
...@@ -294,6 +294,7 @@ void CameraDeviceDelegate::AllocateAndStart( ...@@ -294,6 +294,7 @@ void CameraDeviceDelegate::AllocateAndStart(
is_set_contrast_ = false; is_set_contrast_ = false;
is_set_exposure_time_ = false; is_set_exposure_time_ = false;
is_set_focus_distance_ = false; is_set_focus_distance_ = false;
is_set_iso_ = false;
is_set_pan_ = false; is_set_pan_ = false;
is_set_saturation_ = false; is_set_saturation_ = false;
is_set_sharpness_ = false; is_set_sharpness_ = false;
...@@ -428,6 +429,13 @@ void CameraDeviceDelegate::SetPhotoOptions( ...@@ -428,6 +429,13 @@ void CameraDeviceDelegate::SetPhotoOptions(
// Set the vendor tag into with given |name| and |value|. Returns true if // Set the vendor tag into with given |name| and |value|. Returns true if
// the vendor tag is set and false otherwise. // the vendor tag is set and false otherwise.
auto to_uint8_vector = [](int32_t value) {
std::vector<uint8_t> temp(sizeof(int32_t));
auto* temp_ptr = reinterpret_cast<int32_t*>(temp.data());
*temp_ptr = value;
return temp;
};
auto set_vendor_int = [&](const std::string& name, bool has_field, auto set_vendor_int = [&](const std::string& name, bool has_field,
double value, bool is_set) { double value, bool is_set) {
const VendorTagInfo* info = const VendorTagInfo* info =
...@@ -438,11 +446,8 @@ void CameraDeviceDelegate::SetPhotoOptions( ...@@ -438,11 +446,8 @@ void CameraDeviceDelegate::SetPhotoOptions(
} }
return false; return false;
} }
std::vector<uint8_t> temp(sizeof(int32_t));
auto* temp_ptr = reinterpret_cast<int32_t*>(temp.data());
*temp_ptr = value;
request_manager_->SetRepeatingCaptureMetadata(info->tag, info->type, 1, request_manager_->SetRepeatingCaptureMetadata(info->tag, info->type, 1,
std::move(temp)); to_uint8_vector(value));
return true; return true;
}; };
is_set_brightness_ = set_vendor_int(kBrightness, settings->has_brightness, is_set_brightness_ = set_vendor_int(kBrightness, settings->has_brightness,
...@@ -538,6 +543,20 @@ void CameraDeviceDelegate::SetPhotoOptions( ...@@ -538,6 +543,20 @@ void CameraDeviceDelegate::SetPhotoOptions(
is_set_focus_distance_ = false; is_set_focus_distance_ = false;
} }
if (settings->has_iso) {
request_manager_->SetRepeatingCaptureMetadata(
cros::mojom::CameraMetadataTag::ANDROID_SENSOR_SENSITIVITY,
cros::mojom::EntryType::TYPE_INT32, 1, to_uint8_vector(settings->iso));
is_set_iso_ = true;
if (!is_set_exposure_time_) {
LOG(WARNING) << "set iso doesn't work due to auto exposure time";
}
} else if (is_set_iso_) {
request_manager_->UnsetRepeatingCaptureMetadata(
cros::mojom::CameraMetadataTag::ANDROID_SENSOR_SENSITIVITY);
is_set_iso_ = false;
}
// If there is callback of SetPhotoOptions(), the streams might being // If there is callback of SetPhotoOptions(), the streams might being
// reconfigured and we should notify them once the reconfiguration is done. // reconfigured and we should notify them once the reconfiguration is done.
auto on_reconfigured_callback = base::BindOnce( auto on_reconfigured_callback = base::BindOnce(
...@@ -1328,6 +1347,13 @@ void CameraDeviceDelegate::OnResultMetadataAvailable( ...@@ -1328,6 +1347,13 @@ void CameraDeviceDelegate::OnResultMetadataAvailable(
if (focus_distance.size() == 1) if (focus_distance.size() == 1)
result_metadata_.focus_distance = focus_distance[0]; result_metadata_.focus_distance = focus_distance[0];
result_metadata_.sensitivity.reset();
auto sensitivity = GetMetadataEntryAsSpan<int32_t>(
result_metadata,
cros::mojom::CameraMetadataTag::ANDROID_SENSOR_SENSITIVITY);
if (sensitivity.size() == 1)
result_metadata_.sensitivity = sensitivity[0];
result_metadata_frame_number_ = frame_number; result_metadata_frame_number_ = frame_number;
// We need to wait the new result metadata for new settings. // We need to wait the new result metadata for new settings.
if (result_metadata_frame_number_ > if (result_metadata_frame_number_ >
...@@ -1544,6 +1570,16 @@ void CameraDeviceDelegate::DoGetPhotoState( ...@@ -1544,6 +1570,16 @@ void CameraDeviceDelegate::DoGetPhotoState(
} }
} }
auto sensitivity_range = GetMetadataEntryAsSpan<int32_t>(
static_metadata_,
cros::mojom::CameraMetadataTag::ANDROID_SENSOR_INFO_SENSITIVITY_RANGE);
if (sensitivity_range.size() == 2 && result_metadata_.sensitivity) {
photo_state->iso->min = sensitivity_range[0];
photo_state->iso->max = sensitivity_range[1];
photo_state->iso->step = 1;
photo_state->iso->current = result_metadata_.sensitivity.value();
}
std::move(callback).Run(std::move(photo_state)); std::move(callback).Run(std::move(photo_state));
} }
......
...@@ -52,6 +52,7 @@ struct ResultMetadata { ...@@ -52,6 +52,7 @@ struct ResultMetadata {
base::Optional<float> focus_distance; base::Optional<float> focus_distance;
base::Optional<int32_t> pan; base::Optional<int32_t> pan;
base::Optional<int32_t> saturation; base::Optional<int32_t> saturation;
base::Optional<int32_t> sensitivity;
base::Optional<int32_t> sharpness; base::Optional<int32_t> sharpness;
base::Optional<int32_t> tilt; base::Optional<int32_t> tilt;
base::Optional<int32_t> zoom; base::Optional<int32_t> zoom;
...@@ -256,6 +257,7 @@ class CAPTURE_EXPORT CameraDeviceDelegate final ...@@ -256,6 +257,7 @@ class CAPTURE_EXPORT CameraDeviceDelegate final
bool is_set_contrast_; bool is_set_contrast_;
bool is_set_exposure_time_; bool is_set_exposure_time_;
bool is_set_focus_distance_; bool is_set_focus_distance_;
bool is_set_iso_;
bool is_set_pan_; bool is_set_pan_;
bool is_set_saturation_; bool is_set_saturation_;
bool is_set_sharpness_; bool is_set_sharpness_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment