| Index: services/video_capture/public/interfaces/video_capture_device_descriptor_struct_traits.h
|
| diff --git a/services/video_capture/public/interfaces/video_capture_device_descriptor_struct_traits.h b/services/video_capture/public/interfaces/video_capture_device_descriptor_struct_traits.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3ef2d2865c8fc98e83195d03f6316a137b9c55a5
|
| --- /dev/null
|
| +++ b/services/video_capture/public/interfaces/video_capture_device_descriptor_struct_traits.h
|
| @@ -0,0 +1,172 @@
|
| +// 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_DEVICE_DESCRIPTOR_STRUCT_TRAITS_H_
|
| +#define SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_DEVICE_DESCRIPTOR_STRUCT_TRAITS_H_
|
| +
|
| +#include "media/capture/video/video_capture_device_descriptor.h"
|
| +#include "services/video_capture/public/interfaces/video_capture_device_descriptor.mojom.h"
|
| +
|
| +namespace mojo {
|
| +
|
| +template <>
|
| +struct EnumTraits<video_capture::mojom::VideoCaptureApi,
|
| + media::VideoCaptureApi> {
|
| + static video_capture::mojom::VideoCaptureApi ToMojom(
|
| + media::VideoCaptureApi input) {
|
| + switch (input) {
|
| + case media::VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE:
|
| + return video_capture::mojom::VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE;
|
| + case media::VideoCaptureApi::WIN_MEDIA_FOUNDATION:
|
| + return video_capture::mojom::VideoCaptureApi::WIN_MEDIA_FOUNDATION;
|
| + case media::VideoCaptureApi::WIN_DIRECT_SHOW:
|
| + return video_capture::mojom::VideoCaptureApi::WIN_DIRECT_SHOW;
|
| + case media::VideoCaptureApi::MACOSX_AVFOUNDATION:
|
| + return video_capture::mojom::VideoCaptureApi::MACOSX_AVFOUNDATION;
|
| + case media::VideoCaptureApi::MACOSX_DECKLINK:
|
| + return video_capture::mojom::VideoCaptureApi::MACOSX_DECKLINK;
|
| + case media::VideoCaptureApi::ANDROID_API1:
|
| + return video_capture::mojom::VideoCaptureApi::ANDROID_API1;
|
| + case media::VideoCaptureApi::ANDROID_API2_LEGACY:
|
| + return video_capture::mojom::VideoCaptureApi::ANDROID_API2_LEGACY;
|
| + case media::VideoCaptureApi::ANDROID_API2_FULL:
|
| + return video_capture::mojom::VideoCaptureApi::ANDROID_API2_FULL;
|
| + case media::VideoCaptureApi::ANDROID_API2_LIMITED:
|
| + return video_capture::mojom::VideoCaptureApi::ANDROID_API2_LIMITED;
|
| + case media::VideoCaptureApi::ANDROID_TANGO:
|
| + return video_capture::mojom::VideoCaptureApi::ANDROID_TANGO;
|
| + case media::VideoCaptureApi::UNKNOWN:
|
| + return video_capture::mojom::VideoCaptureApi::UNKNOWN;
|
| + }
|
| + NOTREACHED();
|
| + return video_capture::mojom::VideoCaptureApi::UNKNOWN;
|
| + }
|
| +
|
| + static bool FromMojom(video_capture::mojom::VideoCaptureApi input,
|
| + media::VideoCaptureApi* output) {
|
| + switch (input) {
|
| + case video_capture::mojom::VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE:
|
| + *output = media::VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureApi::WIN_MEDIA_FOUNDATION:
|
| + *output = media::VideoCaptureApi::WIN_MEDIA_FOUNDATION;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureApi::WIN_DIRECT_SHOW:
|
| + *output = media::VideoCaptureApi::WIN_DIRECT_SHOW;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureApi::MACOSX_AVFOUNDATION:
|
| + *output = media::VideoCaptureApi::MACOSX_AVFOUNDATION;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureApi::MACOSX_DECKLINK:
|
| + *output = media::VideoCaptureApi::MACOSX_DECKLINK;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureApi::ANDROID_API1:
|
| + *output = media::VideoCaptureApi::ANDROID_API1;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureApi::ANDROID_API2_LEGACY:
|
| + *output = media::VideoCaptureApi::ANDROID_API2_LEGACY;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureApi::ANDROID_API2_FULL:
|
| + *output = media::VideoCaptureApi::ANDROID_API2_FULL;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureApi::ANDROID_API2_LIMITED:
|
| + *output = media::VideoCaptureApi::ANDROID_API2_LIMITED;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureApi::ANDROID_TANGO:
|
| + *output = media::VideoCaptureApi::ANDROID_TANGO;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureApi::UNKNOWN:
|
| + *output = media::VideoCaptureApi::UNKNOWN;
|
| + return true;
|
| + }
|
| + NOTREACHED();
|
| + return false;
|
| + }
|
| +};
|
| +
|
| +template <>
|
| +struct EnumTraits<video_capture::mojom::VideoCaptureTransportType,
|
| + media::VideoCaptureTransportType> {
|
| + static video_capture::mojom::VideoCaptureTransportType ToMojom(
|
| + media::VideoCaptureTransportType input) {
|
| + switch (input) {
|
| + case media::VideoCaptureTransportType::MACOSX_USB_OR_BUILT_IN:
|
| + return video_capture::mojom::VideoCaptureTransportType::
|
| + MACOSX_USB_OR_BUILT_IN;
|
| + case media::VideoCaptureTransportType::OTHER_TRANSPORT:
|
| + return video_capture::mojom::VideoCaptureTransportType::OTHER_TRANSPORT;
|
| + }
|
| + NOTREACHED();
|
| + return video_capture::mojom::VideoCaptureTransportType::OTHER_TRANSPORT;
|
| + }
|
| +
|
| + static bool FromMojom(video_capture::mojom::VideoCaptureTransportType input,
|
| + media::VideoCaptureTransportType* output) {
|
| + switch (input) {
|
| + case video_capture::mojom::VideoCaptureTransportType::
|
| + MACOSX_USB_OR_BUILT_IN:
|
| + *output = media::VideoCaptureTransportType::MACOSX_USB_OR_BUILT_IN;
|
| + return true;
|
| + case video_capture::mojom::VideoCaptureTransportType::OTHER_TRANSPORT:
|
| + *output = media::VideoCaptureTransportType::OTHER_TRANSPORT;
|
| + return true;
|
| + }
|
| + NOTREACHED();
|
| + return false;
|
| + }
|
| +};
|
| +
|
| +template <>
|
| +struct StructTraits<video_capture::mojom::VideoCaptureDeviceDescriptorDataView,
|
| + media::VideoCaptureDeviceDescriptor> {
|
| + static const std::string& display_name(
|
| + const media::VideoCaptureDeviceDescriptor& input) {
|
| + return input.display_name;
|
| + }
|
| +
|
| + static const std::string& device_id(
|
| + const media::VideoCaptureDeviceDescriptor& input) {
|
| + return input.device_id;
|
| + }
|
| +
|
| + static const std::string& model_id(
|
| + const media::VideoCaptureDeviceDescriptor& input) {
|
| + return input.model_id;
|
| + }
|
| +
|
| + static media::VideoCaptureApi capture_api(
|
| + const media::VideoCaptureDeviceDescriptor& input) {
|
| + return input.capture_api;
|
| + }
|
| +
|
| + static media::VideoCaptureTransportType transport_type(
|
| + const media::VideoCaptureDeviceDescriptor& input) {
|
| + return input.transport_type;
|
| + }
|
| +
|
| + static bool Read(
|
| + video_capture::mojom::VideoCaptureDeviceDescriptorDataView data,
|
| + media::VideoCaptureDeviceDescriptor* output) {
|
| + if (!data.ReadDisplayName(&(output->display_name)))
|
| + return false;
|
| +
|
| + if (!data.ReadDeviceId(&(output->device_id)))
|
| + return false;
|
| +
|
| + if (!data.ReadModelId(&(output->model_id)))
|
| + return false;
|
| +
|
| + if (!data.ReadCaptureApi(&(output->capture_api)))
|
| + return false;
|
| +
|
| + if (!data.ReadTransportType(&(output->transport_type)))
|
| + return false;
|
| +
|
| + return true;
|
| + }
|
| +};
|
| +
|
| +} // namespace mojo
|
| +
|
| +#endif // SERVICES_VIDEO_CAPTURE_PUBLIC_INTERFACES_VIDEO_CAPTURE_DEVICE_DESCRIPTOR_STRUCT_TRAITS_H_
|
|
|