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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 const rtc::scoped_refptr<webrtc::AudioState>& audio_state) | 66 const rtc::scoped_refptr<webrtc::AudioState>& audio_state) |
67 : remote_bitrate_estimator_(remote_bitrate_estimator), | 67 : remote_bitrate_estimator_(remote_bitrate_estimator), |
68 config_(config), | 68 config_(config), |
69 audio_state_(audio_state), | 69 audio_state_(audio_state), |
70 rtp_header_parser_(RtpHeaderParser::Create()) { | 70 rtp_header_parser_(RtpHeaderParser::Create()) { |
71 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); | 71 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); |
72 RTC_DCHECK_NE(config_.voe_channel_id, -1); | 72 RTC_DCHECK_NE(config_.voe_channel_id, -1); |
73 RTC_DCHECK(remote_bitrate_estimator_); | 73 RTC_DCHECK(remote_bitrate_estimator_); |
74 RTC_DCHECK(audio_state_.get()); | 74 RTC_DCHECK(audio_state_.get()); |
75 RTC_DCHECK(rtp_header_parser_); | 75 RTC_DCHECK(rtp_header_parser_); |
76 for (const auto& ext : config.rtp.extensions) { | 76 |
77 const int channel_id = config.voe_channel_id; | |
78 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine()); | |
79 int error = rtp->SetLocalSSRC(channel_id, config.rtp.local_ssrc); | |
80 RTC_DCHECK_EQ(0, error); | |
81 for (const auto& extension : config.rtp.extensions) { | |
77 // One-byte-extension local identifiers are in the range 1-14 inclusive. | 82 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
78 RTC_DCHECK_GE(ext.id, 1); | 83 RTC_DCHECK_GE(extension.id, 1); |
79 RTC_DCHECK_LE(ext.id, 14); | 84 RTC_DCHECK_LE(extension.id, 14); |
80 if (ext.name == RtpExtension::kAudioLevel) { | 85 if (extension.name == RtpExtension::kAudioLevel) { |
81 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | 86 error = rtp->SetReceiveAudioLevelIndicationStatus(channel_id, true, |
82 kRtpExtensionAudioLevel, ext.id)); | 87 extension.id); |
83 } else if (ext.name == RtpExtension::kAbsSendTime) { | 88 RTC_DCHECK_EQ(0, error); |
84 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | 89 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( |
85 kRtpExtensionAbsoluteSendTime, ext.id)); | 90 kRtpExtensionAudioLevel, extension.id); |
86 } else if (ext.name == RtpExtension::kTransportSequenceNumber) { | 91 RTC_DCHECK(registered); |
87 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | 92 } else if (extension.name == RtpExtension::kAbsSendTime) { |
88 kRtpExtensionTransportSequenceNumber, ext.id)); | 93 error = rtp->SetReceiveAbsoluteSenderTimeStatus(channel_id, true, |
94 extension.id); | |
95 RTC_DCHECK_EQ(0, error); | |
96 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( | |
97 kRtpExtensionAbsoluteSendTime, extension.id); | |
98 RTC_DCHECK(registered); | |
99 } else if (extension.name == RtpExtension::kTransportSequenceNumber) { | |
100 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( | |
hlundin-webrtc
2015/11/20 12:59:22
Nothing to report to |rtp| in this case?
the sun
2015/11/20 14:24:09
Not yet; leaving TODO for Stefan.
| |
101 kRtpExtensionTransportSequenceNumber, extension.id); | |
102 RTC_DCHECK(registered); | |
89 } else { | 103 } else { |
90 RTC_NOTREACHED() << "Unsupported RTP extension."; | 104 RTC_NOTREACHED() << "Unsupported RTP extension."; |
91 } | 105 } |
92 } | 106 } |
93 } | 107 } |
94 | 108 |
95 AudioReceiveStream::~AudioReceiveStream() { | 109 AudioReceiveStream::~AudioReceiveStream() { |
96 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 110 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
97 LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString(); | 111 LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString(); |
98 } | 112 } |
99 | 113 |
114 void AudioReceiveStream::Start() { | |
115 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
116 } | |
117 | |
118 void AudioReceiveStream::Stop() { | |
119 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
120 } | |
121 | |
122 void AudioReceiveStream::SignalNetworkState(NetworkState state) { | |
123 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
124 } | |
125 | |
126 bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { | |
127 // TODO(solenberg): Tests call this function on a network thread, libjingle | |
128 // calls on the worker thread. We should move towards always using a network | |
129 // thread. Then this check can be enabled. | |
130 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | |
131 return false; | |
132 } | |
133 | |
134 bool AudioReceiveStream::DeliverRtp(const uint8_t* packet, | |
135 size_t length, | |
136 const PacketTime& packet_time) { | |
137 // TODO(solenberg): Tests call this function on a network thread, libjingle | |
138 // calls on the worker thread. We should move towards always using a network | |
139 // thread. Then this check can be enabled. | |
140 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | |
141 RTPHeader header; | |
142 if (!rtp_header_parser_->Parse(packet, length, &header)) { | |
143 return false; | |
144 } | |
145 | |
146 // Only forward if the parsed header has absolute sender time. RTP timestamps | |
147 // may have different rates for audio and video and shouldn't be mixed. | |
148 if (config_.combined_audio_video_bwe && | |
149 header.extension.hasAbsoluteSendTime) { | |
150 int64_t arrival_time_ms = TickTime::MillisecondTimestamp(); | |
151 if (packet_time.timestamp >= 0) | |
152 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | |
153 size_t payload_size = length - header.headerLength; | |
154 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, | |
155 header, false); | |
156 } | |
157 return true; | |
158 } | |
159 | |
100 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { | 160 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { |
101 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 161 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
102 webrtc::AudioReceiveStream::Stats stats; | 162 webrtc::AudioReceiveStream::Stats stats; |
103 stats.remote_ssrc = config_.rtp.remote_ssrc; | 163 stats.remote_ssrc = config_.rtp.remote_ssrc; |
104 internal::AudioState* audio_state = | 164 ScopedVoEInterface<VoECodec> codec(voice_engine()); |
105 static_cast<internal::AudioState*>(audio_state_.get()); | 165 ScopedVoEInterface<VoENetEqStats> neteq(voice_engine()); |
106 VoiceEngine* voice_engine = audio_state->voice_engine(); | 166 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine()); |
107 ScopedVoEInterface<VoECodec> codec(voice_engine); | 167 ScopedVoEInterface<VoEVideoSync> sync(voice_engine()); |
108 ScopedVoEInterface<VoENetEqStats> neteq(voice_engine); | 168 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine()); |
109 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine); | |
110 ScopedVoEInterface<VoEVideoSync> sync(voice_engine); | |
111 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine); | |
112 | 169 |
113 webrtc::CallStatistics call_stats = {0}; | 170 webrtc::CallStatistics call_stats = {0}; |
114 int error = rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats); | 171 int error = rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats); |
115 RTC_DCHECK_EQ(0, error); | 172 RTC_DCHECK_EQ(0, error); |
116 webrtc::CodecInst codec_inst = {0}; | 173 webrtc::CodecInst codec_inst = {0}; |
117 if (codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) { | 174 if (codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) { |
118 return stats; | 175 return stats; |
119 } | 176 } |
120 | 177 |
121 stats.bytes_rcvd = call_stats.bytesReceived; | 178 stats.bytes_rcvd = call_stats.bytesReceived; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 stats.decoding_plc_cng = ds.decoded_plc_cng; | 225 stats.decoding_plc_cng = ds.decoded_plc_cng; |
169 | 226 |
170 return stats; | 227 return stats; |
171 } | 228 } |
172 | 229 |
173 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { | 230 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { |
174 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 231 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
175 return config_; | 232 return config_; |
176 } | 233 } |
177 | 234 |
178 void AudioReceiveStream::Start() { | 235 VoiceEngine* AudioReceiveStream::voice_engine() const { |
179 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 236 internal::AudioState* audio_state = |
180 } | 237 static_cast<internal::AudioState*>(audio_state_.get()); |
181 | 238 VoiceEngine* voice_engine = audio_state->voice_engine(); |
182 void AudioReceiveStream::Stop() { | 239 RTC_DCHECK(voice_engine); |
183 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 240 return voice_engine; |
184 } | |
185 | |
186 void AudioReceiveStream::SignalNetworkState(NetworkState state) { | |
187 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
188 } | |
189 | |
190 bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { | |
191 // TODO(solenberg): Tests call this function on a network thread, libjingle | |
192 // calls on the worker thread. We should move towards always using a network | |
193 // thread. Then this check can be enabled. | |
194 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | |
195 return false; | |
196 } | |
197 | |
198 bool AudioReceiveStream::DeliverRtp(const uint8_t* packet, | |
199 size_t length, | |
200 const PacketTime& packet_time) { | |
201 // TODO(solenberg): Tests call this function on a network thread, libjingle | |
202 // calls on the worker thread. We should move towards always using a network | |
203 // thread. Then this check can be enabled. | |
204 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | |
205 RTPHeader header; | |
206 if (!rtp_header_parser_->Parse(packet, length, &header)) { | |
207 return false; | |
208 } | |
209 | |
210 // Only forward if the parsed header has absolute sender time. RTP timestamps | |
211 // may have different rates for audio and video and shouldn't be mixed. | |
212 if (config_.combined_audio_video_bwe && | |
213 header.extension.hasAbsoluteSendTime) { | |
214 int64_t arrival_time_ms = TickTime::MillisecondTimestamp(); | |
215 if (packet_time.timestamp >= 0) | |
216 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | |
217 size_t payload_size = length - header.headerLength; | |
218 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, | |
219 header, false); | |
220 } | |
221 return true; | |
222 } | 241 } |
223 } // namespace internal | 242 } // namespace internal |
224 } // namespace webrtc | 243 } // namespace webrtc |
OLD | NEW |