Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(878)

Side by Side Diff: content/renderer/media/audio_input_message_filter.cc

Issue 12440027: Do not pass the string device_id via IPC message to create an audio input stream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "content/renderer/media/audio_input_message_filter.h" 5 #include "content/renderer/media/audio_input_message_filter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "content/common/media/audio_messages.h" 9 #include "content/common/media/audio_messages.h"
10 #include "ipc/ipc_logging.h" 10 #include "ipc/ipc_logging.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 bool AudioInputMessageFilter::OnMessageReceived(const IPC::Message& message) { 43 bool AudioInputMessageFilter::OnMessageReceived(const IPC::Message& message) {
44 DCHECK(io_message_loop_->BelongsToCurrentThread()); 44 DCHECK(io_message_loop_->BelongsToCurrentThread());
45 bool handled = true; 45 bool handled = true;
46 IPC_BEGIN_MESSAGE_MAP(AudioInputMessageFilter, message) 46 IPC_BEGIN_MESSAGE_MAP(AudioInputMessageFilter, message)
47 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamCreated, 47 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamCreated,
48 OnStreamCreated) 48 OnStreamCreated)
49 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamVolume, OnStreamVolume) 49 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamVolume, OnStreamVolume)
50 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamStateChanged, 50 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyStreamStateChanged,
51 OnStreamStateChanged) 51 OnStreamStateChanged)
52 IPC_MESSAGE_HANDLER(AudioInputMsg_NotifyDeviceStarted,
53 OnDeviceStarted)
54 IPC_MESSAGE_UNHANDLED(handled = false) 52 IPC_MESSAGE_UNHANDLED(handled = false)
55 IPC_END_MESSAGE_MAP() 53 IPC_END_MESSAGE_MAP()
56 return handled; 54 return handled;
57 } 55 }
58 56
59 void AudioInputMessageFilter::OnFilterAdded(IPC::Channel* channel) { 57 void AudioInputMessageFilter::OnFilterAdded(IPC::Channel* channel) {
60 DCHECK(io_message_loop_->BelongsToCurrentThread()); 58 DCHECK(io_message_loop_->BelongsToCurrentThread());
61 59
62 // Captures the channel for IPC. 60 // Captures the channel for IPC.
63 channel_ = channel; 61 channel_ = channel;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 DCHECK(io_message_loop_->BelongsToCurrentThread()); 126 DCHECK(io_message_loop_->BelongsToCurrentThread());
129 media::AudioInputIPCDelegate* delegate = delegates_.Lookup(stream_id); 127 media::AudioInputIPCDelegate* delegate = delegates_.Lookup(stream_id);
130 if (!delegate) { 128 if (!delegate) {
131 DLOG(WARNING) << "Got audio stream event for a non-existent or removed" 129 DLOG(WARNING) << "Got audio stream event for a non-existent or removed"
132 << " audio renderer."; 130 << " audio renderer.";
133 return; 131 return;
134 } 132 }
135 delegate->OnStateChanged(state); 133 delegate->OnStateChanged(state);
136 } 134 }
137 135
138 void AudioInputMessageFilter::OnDeviceStarted(int stream_id,
139 const std::string& device_id) {
140 DCHECK(io_message_loop_->BelongsToCurrentThread());
141 media::AudioInputIPCDelegate* delegate = delegates_.Lookup(stream_id);
142 if (!delegate) {
143 NOTREACHED();
144 return;
145 }
146 delegate->OnDeviceReady(device_id);
147 }
148
149 int AudioInputMessageFilter::AddDelegate( 136 int AudioInputMessageFilter::AddDelegate(
150 media::AudioInputIPCDelegate* delegate) { 137 media::AudioInputIPCDelegate* delegate) {
151 DCHECK(io_message_loop_->BelongsToCurrentThread()); 138 DCHECK(io_message_loop_->BelongsToCurrentThread());
152 return delegates_.Add(delegate); 139 return delegates_.Add(delegate);
153 } 140 }
154 141
155 void AudioInputMessageFilter::RemoveDelegate(int id) { 142 void AudioInputMessageFilter::RemoveDelegate(int id) {
156 DCHECK(io_message_loop_->BelongsToCurrentThread()); 143 DCHECK(io_message_loop_->BelongsToCurrentThread());
157 delegates_.Remove(id); 144 delegates_.Remove(id);
158 } 145 }
159 146
160 void AudioInputMessageFilter::CreateStream(int stream_id, 147 void AudioInputMessageFilter::CreateStream(int stream_id,
148 int session_id,
161 const media::AudioParameters& params, 149 const media::AudioParameters& params,
162 const std::string& device_id,
163 bool automatic_gain_control) { 150 bool automatic_gain_control) {
164 Send(new AudioInputHostMsg_CreateStream( 151 Send(new AudioInputHostMsg_CreateStream(
165 stream_id, params, device_id, automatic_gain_control)); 152 stream_id, session_id, params, automatic_gain_control));
166 } 153 }
167 154
168 void AudioInputMessageFilter::AssociateStreamWithConsumer(int stream_id, 155 void AudioInputMessageFilter::AssociateStreamWithConsumer(int stream_id,
169 int render_view_id) { 156 int render_view_id) {
170 Send(new AudioInputHostMsg_AssociateStreamWithConsumer( 157 Send(new AudioInputHostMsg_AssociateStreamWithConsumer(
171 stream_id, render_view_id)); 158 stream_id, render_view_id));
172 } 159 }
173 160
174 void AudioInputMessageFilter::StartDevice(int stream_id, int session_id) {
175 Send(new AudioInputHostMsg_StartDevice(stream_id, session_id));
176 }
177
178 void AudioInputMessageFilter::RecordStream(int stream_id) { 161 void AudioInputMessageFilter::RecordStream(int stream_id) {
179 Send(new AudioInputHostMsg_RecordStream(stream_id)); 162 Send(new AudioInputHostMsg_RecordStream(stream_id));
180 } 163 }
181 164
182 void AudioInputMessageFilter::CloseStream(int stream_id) { 165 void AudioInputMessageFilter::CloseStream(int stream_id) {
183 Send(new AudioInputHostMsg_CloseStream(stream_id)); 166 Send(new AudioInputHostMsg_CloseStream(stream_id));
184 } 167 }
185 168
186 void AudioInputMessageFilter::SetVolume(int stream_id, double volume) { 169 void AudioInputMessageFilter::SetVolume(int stream_id, double volume) {
187 Send(new AudioInputHostMsg_SetVolume(stream_id, volume)); 170 Send(new AudioInputHostMsg_SetVolume(stream_id, volume));
188 } 171 }
189 172
190 } // namespace content 173 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698