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/renderer/media/webrtc_audio_capturer.h" | 5 #include "content/renderer/media/webrtc_audio_capturer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 bool key_pressed) { | 48 bool key_pressed) { |
49 base::AutoLock lock(lock_); | 49 base::AutoLock lock(lock_); |
50 if (delegate_) { | 50 if (delegate_) { |
51 delegate_->Capture(audio_source, | 51 delegate_->Capture(audio_source, |
52 audio_delay_milliseconds, | 52 audio_delay_milliseconds, |
53 volume, | 53 volume, |
54 key_pressed); | 54 key_pressed); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 void SetCaptureFormat(const media::AudioParameters& params) { | 58 void OnSetFormat(const media::AudioParameters& params) { |
59 base::AutoLock lock(lock_); | 59 base::AutoLock lock(lock_); |
60 if (delegate_) | 60 if (delegate_) |
61 delegate_->SetCaptureFormat(params); | 61 delegate_->OnSetFormat(params); |
62 } | 62 } |
63 | 63 |
64 void Reset() { | 64 void Reset() { |
65 base::AutoLock lock(lock_); | 65 base::AutoLock lock(lock_); |
66 delegate_ = NULL; | 66 delegate_ = NULL; |
67 } | 67 } |
68 | 68 |
69 // Wrapper which allows to use std::find_if() when adding and removing | 69 // Wrapper which allows to use std::find_if() when adding and removing |
70 // sinks to/from the list. | 70 // sinks to/from the list. |
71 struct TrackWrapper { | 71 struct TrackWrapper { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 { | 217 { |
218 base::AutoLock auto_lock(lock_); | 218 base::AutoLock auto_lock(lock_); |
219 // Verify that |track| is not already added to the list. | 219 // Verify that |track| is not already added to the list. |
220 DCHECK(std::find_if(tracks_.begin(), tracks_.end(), | 220 DCHECK(std::find_if(tracks_.begin(), tracks_.end(), |
221 TrackOwner::TrackWrapper(track)) == tracks_.end()); | 221 TrackOwner::TrackWrapper(track)) == tracks_.end()); |
222 scoped_refptr<TrackOwner> track_owner(new TrackOwner(track)); | 222 scoped_refptr<TrackOwner> track_owner(new TrackOwner(track)); |
223 tracks_.push_back(track_owner); | 223 tracks_.push_back(track_owner); |
224 | 224 |
225 // Also push the track to |tracks_to_notify_format_| so that we will call | 225 // Also push the track to |tracks_to_notify_format_| so that we will call |
226 // SetCaptureFormat() on the new track. | 226 // OnSetFormat() on the new track. |
227 tracks_to_notify_format_.push_back(track_owner); | 227 tracks_to_notify_format_.push_back(track_owner); |
228 } | 228 } |
229 | 229 |
230 // Start the source if the first audio track is connected to the capturer. | 230 // Start the source if the first audio track is connected to the capturer. |
231 // Start() will do nothing if the capturer has already been started. | 231 // Start() will do nothing if the capturer has already been started. |
232 Start(); | 232 Start(); |
233 | 233 |
234 } | 234 } |
235 | 235 |
236 void WebRtcAudioCapturer::RemoveTrack(WebRtcLocalAudioTrack* track) { | 236 void WebRtcAudioCapturer::RemoveTrack(WebRtcLocalAudioTrack* track) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 CHECK(params_.IsValid()); | 428 CHECK(params_.IsValid()); |
429 CHECK_EQ(audio_source->channels(), params_.channels()); | 429 CHECK_EQ(audio_source->channels(), params_.channels()); |
430 CHECK_EQ(audio_source->frames(), params_.frames_per_buffer()); | 430 CHECK_EQ(audio_source->frames(), params_.frames_per_buffer()); |
431 params = params_; | 431 params = params_; |
432 } | 432 } |
433 | 433 |
434 // Notify the tracks on when the format changes. This will do nothing if | 434 // Notify the tracks on when the format changes. This will do nothing if |
435 // |tracks_to_notify_format| is empty. | 435 // |tracks_to_notify_format| is empty. |
436 for (TrackList::const_iterator it = tracks_to_notify_format.begin(); | 436 for (TrackList::const_iterator it = tracks_to_notify_format.begin(); |
437 it != tracks_to_notify_format.end(); ++it) { | 437 it != tracks_to_notify_format.end(); ++it) { |
438 (*it)->SetCaptureFormat(params); | 438 (*it)->OnSetFormat(params); |
439 } | 439 } |
440 | 440 |
441 // Feed the data to the tracks. | 441 // Feed the data to the tracks. |
442 for (TrackList::const_iterator it = tracks.begin(); | 442 for (TrackList::const_iterator it = tracks.begin(); |
443 it != tracks.end(); | 443 it != tracks.end(); |
444 ++it) { | 444 ++it) { |
445 (*it)->Capture(audio_source, audio_delay_milliseconds, | 445 (*it)->Capture(audio_source, audio_delay_milliseconds, |
446 current_volume, key_pressed); | 446 current_volume, key_pressed); |
447 } | 447 } |
448 } | 448 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 495 |
496 void WebRtcAudioCapturer::GetAudioProcessingParams( | 496 void WebRtcAudioCapturer::GetAudioProcessingParams( |
497 base::TimeDelta* delay, int* volume, bool* key_pressed) { | 497 base::TimeDelta* delay, int* volume, bool* key_pressed) { |
498 base::AutoLock auto_lock(lock_); | 498 base::AutoLock auto_lock(lock_); |
499 *delay = audio_delay_; | 499 *delay = audio_delay_; |
500 *volume = volume_; | 500 *volume = volume_; |
501 *key_pressed = key_pressed_; | 501 *key_pressed = key_pressed_; |
502 } | 502 } |
503 | 503 |
504 } // namespace content | 504 } // namespace content |
OLD | NEW |