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.
10 #include "base/basictypes.h"
11 #include "base/shared_memory.h"
12 #include "base/sync_socket.h"
13 #include "content/common/content_export.h"
14 #include "content/common/media/audio_param_traits.h"
15 #include "ipc/ipc_message_macros.h"
16 #include "media/audio/audio_buffers_state.h"
17 #include "media/audio/audio_input_ipc.h"
18 #include "media/audio/audio_output_ipc.h"
19 #include "media/audio/audio_parameters.h"
21 #undef IPC_MESSAGE_EXPORT
22 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
23 #define IPC_MESSAGE_START AudioMsgStart
25 IPC_ENUM_TRAITS(media::AudioInputIPCDelegate::State
)
26 IPC_ENUM_TRAITS(media::AudioOutputIPCDelegate::State
)
28 // Messages sent from the browser to the renderer.
30 // Tell the renderer process that an audio stream has been created.
31 // The renderer process is given a shared memory handle for the audio data
32 // buffer it shares with the browser process. It is also given a SyncSocket that
33 // it uses to communicate with the browser process about the state of the
34 // buffered audio data.
36 IPC_MESSAGE_CONTROL4(AudioMsg_NotifyStreamCreated
,
38 base::SharedMemoryHandle
/* handle */,
39 base::SyncSocket::Handle
/* socket handle */,
42 IPC_MESSAGE_CONTROL4(AudioMsg_NotifyStreamCreated
,
44 base::SharedMemoryHandle
/* handle */,
45 base::FileDescriptor
/* socket handle */,
49 // Tell the renderer process that an audio input stream has been created.
50 // The renderer process would be given a SyncSocket that it should read
53 IPC_MESSAGE_CONTROL4(AudioInputMsg_NotifyStreamCreated
,
55 base::SharedMemoryHandle
/* handle */,
56 base::SyncSocket::Handle
/* socket handle */,
59 IPC_MESSAGE_CONTROL4(AudioInputMsg_NotifyStreamCreated
,
61 base::SharedMemoryHandle
/* handle */,
62 base::FileDescriptor
/* socket handle */,
66 // Notification message sent from AudioRendererHost to renderer for state
67 // update after the renderer has requested a Create/Start/Close.
68 IPC_MESSAGE_CONTROL2(AudioMsg_NotifyStreamStateChanged
,
70 media::AudioOutputIPCDelegate::State
/* new state */)
72 // Notification message sent from browser to renderer for state update.
73 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyStreamStateChanged
,
75 media::AudioInputIPCDelegate::State
/* new state */)
77 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyStreamVolume
,
81 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyDeviceStarted
,
83 std::string
/* device_id */)
85 // Messages sent from the renderer to the browser.
87 // Request that got sent to browser for creating an audio output stream
88 IPC_MESSAGE_CONTROL3(AudioHostMsg_CreateStream
,
90 media::AudioParameters
, /* params */
91 int /* input_channels */)
93 // Request that got sent to browser for creating an audio input stream
94 IPC_MESSAGE_CONTROL4(AudioInputHostMsg_CreateStream
,
96 media::AudioParameters
/* params */,
97 std::string
/* device_id */,
98 bool /* automatic_gain_control */)
100 // Indicate that audio for a stream is produced by the specified render view.
101 IPC_MESSAGE_CONTROL2(AudioHostMsg_AssociateStreamWithProducer
,
103 int /* render_view_id */)
105 // Indicate that audio for a stream is consumed by the specified render view.
106 IPC_MESSAGE_CONTROL2(AudioInputHostMsg_AssociateStreamWithConsumer
,
108 int /* render_view_id */)
110 // Start buffering and play the audio stream specified by stream_id.
111 IPC_MESSAGE_CONTROL1(AudioHostMsg_PlayStream
,
114 // Start recording the audio input stream specified by stream_id.
115 IPC_MESSAGE_CONTROL1(AudioInputHostMsg_RecordStream
,
118 // Pause the audio stream specified by stream_id.
119 IPC_MESSAGE_CONTROL1(AudioHostMsg_PauseStream
,
122 // Discard all buffered audio data for the specified audio stream.
123 IPC_MESSAGE_CONTROL1(AudioHostMsg_FlushStream
,
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
,
145 // Start the device referenced by the session_id for the input stream specified
147 IPC_MESSAGE_CONTROL2(AudioInputHostMsg_StartDevice
,
149 int /* session_id */)