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

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

Issue 675013005: Split libjingle's signaling thread from the UI thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase after landing data channel change Created 6 years, 1 month 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
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"
11 #include "content/renderer/media/media_stream_audio_track_sink.h" 11 #include "content/renderer/media/media_stream_audio_track_sink.h"
12 #include "content/renderer/media/peer_connection_audio_sink_owner.h" 12 #include "content/renderer/media/peer_connection_audio_sink_owner.h"
13 #include "content/renderer/media/webaudio_capturer_source.h" 13 #include "content/renderer/media/webaudio_capturer_source.h"
14 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" 14 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
15 #include "content/renderer/media/webrtc_audio_capturer.h" 15 #include "content/renderer/media/webrtc_audio_capturer.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 WebRtcLocalAudioTrack::WebRtcLocalAudioTrack( 19 WebRtcLocalAudioTrack::WebRtcLocalAudioTrack(
20 WebRtcLocalAudioTrackAdapter* adapter, 20 WebRtcLocalAudioTrackAdapter* adapter,
21 const scoped_refptr<WebRtcAudioCapturer>& capturer, 21 const scoped_refptr<WebRtcAudioCapturer>& capturer,
22 WebAudioCapturerSource* webaudio_source) 22 WebAudioCapturerSource* webaudio_source)
23 : MediaStreamTrack(adapter, true), 23 : MediaStreamTrack(adapter, true),
24 adapter_(adapter), 24 adapter_(adapter),
25 capturer_(capturer), 25 capturer_(capturer),
26 webaudio_source_(webaudio_source) { 26 webaudio_source_(webaudio_source) {
27 DCHECK(capturer.get() || webaudio_source); 27 DCHECK(capturer.get() || webaudio_source);
28 signal_thread_checker_.DetachFromThread();
28 29
29 adapter_->Initialize(this); 30 adapter_->Initialize(this);
30 31
31 DVLOG(1) << "WebRtcLocalAudioTrack::WebRtcLocalAudioTrack()"; 32 DVLOG(1) << "WebRtcLocalAudioTrack::WebRtcLocalAudioTrack()";
32 } 33 }
33 34
34 WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack() { 35 WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack() {
35 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 36 DCHECK(main_render_thread_checker_.CalledOnValidThread());
36 DVLOG(1) << "WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack()"; 37 DVLOG(1) << "WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack()";
37 // Users might not call Stop() on the track. 38 // Users might not call Stop() on the track.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const scoped_refptr<MediaStreamAudioProcessor>& processor) { 116 const scoped_refptr<MediaStreamAudioProcessor>& processor) {
116 // if the |processor| does not have audio processing, which can happen if 117 // if the |processor| does not have audio processing, which can happen if
117 // kDisableAudioTrackProcessing is set set or all the constraints in 118 // kDisableAudioTrackProcessing is set set or all the constraints in
118 // the |processor| are turned off. In such case, we pass NULL to the 119 // the |processor| are turned off. In such case, we pass NULL to the
119 // adapter to indicate that no stats can be gotten from the processor. 120 // adapter to indicate that no stats can be gotten from the processor.
120 adapter_->SetAudioProcessor(processor->has_audio_processing() ? 121 adapter_->SetAudioProcessor(processor->has_audio_processing() ?
121 processor : NULL); 122 processor : NULL);
122 } 123 }
123 124
124 void WebRtcLocalAudioTrack::AddSink(MediaStreamAudioSink* sink) { 125 void WebRtcLocalAudioTrack::AddSink(MediaStreamAudioSink* sink) {
125 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 126 // This method is called from webrtc, on the signaling thread, when the local
127 // description is set and from the main thread from WebMediaPlayerMS::load
128 // (via WebRtcLocalAudioRenderer::Start).
129 DCHECK(main_render_thread_checker_.CalledOnValidThread() ||
130 signal_thread_checker_.CalledOnValidThread());
126 DVLOG(1) << "WebRtcLocalAudioTrack::AddSink()"; 131 DVLOG(1) << "WebRtcLocalAudioTrack::AddSink()";
127 base::AutoLock auto_lock(lock_); 132 base::AutoLock auto_lock(lock_);
128 133
129 // Verify that |sink| is not already added to the list. 134 // Verify that |sink| is not already added to the list.
130 DCHECK(!sinks_.Contains( 135 DCHECK(!sinks_.Contains(
131 MediaStreamAudioTrackSink::WrapsMediaStreamSink(sink))); 136 MediaStreamAudioTrackSink::WrapsMediaStreamSink(sink)));
132 137
133 // Create (and add to the list) a new MediaStreamAudioTrackSink 138 // Create (and add to the list) a new MediaStreamAudioTrackSink
134 // which owns the |sink| and delagates all calls to the 139 // which owns the |sink| and delagates all calls to the
135 // MediaStreamAudioSink interface. It will be tagged in the list, so 140 // MediaStreamAudioSink interface. It will be tagged in the list, so
136 // we remember to call OnSetFormat() on the new sink. 141 // we remember to call OnSetFormat() on the new sink.
137 scoped_refptr<MediaStreamAudioTrackSink> sink_owner( 142 scoped_refptr<MediaStreamAudioTrackSink> sink_owner(
138 new MediaStreamAudioSinkOwner(sink)); 143 new MediaStreamAudioSinkOwner(sink));
139 sinks_.AddAndTag(sink_owner.get()); 144 sinks_.AddAndTag(sink_owner.get());
140 } 145 }
141 146
142 void WebRtcLocalAudioTrack::RemoveSink(MediaStreamAudioSink* sink) { 147 void WebRtcLocalAudioTrack::RemoveSink(MediaStreamAudioSink* sink) {
143 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 148 DCHECK(main_render_thread_checker_.CalledOnValidThread());
no longer working on chromium 2014/10/30 11:55:14 shouldn't RemoveSink be changed in the same way as
tommi (sloooow) - chröme 2014/10/30 20:37:36 Absolutely
144 DVLOG(1) << "WebRtcLocalAudioTrack::RemoveSink()"; 149 DVLOG(1) << "WebRtcLocalAudioTrack::RemoveSink()";
145 150
146 base::AutoLock auto_lock(lock_); 151 base::AutoLock auto_lock(lock_);
147 152
148 scoped_refptr<MediaStreamAudioTrackSink> removed_item = sinks_.Remove( 153 scoped_refptr<MediaStreamAudioTrackSink> removed_item = sinks_.Remove(
149 MediaStreamAudioTrackSink::WrapsMediaStreamSink(sink)); 154 MediaStreamAudioTrackSink::WrapsMediaStreamSink(sink));
150 155
151 // Clear the delegate to ensure that no more capture callbacks will 156 // Clear the delegate to ensure that no more capture callbacks will
152 // be sent to this sink. Also avoids a possible crash which can happen 157 // be sent to this sink. Also avoids a possible crash which can happen
153 // if this method is called while capturing is active. 158 // if this method is called while capturing is active.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 248
244 for (SinkList::ItemList::const_iterator it = sinks.begin(); 249 for (SinkList::ItemList::const_iterator it = sinks.begin();
245 it != sinks.end(); 250 it != sinks.end();
246 ++it){ 251 ++it){
247 (*it)->OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateEnded); 252 (*it)->OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateEnded);
248 (*it)->Reset(); 253 (*it)->Reset();
249 } 254 }
250 } 255 }
251 256
252 } // namespace content 257 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698