| Index: services/video_capture/public/interfaces/video_capture_settings_struct_traits.h
|
| diff --git a/services/video_capture/public/interfaces/video_capture_settings_struct_traits.h b/services/video_capture/public/interfaces/video_capture_settings_struct_traits.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b3d551c81b8e7d69c99ac027b700c21c81750537
|
| --- /dev/null
|
| +++ b/services/video_capture/public/interfaces/video_capture_settings_struct_traits.h
|
| @@ -0,0 +1,145 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_SETTINGS_STRUCT_TRAITS_H_
|
| +#define SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_SETTINGS_STRUCT_TRAITS_H_
|
| +
|
| +#include "media/base/video_capture_types.h"
|
| +#include "services/video_capture/public/interfaces/video_capture_settings.mojom.h"
|
| +#include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
|
| +
|
| +namespace mojo {
|
| +
|
| +template <>
|
| +struct EnumTraits<video_capture::mojom::ResolutionChangePolicy,
|
| + media::ResolutionChangePolicy> {
|
| + static video_capture::mojom::ResolutionChangePolicy ToMojom(
|
| + media::ResolutionChangePolicy input) {
|
| + switch (input) {
|
| + case media::RESOLUTION_POLICY_FIXED_RESOLUTION:
|
| + return video_capture::mojom::ResolutionChangePolicy::FIXED_RESOLUTION;
|
| + case media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO:
|
| + return video_capture::mojom::ResolutionChangePolicy::FIXED_ASPECT_RATIO;
|
| + case media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT:
|
| + return video_capture::mojom::ResolutionChangePolicy::ANY_WITHIN_LIMIT;
|
| + }
|
| + NOTREACHED();
|
| + return video_capture::mojom::ResolutionChangePolicy::FIXED_RESOLUTION;
|
| + }
|
| +
|
| + static bool FromMojom(video_capture::mojom::ResolutionChangePolicy input,
|
| + media::ResolutionChangePolicy* output) {
|
| + switch (input) {
|
| + case video_capture::mojom::ResolutionChangePolicy::FIXED_RESOLUTION:
|
| + *output = media::RESOLUTION_POLICY_FIXED_RESOLUTION;
|
| + return true;
|
| + case video_capture::mojom::ResolutionChangePolicy::FIXED_ASPECT_RATIO:
|
| + *output = media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO;
|
| + return true;
|
| + case video_capture::mojom::ResolutionChangePolicy::ANY_WITHIN_LIMIT:
|
| + *output = media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT;
|
| + return true;
|
| + }
|
| + NOTREACHED();
|
| + return false;
|
| + }
|
| +};
|
| +
|
| +template <>
|
| +struct EnumTraits<video_capture::mojom::PowerLineFrequency,
|
| + media::PowerLineFrequency> {
|
| + static video_capture::mojom::PowerLineFrequency ToMojom(
|
| + media::PowerLineFrequency input) {
|
| + switch (input) {
|
| + case media::PowerLineFrequency::FREQUENCY_DEFAULT:
|
| + return video_capture::mojom::PowerLineFrequency::DEFAULT;
|
| + case media::PowerLineFrequency::FREQUENCY_50HZ:
|
| + return video_capture::mojom::PowerLineFrequency::HZ_50;
|
| + case media::PowerLineFrequency::FREQUENCY_60HZ:
|
| + return video_capture::mojom::PowerLineFrequency::HZ_60;
|
| + }
|
| + NOTREACHED();
|
| + return video_capture::mojom::PowerLineFrequency::DEFAULT;
|
| + }
|
| +
|
| + static bool FromMojom(video_capture::mojom::PowerLineFrequency input,
|
| + media::PowerLineFrequency* output) {
|
| + switch (input) {
|
| + case video_capture::mojom::PowerLineFrequency::DEFAULT:
|
| + *output = media::PowerLineFrequency::FREQUENCY_DEFAULT;
|
| + return true;
|
| + case video_capture::mojom::PowerLineFrequency::HZ_50:
|
| + *output = media::PowerLineFrequency::FREQUENCY_50HZ;
|
| + return true;
|
| + case video_capture::mojom::PowerLineFrequency::HZ_60:
|
| + *output = media::PowerLineFrequency::FREQUENCY_60HZ;
|
| + return true;
|
| + }
|
| + NOTREACHED();
|
| + return false;
|
| + }
|
| +};
|
| +
|
| +template <>
|
| +struct StructTraits<video_capture::mojom::VideoCaptureFormatDataView,
|
| + media::VideoCaptureFormat> {
|
| + static const gfx::Size& frame_size(
|
| + const media::VideoCaptureFormat& input) {
|
| + return input.frame_size;
|
| + }
|
| +
|
| + static float frame_rate(
|
| + const media::VideoCaptureFormat& input) {
|
| + return input.frame_rate;
|
| + }
|
| +
|
| + static bool Read(
|
| + video_capture::mojom::VideoCaptureFormatDataView data,
|
| + media::VideoCaptureFormat* output) {
|
| + if (!data.ReadFrameSize(&(output->frame_size)))
|
| + return false;
|
| +
|
| + output->frame_rate = data.frame_rate();
|
| + return true;
|
| + }
|
| +};
|
| +
|
| +template <>
|
| +struct StructTraits<video_capture::mojom::VideoCaptureSettingsDataView,
|
| + media::VideoCaptureParams> {
|
| + static const media::VideoCaptureFormat& format(
|
| + const media::VideoCaptureParams& input) {
|
| + return input.requested_format;
|
| + }
|
| +
|
| + static media::ResolutionChangePolicy resolution_change_policy(
|
| + const media::VideoCaptureParams& input) {
|
| + return input.resolution_change_policy;
|
| + }
|
| +
|
| + static media::PowerLineFrequency power_line_frequency(
|
| + const media::VideoCaptureParams& input) {
|
| + return input.power_line_frequency;
|
| + }
|
| +
|
| + static bool Read(
|
| + video_capture::mojom::VideoCaptureSettingsDataView data,
|
| + media::VideoCaptureParams* output) {
|
| +
|
| + if (!data.ReadFormat(&(output->requested_format)))
|
| + return false;
|
| +
|
| + if (!data.ReadResolutionChangePolicy(&(output->resolution_change_policy)))
|
| + return false;
|
| +
|
| + if (!data.ReadPowerLineFrequency(&(output->power_line_frequency)))
|
| + return false;
|
| +
|
| + return true;
|
| + }
|
| +};
|
| +
|
| +} // namespace mojo
|
| +
|
| +#endif // SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_SETTINGS_STRUCT_TRAITS_H_
|
|
|