media_stream_messages.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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_ENUM_TRAITS_MAX_VALUE(content::MediaStreamRequestResult,
27                          content::NUM_MEDIA_REQUEST_RESULTS - 1)
28
29IPC_STRUCT_TRAITS_BEGIN(content::StreamOptions::Constraint)
30  IPC_STRUCT_TRAITS_MEMBER(name)
31  IPC_STRUCT_TRAITS_MEMBER(value)
32IPC_STRUCT_TRAITS_END()
33
34IPC_STRUCT_TRAITS_BEGIN(content::StreamOptions)
35  IPC_STRUCT_TRAITS_MEMBER(audio_requested)
36  IPC_STRUCT_TRAITS_MEMBER(mandatory_audio)
37  IPC_STRUCT_TRAITS_MEMBER(optional_audio)
38  IPC_STRUCT_TRAITS_MEMBER(video_requested)
39  IPC_STRUCT_TRAITS_MEMBER(mandatory_video)
40  IPC_STRUCT_TRAITS_MEMBER(optional_video)
41IPC_STRUCT_TRAITS_END()
42
43IPC_STRUCT_TRAITS_BEGIN(content::StreamDeviceInfo)
44  IPC_STRUCT_TRAITS_MEMBER(device.type)
45  IPC_STRUCT_TRAITS_MEMBER(device.name)
46  IPC_STRUCT_TRAITS_MEMBER(device.id)
47  IPC_STRUCT_TRAITS_MEMBER(device.video_facing)
48  IPC_STRUCT_TRAITS_MEMBER(device.matched_output_device_id)
49  IPC_STRUCT_TRAITS_MEMBER(device.input.sample_rate)
50  IPC_STRUCT_TRAITS_MEMBER(device.input.channel_layout)
51  IPC_STRUCT_TRAITS_MEMBER(device.input.frames_per_buffer)
52  IPC_STRUCT_TRAITS_MEMBER(device.input.effects)
53  IPC_STRUCT_TRAITS_MEMBER(device.matched_output.sample_rate)
54  IPC_STRUCT_TRAITS_MEMBER(device.matched_output.channel_layout)
55  IPC_STRUCT_TRAITS_MEMBER(device.matched_output.frames_per_buffer)
56  IPC_STRUCT_TRAITS_MEMBER(session_id)
57IPC_STRUCT_TRAITS_END()
58
59// Message sent from the browser to the renderer
60
61// The browser has generated a stream successfully.
62IPC_MESSAGE_ROUTED4(MediaStreamMsg_StreamGenerated,
63                    int /* request id */,
64                    std::string /* label */,
65                    content::StreamDeviceInfoArray /* audio_device_list */,
66                    content::StreamDeviceInfoArray /* video_device_list */)
67
68// The browser has failed to generate a stream.
69IPC_MESSAGE_ROUTED2(MediaStreamMsg_StreamGenerationFailed,
70                    int /* request id */,
71                    content::MediaStreamRequestResult /* result */)
72
73// The browser reports that a media device has been stopped. Stopping was
74// triggered from the browser process.
75IPC_MESSAGE_ROUTED2(MediaStreamMsg_DeviceStopped,
76                    std::string /* label */,
77                    content::StreamDeviceInfo /* the device */)
78
79// The browser has enumerated devices. If no devices are found
80// |device_list| is empty.
81// Used by Pepper.
82// TODO(vrk,wjia): Move this to pepper code.
83IPC_MESSAGE_ROUTED2(MediaStreamMsg_DevicesEnumerated,
84                    int /* request id */,
85                    content::StreamDeviceInfoArray /* device_list */)
86
87// TODO(wjia): should DeviceOpen* messages be merged with
88// StreamGenerat* ones?
89// The browser has opened a device successfully.
90IPC_MESSAGE_ROUTED3(MediaStreamMsg_DeviceOpened,
91                    int /* request id */,
92                    std::string /* label */,
93                    content::StreamDeviceInfo /* the device */)
94
95// The browser has failed to open a device.
96IPC_MESSAGE_ROUTED1(MediaStreamMsg_DeviceOpenFailed,
97                    int /* request id */)
98
99// Response to enumerate devices request.
100IPC_MESSAGE_CONTROL2(MediaStreamMsg_GetSourcesACK,
101                     int /* request id */,
102                     content::StreamDeviceInfoArray /* device_list */)
103
104// Messages sent from the renderer to the browser.
105
106// Request a new media stream.
107IPC_MESSAGE_CONTROL5(MediaStreamHostMsg_GenerateStream,
108                     int /* render view id */,
109                     int /* request id */,
110                     content::StreamOptions /* components */,
111                     GURL /* security origin */,
112                     bool /* user_gesture */)
113
114// Request to cancel the request for a new media stream.
115IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelGenerateStream,
116                     int /* render view id */,
117                     int /* request id */)
118
119// Request to close a device that has been opened by GenerateStream.
120IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_StopStreamDevice,
121                     int /* render view id */,
122                     std::string /*device_id*/)
123
124// Request to enumerate devices.
125IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_GetSources,
126                     int /* request id */,
127                     GURL /* origin */)
128
129// Request to enumerate devices.
130// Used by Pepper and WebRTC.
131IPC_MESSAGE_CONTROL5(MediaStreamHostMsg_EnumerateDevices,
132                     int /* render view id */,
133                     int /* request id */,
134                     content::MediaStreamType /* type */,
135                     GURL /* security origin */,
136                     bool /* hide_labels_if_no_access */)
137
138// Request to stop enumerating devices.
139IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelEnumerateDevices,
140                     int /* render view id */,
141                     int /* request id */)
142
143// Request to open the device.
144IPC_MESSAGE_CONTROL5(MediaStreamHostMsg_OpenDevice,
145                     int /* render view id */,
146                     int /* request id */,
147                     std::string /* device_id */,
148                     content::MediaStreamType /* type */,
149                     GURL /* security origin */)
150
151// Request to close a device.
152IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CloseDevice,
153                     int /* render view id */,
154                     std::string /*label*/)
155