• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 audio.
6 // Multiply-included message file, hence no include guard.
7 
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"
18 
19 #undef IPC_MESSAGE_EXPORT
20 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
21 #define IPC_MESSAGE_START AudioMsgStart
22 
23 IPC_ENUM_TRAITS(media::AudioInputIPCDelegate::State)
24 IPC_ENUM_TRAITS(media::AudioOutputIPCDelegate::State)
25 
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)
30 IPC_STRUCT_END()
31 
32 // Messages sent from the browser to the renderer.
33 
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.
39 #if defined(OS_WIN)
40 IPC_MESSAGE_CONTROL4(AudioMsg_NotifyStreamCreated,
41                      int /* stream id */,
42                      base::SharedMemoryHandle /* handle */,
43                      base::SyncSocket::Handle /* socket handle */,
44                      uint32 /* length */)
45 #else
46 IPC_MESSAGE_CONTROL4(AudioMsg_NotifyStreamCreated,
47                      int /* stream id */,
48                      base::SharedMemoryHandle /* handle */,
49                      base::FileDescriptor /* socket handle */,
50                      uint32 /* length */)
51 #endif
52 
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.
56 #if defined(OS_WIN)
57 IPC_MESSAGE_CONTROL5(AudioInputMsg_NotifyStreamCreated,
58                      int /* stream id */,
59                      base::SharedMemoryHandle /* handle */,
60                      base::SyncSocket::Handle /* socket handle */,
61                      uint32 /* length */,
62                      uint32 /* segment count */)
63 #else
64 IPC_MESSAGE_CONTROL5(AudioInputMsg_NotifyStreamCreated,
65                      int /* stream id */,
66                      base::SharedMemoryHandle /* handle */,
67                      base::FileDescriptor /* socket handle */,
68                      uint32 /* length */,
69                      uint32 /* segment count */)
70 #endif
71 
72 // Notification message sent from AudioRendererHost to renderer after an output
73 // device change has occurred.
74 IPC_MESSAGE_CONTROL3(AudioMsg_NotifyDeviceChanged,
75                      int /* stream_id */,
76                      int /* new_buffer_size */,
77                      int /* new_sample_rate */)
78 
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,
82                      int /* stream id */,
83                      media::AudioOutputIPCDelegate::State /* new state */)
84 
85 // Notification message sent from browser to renderer for state update.
86 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyStreamStateChanged,
87                      int /* stream id */,
88                      media::AudioInputIPCDelegate::State /* new state */)
89 
90 IPC_MESSAGE_CONTROL2(AudioInputMsg_NotifyStreamVolume,
91                      int /* stream id */,
92                      double /* volume */)
93 
94 // Messages sent from the renderer to the browser.
95 
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
98 // data.
99 IPC_MESSAGE_CONTROL4(AudioHostMsg_CreateStream,
100                      int /* stream_id */,
101                      int /* render_view_id */,
102                      int /* session_id */,
103                      media::AudioParameters /* params */)
104 
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
107 // data.
108 IPC_MESSAGE_CONTROL4(AudioInputHostMsg_CreateStream,
109                      int /* stream_id */,
110                      int /* render_view_id */,
111                      int /* session_id */,
112                      AudioInputHostMsg_CreateStream_Config)
113 
114 // Start buffering and play the audio stream specified by stream_id.
115 IPC_MESSAGE_CONTROL1(AudioHostMsg_PlayStream,
116                      int /* stream_id */)
117 
118 // Start recording the audio input stream specified by stream_id.
119 IPC_MESSAGE_CONTROL1(AudioInputHostMsg_RecordStream,
120                      int /* stream_id */)
121 
122 // Pause the audio stream specified by stream_id.
123 IPC_MESSAGE_CONTROL1(AudioHostMsg_PauseStream,
124                      int /* stream_id */)
125 
126 // Close an audio stream specified by stream_id.
127 IPC_MESSAGE_CONTROL1(AudioHostMsg_CloseStream,
128                      int /* stream_id */)
129 
130 // Close an audio input stream specified by stream_id.
131 IPC_MESSAGE_CONTROL1(AudioInputHostMsg_CloseStream,
132                      int /* stream_id */)
133 
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,
137                      int /* stream_id */,
138                      double /* volume */)
139 
140 // Set audio volume of the input stream specified by stream_id.
141 IPC_MESSAGE_CONTROL2(AudioInputHostMsg_SetVolume,
142                      int /* stream_id */,
143                      double /* volume */)
144