| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // IPC messages for the audio. | 5 // IPC messages for the audio. |
| 6 // Multiply-included message file, hence no include guard. | 6 // Multiply-included message file, hence no include guard. |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
| 13 #include "base/sync_socket.h" | 13 #include "base/sync_socket.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "ipc/ipc_message_macros.h" | 15 #include "ipc/ipc_message_macros.h" |
| 16 #include "media/audio/audio_input_ipc.h" | 16 #include "media/audio/audio_input_ipc.h" |
| 17 #include "media/audio/audio_output_ipc.h" | 17 #include "media/audio/audio_output_ipc.h" |
| 18 #include "media/base/ipc/media_param_traits.h" | 18 #include "media/base/ipc/media_param_traits.h" |
| 19 #include "media/gpu/ipc/common/media_param_traits.h" | 19 #include "media/gpu/ipc/common/media_param_traits.h" |
| 20 #include "url/origin.h" | 20 #include "url/origin.h" |
| 21 | 21 |
| 22 #undef IPC_MESSAGE_EXPORT | 22 #undef IPC_MESSAGE_EXPORT |
| 23 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT | 23 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT |
| 24 #define IPC_MESSAGE_START AudioMsgStart | 24 #define IPC_MESSAGE_START AudioMsgStart |
| 25 | 25 |
| 26 IPC_ENUM_TRAITS_MAX_VALUE(media::AudioInputIPCDelegateState, | 26 IPC_ENUM_TRAITS_MAX_VALUE(media::AudioInputIPCDelegateState, |
| 27 media::AUDIO_INPUT_IPC_DELEGATE_STATE_LAST) | 27 media::AUDIO_INPUT_IPC_DELEGATE_STATE_LAST) |
| 28 | 28 |
| 29 IPC_ENUM_TRAITS_MAX_VALUE(media::AudioOutputIPCDelegateState, | |
| 30 media::AUDIO_OUTPUT_IPC_DELEGATE_STATE_LAST) | |
| 31 | |
| 32 IPC_ENUM_TRAITS_MAX_VALUE(media::OutputDeviceStatus, | |
| 33 media::OUTPUT_DEVICE_STATUS_LAST) | |
| 34 | |
| 35 IPC_STRUCT_BEGIN(AudioInputHostMsg_CreateStream_Config) | 29 IPC_STRUCT_BEGIN(AudioInputHostMsg_CreateStream_Config) |
| 36 IPC_STRUCT_MEMBER(media::AudioParameters, params) | 30 IPC_STRUCT_MEMBER(media::AudioParameters, params) |
| 37 IPC_STRUCT_MEMBER(bool, automatic_gain_control) | 31 IPC_STRUCT_MEMBER(bool, automatic_gain_control) |
| 38 IPC_STRUCT_MEMBER(uint32_t, shared_memory_count) | 32 IPC_STRUCT_MEMBER(uint32_t, shared_memory_count) |
| 39 IPC_STRUCT_END() | 33 IPC_STRUCT_END() |
| 40 | 34 |
| 41 // Messages sent from the browser to the renderer. | 35 // Messages sent from the browser to the renderer. |
| 42 | 36 |
| 43 // Tell the renderer process that an audio output device has been authorized | |
| 44 // for a given stream. The renderer is given the output parameters for the | |
| 45 // authorized device. | |
| 46 IPC_MESSAGE_CONTROL4(AudioMsg_NotifyDeviceAuthorized, | |
| 47 int /* stream id */, | |
| 48 media::OutputDeviceStatus /* device_status */, | |
| 49 media::AudioParameters /* output parameters */, | |
| 50 std::string /* matched_device_id */) | |
| 51 | |
| 52 // Tell the renderer process that an audio stream has been created. | |
| 53 // The renderer process is given a shared memory handle for the audio data | |
| 54 // buffer it shares with the browser process. It is also given a SyncSocket that | |
| 55 // it uses to communicate with the browser process about the state of the | |
| 56 // buffered audio data. | |
| 57 IPC_MESSAGE_CONTROL4( | |
| 58 AudioMsg_NotifyStreamCreated, | |
| 59 int /* stream id */, | |
| 60 base::SharedMemoryHandle /* handle */, | |
| 61 base::SyncSocket::TransitDescriptor /* socket descriptor */, | |
| 62 uint32_t /* length */) | |
| 63 | |
| 64 // Tell the renderer process that an audio input stream has been created. | 37 // Tell the renderer process that an audio input stream has been created. |
| 65 // The renderer process would be given a SyncSocket that it should read | 38 // The renderer process would be given a SyncSocket that it should read |
| 66 // from from then on. It is also given number of segments in shared memory. | 39 // from from then on. It is also given number of segments in shared memory. |
| 67 IPC_MESSAGE_CONTROL5( | 40 IPC_MESSAGE_CONTROL5( |
| 68 AudioInputMsg_NotifyStreamCreated, | 41 AudioInputMsg_NotifyStreamCreated, |
| 69 int /* stream id */, | 42 int /* stream id */, |
| 70 base::SharedMemoryHandle /* handle */, | 43 base::SharedMemoryHandle /* handle */, |
| 71 base::SyncSocket::TransitDescriptor /* socket descriptor */, | 44 base::SyncSocket::TransitDescriptor /* socket descriptor */, |
| 72 uint32_t /* length */, | 45 uint32_t /* length */, |
| 73 uint32_t /* segment count */) | 46 uint32_t /* segment count */) |
| 74 | 47 |
| 75 // Notification message sent from AudioRendererHost to renderer for state | |
| 76 // update after the renderer has requested a Create/Start/Close. | |
| 77 IPC_MESSAGE_CONTROL2(AudioMsg_NotifyStreamStateChanged, | |
| 78 int /* stream id */, | |
| 79 media::AudioOutputIPCDelegateState /* new state */) | |
| 80 | |
| 81 // Notification message sent from browser to renderer for state update. | 48 // Notification message sent from browser to renderer for state update. |
| 82 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyStreamStateChanged, | 49 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyStreamStateChanged, |
| 83 int /* stream id */, | 50 int /* stream id */, |
| 84 media::AudioInputIPCDelegateState /* new state */) | 51 media::AudioInputIPCDelegateState /* new state */) |
| 85 | 52 |
| 86 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyStreamVolume, | 53 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyStreamVolume, |
| 87 int /* stream id */, | 54 int /* stream id */, |
| 88 double /* volume */) | 55 double /* volume */) |
| 89 | 56 |
| 90 // Messages sent from the renderer to the browser. | 57 // Messages sent from the renderer to the browser. |
| 91 | 58 |
| 92 // Message sent to the browser to request the use of an audio output | |
| 93 // device. |render_frame_id| is the routing ID for the RenderFrame producing | |
| 94 // the audio data. | |
| 95 IPC_MESSAGE_CONTROL5(AudioHostMsg_RequestDeviceAuthorization, | |
| 96 int /* stream_id */, | |
| 97 int /* render_frame_id */, | |
| 98 int /* session_id */, | |
| 99 std::string /* device_id */, | |
| 100 url::Origin /* security_origin */) | |
| 101 | |
| 102 // Request that is sent to the browser for creating an audio output stream. | |
| 103 IPC_MESSAGE_CONTROL3(AudioHostMsg_CreateStream, | |
| 104 int /* stream_id */, | |
| 105 int /* render_frame_id */, | |
| 106 media::AudioParameters /* params */) | |
| 107 | |
| 108 // Request that is sent to the browser for creating an audio input stream. | 59 // Request that is sent to the browser for creating an audio input stream. |
| 109 // |render_frame_id| is the routing ID for the RenderFrame consuming the audio | 60 // |render_frame_id| is the routing ID for the RenderFrame consuming the audio |
| 110 // data. | 61 // data. |
| 111 IPC_MESSAGE_CONTROL4(AudioInputHostMsg_CreateStream, | 62 IPC_MESSAGE_CONTROL4(AudioInputHostMsg_CreateStream, |
| 112 int /* stream_id */, | 63 int /* stream_id */, |
| 113 int /* render_frame_id */, | 64 int /* render_frame_id */, |
| 114 int /* session_id */, | 65 int /* session_id */, |
| 115 AudioInputHostMsg_CreateStream_Config) | 66 AudioInputHostMsg_CreateStream_Config) |
| 116 | 67 |
| 117 // Start buffering and play the audio stream specified by stream_id. | |
| 118 IPC_MESSAGE_CONTROL1(AudioHostMsg_PlayStream, | |
| 119 int /* stream_id */) | |
| 120 | |
| 121 // Start recording the audio input stream specified by stream_id. | 68 // Start recording the audio input stream specified by stream_id. |
| 122 IPC_MESSAGE_CONTROL1(AudioInputHostMsg_RecordStream, | 69 IPC_MESSAGE_CONTROL1(AudioInputHostMsg_RecordStream, |
| 123 int /* stream_id */) | 70 int /* stream_id */) |
| 124 | 71 |
| 125 // Pause the audio stream specified by stream_id. | |
| 126 IPC_MESSAGE_CONTROL1(AudioHostMsg_PauseStream, | |
| 127 int /* stream_id */) | |
| 128 | |
| 129 // Close an audio stream specified by stream_id. | |
| 130 IPC_MESSAGE_CONTROL1(AudioHostMsg_CloseStream, | |
| 131 int /* stream_id */) | |
| 132 | |
| 133 // Close an audio input stream specified by stream_id. | 72 // Close an audio input stream specified by stream_id. |
| 134 IPC_MESSAGE_CONTROL1(AudioInputHostMsg_CloseStream, | 73 IPC_MESSAGE_CONTROL1(AudioInputHostMsg_CloseStream, |
| 135 int /* stream_id */) | 74 int /* stream_id */) |
| 136 | 75 |
| 137 // Set audio volume of the stream specified by stream_id. | |
| 138 // TODO(hclam): change this to vector if we have channel numbers other than 2. | |
| 139 IPC_MESSAGE_CONTROL2(AudioHostMsg_SetVolume, | |
| 140 int /* stream_id */, | |
| 141 double /* volume */) | |
| 142 | |
| 143 // Set audio volume of the input stream specified by stream_id. | 76 // Set audio volume of the input stream specified by stream_id. |
| 144 IPC_MESSAGE_CONTROL2(AudioInputHostMsg_SetVolume, | 77 IPC_MESSAGE_CONTROL2(AudioInputHostMsg_SetVolume, |
| 145 int /* stream_id */, | 78 int /* stream_id */, |
| 146 double /* volume */) | 79 double /* volume */) |
| OLD | NEW |