1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // IPC messages for the media streaming.
6 // Multiply-included message file, hence no include guard.
10 #include "content/common/content_export.h"
11 #include "content/common/media/media_stream_options.h"
12 #include "ipc/ipc_message_macros.h"
13 #include "ipc/ipc_platform_file.h"
16 #undef IPC_MESSAGE_EXPORT
17 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
18 #define IPC_MESSAGE_START MediaStreamMsgStart
20 IPC_ENUM_TRAITS_MAX_VALUE(content::MediaStreamType
,
21 content::NUM_MEDIA_TYPES
- 1)
23 IPC_ENUM_TRAITS_MAX_VALUE(content::VideoFacingMode
,
24 content::NUM_MEDIA_VIDEO_FACING_MODE
- 1)
26 IPC_STRUCT_TRAITS_BEGIN(content::StreamOptions::Constraint
)
27 IPC_STRUCT_TRAITS_MEMBER(name
)
28 IPC_STRUCT_TRAITS_MEMBER(value
)
29 IPC_STRUCT_TRAITS_END()
31 IPC_STRUCT_TRAITS_BEGIN(content::StreamOptions
)
32 IPC_STRUCT_TRAITS_MEMBER(audio_requested
)
33 IPC_STRUCT_TRAITS_MEMBER(mandatory_audio
)
34 IPC_STRUCT_TRAITS_MEMBER(optional_audio
)
35 IPC_STRUCT_TRAITS_MEMBER(video_requested
)
36 IPC_STRUCT_TRAITS_MEMBER(mandatory_video
)
37 IPC_STRUCT_TRAITS_MEMBER(optional_video
)
38 IPC_STRUCT_TRAITS_END()
40 IPC_STRUCT_TRAITS_BEGIN(content::StreamDeviceInfo
)
41 IPC_STRUCT_TRAITS_MEMBER(device
.type
)
42 IPC_STRUCT_TRAITS_MEMBER(device
.name
)
43 IPC_STRUCT_TRAITS_MEMBER(device
.id
)
44 IPC_STRUCT_TRAITS_MEMBER(device
.video_facing
)
45 IPC_STRUCT_TRAITS_MEMBER(device
.matched_output_device_id
)
46 IPC_STRUCT_TRAITS_MEMBER(device
.input
.sample_rate
)
47 IPC_STRUCT_TRAITS_MEMBER(device
.input
.channel_layout
)
48 IPC_STRUCT_TRAITS_MEMBER(device
.input
.frames_per_buffer
)
49 IPC_STRUCT_TRAITS_MEMBER(device
.input
.effects
)
50 IPC_STRUCT_TRAITS_MEMBER(device
.matched_output
.sample_rate
)
51 IPC_STRUCT_TRAITS_MEMBER(device
.matched_output
.channel_layout
)
52 IPC_STRUCT_TRAITS_MEMBER(device
.matched_output
.frames_per_buffer
)
53 IPC_STRUCT_TRAITS_MEMBER(session_id
)
54 IPC_STRUCT_TRAITS_END()
56 // Message sent from the browser to the renderer
58 // The browser has generated a stream successfully.
59 IPC_MESSAGE_ROUTED4(MediaStreamMsg_StreamGenerated
,
61 std::string
/* label */,
62 content::StreamDeviceInfoArray
/* audio_device_list */,
63 content::StreamDeviceInfoArray
/* video_device_list */)
65 // The browser has failed to generate a stream.
66 IPC_MESSAGE_ROUTED1(MediaStreamMsg_StreamGenerationFailed
,
69 // The browser reports that a media device has been stopped. Stopping was
70 // triggered from the browser process.
71 IPC_MESSAGE_ROUTED2(MediaStreamMsg_DeviceStopped
,
72 std::string
/* label */,
73 content::StreamDeviceInfo
/* the device */)
75 // The browser has enumerated devices. If no devices are found
76 // |device_list| is empty.
78 // TODO(vrk,wjia): Move this to pepper code.
79 IPC_MESSAGE_ROUTED2(MediaStreamMsg_DevicesEnumerated
,
81 content::StreamDeviceInfoArray
/* device_list */)
83 // TODO(wjia): should DeviceOpen* messages be merged with
84 // StreamGenerat* ones?
85 // The browser has opened a device successfully.
86 IPC_MESSAGE_ROUTED3(MediaStreamMsg_DeviceOpened
,
88 std::string
/* label */,
89 content::StreamDeviceInfo
/* the device */)
91 // The browser has failed to open a device.
92 IPC_MESSAGE_ROUTED1(MediaStreamMsg_DeviceOpenFailed
,
95 // Response to enumerate devices request.
96 IPC_MESSAGE_CONTROL2(MediaStreamMsg_GetSourcesACK
,
98 content::StreamDeviceInfoArray
/* device_list */)
100 // The browser hands over a file handle to the renderer to use for AEC dump.
101 // TODO(grunell): This should not belong to media stream. Change when
102 // refactoring MediaStreamDependencyFactory.
103 IPC_MESSAGE_CONTROL1(MediaStreamMsg_EnableAecDump
,
104 IPC::PlatformFileForTransit
/* file_handle */)
106 // Tell the renderer to disable AEC dump.
107 IPC_MESSAGE_CONTROL0(MediaStreamMsg_DisableAecDump
)
109 // Messages sent from the renderer to the browser.
111 // Request a new media stream.
112 IPC_MESSAGE_CONTROL4(MediaStreamHostMsg_GenerateStream
,
113 int /* render view id */,
114 int /* request id */,
115 content::StreamOptions
/* components */,
116 GURL
/* security origin */)
118 // Request to cancel the request for a new media stream.
119 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelGenerateStream
,
120 int /* render view id */,
121 int /* request id */)
123 // Request to close a device that has been opened by GenerateStream.
124 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_StopStreamDevice
,
125 int /* render view id */,
126 std::string
/*device_id*/)
128 // Request to enumerate devices.
129 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_GetSources
,
130 int /* request id */,
134 // Request to enumerate devices.
136 // TODO(vrk,wjia): Move this to pepper code.
137 IPC_MESSAGE_CONTROL4(MediaStreamHostMsg_EnumerateDevices
,
138 int /* render view id */,
139 int /* request id */,
140 content::MediaStreamType
/* type */,
141 GURL
/* security origin */)
143 // Request to stop enumerating devices.
144 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelEnumerateDevices
,
145 int /* render view id */,
146 int /* request id */)
148 // Request to open the device.
149 IPC_MESSAGE_CONTROL5(MediaStreamHostMsg_OpenDevice
,
150 int /* render view id */,
151 int /* request id */,
152 std::string
/* device_id */,
153 content::MediaStreamType
/* type */,
154 GURL
/* security origin */)
156 // Request to close a device.
157 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CloseDevice
,
158 int /* render view id */,
159 std::string
/*label*/)