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

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

Issue 185413009: Implements the GetSignalLevel and GetStats interface for the local audio track. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased https://codereview.chromium.org/178223013 and used scope_refpt Created 6 years, 9 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
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_sink_owner.h" 10 #include "content/renderer/media/media_stream_audio_sink_owner.h"
10 #include "content/renderer/media/media_stream_audio_track_sink.h" 11 #include "content/renderer/media/media_stream_audio_track_sink.h"
11 #include "content/renderer/media/peer_connection_audio_sink_owner.h" 12 #include "content/renderer/media/peer_connection_audio_sink_owner.h"
12 #include "content/renderer/media/webaudio_capturer_source.h" 13 #include "content/renderer/media/webaudio_capturer_source.h"
13 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" 14 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
14 #include "content/renderer/media/webrtc_audio_capturer.h" 15 #include "content/renderer/media/webrtc_audio_capturer.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 WebRtcLocalAudioTrack::WebRtcLocalAudioTrack( 19 WebRtcLocalAudioTrack::WebRtcLocalAudioTrack(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 DCHECK(capture_thread_checker_.CalledOnValidThread()); 107 DCHECK(capture_thread_checker_.CalledOnValidThread());
107 108
108 audio_parameters_ = params; 109 audio_parameters_ = params;
109 level_calculator_.reset(new MediaStreamAudioLevelCalculator()); 110 level_calculator_.reset(new MediaStreamAudioLevelCalculator());
110 111
111 base::AutoLock auto_lock(lock_); 112 base::AutoLock auto_lock(lock_);
112 // Remember to notify all sinks of the new format. 113 // Remember to notify all sinks of the new format.
113 sinks_.TagAll(); 114 sinks_.TagAll();
114 } 115 }
115 116
117 void WebRtcLocalAudioTrack::SetAudioProcessor(
118 const scoped_refptr<MediaStreamAudioProcessor>& processor) {
119 // if the |processor| does not have audio processing, which can happen if
120 // kEnableAudioTrackProcessing is not set or all the constraints in
121 // the |processor| are turned off. In such case, we pass NULL to the
122 // adapter to indicate that no stats can be gotten from the processor.
123 if (processor->has_audio_processing())
124 adapter_->SetAudioProcessor(processor.get());
125 else
126 adapter_->SetAudioProcessor(NULL);
tommi (sloooow) - chröme 2014/03/04 17:33:54 nit: for fewer call sites and less code: adapter_-
no longer working on chromium 2014/03/04 18:54:07 Done.
127 }
128
116 void WebRtcLocalAudioTrack::AddSink(MediaStreamAudioSink* sink) { 129 void WebRtcLocalAudioTrack::AddSink(MediaStreamAudioSink* sink) {
117 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 130 DCHECK(main_render_thread_checker_.CalledOnValidThread());
118 DVLOG(1) << "WebRtcLocalAudioTrack::AddSink()"; 131 DVLOG(1) << "WebRtcLocalAudioTrack::AddSink()";
119 base::AutoLock auto_lock(lock_); 132 base::AutoLock auto_lock(lock_);
120 133
121 // Verify that |sink| is not already added to the list. 134 // Verify that |sink| is not already added to the list.
122 DCHECK(!sinks_.Contains( 135 DCHECK(!sinks_.Contains(
123 MediaStreamAudioTrackSink::WrapsMediaStreamSink(sink))); 136 MediaStreamAudioTrackSink::WrapsMediaStreamSink(sink)));
124 137
125 // Create (and add to the list) a new MediaStreamAudioTrackSink 138 // Create (and add to the list) a new MediaStreamAudioTrackSink
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 248
236 for (SinkList::ItemList::const_iterator it = sinks.begin(); 249 for (SinkList::ItemList::const_iterator it = sinks.begin();
237 it != sinks.end(); 250 it != sinks.end();
238 ++it){ 251 ++it){
239 (*it)->OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateEnded); 252 (*it)->OnReadyStateChanged(blink::WebMediaStreamSource::ReadyStateEnded);
240 (*it)->Reset(); 253 (*it)->Reset();
241 } 254 }
242 } 255 }
243 256
244 } // namespace content 257 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698