OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/audio/audio_send_stream.h" | 11 #include "webrtc/audio/audio_send_stream.h" |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "webrtc/audio/conversion.h" | 15 #include "webrtc/audio/conversion.h" |
| 16 #include "webrtc/audio/scoped_voe_interface.h" |
16 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
18 #include "webrtc/voice_engine/include/voe_audio_processing.h" | 19 #include "webrtc/voice_engine/include/voe_audio_processing.h" |
19 #include "webrtc/voice_engine/include/voe_codec.h" | 20 #include "webrtc/voice_engine/include/voe_codec.h" |
20 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 21 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
21 #include "webrtc/voice_engine/include/voe_volume_control.h" | 22 #include "webrtc/voice_engine/include/voe_volume_control.h" |
22 | 23 |
23 namespace webrtc { | 24 namespace webrtc { |
24 std::string AudioSendStream::Config::Rtp::ToString() const { | 25 std::string AudioSendStream::Config::Rtp::ToString() const { |
25 std::stringstream ss; | 26 std::stringstream ss; |
(...skipping 15 matching lines...) Expand all Loading... |
41 ss << "{rtp: " << rtp.ToString(); | 42 ss << "{rtp: " << rtp.ToString(); |
42 ss << ", voe_channel_id: " << voe_channel_id; | 43 ss << ", voe_channel_id: " << voe_channel_id; |
43 // TODO(solenberg): Encoder config. | 44 // TODO(solenberg): Encoder config. |
44 ss << ", cng_payload_type: " << cng_payload_type; | 45 ss << ", cng_payload_type: " << cng_payload_type; |
45 ss << ", red_payload_type: " << red_payload_type; | 46 ss << ", red_payload_type: " << red_payload_type; |
46 ss << '}'; | 47 ss << '}'; |
47 return ss.str(); | 48 return ss.str(); |
48 } | 49 } |
49 | 50 |
50 namespace internal { | 51 namespace internal { |
| 52 |
| 53 VoiceEngines AudioSendStream::gVoiceEngines; |
| 54 |
51 AudioSendStream::AudioSendStream(const webrtc::AudioSendStream::Config& config, | 55 AudioSendStream::AudioSendStream(const webrtc::AudioSendStream::Config& config, |
52 VoiceEngine* voice_engine) | 56 VoiceEngine* voice_engine) |
53 : config_(config), | 57 : config_(config), |
54 voice_engine_(voice_engine), | 58 voice_engine_(voice_engine) { |
55 voe_base_(voice_engine) { | |
56 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); | 59 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); |
57 RTC_DCHECK_NE(config.voe_channel_id, -1); | 60 RTC_DCHECK_NE(config.voe_channel_id, -1); |
58 RTC_DCHECK(voice_engine_); | 61 RTC_DCHECK(voice_engine_); |
| 62 gVoiceEngines.RegisterVoiceEngine(voice_engine); |
59 } | 63 } |
60 | 64 |
61 AudioSendStream::~AudioSendStream() { | 65 AudioSendStream::~AudioSendStream() { |
62 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 66 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
63 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); | 67 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); |
| 68 gVoiceEngines.DeregisterVoiceEngine(voice_engine_); |
64 } | 69 } |
65 | 70 |
66 webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { | 71 webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { |
67 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 72 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
68 webrtc::AudioSendStream::Stats stats; | 73 webrtc::AudioSendStream::Stats stats; |
69 stats.local_ssrc = config_.rtp.ssrc; | 74 stats.local_ssrc = config_.rtp.ssrc; |
70 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine_); | 75 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine_); |
71 ScopedVoEInterface<VoECodec> codec(voice_engine_); | 76 ScopedVoEInterface<VoECodec> codec(voice_engine_); |
72 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine_); | 77 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine_); |
73 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine_); | 78 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine_); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 int erl = -100; | 146 int erl = -100; |
142 int erle = -100; | 147 int erle = -100; |
143 int dummy1 = 0; | 148 int dummy1 = 0; |
144 int dummy2 = 0; | 149 int dummy2 = 0; |
145 if (processing->GetEchoMetrics(erl, erle, dummy1, dummy2) != -1) { | 150 if (processing->GetEchoMetrics(erl, erle, dummy1, dummy2) != -1) { |
146 stats.echo_return_loss = erl; | 151 stats.echo_return_loss = erl; |
147 stats.echo_return_loss_enhancement = erle; | 152 stats.echo_return_loss_enhancement = erle; |
148 } | 153 } |
149 } | 154 } |
150 | 155 |
151 // TODO(solenberg): Collect typing noise warnings here too! | 156 stats.typing_noise_detected = |
152 // bool typing_noise_detected = typing_noise_detected_; | 157 gVoiceEngines.GetTypingNoiseDetected(voice_engine_); |
153 | 158 |
154 return stats; | 159 return stats; |
155 } | 160 } |
156 | 161 |
157 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { | 162 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { |
158 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 163 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
159 return config_; | 164 return config_; |
160 } | 165 } |
161 | 166 |
162 void AudioSendStream::Start() { | 167 void AudioSendStream::Start() { |
(...skipping 10 matching lines...) Expand all Loading... |
173 | 178 |
174 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 179 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
175 // TODO(solenberg): Tests call this function on a network thread, libjingle | 180 // TODO(solenberg): Tests call this function on a network thread, libjingle |
176 // calls on the worker thread. We should move towards always using a network | 181 // calls on the worker thread. We should move towards always using a network |
177 // thread. Then this check can be enabled. | 182 // thread. Then this check can be enabled. |
178 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | 183 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); |
179 return false; | 184 return false; |
180 } | 185 } |
181 } // namespace internal | 186 } // namespace internal |
182 } // namespace webrtc | 187 } // namespace webrtc |
OLD | NEW |