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 20 IPC_ENUM_TRAITS_MAX_VALUE(content::MediaStreamType, 21 content::NUM_MEDIA_TYPES - 1) 22 23 IPC_ENUM_TRAITS_MAX_VALUE(content::VideoFacingMode, 24 content::NUM_MEDIA_VIDEO_FACING_MODE - 1) 25 26 IPC_ENUM_TRAITS_MAX_VALUE(content::MediaStreamRequestResult, 27 content::NUM_MEDIA_REQUEST_RESULTS - 1) 28 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() 33 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() 42 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() 58 59 // Message sent from the browser to the renderer 60 61 // The browser has generated a stream successfully. 62 IPC_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. 69 IPC_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. 75 IPC_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. 83 IPC_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. 90 IPC_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. 96 IPC_MESSAGE_ROUTED1(MediaStreamMsg_DeviceOpenFailed, 97 int /* request id */) 98 99 // Response to enumerate devices request. 100 IPC_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. 107 IPC_MESSAGE_CONTROL5(MediaStreamHostMsg_GenerateStream, 108 int /* render frame 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. 115 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelGenerateStream, 116 int /* render frame id */, 117 int /* request id */) 118 119 // Request to close a device that has been opened by GenerateStream. 120 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_StopStreamDevice, 121 int /* render frame id */, 122 std::string /*device_id*/) 123 124 // Request to enumerate devices. 125 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_GetSources, 126 int /* request id */, 127 GURL /* origin */) 128 129 // Request to enumerate devices. 130 // Used by Pepper and WebRTC. 131 IPC_MESSAGE_CONTROL4(MediaStreamHostMsg_EnumerateDevices, 132 int /* render frame id */, 133 int /* request id */, 134 content::MediaStreamType /* type */, 135 GURL /* security origin */) 136 137 // Request to stop enumerating devices. 138 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelEnumerateDevices, 139 int /* render frame id */, 140 int /* request id */) 141 142 // Request to open the device. 143 IPC_MESSAGE_CONTROL5(MediaStreamHostMsg_OpenDevice, 144 int /* render frame id */, 145 int /* request id */, 146 std::string /* device_id */, 147 content::MediaStreamType /* type */, 148 GURL /* security origin */) 149 150 // Request to close a device. 151 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CloseDevice, 152 int /* render frame id */, 153 std::string /*label*/) 154