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/audio_state.h" |
15 #include "webrtc/audio/conversion.h" | 16 #include "webrtc/audio/conversion.h" |
| 17 #include "webrtc/audio/scoped_voe_interface.h" |
16 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
18 #include "webrtc/voice_engine/include/voe_audio_processing.h" | 20 #include "webrtc/voice_engine/include/voe_audio_processing.h" |
19 #include "webrtc/voice_engine/include/voe_codec.h" | 21 #include "webrtc/voice_engine/include/voe_codec.h" |
20 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 22 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
21 #include "webrtc/voice_engine/include/voe_volume_control.h" | 23 #include "webrtc/voice_engine/include/voe_volume_control.h" |
22 | 24 |
23 namespace webrtc { | 25 namespace webrtc { |
24 std::string AudioSendStream::Config::Rtp::ToString() const { | 26 std::string AudioSendStream::Config::Rtp::ToString() const { |
25 std::stringstream ss; | 27 std::stringstream ss; |
(...skipping 15 matching lines...) Expand all Loading... |
41 ss << "{rtp: " << rtp.ToString(); | 43 ss << "{rtp: " << rtp.ToString(); |
42 ss << ", voe_channel_id: " << voe_channel_id; | 44 ss << ", voe_channel_id: " << voe_channel_id; |
43 // TODO(solenberg): Encoder config. | 45 // TODO(solenberg): Encoder config. |
44 ss << ", cng_payload_type: " << cng_payload_type; | 46 ss << ", cng_payload_type: " << cng_payload_type; |
45 ss << ", red_payload_type: " << red_payload_type; | 47 ss << ", red_payload_type: " << red_payload_type; |
46 ss << '}'; | 48 ss << '}'; |
47 return ss.str(); | 49 return ss.str(); |
48 } | 50 } |
49 | 51 |
50 namespace internal { | 52 namespace internal { |
51 AudioSendStream::AudioSendStream(const webrtc::AudioSendStream::Config& config, | 53 |
52 VoiceEngine* voice_engine) | 54 AudioSendStream::AudioSendStream( |
53 : config_(config), | 55 const webrtc::AudioSendStream::Config& config, |
54 voice_engine_(voice_engine), | 56 const rtc::scoped_refptr<webrtc::AudioState>& audio_state) |
55 voe_base_(voice_engine) { | 57 : config_(config), audio_state_(audio_state) { |
56 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); | 58 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); |
57 RTC_DCHECK_NE(config.voe_channel_id, -1); | 59 RTC_DCHECK_NE(config_.voe_channel_id, -1); |
58 RTC_DCHECK(voice_engine_); | 60 RTC_DCHECK(audio_state_.get()); |
59 } | 61 } |
60 | 62 |
61 AudioSendStream::~AudioSendStream() { | 63 AudioSendStream::~AudioSendStream() { |
62 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 64 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
63 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); | 65 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); |
64 } | 66 } |
65 | 67 |
66 webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { | 68 webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { |
67 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 69 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
68 webrtc::AudioSendStream::Stats stats; | 70 webrtc::AudioSendStream::Stats stats; |
69 stats.local_ssrc = config_.rtp.ssrc; | 71 stats.local_ssrc = config_.rtp.ssrc; |
70 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine_); | 72 internal::AudioState* audio_state = |
71 ScopedVoEInterface<VoECodec> codec(voice_engine_); | 73 static_cast<internal::AudioState*>(audio_state_.get()); |
72 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine_); | 74 VoiceEngine* voice_engine = audio_state->voice_engine(); |
73 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine_); | 75 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine); |
| 76 ScopedVoEInterface<VoECodec> codec(voice_engine); |
| 77 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine); |
| 78 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine); |
74 unsigned int ssrc = 0; | 79 unsigned int ssrc = 0; |
75 webrtc::CallStatistics call_stats = {0}; | 80 webrtc::CallStatistics call_stats = {0}; |
76 if (rtp->GetLocalSSRC(config_.voe_channel_id, ssrc) == -1 || | 81 if (rtp->GetLocalSSRC(config_.voe_channel_id, ssrc) == -1 || |
77 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1) { | 82 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1) { |
78 return stats; | 83 return stats; |
79 } | 84 } |
80 | 85 |
81 stats.bytes_sent = call_stats.bytesSent; | 86 stats.bytes_sent = call_stats.bytesSent; |
82 stats.packets_sent = call_stats.packetsSent; | 87 stats.packets_sent = call_stats.packetsSent; |
83 | 88 |
(...skipping 57 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 = audio_state->typing_noise_detected(); |
152 // bool typing_noise_detected = typing_noise_detected_; | |
153 | 157 |
154 return stats; | 158 return stats; |
155 } | 159 } |
156 | 160 |
157 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { | 161 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { |
158 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 162 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
159 return config_; | 163 return config_; |
160 } | 164 } |
161 | 165 |
162 void AudioSendStream::Start() { | 166 void AudioSendStream::Start() { |
(...skipping 10 matching lines...) Expand all Loading... |
173 | 177 |
174 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 178 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
175 // TODO(solenberg): Tests call this function on a network thread, libjingle | 179 // 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 | 180 // calls on the worker thread. We should move towards always using a network |
177 // thread. Then this check can be enabled. | 181 // thread. Then this check can be enabled. |
178 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | 182 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); |
179 return false; | 183 return false; |
180 } | 184 } |
181 } // namespace internal | 185 } // namespace internal |
182 } // namespace webrtc | 186 } // namespace webrtc |
OLD | NEW |