Chromium Code Reviews| 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/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 12 matching lines...) Expand all Loading... | |
| 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); | 31 DCHECK(capturer); |
| 32 capturer_->AddSink(this); | 32 capturer_->AddSink(this); |
| 33 params_ = capturer_->audio_parameters(); | |
| 34 DVLOG(1) << "WebRtcLocalAudioTrack::WebRtcLocalAudioTrack()"; | 33 DVLOG(1) << "WebRtcLocalAudioTrack::WebRtcLocalAudioTrack()"; |
| 35 } | 34 } |
| 36 | 35 |
| 37 WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack() { | 36 WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack() { |
| 38 DCHECK(thread_checker_.CalledOnValidThread()); | 37 DCHECK(thread_checker_.CalledOnValidThread()); |
| 39 DCHECK(sinks_.empty()); | 38 DCHECK(sinks_.empty()); |
| 40 capturer_->RemoveSink(this); | 39 capturer_->RemoveSink(this); |
| 41 DVLOG(1) << "WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack()"; | 40 DVLOG(1) << "WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack()"; |
| 42 } | 41 } |
| 43 | 42 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 65 ++it) { | 64 ++it) { |
| 66 (*it)->CaptureData(audio_data, number_of_channels, number_of_frames, | 65 (*it)->CaptureData(audio_data, number_of_channels, number_of_frames, |
| 67 audio_delay_milliseconds, volume); | 66 audio_delay_milliseconds, volume); |
| 68 } | 67 } |
| 69 } | 68 } |
| 70 | 69 |
| 71 void WebRtcLocalAudioTrack::SetCaptureFormat( | 70 void WebRtcLocalAudioTrack::SetCaptureFormat( |
| 72 const media::AudioParameters& params) { | 71 const media::AudioParameters& params) { |
| 73 base::AutoLock auto_lock(lock_); | 72 base::AutoLock auto_lock(lock_); |
| 74 params_ = params; | 73 params_ = params; |
| 74 // Update all the existing sinks with the new format. | |
|
henrika (OOO until Aug 14)
2013/05/07 09:13:27
nit, new line above comment
no longer working on chromium
2013/05/07 09:21:48
Done.
| |
| 75 for (SinkList::const_iterator it = sinks_.begin(); | |
| 76 it != sinks_.end(); ++it) | |
| 77 (*it)->SetCaptureFormat(params); | |
| 75 } | 78 } |
| 76 | 79 |
| 77 // webrtc::AudioTrackInterface implementation. | 80 // webrtc::AudioTrackInterface implementation. |
| 78 webrtc::AudioSourceInterface* WebRtcLocalAudioTrack::GetSource() const { | 81 webrtc::AudioSourceInterface* WebRtcLocalAudioTrack::GetSource() const { |
| 79 return track_source_; | 82 return track_source_; |
| 80 } | 83 } |
| 81 | 84 |
| 82 std::string WebRtcLocalAudioTrack::kind() const { | 85 std::string WebRtcLocalAudioTrack::kind() const { |
| 83 return kAudioTrackKind; | 86 return kAudioTrackKind; |
| 84 } | 87 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 114 if (it != sinks_.end()) { | 117 if (it != sinks_.end()) { |
| 115 // Clear the delegate to ensure that no more capture callbacks will | 118 // Clear the delegate to ensure that no more capture callbacks will |
| 116 // 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 |
| 117 // if this method is called while capturing is active. | 120 // if this method is called while capturing is active. |
| 118 (*it)->Reset(); | 121 (*it)->Reset(); |
| 119 sinks_.erase(it); | 122 sinks_.erase(it); |
| 120 } | 123 } |
| 121 } | 124 } |
| 122 | 125 |
| 123 } // namespace content | 126 } // namespace content |
| OLD | NEW |