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_ENUM_TRAITS_MAX_VALUE(content::MediaStreamRequestResult
,
27 content::NUM_MEDIA_REQUEST_RESULTS
- 1)
29 IPC_STRUCT_TRAITS_BEGIN(content::StreamOptions::Constraint
)
30 IPC_STRUCT_TRAITS_MEMBER(name
)
31 IPC_STRUCT_TRAITS_MEMBER(value
)
32 IPC_STRUCT_TRAITS_END()
34 IPC_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
)
41 IPC_STRUCT_TRAITS_END()
43 IPC_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
)
57 IPC_STRUCT_TRAITS_END()
59 // Message sent from the browser to the renderer
61 // The browser has generated a stream successfully.
62 IPC_MESSAGE_ROUTED4(MediaStreamMsg_StreamGenerated
,
64 std::string
/* label */,
65 content::StreamDeviceInfoArray
/* audio_device_list */,
66 content::StreamDeviceInfoArray
/* video_device_list */)
68 // The browser has failed to generate a stream.
69 IPC_MESSAGE_ROUTED2(MediaStreamMsg_StreamGenerationFailed
,
71 content::MediaStreamRequestResult
/* result */)
73 // The browser reports that a media device has been stopped. Stopping was
74 // triggered from the browser process.
75 IPC_MESSAGE_ROUTED2(MediaStreamMsg_DeviceStopped
,
76 std::string
/* label */,
77 content::StreamDeviceInfo
/* the device */)
79 // The browser has enumerated devices. If no devices are found
80 // |device_list| is empty.
81 // Used by Pepper and WebRTC.
82 IPC_MESSAGE_ROUTED2(MediaStreamMsg_DevicesEnumerated
,
84 content::StreamDeviceInfoArray
/* device_list */)
86 // TODO(wjia): should DeviceOpen* messages be merged with
87 // StreamGenerat* ones?
88 // The browser has opened a device successfully.
89 IPC_MESSAGE_ROUTED3(MediaStreamMsg_DeviceOpened
,
91 std::string
/* label */,
92 content::StreamDeviceInfo
/* the device */)
94 // The browser has failed to open a device.
95 IPC_MESSAGE_ROUTED1(MediaStreamMsg_DeviceOpenFailed
,
98 // Messages sent from the renderer to the browser.
100 // Request a new media stream.
101 IPC_MESSAGE_CONTROL5(MediaStreamHostMsg_GenerateStream
,
102 int /* render frame id */,
103 int /* request id */,
104 content::StreamOptions
/* components */,
105 GURL
/* security origin */,
106 bool /* user_gesture */)
108 // Request to cancel the request for a new media stream.
109 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelGenerateStream
,
110 int /* render frame id */,
111 int /* request id */)
113 // Request to close a device that has been opened by GenerateStream.
114 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_StopStreamDevice
,
115 int /* render frame id */,
116 std::string
/*device_id*/)
118 // Request to enumerate devices.
119 // Used by Pepper and WebRTC.
120 IPC_MESSAGE_CONTROL4(MediaStreamHostMsg_EnumerateDevices
,
121 int /* render frame id */,
122 int /* request id */,
123 content::MediaStreamType
/* type */,
124 GURL
/* security origin */)
126 // Request to stop enumerating devices.
127 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelEnumerateDevices
,
128 int /* render frame id */,
129 int /* request id */)
131 // Request to open the device.
132 IPC_MESSAGE_CONTROL5(MediaStreamHostMsg_OpenDevice
,
133 int /* render frame id */,
134 int /* request id */,
135 std::string
/* device_id */,
136 content::MediaStreamType
/* type */,
137 GURL
/* security origin */)
139 // Request to close a device.
140 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CloseDevice
,
141 int /* render frame id */,
142 std::string
/*label*/)