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) { |
51 scoped_refptr<WebRtcAudioCapturer> capturer; | 52 scoped_refptr<WebRtcAudioCapturer> capturer; |
52 std::vector<int> voe_channels; | 53 std::vector<int> voe_channels; |
53 int sample_rate = 0; | 54 int sample_rate = 0; |
54 SinkList sinks; | 55 SinkList sinks; |
55 { | 56 { |
56 base::AutoLock auto_lock(lock_); | 57 base::AutoLock auto_lock(lock_); |
57 // When the track is diabled, we simply return here. | 58 // When the track is diabled, we simply return here. |
58 // TODO(xians): Figure out if we should feed zero to sinks instead, in | 59 // TODO(xians): Figure out if we should feed zero to sinks instead, in |
59 // order to inject VAD data in such case. | 60 // order to inject VAD data in such case. |
60 if (!enabled()) | 61 if (!enabled()) |
61 return; | 62 return; |
62 | 63 |
63 capturer = capturer_; | 64 capturer = capturer_; |
64 voe_channels = voe_channels_; | 65 voe_channels = voe_channels_; |
65 sample_rate = params_.sample_rate(), | 66 sample_rate = params_.sample_rate(), |
66 sinks = sinks_; | 67 sinks = sinks_; |
67 } | 68 } |
68 | 69 |
69 // Feed the data to the sinks. | 70 // Feed the data to the sinks. |
70 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) { | 71 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) { |
71 int new_volume = (*it)->CaptureData(voe_channels, audio_data, sample_rate, | 72 int new_volume = (*it)->CaptureData(voe_channels, |
72 number_of_channels, number_of_frames, | 73 audio_data, |
73 audio_delay_milliseconds, volume, | 74 sample_rate, |
74 need_audio_processing_); | 75 number_of_channels, |
| 76 number_of_frames, |
| 77 audio_delay_milliseconds, |
| 78 volume, |
| 79 need_audio_processing_, |
| 80 key_pressed); |
75 if (new_volume != 0 && capturer.get()) | 81 if (new_volume != 0 && capturer.get()) |
76 capturer->SetVolume(new_volume); | 82 capturer->SetVolume(new_volume); |
77 } | 83 } |
78 } | 84 } |
79 | 85 |
80 void WebRtcLocalAudioTrack::SetCaptureFormat( | 86 void WebRtcLocalAudioTrack::SetCaptureFormat( |
81 const media::AudioParameters& params) { | 87 const media::AudioParameters& params) { |
82 base::AutoLock auto_lock(lock_); | 88 base::AutoLock auto_lock(lock_); |
83 params_ = params; | 89 params_ = params; |
84 | 90 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 base::AutoLock auto_lock(lock_); | 189 base::AutoLock auto_lock(lock_); |
184 sinks = sinks_; | 190 sinks = sinks_; |
185 capturer_ = NULL; | 191 capturer_ = NULL; |
186 } | 192 } |
187 | 193 |
188 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) | 194 for (SinkList::const_iterator it = sinks.begin(); it != sinks.end(); ++it) |
189 (*it)->Reset(); | 195 (*it)->Reset(); |
190 } | 196 } |
191 | 197 |
192 } // namespace content | 198 } // namespace content |
OLD | NEW |