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 { |
| 53 |
51 AudioSendStream::AudioSendStream(const webrtc::AudioSendStream::Config& config, | 54 AudioSendStream::AudioSendStream(const webrtc::AudioSendStream::Config& config, |
52 VoiceEngine* voice_engine) | 55 AudioState* audio_state) |
53 : config_(config), | 56 : config_(config), |
54 voice_engine_(voice_engine), | 57 audio_state_(audio_state) { |
55 voe_base_(voice_engine) { | |
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_); |
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 VoiceEngine* voice_engine = audio_state_->voice_engine(); |
71 ScopedVoEInterface<VoECodec> codec(voice_engine_); | 73 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine); |
72 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine_); | 74 ScopedVoEInterface<VoECodec> codec(voice_engine); |
73 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine_); | 75 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine); |
| 76 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine); |
74 unsigned int ssrc = 0; | 77 unsigned int ssrc = 0; |
75 webrtc::CallStatistics call_stats = {0}; | 78 webrtc::CallStatistics call_stats = {0}; |
76 if (rtp->GetLocalSSRC(config_.voe_channel_id, ssrc) == -1 || | 79 if (rtp->GetLocalSSRC(config_.voe_channel_id, ssrc) == -1 || |
77 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1) { | 80 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1) { |
78 return stats; | 81 return stats; |
79 } | 82 } |
80 | 83 |
81 stats.bytes_sent = call_stats.bytesSent; | 84 stats.bytes_sent = call_stats.bytesSent; |
82 stats.packets_sent = call_stats.packetsSent; | 85 stats.packets_sent = call_stats.packetsSent; |
83 | 86 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 int erl = -100; | 144 int erl = -100; |
142 int erle = -100; | 145 int erle = -100; |
143 int dummy1 = 0; | 146 int dummy1 = 0; |
144 int dummy2 = 0; | 147 int dummy2 = 0; |
145 if (processing->GetEchoMetrics(erl, erle, dummy1, dummy2) != -1) { | 148 if (processing->GetEchoMetrics(erl, erle, dummy1, dummy2) != -1) { |
146 stats.echo_return_loss = erl; | 149 stats.echo_return_loss = erl; |
147 stats.echo_return_loss_enhancement = erle; | 150 stats.echo_return_loss_enhancement = erle; |
148 } | 151 } |
149 } | 152 } |
150 | 153 |
151 // TODO(solenberg): Collect typing noise warnings here too! | 154 stats.typing_noise_detected = audio_state_->typing_noise_detected(); |
152 // bool typing_noise_detected = typing_noise_detected_; | |
153 | 155 |
154 return stats; | 156 return stats; |
155 } | 157 } |
156 | 158 |
157 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { | 159 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { |
158 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 160 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
159 return config_; | 161 return config_; |
160 } | 162 } |
161 | 163 |
162 void AudioSendStream::Start() { | 164 void AudioSendStream::Start() { |
(...skipping 10 matching lines...) Expand all Loading... |
173 | 175 |
174 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 176 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
175 // TODO(solenberg): Tests call this function on a network thread, libjingle | 177 // 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 | 178 // calls on the worker thread. We should move towards always using a network |
177 // thread. Then this check can be enabled. | 179 // thread. Then this check can be enabled. |
178 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | 180 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); |
179 return false; | 181 return false; |
180 } | 182 } |
181 } // namespace internal | 183 } // namespace internal |
182 } // namespace webrtc | 184 } // namespace webrtc |
OLD | NEW |