Commit db8656c1 authored by Eero Häkkinen's avatar Eero Häkkinen Committed by Commit Bot

[PTZ] Add pan-tilt-zoom support state to fake video capture config

This CL adds pan-tilt-zoom support state to fake photo device config and
allows that state to controller.

Bug: 934063

Change-Id: I4cf4a0525962bfb504d7e57bf18d97bde2766381
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225716
Commit-Queue: Eero Häkkinen <eero.hakkinen@intel.com>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774997}
parent 39e5cfe8
......@@ -610,22 +610,28 @@ void FakePhotoDevice::GetPhotoState(
photo_state->focus_distance->step = kFocusDistanceStep;
photo_state->pan = mojom::Range::New();
if (config_.pan_tilt_zoom_supported) {
photo_state->pan->current = fake_device_state_->pan;
photo_state->pan->max = kMaxPan;
photo_state->pan->min = kMinPan;
photo_state->pan->step = kPanStep;
}
photo_state->tilt = mojom::Range::New();
if (config_.pan_tilt_zoom_supported) {
photo_state->tilt->current = fake_device_state_->tilt;
photo_state->tilt->max = kMaxTilt;
photo_state->tilt->min = kMinTilt;
photo_state->tilt->step = kTiltStep;
}
photo_state->zoom = mojom::Range::New();
if (config_.pan_tilt_zoom_supported) {
photo_state->zoom->current = fake_device_state_->zoom;
photo_state->zoom->max = kMaxZoom;
photo_state->zoom->min = kMinZoom;
photo_state->zoom->step = kZoomStep;
}
photo_state->supports_torch = false;
photo_state->torch = false;
......
......@@ -156,14 +156,10 @@ class FrameDelivererFactory {
};
struct FakePhotoDeviceConfig {
FakePhotoDeviceConfig()
: should_fail_get_photo_capabilities(false),
should_fail_set_photo_options(false),
should_fail_take_photo(false) {}
bool should_fail_get_photo_capabilities;
bool should_fail_set_photo_options;
bool should_fail_take_photo;
bool pan_tilt_zoom_supported = true;
bool should_fail_get_photo_capabilities = false;
bool should_fail_set_photo_options = false;
bool should_fail_take_photo = false;
};
// Implements the photo functionality of a FakeVideoCaptureDevice
......
......@@ -209,17 +209,18 @@ void FakeVideoCaptureDeviceFactory::GetDeviceDescriptors(
device_descriptors->emplace_back(
base::StringPrintf("fake_device_%d", entry_index), entry.device_id,
#if defined(OS_LINUX)
VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE
VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE,
#elif defined(OS_MACOSX)
VideoCaptureApi::MACOSX_AVFOUNDATION
VideoCaptureApi::MACOSX_AVFOUNDATION,
#elif defined(OS_WIN)
VideoCaptureApi::WIN_DIRECT_SHOW
VideoCaptureApi::WIN_DIRECT_SHOW,
#elif defined(OS_ANDROID)
VideoCaptureApi::ANDROID_API2_LEGACY
VideoCaptureApi::ANDROID_API2_LEGACY,
#elif defined(OS_FUCHSIA)
VideoCaptureApi::UNKNOWN
VideoCaptureApi::UNKNOWN,
#endif
);
VideoCaptureTransportType::OTHER_TRANSPORT,
entry.photo_device_config.pan_tilt_zoom_supported);
entry_index++;
}
}
......@@ -255,6 +256,7 @@ void FakeVideoCaptureDeviceFactory::ParseFakeDevicesConfigFromOptionsString(
std::vector<gfx::Size> resolutions = ArrayToVector(kDefaultResolutions);
std::vector<float> frame_rates = ArrayToVector(kDefaultFrameRates);
int device_count = kDefaultDeviceCount;
FakePhotoDeviceConfig photo_device_config;
FakeVideoCaptureDevice::DisplayMediaType display_media_type =
FakeVideoCaptureDevice::DisplayMediaType::ANY;
......@@ -331,6 +333,13 @@ void FakeVideoCaptureDeviceFactory::ParseFakeDevicesConfigFromOptionsString(
} else if (base::EqualsCaseInsensitiveASCII(param.back(), "browser")) {
display_media_type = FakeVideoCaptureDevice::DisplayMediaType::BROWSER;
}
} else if (base::EqualsCaseInsensitiveASCII(param.front(),
"hardware-support")) {
photo_device_config.pan_tilt_zoom_supported = false;
if (base::EqualsCaseInsensitiveASCII(param.back(), "pan-tilt-zoom"))
photo_device_config.pan_tilt_zoom_supported = true;
else if (!base::EqualsCaseInsensitiveASCII(param.back(), "none"))
LOG(WARNING) << "Unknown hardware support " << param.back();
}
}
......@@ -342,6 +351,7 @@ void FakeVideoCaptureDeviceFactory::ParseFakeDevicesConfigFromOptionsString(
settings.device_id = base::StringPrintf(kDefaultDeviceIdMask, device_index);
AppendAllCombinationsToFormatsContainer(
pixel_formats, resolutions, frame_rates, &settings.supported_formats);
settings.photo_device_config = photo_device_config;
settings.display_media_type = display_media_type;
config->push_back(settings);
}
......
......@@ -33,6 +33,11 @@ using ::testing::Values;
namespace media {
bool operator==(const FakePhotoDeviceConfig& lhs,
const FakePhotoDeviceConfig& rhs) {
return std::memcmp(&lhs, &rhs, sizeof(lhs)) == 0;
}
namespace {
class ImageCaptureClient : public base::RefCounted<ImageCaptureClient> {
......@@ -405,6 +410,7 @@ struct CommandLineTestData {
size_t expected_device_count;
FakeVideoCaptureDevice::DisplayMediaType expected_display_media_type;
std::vector<VideoPixelFormat> expected_pixel_formats;
FakePhotoDeviceConfig expected_photo_device_config;
};
class FakeVideoCaptureDeviceFactoryTest
......@@ -442,6 +448,8 @@ TEST_P(FakeVideoCaptureDeviceFactoryTest,
FakeVideoCaptureDeviceFactory::ParseFakeDevicesConfigFromOptionsString(
GetParam().switch_value_string, &config);
for (const auto& settings : config) {
EXPECT_EQ(GetParam().expected_photo_device_config,
settings.photo_device_config);
EXPECT_EQ(GetParam().expected_display_media_type,
settings.display_media_type);
}
......@@ -491,7 +499,8 @@ INSTANTIATE_TEST_SUITE_P(
5,
1u,
FakeVideoCaptureDevice::DisplayMediaType::ANY,
{PIXEL_FORMAT_I420}},
{PIXEL_FORMAT_I420},
{true, false, false, false}},
CommandLineTestData{"fps=29.97,device-count=1",
29.97f,
1u,
......@@ -524,6 +533,18 @@ INSTANTIATE_TEST_SUITE_P(
0u,
FakeVideoCaptureDevice::DisplayMediaType::ANY,
{PIXEL_FORMAT_I420}},
CommandLineTestData{"hardware-support=none",
20,
1u,
FakeVideoCaptureDevice::DisplayMediaType::ANY,
{PIXEL_FORMAT_I420},
{false}},
CommandLineTestData{"hardware-support=pan-tilt-zoom,fps=60",
60,
1u,
FakeVideoCaptureDevice::DisplayMediaType::ANY,
{PIXEL_FORMAT_I420},
{true}},
CommandLineTestData{"display-media-type=window",
20,
1u,
......
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