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 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 void AudioInputRendererHost::OnChannelClosing() { | 129 void AudioInputRendererHost::OnChannelClosing() { |
130 // Since the IPC sender is gone, close all requested audio streams. | 130 // Since the IPC sender is gone, close all requested audio streams. |
131 DeleteEntries(); | 131 DeleteEntries(); |
132 } | 132 } |
133 | 133 |
134 void AudioInputRendererHost::OnDestruct() const { | 134 void AudioInputRendererHost::OnDestruct() const { |
135 BrowserThread::DeleteOnIOThread::Destruct(this); | 135 BrowserThread::DeleteOnIOThread::Destruct(this); |
136 } | 136 } |
137 | 137 |
138 void AudioInputRendererHost::OnCreated( | 138 void AudioInputRendererHost::OnCreated(media::AudioInputController* controller, |
139 media::AudioInputController* controller) { | 139 bool initially_muted) { |
140 BrowserThread::PostTask( | 140 BrowserThread::PostTask( |
141 BrowserThread::IO, FROM_HERE, | 141 BrowserThread::IO, FROM_HERE, |
142 base::BindOnce(&AudioInputRendererHost::DoCompleteCreation, this, | 142 base::BindOnce(&AudioInputRendererHost::DoCompleteCreation, this, |
143 base::RetainedRef(controller))); | 143 base::RetainedRef(controller), initially_muted)); |
144 } | 144 } |
145 | 145 |
146 void AudioInputRendererHost::OnError(media::AudioInputController* controller, | 146 void AudioInputRendererHost::OnError(media::AudioInputController* controller, |
147 media::AudioInputController::ErrorCode error_code) { | 147 media::AudioInputController::ErrorCode error_code) { |
148 BrowserThread::PostTask( | 148 BrowserThread::PostTask( |
149 BrowserThread::IO, FROM_HERE, | 149 BrowserThread::IO, FROM_HERE, |
150 base::BindOnce(&AudioInputRendererHost::DoHandleError, this, | 150 base::BindOnce(&AudioInputRendererHost::DoHandleError, this, |
151 base::RetainedRef(controller), error_code)); | 151 base::RetainedRef(controller), error_code)); |
152 } | 152 } |
153 | 153 |
(...skipping 12 matching lines...) Expand all Loading... |
166 base::Bind(&AudioInputRendererHost::DoNotifyMutedState, this, | 166 base::Bind(&AudioInputRendererHost::DoNotifyMutedState, this, |
167 base::RetainedRef(controller), is_muted)); | 167 base::RetainedRef(controller), is_muted)); |
168 } | 168 } |
169 | 169 |
170 void AudioInputRendererHost::set_renderer_pid(int32_t renderer_pid) { | 170 void AudioInputRendererHost::set_renderer_pid(int32_t renderer_pid) { |
171 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 171 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
172 renderer_pid_ = renderer_pid; | 172 renderer_pid_ = renderer_pid; |
173 } | 173 } |
174 | 174 |
175 void AudioInputRendererHost::DoCompleteCreation( | 175 void AudioInputRendererHost::DoCompleteCreation( |
176 media::AudioInputController* controller) { | 176 media::AudioInputController* controller, |
| 177 bool initially_muted) { |
177 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 178 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
178 | 179 |
179 AudioEntry* entry = LookupByController(controller); | 180 AudioEntry* entry = LookupByController(controller); |
180 DCHECK(entry); | 181 DCHECK(entry); |
181 AudioInputSyncWriter* writer = entry->writer.get(); | 182 AudioInputSyncWriter* writer = entry->writer.get(); |
182 DCHECK(writer); | 183 DCHECK(writer); |
183 DCHECK(PeerHandle()); | 184 DCHECK(PeerHandle()); |
184 | 185 |
185 // Once the audio stream is created then complete the creation process by | 186 // Once the audio stream is created then complete the creation process by |
186 // mapping shared memory and sharing with the renderer process. | 187 // mapping shared memory and sharing with the renderer process. |
(...skipping 11 matching lines...) Expand all Loading... |
198 // If we failed to prepare the sync socket for the renderer then we fail | 199 // If we failed to prepare the sync socket for the renderer then we fail |
199 // the construction of audio input stream. | 200 // the construction of audio input stream. |
200 if (!entry->foreign_socket.PrepareTransitDescriptor( | 201 if (!entry->foreign_socket.PrepareTransitDescriptor( |
201 PeerHandle(), &socket_transit_descriptor)) { | 202 PeerHandle(), &socket_transit_descriptor)) { |
202 foreign_memory_handle.Close(); | 203 foreign_memory_handle.Close(); |
203 DeleteEntryOnError(entry, SYNC_SOCKET_ERROR); | 204 DeleteEntryOnError(entry, SYNC_SOCKET_ERROR); |
204 return; | 205 return; |
205 } | 206 } |
206 | 207 |
207 LogMessage(entry->stream_id, | 208 LogMessage(entry->stream_id, |
208 "DoCompleteCreation: IPC channel and stream are now open", | 209 base::StringPrintf("DoCompleteCreation: IPC channel and stream " |
| 210 "are now open (initially %s", |
| 211 initially_muted ? "muted" : "not muted"), |
209 true); | 212 true); |
210 | 213 |
211 Send(new AudioInputMsg_NotifyStreamCreated( | 214 Send(new AudioInputMsg_NotifyStreamCreated( |
212 entry->stream_id, foreign_memory_handle, socket_transit_descriptor, | 215 entry->stream_id, foreign_memory_handle, socket_transit_descriptor, |
213 writer->shared_memory()->requested_size(), | 216 writer->shared_memory()->requested_size(), |
214 writer->shared_memory_segment_count())); | 217 writer->shared_memory_segment_count(), initially_muted)); |
215 | 218 |
216 // Free the foreign socket on here since it isn't needed anymore in this | 219 // Free the foreign socket on here since it isn't needed anymore in this |
217 // process. | 220 // process. |
218 entry->foreign_socket.Close(); | 221 entry->foreign_socket.Close(); |
219 } | 222 } |
220 | 223 |
221 void AudioInputRendererHost::DoHandleError( | 224 void AudioInputRendererHost::DoHandleError( |
222 media::AudioInputController* controller, | 225 media::AudioInputController* controller, |
223 media::AudioInputController::ErrorCode error_code) { | 226 media::AudioInputController::ErrorCode error_code) { |
224 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 227 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 const base::FilePath& file, | 598 const base::FilePath& file, |
596 int stream_id) { | 599 int stream_id) { |
597 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 600 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
598 EnableDebugRecordingForId(GetDebugRecordingFilePathWithExtensions(file), | 601 EnableDebugRecordingForId(GetDebugRecordingFilePathWithExtensions(file), |
599 stream_id); | 602 stream_id); |
600 } | 603 } |
601 | 604 |
602 #endif // BUILDFLAG(ENABLE_WEBRTC) | 605 #endif // BUILDFLAG(ENABLE_WEBRTC) |
603 | 606 |
604 } // namespace content | 607 } // namespace content |
OLD | NEW |