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/public/renderer/media_stream_audio_sink.h" | 7 #include "content/public/renderer/media_stream_audio_sink.h" |
8 #include "content/renderer/media/media_stream_audio_level_calculator.h" | 8 #include "content/renderer/media/media_stream_audio_level_calculator.h" |
9 #include "content/renderer/media/media_stream_audio_processor.h" | 9 #include "content/renderer/media/media_stream_audio_processor.h" |
10 #include "content/renderer/media/media_stream_audio_sink_owner.h" | 10 #include "content/renderer/media/media_stream_audio_sink_owner.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 ++it) { | 79 ++it) { |
80 int new_volume = (*it)->OnData(audio_data, | 80 int new_volume = (*it)->OnData(audio_data, |
81 audio_parameters_.sample_rate(), | 81 audio_parameters_.sample_rate(), |
82 audio_parameters_.channels(), | 82 audio_parameters_.channels(), |
83 audio_parameters_.frames_per_buffer(), | 83 audio_parameters_.frames_per_buffer(), |
84 voe_channels, | 84 voe_channels, |
85 delay.InMilliseconds(), | 85 delay.InMilliseconds(), |
86 volume, | 86 volume, |
87 need_audio_processing, | 87 need_audio_processing, |
88 key_pressed); | 88 key_pressed); |
89 if (new_volume != 0 && capturer.get() && !webaudio_source_) { | 89 if (new_volume != 0 && capturer.get() && !webaudio_source_.get()) { |
90 // Feed the new volume to WebRtc while changing the volume on the | 90 // Feed the new volume to WebRtc while changing the volume on the |
91 // browser. | 91 // browser. |
92 capturer->SetVolume(new_volume); | 92 capturer->SetVolume(new_volume); |
93 } | 93 } |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 void WebRtcLocalAudioTrack::OnSetFormat( | 97 void WebRtcLocalAudioTrack::OnSetFormat( |
98 const media::AudioParameters& params) { | 98 const media::AudioParameters& params) { |
99 DVLOG(1) << "WebRtcLocalAudioTrack::OnSetFormat()"; | 99 DVLOG(1) << "WebRtcLocalAudioTrack::OnSetFormat()"; |
(...skipping 28 matching lines...) Expand all Loading... |
128 // Verify that |sink| is not already added to the list. | 128 // Verify that |sink| is not already added to the list. |
129 DCHECK(!sinks_.Contains( | 129 DCHECK(!sinks_.Contains( |
130 MediaStreamAudioTrackSink::WrapsMediaStreamSink(sink))); | 130 MediaStreamAudioTrackSink::WrapsMediaStreamSink(sink))); |
131 | 131 |
132 // Create (and add to the list) a new MediaStreamAudioTrackSink | 132 // Create (and add to the list) a new MediaStreamAudioTrackSink |
133 // which owns the |sink| and delagates all calls to the | 133 // which owns the |sink| and delagates all calls to the |
134 // MediaStreamAudioSink interface. It will be tagged in the list, so | 134 // MediaStreamAudioSink interface. It will be tagged in the list, so |
135 // we remember to call OnSetFormat() on the new sink. | 135 // we remember to call OnSetFormat() on the new sink. |
136 scoped_refptr<MediaStreamAudioTrackSink> sink_owner( | 136 scoped_refptr<MediaStreamAudioTrackSink> sink_owner( |
137 new MediaStreamAudioSinkOwner(sink)); | 137 new MediaStreamAudioSinkOwner(sink)); |
138 sinks_.AddAndTag(sink_owner); | 138 sinks_.AddAndTag(sink_owner.get()); |
139 } | 139 } |
140 | 140 |
141 void WebRtcLocalAudioTrack::RemoveSink(MediaStreamAudioSink* sink) { | 141 void WebRtcLocalAudioTrack::RemoveSink(MediaStreamAudioSink* sink) { |
142 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 142 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
143 DVLOG(1) << "WebRtcLocalAudioTrack::RemoveSink()"; | 143 DVLOG(1) << "WebRtcLocalAudioTrack::RemoveSink()"; |
144 | 144 |
145 base::AutoLock auto_lock(lock_); | 145 base::AutoLock auto_lock(lock_); |
146 | 146 |
147 scoped_refptr<MediaStreamAudioTrackSink> removed_item = sinks_.Remove( | 147 scoped_refptr<MediaStreamAudioTrackSink> removed_item = sinks_.Remove( |
148 MediaStreamAudioTrackSink::WrapsMediaStreamSink(sink)); | 148 MediaStreamAudioTrackSink::WrapsMediaStreamSink(sink)); |
(...skipping 13 matching lines...) Expand all Loading... |
162 // Verify that |sink| is not already added to the list. | 162 // Verify that |sink| is not already added to the list. |
163 DCHECK(!sinks_.Contains( | 163 DCHECK(!sinks_.Contains( |
164 MediaStreamAudioTrackSink::WrapsPeerConnectionSink(sink))); | 164 MediaStreamAudioTrackSink::WrapsPeerConnectionSink(sink))); |
165 | 165 |
166 // Create (and add to the list) a new MediaStreamAudioTrackSink | 166 // Create (and add to the list) a new MediaStreamAudioTrackSink |
167 // which owns the |sink| and delagates all calls to the | 167 // which owns the |sink| and delagates all calls to the |
168 // MediaStreamAudioSink interface. It will be tagged in the list, so | 168 // MediaStreamAudioSink interface. It will be tagged in the list, so |
169 // we remember to call OnSetFormat() on the new sink. | 169 // we remember to call OnSetFormat() on the new sink. |
170 scoped_refptr<MediaStreamAudioTrackSink> sink_owner( | 170 scoped_refptr<MediaStreamAudioTrackSink> sink_owner( |
171 new PeerConnectionAudioSinkOwner(sink)); | 171 new PeerConnectionAudioSinkOwner(sink)); |
172 sinks_.AddAndTag(sink_owner); | 172 sinks_.AddAndTag(sink_owner.get()); |
173 } | 173 } |
174 | 174 |
175 void WebRtcLocalAudioTrack::RemoveSink(PeerConnectionAudioSink* sink) { | 175 void WebRtcLocalAudioTrack::RemoveSink(PeerConnectionAudioSink* sink) { |
176 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 176 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
177 DVLOG(1) << "WebRtcLocalAudioTrack::RemoveSink()"; | 177 DVLOG(1) << "WebRtcLocalAudioTrack::RemoveSink()"; |
178 | 178 |
179 base::AutoLock auto_lock(lock_); | 179 base::AutoLock auto_lock(lock_); |
180 | 180 |
181 scoped_refptr<MediaStreamAudioTrackSink> removed_item = sinks_.Remove( | 181 scoped_refptr<MediaStreamAudioTrackSink> removed_item = sinks_.Remove( |
182 MediaStreamAudioTrackSink::WrapsPeerConnectionSink(sink)); | 182 MediaStreamAudioTrackSink::WrapsPeerConnectionSink(sink)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 242 |
243 for (SinkList::ItemList::const_iterator it = sinks.begin(); | 243 for (SinkList::ItemList::const_iterator it = sinks.begin(); |
244 it != sinks.end(); | 244 it != sinks.end(); |
245 ++it){ | 245 ++it){ |
246 (*it)->OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateEnded); | 246 (*it)->OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateEnded); |
247 (*it)->Reset(); | 247 (*it)->Reset(); |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 } // namespace content | 251 } // namespace content |
OLD | NEW |