OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/webrtc_local_audio_track_adapter.h" | 5 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/renderer/media/webrtc/webrtc_audio_sink_adapter.h" | 8 #include "content/renderer/media/webrtc/webrtc_audio_sink_adapter.h" |
9 #include "content/renderer/media/webrtc_local_audio_track.h" | 9 #include "content/renderer/media/webrtc_local_audio_track.h" |
10 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | |
10 | 11 |
11 namespace content { | 12 namespace content { |
12 | 13 |
13 static const char kAudioTrackKind[] = "audio"; | 14 static const char kAudioTrackKind[] = "audio"; |
14 | 15 |
15 scoped_refptr<WebRtcLocalAudioTrackAdapter> | 16 scoped_refptr<WebRtcLocalAudioTrackAdapter> |
16 WebRtcLocalAudioTrackAdapter::Create( | 17 WebRtcLocalAudioTrackAdapter::Create( |
17 const std::string& label, | 18 const std::string& label, |
18 webrtc::AudioSourceInterface* track_source) { | 19 webrtc::AudioSourceInterface* track_source) { |
19 talk_base::RefCountedObject<WebRtcLocalAudioTrackAdapter>* adapter = | 20 talk_base::RefCountedObject<WebRtcLocalAudioTrackAdapter>* adapter = |
20 new talk_base::RefCountedObject<WebRtcLocalAudioTrackAdapter>( | 21 new talk_base::RefCountedObject<WebRtcLocalAudioTrackAdapter>( |
21 label, track_source); | 22 label, track_source); |
22 return adapter; | 23 return adapter; |
23 } | 24 } |
24 | 25 |
25 WebRtcLocalAudioTrackAdapter::WebRtcLocalAudioTrackAdapter( | 26 WebRtcLocalAudioTrackAdapter::WebRtcLocalAudioTrackAdapter( |
26 const std::string& label, | 27 const std::string& label, |
27 webrtc::AudioSourceInterface* track_source) | 28 webrtc::AudioSourceInterface* track_source) |
28 : webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>(label), | 29 : webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>(label), |
29 owner_(NULL), | 30 owner_(NULL), |
30 track_source_(track_source) { | 31 track_source_(track_source), |
32 signal_level_(0) { | |
31 } | 33 } |
32 | 34 |
33 WebRtcLocalAudioTrackAdapter::~WebRtcLocalAudioTrackAdapter() { | 35 WebRtcLocalAudioTrackAdapter::~WebRtcLocalAudioTrackAdapter() { |
34 } | 36 } |
35 | 37 |
36 void WebRtcLocalAudioTrackAdapter::Initialize(WebRtcLocalAudioTrack* owner) { | 38 void WebRtcLocalAudioTrackAdapter::Initialize(WebRtcLocalAudioTrack* owner) { |
37 DCHECK(!owner_); | 39 DCHECK(!owner_); |
38 DCHECK(owner); | 40 DCHECK(owner); |
39 owner_ = owner; | 41 owner_ = owner; |
40 } | 42 } |
41 | 43 |
44 void WebRtcLocalAudioTrackAdapter::SetAudioProcessor( | |
45 webrtc::AudioProcessorInterface* processor) { | |
46 base::AutoLock auto_lock(lock_); | |
47 audio_processor_ = processor; | |
48 } | |
49 | |
42 std::string WebRtcLocalAudioTrackAdapter::kind() const { | 50 std::string WebRtcLocalAudioTrackAdapter::kind() const { |
43 return kAudioTrackKind; | 51 return kAudioTrackKind; |
44 } | 52 } |
45 | 53 |
46 void WebRtcLocalAudioTrackAdapter::AddSink( | 54 void WebRtcLocalAudioTrackAdapter::AddSink( |
47 webrtc::AudioTrackSinkInterface* sink) { | 55 webrtc::AudioTrackSinkInterface* sink) { |
48 DCHECK(sink); | 56 DCHECK(sink); |
49 #ifndef NDEBUG | 57 #ifndef NDEBUG |
50 // Verify that |sink| has not been added. | 58 // Verify that |sink| has not been added. |
51 for (ScopedVector<WebRtcAudioSinkAdapter>::const_iterator it = | 59 for (ScopedVector<WebRtcAudioSinkAdapter>::const_iterator it = |
(...skipping 16 matching lines...) Expand all Loading... | |
68 sink_adapters_.begin(); | 76 sink_adapters_.begin(); |
69 it != sink_adapters_.end(); ++it) { | 77 it != sink_adapters_.end(); ++it) { |
70 if ((*it)->IsEqual(sink)) { | 78 if ((*it)->IsEqual(sink)) { |
71 owner_->RemoveSink(*it); | 79 owner_->RemoveSink(*it); |
72 sink_adapters_.erase(it); | 80 sink_adapters_.erase(it); |
73 return; | 81 return; |
74 } | 82 } |
75 } | 83 } |
76 } | 84 } |
77 | 85 |
86 bool WebRtcLocalAudioTrackAdapter::GetSignalLevel(int* level) { | |
87 // TODO(xians): Implement this and return true. | |
88 return false; | |
89 } | |
90 | |
91 webrtc::AudioProcessorInterface* | |
92 WebRtcLocalAudioTrackAdapter::GetAudioProcessor() { | |
93 base::AutoLock auto_lock(lock_); | |
tommi (sloooow) - chröme
2014/03/03 15:25:18
GetAudioProcessor should really return a scoped_re
no longer working on chromium
2014/03/04 15:48:59
Done.
| |
94 return audio_processor_.get(); | |
95 } | |
96 | |
78 std::vector<int> WebRtcLocalAudioTrackAdapter::VoeChannels() const { | 97 std::vector<int> WebRtcLocalAudioTrackAdapter::VoeChannels() const { |
79 base::AutoLock auto_lock(lock_); | 98 base::AutoLock auto_lock(lock_); |
80 return voe_channels_; | 99 return voe_channels_; |
81 } | 100 } |
82 | 101 |
83 void WebRtcLocalAudioTrackAdapter::AddChannel(int channel_id) { | 102 void WebRtcLocalAudioTrackAdapter::AddChannel(int channel_id) { |
84 DVLOG(1) << "WebRtcLocalAudioTrack::AddChannel(channel_id=" | 103 DVLOG(1) << "WebRtcLocalAudioTrack::AddChannel(channel_id=" |
85 << channel_id << ")"; | 104 << channel_id << ")"; |
86 base::AutoLock auto_lock(lock_); | 105 base::AutoLock auto_lock(lock_); |
87 if (std::find(voe_channels_.begin(), voe_channels_.end(), channel_id) != | 106 if (std::find(voe_channels_.begin(), voe_channels_.end(), channel_id) != |
(...skipping 18 matching lines...) Expand all Loading... | |
106 | 125 |
107 webrtc::AudioSourceInterface* WebRtcLocalAudioTrackAdapter::GetSource() const { | 126 webrtc::AudioSourceInterface* WebRtcLocalAudioTrackAdapter::GetSource() const { |
108 return track_source_; | 127 return track_source_; |
109 } | 128 } |
110 | 129 |
111 cricket::AudioRenderer* WebRtcLocalAudioTrackAdapter::GetRenderer() { | 130 cricket::AudioRenderer* WebRtcLocalAudioTrackAdapter::GetRenderer() { |
112 return this; | 131 return this; |
113 } | 132 } |
114 | 133 |
115 } // namespace content | 134 } // namespace content |
OLD | NEW |