media_stream_messages.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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.
4
5// IPC messages for the media streaming.
6// Multiply-included message file, hence no include guard.
7
8#include <string>
9
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"
14#include "url/gurl.h"
15
16#undef IPC_MESSAGE_EXPORT
17#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
18#define IPC_MESSAGE_START MediaStreamMsgStart
19
20IPC_ENUM_TRAITS_MAX_VALUE(content::MediaStreamType,
21                          content::NUM_MEDIA_TYPES - 1)
22
23IPC_ENUM_TRAITS_MAX_VALUE(content::VideoFacingMode,
24                          content::NUM_MEDIA_VIDEO_FACING_MODE - 1)
25
26IPC_STRUCT_TRAITS_BEGIN(content::StreamOptions::Constraint)
27  IPC_STRUCT_TRAITS_MEMBER(name)
28  IPC_STRUCT_TRAITS_MEMBER(value)
29IPC_STRUCT_TRAITS_END()
30
31IPC_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)
38IPC_STRUCT_TRAITS_END()
39
40IPC_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)
54IPC_STRUCT_TRAITS_END()
55
56// Message sent from the browser to the renderer
57
58// The browser has generated a stream successfully.
59IPC_MESSAGE_ROUTED4(MediaStreamMsg_StreamGenerated,
60                    int /* request id */,
61                    std::string /* label */,
62                    content::StreamDeviceInfoArray /* audio_device_list */,
63                    content::StreamDeviceInfoArray /* video_device_list */)
64
65// The browser has failed to generate a stream.
66IPC_MESSAGE_ROUTED1(MediaStreamMsg_StreamGenerationFailed,
67                    int /* request id */)
68
69// The browser reports that a media device has been stopped. Stopping was
70// triggered from the browser process.
71IPC_MESSAGE_ROUTED2(MediaStreamMsg_DeviceStopped,
72                    std::string /* label */,
73                    content::StreamDeviceInfo /* the device */)
74
75// The browser has enumerated devices. If no devices are found
76// |device_list| is empty.
77// Used by Pepper.
78// TODO(vrk,wjia): Move this to pepper code.
79IPC_MESSAGE_ROUTED2(MediaStreamMsg_DevicesEnumerated,
80                    int /* request id */,
81                    content::StreamDeviceInfoArray /* device_list */)
82
83// TODO(wjia): should DeviceOpen* messages be merged with
84// StreamGenerat* ones?
85// The browser has opened a device successfully.
86IPC_MESSAGE_ROUTED3(MediaStreamMsg_DeviceOpened,
87                    int /* request id */,
88                    std::string /* label */,
89                    content::StreamDeviceInfo /* the device */)
90
91// The browser has failed to open a device.
92IPC_MESSAGE_ROUTED1(MediaStreamMsg_DeviceOpenFailed,
93                    int /* request id */)
94
95// Response to enumerate devices request.
96IPC_MESSAGE_CONTROL2(MediaStreamMsg_GetSourcesACK,
97                     int /* request id */,
98                     content::StreamDeviceInfoArray /* device_list */)
99
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.
103IPC_MESSAGE_CONTROL1(MediaStreamMsg_EnableAecDump,
104                     IPC::PlatformFileForTransit /* file_handle */)
105
106// Tell the renderer to disable AEC dump.
107IPC_MESSAGE_CONTROL0(MediaStreamMsg_DisableAecDump)
108
109// Messages sent from the renderer to the browser.
110
111// Request a new media stream.
112IPC_MESSAGE_CONTROL4(MediaStreamHostMsg_GenerateStream,
113                     int /* render view id */,
114                     int /* request id */,
115                     content::StreamOptions /* components */,
116                     GURL /* security origin */)
117
118// Request to cancel the request for a new media stream.
119IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelGenerateStream,
120                     int /* render view id */,
121                     int /* request id */)
122
123// Request to close a device that has been opened by GenerateStream.
124IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_StopStreamDevice,
125                     int /* render view id */,
126                     std::string /*device_id*/)
127
128// Request to enumerate devices.
129IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_GetSources,
130                     int /* request id */,
131                     GURL /* origin */)
132
133
134// Request to enumerate devices.
135// Used by Pepper.
136// TODO(vrk,wjia): Move this to pepper code.
137IPC_MESSAGE_CONTROL4(MediaStreamHostMsg_EnumerateDevices,
138                     int /* render view id */,
139                     int /* request id */,
140                     content::MediaStreamType /* type */,
141                     GURL /* security origin */)
142
143// Request to stop enumerating devices.
144IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelEnumerateDevices,
145                     int /* render view id */,
146                     int /* request id */)
147
148// Request to open the device.
149IPC_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 */)
155
156// Request to close a device.
157IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CloseDevice,
158                     int /* render view id */,
159                     std::string /*label*/)
160