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 audio.
6 // Multiply-included message file, hence no include guard.
8 #include "base/basictypes.h"
9 #include "base/memory/shared_memory.h"
10 #include "base/sync_socket.h"
11 #include "content/common/content_export.h"
12 #include "content/common/media/media_param_traits.h"
13 #include "ipc/ipc_message_macros.h"
14 #include "media/audio/audio_buffers_state.h"
15 #include "media/audio/audio_input_ipc.h"
16 #include "media/audio/audio_output_ipc.h"
17 #include "media/audio/audio_parameters.h"
19 #undef IPC_MESSAGE_EXPORT
20 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
21 #define IPC_MESSAGE_START AudioMsgStart
23 IPC_ENUM_TRAITS(media::AudioInputIPCDelegate::State)
24 IPC_ENUM_TRAITS(media::AudioOutputIPCDelegate::State)
26 IPC_STRUCT_BEGIN(AudioInputHostMsg_CreateStream_Config)
27 IPC_STRUCT_MEMBER(media::AudioParameters, params)
28 IPC_STRUCT_MEMBER(bool, automatic_gain_control)
29 IPC_STRUCT_MEMBER(uint32, shared_memory_count)
32 // Messages sent from the browser to the renderer.
34 // Tell the renderer process that an audio stream has been created.
35 // The renderer process is given a shared memory handle for the audio data
36 // buffer it shares with the browser process. It is also given a SyncSocket that
37 // it uses to communicate with the browser process about the state of the
38 // buffered audio data.
40 IPC_MESSAGE_CONTROL4(AudioMsg_NotifyStreamCreated,
42 base::SharedMemoryHandle /* handle */,
43 base::SyncSocket::Handle /* socket handle */,
46 IPC_MESSAGE_CONTROL4(AudioMsg_NotifyStreamCreated,
48 base::SharedMemoryHandle /* handle */,
49 base::FileDescriptor /* socket handle */,
53 // Tell the renderer process that an audio input stream has been created.
54 // The renderer process would be given a SyncSocket that it should read
55 // from from then on. It is also given number of segments in shared memory.
57 IPC_MESSAGE_CONTROL5(AudioInputMsg_NotifyStreamCreated,
59 base::SharedMemoryHandle /* handle */,
60 base::SyncSocket::Handle /* socket handle */,
62 uint32 /* segment count */)
64 IPC_MESSAGE_CONTROL5(AudioInputMsg_NotifyStreamCreated,
66 base::SharedMemoryHandle /* handle */,
67 base::FileDescriptor /* socket handle */,
69 uint32 /* segment count */)
72 // Notification message sent from AudioRendererHost to renderer after an output
73 // device change has occurred.
74 IPC_MESSAGE_CONTROL3(AudioMsg_NotifyDeviceChanged,
76 int /* new_buffer_size */,
77 int /* new_sample_rate */)
79 // Notification message sent from AudioRendererHost to renderer for state
80 // update after the renderer has requested a Create/Start/Close.
81 IPC_MESSAGE_CONTROL2(AudioMsg_NotifyStreamStateChanged,
83 media::AudioOutputIPCDelegate::State /* new state */)
85 // Notification message sent from browser to renderer for state update.
86 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyStreamStateChanged,
88 media::AudioInputIPCDelegate::State /* new state */)
90 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyStreamVolume,
94 // Messages sent from the renderer to the browser.
96 // Request that is sent to the browser for creating an audio output stream.
97 // |render_view_id| is the routing ID for the render view producing the audio
99 IPC_MESSAGE_CONTROL4(AudioHostMsg_CreateStream,
101 int /* render_view_id */,
102 int /* session_id */,
103 media::AudioParameters /* params */)
105 // Request that is sent to the browser for creating an audio input stream.
106 // |render_view_id| is the routing ID for the render view consuming the audio
108 IPC_MESSAGE_CONTROL4(AudioInputHostMsg_CreateStream,
110 int /* render_view_id */,
111 int /* session_id */,
112 AudioInputHostMsg_CreateStream_Config)
114 // Start buffering and play the audio stream specified by stream_id.
115 IPC_MESSAGE_CONTROL1(AudioHostMsg_PlayStream,
118 // Start recording the audio input stream specified by stream_id.
119 IPC_MESSAGE_CONTROL1(AudioInputHostMsg_RecordStream,
122 // Pause the audio stream specified by stream_id.
123 IPC_MESSAGE_CONTROL1(AudioHostMsg_PauseStream,
126 // Close an audio stream specified by stream_id.
127 IPC_MESSAGE_CONTROL1(AudioHostMsg_CloseStream,
130 // Close an audio input stream specified by stream_id.
131 IPC_MESSAGE_CONTROL1(AudioInputHostMsg_CloseStream,
134 // Set audio volume of the stream specified by stream_id.
135 // TODO(hclam): change this to vector if we have channel numbers other than 2.
136 IPC_MESSAGE_CONTROL2(AudioHostMsg_SetVolume,
140 // Set audio volume of the input stream specified by stream_id.
141 IPC_MESSAGE_CONTROL2(AudioInputHostMsg_SetVolume,