Commit 97d63b00 authored by Chandan Padhi's avatar Chandan Padhi Committed by Commit Bot

Define StructTraits for content::MediaDeviceInfo

This CL introduces Mojom struct for content::MediaDeviceInfo and removes
its IPC_STRUCT_TRAITS in favor of StructTraits.
This is in preparation for migration of MediaDevices.enumerateDevices()
processing from content to Blink.

Bug: 764680
Change-Id: Idc17f1b53963d2fb7a80b4ac98890913cb5ad521
Reviewed-on: https://chromium-review.googlesource.com/807840
Commit-Queue: Chandan Padhi <c.padhi@samsung.com>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521977}
parent ae4d5c3e
...@@ -211,8 +211,6 @@ source_set("common") { ...@@ -211,8 +211,6 @@ source_set("common") {
"media/cdm_info.cc", "media/cdm_info.cc",
"media/media_devices.cc", "media/media_devices.cc",
"media/media_devices.h", "media/media_devices.h",
"media/media_devices_param_traits.cc",
"media/media_devices_param_traits.h",
"media/media_player_delegate_messages.h", "media/media_player_delegate_messages.h",
"media/media_player_messages_android.h", "media/media_player_messages_android.h",
"media/media_stream_controls.cc", "media/media_stream_controls.cc",
......
...@@ -4,10 +4,7 @@ ...@@ -4,10 +4,7 @@
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 = [ traits_headers = [ "//content/common/media/media_devices_typemap_traits.h" ]
"//content/common/media/media_devices_param_traits.h",
"//content/common/media/media_devices_typemap_traits.h",
]
sources = [ sources = [
"//content/common/media/media_devices_typemap_traits.cc", "//content/common/media/media_devices_typemap_traits.cc",
] ]
......
// 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.
#include "content/common/media/media_devices_param_traits.h"
// Generate param traits write methods.
#include "ipc/param_traits_write_macros.h"
namespace IPC {
#include "content/common/media/media_devices_param_traits.h"
} // namespace IPC
// Generate param traits read methods.
#include "ipc/param_traits_read_macros.h"
namespace IPC {
#include "content/common/media/media_devices_param_traits.h"
} // namespace IPC
// Generate param traits log methods.
#include "ipc/param_traits_log_macros.h"
namespace IPC {
#include "content/common/media/media_devices_param_traits.h"
} // namespace IPC
// 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.
// Multiply-included IPC traits file, hence no include guard.
#include "content/common/content_export.h"
#include "content/common/media/media_devices.h"
#include "ipc/ipc_message_macros.h"
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
IPC_STRUCT_TRAITS_BEGIN(content::MediaDeviceInfo)
IPC_STRUCT_TRAITS_MEMBER(device_id)
IPC_STRUCT_TRAITS_MEMBER(label)
IPC_STRUCT_TRAITS_MEMBER(group_id)
IPC_STRUCT_TRAITS_END()
...@@ -47,4 +47,18 @@ bool EnumTraits<blink::mojom::MediaDeviceType, content::MediaDeviceType>:: ...@@ -47,4 +47,18 @@ bool EnumTraits<blink::mojom::MediaDeviceType, content::MediaDeviceType>::
return false; return false;
} }
// static
bool StructTraits<
blink::mojom::MediaDeviceInfoDataView,
content::MediaDeviceInfo>::Read(blink::mojom::MediaDeviceInfoDataView input,
content::MediaDeviceInfo* out) {
if (!input.ReadDeviceId(&out->device_id))
return false;
if (!input.ReadLabel(&out->label))
return false;
if (!input.ReadGroupId(&out->group_id))
return false;
return true;
}
} // namespace mojo } // namespace mojo
...@@ -18,6 +18,25 @@ struct EnumTraits<blink::mojom::MediaDeviceType, content::MediaDeviceType> { ...@@ -18,6 +18,25 @@ struct EnumTraits<blink::mojom::MediaDeviceType, content::MediaDeviceType> {
content::MediaDeviceType* out); content::MediaDeviceType* out);
}; };
template <>
struct StructTraits<blink::mojom::MediaDeviceInfoDataView,
content::MediaDeviceInfo> {
static const std::string& device_id(const content::MediaDeviceInfo& info) {
return info.device_id;
}
static const std::string& label(const content::MediaDeviceInfo& info) {
return info.label;
}
static const std::string& group_id(const content::MediaDeviceInfo& info) {
return info.group_id;
}
static bool Read(blink::mojom::MediaDeviceInfoDataView input,
content::MediaDeviceInfo* out);
};
} // namespace mojo } // namespace mojo
#endif // CONTENT_COMMON_MEDIA_MEDIA_DEVICES_TYPEMAP_TRAITS_H_ #endif // CONTENT_COMMON_MEDIA_MEDIA_DEVICES_TYPEMAP_TRAITS_H_
\ No newline at end of file
...@@ -7,9 +7,6 @@ module blink.mojom; ...@@ -7,9 +7,6 @@ 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]
struct MediaDeviceInfo;
enum MediaDeviceType { enum MediaDeviceType {
MEDIA_AUDIO_INPUT, MEDIA_AUDIO_INPUT,
MEDIA_VIDEO_INPUT, MEDIA_VIDEO_INPUT,
...@@ -23,6 +20,12 @@ enum MediaDeviceType { ...@@ -23,6 +20,12 @@ enum MediaDeviceType {
// JavaScript. // JavaScript.
enum FacingMode { NONE, USER, ENVIRONMENT, LEFT, RIGHT }; enum FacingMode { NONE, USER, ENVIRONMENT, LEFT, RIGHT };
struct MediaDeviceInfo {
string device_id;
string label;
string group_id;
};
struct VideoInputDeviceCapabilities { struct VideoInputDeviceCapabilities {
string device_id; string device_id;
array<media.mojom.VideoCaptureFormat> formats; array<media.mojom.VideoCaptureFormat> formats;
......
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