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

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

Issue 15979027: start/stop the source of the capturer when 1st audiotrack/last audiotrack is added/removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/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 9
10 namespace content { 10 namespace content {
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 WebRtcLocalAudioTrack::WebRtcLocalAudioTrack( 24 WebRtcLocalAudioTrack::WebRtcLocalAudioTrack(
25 const std::string& label, 25 const std::string& label,
26 const scoped_refptr<WebRtcAudioCapturer>& capturer, 26 const scoped_refptr<WebRtcAudioCapturer>& capturer,
27 webrtc::AudioSourceInterface* track_source) 27 webrtc::AudioSourceInterface* track_source)
28 : webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>(label), 28 : webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>(label),
29 capturer_(capturer), 29 capturer_(capturer),
30 track_source_(track_source) { 30 track_source_(track_source) {
31 DCHECK(capturer.get()); 31 DCHECK(capturer.get());
32 capturer_->AddSink(this);
33 DVLOG(1) << "WebRtcLocalAudioTrack::WebRtcLocalAudioTrack()"; 32 DVLOG(1) << "WebRtcLocalAudioTrack::WebRtcLocalAudioTrack()";
34 } 33 }
35 34
36 WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack() { 35 WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack() {
37 DCHECK(thread_checker_.CalledOnValidThread()); 36 DCHECK(thread_checker_.CalledOnValidThread());
38 DCHECK(sinks_.empty()); 37 DCHECK(sinks_.empty());
39 capturer_->RemoveSink(this); 38 DCHECK(!capturer_.get());
henrika (OOO until Aug 14) 2013/06/05 09:09:20 What ensures that RemoveSink i called now?
no longer working on chromium 2013/06/05 16:29:45 Right, I also realized it this morning, we should
40 DVLOG(1) << "WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack()"; 39 DVLOG(1) << "WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack()";
41 } 40 }
42 41
43 // Content::WebRtcAudioCapturerSink implementation. 42 // Content::WebRtcAudioCapturerSink implementation.
44 void WebRtcLocalAudioTrack::CaptureData(const int16* audio_data, 43 void WebRtcLocalAudioTrack::CaptureData(const int16* audio_data,
45 int number_of_channels, 44 int number_of_channels,
46 int number_of_frames, 45 int number_of_frames,
47 int audio_delay_milliseconds, 46 int audio_delay_milliseconds,
48 double volume) { 47 double volume) {
49 SinkList sinks; 48 SinkList sinks;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 WebRtcAudioCapturerSinkOwner::WrapsSink(sink)); 116 WebRtcAudioCapturerSinkOwner::WrapsSink(sink));
118 if (it != sinks_.end()) { 117 if (it != sinks_.end()) {
119 // Clear the delegate to ensure that no more capture callbacks will 118 // Clear the delegate to ensure that no more capture callbacks will
120 // be sent to this sink. Also avoids a possible crash which can happen 119 // be sent to this sink. Also avoids a possible crash which can happen
121 // if this method is called while capturing is active. 120 // if this method is called while capturing is active.
122 (*it)->Reset(); 121 (*it)->Reset();
123 sinks_.erase(it); 122 sinks_.erase(it);
124 } 123 }
125 } 124 }
126 125
126 void WebRtcLocalAudioTrack::Start() {
127 DCHECK(thread_checker_.CalledOnValidThread());
128 DVLOG(1) << "WebRtcLocalAudioTrack::Start()";
129 capturer_->AddSink(this);
130 }
131
132 void WebRtcLocalAudioTrack::Stop() {
133 DCHECK(thread_checker_.CalledOnValidThread());
134 DVLOG(1) << "WebRtcLocalAudioTrack::Stop()";
135 capturer_->RemoveSink(this);
136 capturer_ = NULL;
137 }
138
127 } // namespace content 139 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698