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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 bool key_pressed) { | 50 bool key_pressed) { |
51 base::AutoLock lock(lock_); | 51 base::AutoLock lock(lock_); |
52 if (delegate_) { | 52 if (delegate_) { |
53 delegate_->Capture(audio_source, | 53 delegate_->Capture(audio_source, |
54 audio_delay_milliseconds, | 54 audio_delay_milliseconds, |
55 volume, | 55 volume, |
56 key_pressed); | 56 key_pressed); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 void SetCaptureFormat(const media::AudioParameters& params) { | 60 void OnSetFormat(const media::AudioParameters& params) { |
61 base::AutoLock lock(lock_); | 61 base::AutoLock lock(lock_); |
62 if (delegate_) | 62 if (delegate_) |
63 delegate_->SetCaptureFormat(params); | 63 delegate_->OnSetFormat(params); |
64 } | 64 } |
65 | 65 |
66 void Reset() { | 66 void Reset() { |
67 base::AutoLock lock(lock_); | 67 base::AutoLock lock(lock_); |
68 delegate_ = NULL; | 68 delegate_ = NULL; |
69 } | 69 } |
70 | 70 |
71 // Wrapper which allows to use std::find_if() when adding and removing | 71 // Wrapper which allows to use std::find_if() when adding and removing |
72 // sinks to/from the list. | 72 // sinks to/from the list. |
73 struct TrackWrapper { | 73 struct TrackWrapper { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 { | 232 { |
233 base::AutoLock auto_lock(lock_); | 233 base::AutoLock auto_lock(lock_); |
234 // Verify that |track| is not already added to the list. | 234 // Verify that |track| is not already added to the list. |
235 DCHECK(std::find_if(tracks_.begin(), tracks_.end(), | 235 DCHECK(std::find_if(tracks_.begin(), tracks_.end(), |
236 TrackOwner::TrackWrapper(track)) == tracks_.end()); | 236 TrackOwner::TrackWrapper(track)) == tracks_.end()); |
237 scoped_refptr<TrackOwner> track_owner(new TrackOwner(track)); | 237 scoped_refptr<TrackOwner> track_owner(new TrackOwner(track)); |
238 tracks_.push_back(track_owner); | 238 tracks_.push_back(track_owner); |
239 | 239 |
240 // Also push the track to |tracks_to_notify_format_| so that we will call | 240 // Also push the track to |tracks_to_notify_format_| so that we will call |
241 // SetCaptureFormat() on the new track. | 241 // OnSetFormat() on the new track. |
242 tracks_to_notify_format_.push_back(track_owner); | 242 tracks_to_notify_format_.push_back(track_owner); |
243 } | 243 } |
244 | 244 |
245 // Start the source if the first audio track is connected to the capturer. | 245 // Start the source if the first audio track is connected to the capturer. |
246 // Start() will do nothing if the capturer has already been started. | 246 // Start() will do nothing if the capturer has already been started. |
247 Start(); | 247 Start(); |
248 | 248 |
249 } | 249 } |
250 | 250 |
251 void WebRtcAudioCapturer::RemoveTrack(WebRtcLocalAudioTrack* track) { | 251 void WebRtcAudioCapturer::RemoveTrack(WebRtcLocalAudioTrack* track) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 CHECK(params_.IsValid()); | 443 CHECK(params_.IsValid()); |
444 CHECK_EQ(audio_source->channels(), params_.channels()); | 444 CHECK_EQ(audio_source->channels(), params_.channels()); |
445 CHECK_EQ(audio_source->frames(), params_.frames_per_buffer()); | 445 CHECK_EQ(audio_source->frames(), params_.frames_per_buffer()); |
446 params = params_; | 446 params = params_; |
447 } | 447 } |
448 | 448 |
449 // Notify the tracks on when the format changes. This will do nothing if | 449 // Notify the tracks on when the format changes. This will do nothing if |
450 // |tracks_to_notify_format| is empty. | 450 // |tracks_to_notify_format| is empty. |
451 for (TrackList::const_iterator it = tracks_to_notify_format.begin(); | 451 for (TrackList::const_iterator it = tracks_to_notify_format.begin(); |
452 it != tracks_to_notify_format.end(); ++it) { | 452 it != tracks_to_notify_format.end(); ++it) { |
453 (*it)->SetCaptureFormat(params); | 453 (*it)->OnSetFormat(params); |
454 } | 454 } |
455 | 455 |
456 // Feed the data to the tracks. | 456 // Feed the data to the tracks. |
457 for (TrackList::const_iterator it = tracks.begin(); | 457 for (TrackList::const_iterator it = tracks.begin(); |
458 it != tracks.end(); | 458 it != tracks.end(); |
459 ++it) { | 459 ++it) { |
460 (*it)->Capture(audio_source, audio_delay_milliseconds, | 460 (*it)->Capture(audio_source, audio_delay_milliseconds, |
461 current_volume, key_pressed); | 461 current_volume, key_pressed); |
462 } | 462 } |
463 } | 463 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 510 |
511 void WebRtcAudioCapturer::GetAudioProcessingParams( | 511 void WebRtcAudioCapturer::GetAudioProcessingParams( |
512 base::TimeDelta* delay, int* volume, bool* key_pressed) { | 512 base::TimeDelta* delay, int* volume, bool* key_pressed) { |
513 base::AutoLock auto_lock(lock_); | 513 base::AutoLock auto_lock(lock_); |
514 *delay = audio_delay_; | 514 *delay = audio_delay_; |
515 *volume = volume_; | 515 *volume = volume_; |
516 *key_pressed = key_pressed_; | 516 *key_pressed = key_pressed_; |
517 } | 517 } |
518 | 518 |
519 } // namespace content | 519 } // namespace content |
OLD | NEW |