Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: content/renderer/media/webrtc_local_audio_track.cc

Issue 218763007: Update MediaStreamTrack::Stop to latest draft. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments and added tests. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 20 matching lines...) Expand all
31 if (!webaudio_source_) { 31 if (!webaudio_source_) {
32 source_provider_.reset(new WebRtcLocalAudioSourceProvider()); 32 source_provider_.reset(new WebRtcLocalAudioSourceProvider());
33 AddSink(source_provider_.get()); 33 AddSink(source_provider_.get());
34 } 34 }
35 DVLOG(1) << "WebRtcLocalAudioTrack::WebRtcLocalAudioTrack()"; 35 DVLOG(1) << "WebRtcLocalAudioTrack::WebRtcLocalAudioTrack()";
36 } 36 }
37 37
38 WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack() { 38 WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack() {
39 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 39 DCHECK(main_render_thread_checker_.CalledOnValidThread());
40 DVLOG(1) << "WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack()"; 40 DVLOG(1) << "WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack()";
41 // Users might not call Stop() on the track. 41 // Users might not call StopTrack() on the track.
tommi (sloooow) - chröme 2014/04/03 08:53:16 is this something we should rather enforce than wo
perkj_chrome 2014/04/03 11:58:34 I would rather just remove the comment... StopTrac
42 Stop(); 42 StopTrack();
43 } 43 }
44 44
45 void WebRtcLocalAudioTrack::Capture(const int16* audio_data, 45 void WebRtcLocalAudioTrack::Capture(const int16* audio_data,
46 base::TimeDelta delay, 46 base::TimeDelta delay,
47 int volume, 47 int volume,
48 bool key_pressed, 48 bool key_pressed,
49 bool need_audio_processing) { 49 bool need_audio_processing) {
50 DCHECK(capture_thread_checker_.CalledOnValidThread()); 50 DCHECK(capture_thread_checker_.CalledOnValidThread());
51 51
52 // Calculate the signal level regardless if the track is disabled or enabled. 52 // Calculate the signal level regardless if the track is disabled or enabled.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 base::AutoLock auto_lock(lock_); 208 base::AutoLock auto_lock(lock_);
209 sinks = sinks_.Items(); 209 sinks = sinks_.Items();
210 } 210 }
211 for (SinkList::ItemList::const_iterator it = sinks.begin(); 211 for (SinkList::ItemList::const_iterator it = sinks.begin();
212 it != sinks.end(); 212 it != sinks.end();
213 ++it) { 213 ++it) {
214 (*it)->OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateLive); 214 (*it)->OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateLive);
215 } 215 }
216 } 216 }
217 217
218 void WebRtcLocalAudioTrack::Stop() { 218 void WebRtcLocalAudioTrack::StopTrack() {
219 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 219 DCHECK(main_render_thread_checker_.CalledOnValidThread());
220 DVLOG(1) << "WebRtcLocalAudioTrack::Stop()"; 220 DVLOG(1) << "WebRtcLocalAudioTrack::Stop()";
221 if (!capturer_.get() && !webaudio_source_.get()) 221 if (!capturer_.get() && !webaudio_source_.get())
222 return; 222 return;
223 223
224 if (webaudio_source_.get()) { 224 if (webaudio_source_.get()) {
225 // Called Stop() on the |webaudio_source_| explicitly so that 225 // Called Stop() on the |webaudio_source_| explicitly so that
226 // |webaudio_source_| won't push more data to the track anymore. 226 // |webaudio_source_| won't push more data to the track anymore.
227 // Also note that the track is not registered as a sink to the |capturer_| 227 // Also note that the track is not registered as a sink to the |capturer_|
228 // in such case and no need to call RemoveTrack(). 228 // in such case and no need to call RemoveTrack().
(...skipping 17 matching lines...) Expand all
246 246
247 for (SinkList::ItemList::const_iterator it = sinks.begin(); 247 for (SinkList::ItemList::const_iterator it = sinks.begin();
248 it != sinks.end(); 248 it != sinks.end();
249 ++it){ 249 ++it){
250 (*it)->OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateEnded); 250 (*it)->OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateEnded);
251 (*it)->Reset(); 251 (*it)->Reset();
252 } 252 }
253 } 253 }
254 254
255 } // namespace content 255 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698