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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 std::stringstream ss; | 27 std::stringstream ss; |
28 ss << "{ssrc: " << ssrc; | 28 ss << "{ssrc: " << ssrc; |
29 ss << ", extensions: ["; | 29 ss << ", extensions: ["; |
30 for (size_t i = 0; i < extensions.size(); ++i) { | 30 for (size_t i = 0; i < extensions.size(); ++i) { |
31 ss << extensions[i].ToString(); | 31 ss << extensions[i].ToString(); |
32 if (i != extensions.size() - 1) { | 32 if (i != extensions.size() - 1) { |
33 ss << ", "; | 33 ss << ", "; |
34 } | 34 } |
35 } | 35 } |
36 ss << ']'; | 36 ss << ']'; |
| 37 ss << ", c_name: " << c_name; |
37 ss << '}'; | 38 ss << '}'; |
38 return ss.str(); | 39 return ss.str(); |
39 } | 40 } |
40 | 41 |
41 std::string AudioSendStream::Config::ToString() const { | 42 std::string AudioSendStream::Config::ToString() const { |
42 std::stringstream ss; | 43 std::stringstream ss; |
43 ss << "{rtp: " << rtp.ToString(); | 44 ss << "{rtp: " << rtp.ToString(); |
44 ss << ", voe_channel_id: " << voe_channel_id; | 45 ss << ", voe_channel_id: " << voe_channel_id; |
45 // TODO(solenberg): Encoder config. | 46 // TODO(solenberg): Encoder config. |
46 ss << ", cng_payload_type: " << cng_payload_type; | 47 ss << ", cng_payload_type: " << cng_payload_type; |
47 ss << ", red_payload_type: " << red_payload_type; | 48 ss << ", red_payload_type: " << red_payload_type; |
48 ss << '}'; | 49 ss << '}'; |
49 return ss.str(); | 50 return ss.str(); |
50 } | 51 } |
51 | 52 |
52 namespace internal { | 53 namespace internal { |
53 | 54 |
54 AudioSendStream::AudioSendStream( | 55 AudioSendStream::AudioSendStream( |
55 const webrtc::AudioSendStream::Config& config, | 56 const webrtc::AudioSendStream::Config& config, |
56 const rtc::scoped_refptr<webrtc::AudioState>& audio_state) | 57 const rtc::scoped_refptr<webrtc::AudioState>& audio_state) |
57 : config_(config), audio_state_(audio_state) { | 58 : config_(config), audio_state_(audio_state) { |
58 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); | 59 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); |
59 RTC_DCHECK_NE(config_.voe_channel_id, -1); | 60 RTC_DCHECK_NE(config_.voe_channel_id, -1); |
60 RTC_DCHECK(audio_state_.get()); | 61 RTC_DCHECK(audio_state_.get()); |
| 62 |
| 63 const int channel_id = config.voe_channel_id; |
| 64 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine()); |
| 65 int error = rtp->SetRTCPStatus(channel_id, true); |
| 66 RTC_DCHECK_EQ(0, error); |
| 67 error = rtp->SetLocalSSRC(channel_id, config.rtp.ssrc); |
| 68 RTC_DCHECK_EQ(0, error); |
| 69 error = rtp->SetRTCP_CNAME(channel_id, config.rtp.c_name.c_str()); |
| 70 RTC_DCHECK_EQ(0, error); |
| 71 for (const auto& extension : config.rtp.extensions) { |
| 72 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
| 73 RTC_DCHECK_GE(extension.id, 1); |
| 74 RTC_DCHECK_LE(extension.id, 14); |
| 75 if (extension.name == RtpExtension::kAbsSendTime) { |
| 76 error = rtp->SetSendAbsoluteSenderTimeStatus(channel_id, true, |
| 77 extension.id); |
| 78 RTC_DCHECK_EQ(0, error); |
| 79 } else if (extension.name == RtpExtension::kAudioLevel) { |
| 80 error = rtp->SetSendAudioLevelIndicationStatus(channel_id, true, |
| 81 extension.id); |
| 82 RTC_DCHECK_EQ(0, error); |
| 83 } else { |
| 84 RTC_NOTREACHED() << "Registering unsupported RTP extension."; |
| 85 } |
| 86 } |
61 } | 87 } |
62 | 88 |
63 AudioSendStream::~AudioSendStream() { | 89 AudioSendStream::~AudioSendStream() { |
64 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 90 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
65 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); | 91 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); |
66 } | 92 } |
67 | 93 |
| 94 void AudioSendStream::Start() { |
| 95 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 96 } |
| 97 |
| 98 void AudioSendStream::Stop() { |
| 99 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 100 } |
| 101 |
| 102 void AudioSendStream::SignalNetworkState(NetworkState state) { |
| 103 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 104 } |
| 105 |
| 106 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
| 107 // TODO(solenberg): Tests call this function on a network thread, libjingle |
| 108 // calls on the worker thread. We should move towards always using a network |
| 109 // thread. Then this check can be enabled. |
| 110 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); |
| 111 return false; |
| 112 } |
| 113 |
68 webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { | 114 webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { |
69 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 115 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
70 webrtc::AudioSendStream::Stats stats; | 116 webrtc::AudioSendStream::Stats stats; |
71 stats.local_ssrc = config_.rtp.ssrc; | 117 stats.local_ssrc = config_.rtp.ssrc; |
72 internal::AudioState* audio_state = | 118 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine()); |
73 static_cast<internal::AudioState*>(audio_state_.get()); | 119 ScopedVoEInterface<VoECodec> codec(voice_engine()); |
74 VoiceEngine* voice_engine = audio_state->voice_engine(); | 120 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine()); |
75 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine); | 121 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine()); |
76 ScopedVoEInterface<VoECodec> codec(voice_engine); | |
77 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine); | |
78 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine); | |
79 unsigned int ssrc = 0; | 122 unsigned int ssrc = 0; |
80 webrtc::CallStatistics call_stats = {0}; | 123 webrtc::CallStatistics call_stats = {0}; |
| 124 // TODO(solenberg): Change error code checking to RTC_CHECK_EQ(..., -1), if |
| 125 // possible... |
81 if (rtp->GetLocalSSRC(config_.voe_channel_id, ssrc) == -1 || | 126 if (rtp->GetLocalSSRC(config_.voe_channel_id, ssrc) == -1 || |
82 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1) { | 127 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1) { |
83 return stats; | 128 return stats; |
84 } | 129 } |
85 | 130 |
86 stats.bytes_sent = call_stats.bytesSent; | 131 stats.bytes_sent = call_stats.bytesSent; |
87 stats.packets_sent = call_stats.packetsSent; | 132 stats.packets_sent = call_stats.packetsSent; |
88 | 133 |
89 webrtc::CodecInst codec_inst = {0}; | 134 webrtc::CodecInst codec_inst = {0}; |
90 if (codec->GetSendCodec(config_.voe_channel_id, codec_inst) != -1) { | 135 if (codec->GetSendCodec(config_.voe_channel_id, codec_inst) != -1) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 int erl = -100; | 191 int erl = -100; |
147 int erle = -100; | 192 int erle = -100; |
148 int dummy1 = 0; | 193 int dummy1 = 0; |
149 int dummy2 = 0; | 194 int dummy2 = 0; |
150 if (processing->GetEchoMetrics(erl, erle, dummy1, dummy2) != -1) { | 195 if (processing->GetEchoMetrics(erl, erle, dummy1, dummy2) != -1) { |
151 stats.echo_return_loss = erl; | 196 stats.echo_return_loss = erl; |
152 stats.echo_return_loss_enhancement = erle; | 197 stats.echo_return_loss_enhancement = erle; |
153 } | 198 } |
154 } | 199 } |
155 | 200 |
| 201 internal::AudioState* audio_state = |
| 202 static_cast<internal::AudioState*>(audio_state_.get()); |
156 stats.typing_noise_detected = audio_state->typing_noise_detected(); | 203 stats.typing_noise_detected = audio_state->typing_noise_detected(); |
157 | 204 |
158 return stats; | 205 return stats; |
159 } | 206 } |
160 | 207 |
161 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { | 208 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { |
162 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 209 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
163 return config_; | 210 return config_; |
164 } | 211 } |
165 | 212 |
166 void AudioSendStream::Start() { | 213 VoiceEngine* AudioSendStream::voice_engine() const { |
167 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 214 internal::AudioState* audio_state = |
168 } | 215 static_cast<internal::AudioState*>(audio_state_.get()); |
169 | 216 VoiceEngine* voice_engine = audio_state->voice_engine(); |
170 void AudioSendStream::Stop() { | 217 RTC_DCHECK(voice_engine); |
171 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 218 return voice_engine; |
172 } | |
173 | |
174 void AudioSendStream::SignalNetworkState(NetworkState state) { | |
175 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
176 } | |
177 | |
178 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { | |
179 // TODO(solenberg): Tests call this function on a network thread, libjingle | |
180 // calls on the worker thread. We should move towards always using a network | |
181 // thread. Then this check can be enabled. | |
182 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | |
183 return false; | |
184 } | 219 } |
185 } // namespace internal | 220 } // namespace internal |
186 } // namespace webrtc | 221 } // namespace webrtc |
OLD | NEW |