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_local_audio_track.h" | 5 #include "content/renderer/media/webrtc_local_audio_track.h" |
6 | 6 |
7 #include "content/renderer/media/webrtc_audio_capturer.h" | 7 #include "content/renderer/media/webrtc_audio_capturer.h" |
8 #include "content/renderer/media/webrtc_audio_capturer_sink_owner.h" | 8 #include "content/renderer/media/webrtc_audio_capturer_sink_owner.h" |
9 #include "third_party/libjingle/source/talk/media/base/audiorenderer.h" | 9 #include "third_party/libjingle/source/talk/media/base/audiorenderer.h" |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 DCHECK(thread_checker_.CalledOnValidThread()); | 40 DCHECK(thread_checker_.CalledOnValidThread()); |
41 DVLOG(1) << "WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack()"; | 41 DVLOG(1) << "WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack()"; |
42 // Users might not call Stop() on the track. | 42 // Users might not call Stop() on the track. |
43 Stop(); | 43 Stop(); |
44 } | 44 } |
45 | 45 |
46 void WebRtcLocalAudioTrack::CaptureData(const int16* audio_data, | 46 void WebRtcLocalAudioTrack::CaptureData(const int16* audio_data, |
47 int number_of_channels, | 47 int number_of_channels, |
48 int number_of_frames, | 48 int number_of_frames, |
49 int audio_delay_milliseconds, | 49 int audio_delay_milliseconds, |
50 int volume, | 50 int volume) { |
51 bool key_pressed) { | |
52 scoped_refptr<WebRtcAudioCapturer> capturer; | 51 scoped_refptr<WebRtcAudioCapturer> capturer; |
53 std::vector<int> voe_channels; | 52 std::vector<int> voe_channels; |
54 int sample_rate = 0; | 53 int sample_rate = 0; |
55 SinkList sinks; | 54 SinkList sinks; |
56 { | 55 { |
57 base::AutoLock auto_lock(lock_); | 56 base::AutoLock auto_lock(lock_); |
58 // When the track is diabled, we simply return here. | 57 // When the track is diabled, we simply return here. |
59 // TODO(xians): Figure out if we should feed zero to sinks instead, in | 58 // TODO(xians): Figure out if we should feed zero to sinks instead, in |
60 // order to inject VAD data in such case. | 59 // order to inject VAD data in such case. |
61 if (!enabled()) | 60 if (!enabled()) |
62 return; | 61 return; |
63 | 62 |
64 capturer = capturer_; | 63 capturer = capturer_; |
65 voe_channels = voe_channels_; | 64 voe_channels = voe_channels_; |
66 sample_rate = params_.sample_rate(), | 65 sample_rate = params_.sample_rate(), |
67 sinks = sinks_; | 66 sinks = sinks_; |
68 } | 67 } |
69 | 68 |
70 // Feed the data to the sinks. | 69 // Feed the data to the sinks. |
71 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) { | 70 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) { |
72 int new_volume = (*it)->CaptureData(voe_channels, | 71 int new_volume = (*it)->CaptureData(voe_channels, audio_data, sample_rate, |
73 audio_data, | 72 number_of_channels, number_of_frames, |
74 sample_rate, | 73 audio_delay_milliseconds, volume, |
75 number_of_channels, | 74 need_audio_processing_); |
76 number_of_frames, | |
77 audio_delay_milliseconds, | |
78 volume, | |
79 need_audio_processing_, | |
80 key_pressed); | |
81 if (new_volume != 0 && capturer.get()) | 75 if (new_volume != 0 && capturer.get()) |
82 capturer->SetVolume(new_volume); | 76 capturer->SetVolume(new_volume); |
83 } | 77 } |
84 } | 78 } |
85 | 79 |
86 void WebRtcLocalAudioTrack::SetCaptureFormat( | 80 void WebRtcLocalAudioTrack::SetCaptureFormat( |
87 const media::AudioParameters& params) { | 81 const media::AudioParameters& params) { |
88 base::AutoLock auto_lock(lock_); | 82 base::AutoLock auto_lock(lock_); |
89 params_ = params; | 83 params_ = params; |
90 | 84 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 base::AutoLock auto_lock(lock_); | 183 base::AutoLock auto_lock(lock_); |
190 sinks = sinks_; | 184 sinks = sinks_; |
191 capturer_ = NULL; | 185 capturer_ = NULL; |
192 } | 186 } |
193 | 187 |
194 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) | 188 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) |
195 (*it)->Reset(); | 189 (*it)->Reset(); |
196 } | 190 } |
197 | 191 |
198 } // namespace content | 192 } // namespace content |
OLD | NEW |