Commit c91d6267 authored by Chandan Padhi's avatar Chandan Padhi Committed by Commit Bot

Define EnumTraits for content::MediaDeviceType

This CL introduces Mojom enum for content::MediaDeviceType and removes
its IPC_ENUM_TRAITS in favor of EnumTraits.
This is in preparation for migration of MediaDevices.enumerateDevices()
processing from content to Blink.

Bug: 764680
Change-Id: I5e3c96adb7fd96e1d0ea41dff933ecac017228fa
Reviewed-on: https://chromium-review.googlesource.com/806054Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Chandan Padhi <c.padhi@samsung.com>
Cr-Commit-Position: refs/heads/master@{#521971}
parent 6567c2d7
...@@ -52,6 +52,7 @@ include_rules = [ ...@@ -52,6 +52,7 @@ include_rules = [
"+third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom.h", "+third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom.h",
"+third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h", "+third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h",
"+third_party/WebKit/public/platform/modules/mediasession/media_session.mojom.h", "+third_party/WebKit/public/platform/modules/mediasession/media_session.mojom.h",
"+third_party/WebKit/public/platform/modules/mediastream/media_devices.mojom.h",
"+third_party/WebKit/public/platform/modules/permissions/permission.mojom.h", "+third_party/WebKit/public/platform/modules/permissions/permission.mojom.h",
"+third_party/WebKit/public/platform/modules/permissions/permission_status.mojom.h", "+third_party/WebKit/public/platform/modules/permissions/permission_status.mojom.h",
"+third_party/WebKit/public/platform/modules/presentation/presentation.mojom.h", "+third_party/WebKit/public/platform/modules/presentation/presentation.mojom.h",
......
...@@ -4,7 +4,13 @@ ...@@ -4,7 +4,13 @@
mojom = "//third_party/WebKit/public/platform/modules/mediastream/media_devices.mojom" mojom = "//third_party/WebKit/public/platform/modules/mediastream/media_devices.mojom"
public_headers = [ "//content/common/media/media_devices.h" ] public_headers = [ "//content/common/media/media_devices.h" ]
traits_headers = [ "//content/common/media/media_devices_param_traits.h" ] traits_headers = [
"//content/common/media/media_devices_param_traits.h",
"//content/common/media/media_devices_typemap_traits.h",
]
sources = [
"//content/common/media/media_devices_typemap_traits.cc",
]
type_mappings = [ type_mappings = [
"blink.mojom.MediaDeviceType=content::MediaDeviceType", "blink.mojom.MediaDeviceType=content::MediaDeviceType",
"blink.mojom.MediaDeviceInfo=content::MediaDeviceInfo", "blink.mojom.MediaDeviceInfo=content::MediaDeviceInfo",
......
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
#undef IPC_MESSAGE_EXPORT #undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
IPC_ENUM_TRAITS_MAX_VALUE(content::MediaDeviceType,
content::NUM_MEDIA_DEVICE_TYPES - 1)
IPC_STRUCT_TRAITS_BEGIN(content::MediaDeviceInfo) IPC_STRUCT_TRAITS_BEGIN(content::MediaDeviceInfo)
IPC_STRUCT_TRAITS_MEMBER(device_id) IPC_STRUCT_TRAITS_MEMBER(device_id)
IPC_STRUCT_TRAITS_MEMBER(label) IPC_STRUCT_TRAITS_MEMBER(label)
......
// Copyright 2017 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.
#include "content/common/media/media_devices_typemap_traits.h"
#include "base/logging.h"
namespace mojo {
// static
blink::mojom::MediaDeviceType
EnumTraits<blink::mojom::MediaDeviceType, content::MediaDeviceType>::ToMojom(
content::MediaDeviceType type) {
switch (type) {
case content::MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_INPUT:
return blink::mojom::MediaDeviceType::MEDIA_AUDIO_INPUT;
case content::MediaDeviceType::MEDIA_DEVICE_TYPE_VIDEO_INPUT:
return blink::mojom::MediaDeviceType::MEDIA_VIDEO_INPUT;
case content::MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_OUTPUT:
return blink::mojom::MediaDeviceType::MEDIA_AUDIO_OUTPUT;
default:
break;
}
NOTREACHED();
return blink::mojom::MediaDeviceType::NUM_MEDIA_DEVICE_TYPES;
}
// static
bool EnumTraits<blink::mojom::MediaDeviceType, content::MediaDeviceType>::
FromMojom(blink::mojom::MediaDeviceType input,
content::MediaDeviceType* out) {
switch (input) {
case blink::mojom::MediaDeviceType::MEDIA_AUDIO_INPUT:
*out = content::MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_INPUT;
return true;
case blink::mojom::MediaDeviceType::MEDIA_VIDEO_INPUT:
*out = content::MediaDeviceType::MEDIA_DEVICE_TYPE_VIDEO_INPUT;
return true;
case blink::mojom::MediaDeviceType::MEDIA_AUDIO_OUTPUT:
*out = content::MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_OUTPUT;
return true;
default:
break;
}
NOTREACHED();
return false;
}
} // namespace mojo
// Copyright 2017 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 CONTENT_COMMON_MEDIA_MEDIA_DEVICES_TYPEMAP_TRAITS_H_
#define CONTENT_COMMON_MEDIA_MEDIA_DEVICES_TYPEMAP_TRAITS_H_
#include "content/common/media/media_devices.h"
#include "third_party/WebKit/public/platform/modules/mediastream/media_devices.mojom.h"
namespace mojo {
template <>
struct EnumTraits<blink::mojom::MediaDeviceType, content::MediaDeviceType> {
static blink::mojom::MediaDeviceType ToMojom(content::MediaDeviceType type);
static bool FromMojom(blink::mojom::MediaDeviceType input,
content::MediaDeviceType* out);
};
} // namespace mojo
#endif // CONTENT_COMMON_MEDIA_MEDIA_DEVICES_TYPEMAP_TRAITS_H_
\ No newline at end of file
...@@ -7,23 +7,21 @@ module blink.mojom; ...@@ -7,23 +7,21 @@ module blink.mojom;
import "media/capture/mojo/video_capture_types.mojom"; import "media/capture/mojo/video_capture_types.mojom";
import "media/mojo/interfaces/audio_parameters.mojom"; import "media/mojo/interfaces/audio_parameters.mojom";
[Native]
enum MediaDeviceType;
[Native] [Native]
struct MediaDeviceInfo; struct MediaDeviceInfo;
enum MediaDeviceType {
MEDIA_AUDIO_INPUT,
MEDIA_VIDEO_INPUT,
MEDIA_AUDIO_OUTPUT,
NUM_MEDIA_DEVICE_TYPES
};
// The values for this enum match the ones defined in // The values for this enum match the ones defined in
// https://w3c.github.io/mediacapture-main/#def-constraint-facingMode // https://w3c.github.io/mediacapture-main/#def-constraint-facingMode
// with the addition of NONE, which would map to the empty string in // with the addition of NONE, which would map to the empty string in
// JavaScript. // JavaScript.
enum FacingMode { enum FacingMode { NONE, USER, ENVIRONMENT, LEFT, RIGHT };
NONE,
USER,
ENVIRONMENT,
LEFT,
RIGHT
};
struct VideoInputDeviceCapabilities { struct VideoInputDeviceCapabilities {
string device_id; string device_id;
...@@ -41,7 +39,7 @@ struct AudioInputDeviceCapabilities { ...@@ -41,7 +39,7 @@ struct AudioInputDeviceCapabilities {
// notifications. // notifications.
interface MediaDevicesDispatcherHost { interface MediaDevicesDispatcherHost {
// The reply always contains NUM_MEDIA_DEVICE_TYPES elements. // The reply always contains NUM_MEDIA_DEVICE_TYPES elements.
// The result is indexed by device type as defined in // The result is indexed by device type as defined in
// content/common/media/media_devices.h. // content/common/media/media_devices.h.
EnumerateDevices(bool request_audio_input, EnumerateDevices(bool request_audio_input,
bool request_video_input, bool request_video_input,
......
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