Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: webrtc/call/call.cc

Issue 2693123002: Make Call::OnRecoveredPacket parse RTP header and call OnRtpPacket. (Closed)
Patch Set: Delete unused RtpPacketReceived::retransmit_ property. Replaced by recovered_. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 Stats GetStats() const override; 131 Stats GetStats() const override;
132 132
133 // Implements PacketReceiver. 133 // Implements PacketReceiver.
134 DeliveryStatus DeliverPacket(MediaType media_type, 134 DeliveryStatus DeliverPacket(MediaType media_type,
135 const uint8_t* packet, 135 const uint8_t* packet,
136 size_t length, 136 size_t length,
137 const PacketTime& packet_time) override; 137 const PacketTime& packet_time) override;
138 138
139 // Implements RecoveredPacketReceiver. 139 // Implements RecoveredPacketReceiver.
140 bool OnRecoveredPacket(const uint8_t* packet, size_t length) override; 140 void OnRecoveredPacket(const uint8_t* packet, size_t length) override;
141 141
142 void SetBitrateConfig( 142 void SetBitrateConfig(
143 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; 143 const webrtc::Call::Config::BitrateConfig& bitrate_config) override;
144 144
145 void SignalChannelNetworkState(MediaType media, NetworkState state) override; 145 void SignalChannelNetworkState(MediaType media, NetworkState state) override;
146 146
147 void OnTransportOverheadChanged(MediaType media, 147 void OnTransportOverheadChanged(MediaType media,
148 int transport_overhead_per_packet) override; 148 int transport_overhead_per_packet) override;
149 149
150 void OnNetworkRouteChanged(const std::string& transport_name, 150 void OnNetworkRouteChanged(const std::string& transport_name,
(...skipping 21 matching lines...) Expand all
172 const PacketTime& packet_time); 172 const PacketTime& packet_time);
173 void ConfigureSync(const std::string& sync_group) 173 void ConfigureSync(const std::string& sync_group)
174 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); 174 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_);
175 175
176 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, 176 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet,
177 MediaType media_type) 177 MediaType media_type)
178 SHARED_LOCKS_REQUIRED(receive_crit_); 178 SHARED_LOCKS_REQUIRED(receive_crit_);
179 179
180 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, 180 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet,
181 size_t length, 181 size_t length,
182 const PacketTime& packet_time) 182 const PacketTime* packet_time)
183 SHARED_LOCKS_REQUIRED(receive_crit_); 183 SHARED_LOCKS_REQUIRED(receive_crit_);
184 184
185 void UpdateSendHistograms(int64_t first_sent_packet_ms) 185 void UpdateSendHistograms(int64_t first_sent_packet_ms)
186 EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); 186 EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_);
187 void UpdateReceiveHistograms(); 187 void UpdateReceiveHistograms();
188 void UpdateHistograms(); 188 void UpdateHistograms();
189 void UpdateAggregateNetworkState(); 189 void UpdateAggregateNetworkState();
190 190
191 Clock* const clock_; 191 Clock* const clock_;
192 192
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 402 }
403 UpdateReceiveHistograms(); 403 UpdateReceiveHistograms();
404 UpdateHistograms(); 404 UpdateHistograms();
405 405
406 Trace::ReturnTrace(); 406 Trace::ReturnTrace();
407 } 407 }
408 408
409 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( 409 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket(
410 const uint8_t* packet, 410 const uint8_t* packet,
411 size_t length, 411 size_t length,
412 const PacketTime& packet_time) { 412 const PacketTime* packet_time) {
413 RtpPacketReceived parsed_packet; 413 RtpPacketReceived parsed_packet;
414 if (!parsed_packet.Parse(packet, length)) 414 if (!parsed_packet.Parse(packet, length))
415 return rtc::Optional<RtpPacketReceived>(); 415 return rtc::Optional<RtpPacketReceived>();
416 416
417 auto it = receive_rtp_config_.find(parsed_packet.Ssrc()); 417 auto it = receive_rtp_config_.find(parsed_packet.Ssrc());
418 if (it != receive_rtp_config_.end()) 418 if (it != receive_rtp_config_.end())
419 parsed_packet.IdentifyExtensions(it->second.extensions); 419 parsed_packet.IdentifyExtensions(it->second.extensions);
420 420
421 int64_t arrival_time_ms; 421 int64_t arrival_time_ms;
422 if (packet_time.timestamp != -1) { 422 if (packet_time && packet_time->timestamp != -1) {
423 arrival_time_ms = (packet_time.timestamp + 500) / 1000; 423 arrival_time_ms = (packet_time->timestamp + 500) / 1000;
424 } else { 424 } else {
425 arrival_time_ms = clock_->TimeInMilliseconds(); 425 arrival_time_ms = clock_->TimeInMilliseconds();
426 } 426 }
427 parsed_packet.set_arrival_time_ms(arrival_time_ms); 427 parsed_packet.set_arrival_time_ms(arrival_time_ms);
428 428
429 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); 429 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet));
430 } 430 }
431 431
432 void Call::UpdateHistograms() { 432 void Call::UpdateHistograms() {
433 RTC_HISTOGRAM_COUNTS_100000( 433 RTC_HISTOGRAM_COUNTS_100000(
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 size_t length, 1182 size_t length,
1183 const PacketTime& packet_time) { 1183 const PacketTime& packet_time) {
1184 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); 1184 TRACE_EVENT0("webrtc", "Call::DeliverRtp");
1185 1185
1186 RTC_DCHECK(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO); 1186 RTC_DCHECK(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO);
1187 1187
1188 ReadLockScoped read_lock(*receive_crit_); 1188 ReadLockScoped read_lock(*receive_crit_);
1189 // TODO(nisse): We should parse the RTP header only here, and pass 1189 // TODO(nisse): We should parse the RTP header only here, and pass
1190 // on parsed_packet to the receive streams. 1190 // on parsed_packet to the receive streams.
1191 rtc::Optional<RtpPacketReceived> parsed_packet = 1191 rtc::Optional<RtpPacketReceived> parsed_packet =
1192 ParseRtpPacket(packet, length, packet_time); 1192 ParseRtpPacket(packet, length, &packet_time);
1193 1193
1194 if (!parsed_packet) 1194 if (!parsed_packet)
1195 return DELIVERY_PACKET_ERROR; 1195 return DELIVERY_PACKET_ERROR;
1196 1196
1197 NotifyBweOfReceivedPacket(*parsed_packet, media_type); 1197 NotifyBweOfReceivedPacket(*parsed_packet, media_type);
1198 1198
1199 uint32_t ssrc = parsed_packet->Ssrc(); 1199 uint32_t ssrc = parsed_packet->Ssrc();
1200 1200
1201 if (media_type == MediaType::AUDIO) { 1201 if (media_type == MediaType::AUDIO) {
1202 auto it = audio_receive_ssrcs_.find(ssrc); 1202 auto it = audio_receive_ssrcs_.find(ssrc);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 // thread. Then this check can be enabled. 1248 // thread. Then this check can be enabled.
1249 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); 1249 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread());
1250 if (RtpHeaderParser::IsRtcp(packet, length)) 1250 if (RtpHeaderParser::IsRtcp(packet, length))
1251 return DeliverRtcp(media_type, packet, length); 1251 return DeliverRtcp(media_type, packet, length);
1252 1252
1253 return DeliverRtp(media_type, packet, length, packet_time); 1253 return DeliverRtp(media_type, packet, length, packet_time);
1254 } 1254 }
1255 1255
1256 // TODO(brandtr): Update this member function when we support protecting 1256 // TODO(brandtr): Update this member function when we support protecting
1257 // audio packets with FlexFEC. 1257 // audio packets with FlexFEC.
1258 bool Call::OnRecoveredPacket(const uint8_t* packet, size_t length) { 1258 void Call::OnRecoveredPacket(const uint8_t* packet, size_t length) {
1259 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]);
brandtr 2017/05/10 14:27:29 Nice to get rid of this!
1260 ReadLockScoped read_lock(*receive_crit_); 1259 ReadLockScoped read_lock(*receive_crit_);
1261 auto it = video_receive_ssrcs_.find(ssrc); 1260 rtc::Optional<RtpPacketReceived> parsed_packet =
1261 ParseRtpPacket(packet, length, nullptr);
1262 if (!parsed_packet)
1263 return;
1264
1265 parsed_packet->set_recovered(true);
1266
1267 auto it = video_receive_ssrcs_.find(parsed_packet->Ssrc());
1262 if (it == video_receive_ssrcs_.end()) 1268 if (it == video_receive_ssrcs_.end())
1263 return false; 1269 return;
1264 return it->second->OnRecoveredPacket(packet, length); 1270
1271 it->second->OnRtpPacket(*parsed_packet);
1265 } 1272 }
1266 1273
1267 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, 1274 void Call::NotifyBweOfReceivedPacket(const RtpPacketReceived& packet,
1268 MediaType media_type) { 1275 MediaType media_type) {
1269 auto it = receive_rtp_config_.find(packet.Ssrc()); 1276 auto it = receive_rtp_config_.find(packet.Ssrc());
1270 bool use_send_side_bwe = 1277 bool use_send_side_bwe =
1271 (it != receive_rtp_config_.end()) && it->second.use_send_side_bwe; 1278 (it != receive_rtp_config_.end()) && it->second.use_send_side_bwe;
1272 1279
1273 RTPHeader header; 1280 RTPHeader header;
1274 packet.GetHeader(&header); 1281 packet.GetHeader(&header);
(...skipping 13 matching lines...) Expand all
1288 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { 1295 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) {
1289 receive_side_cc_.OnReceivedPacket( 1296 receive_side_cc_.OnReceivedPacket(
1290 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), 1297 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(),
1291 header); 1298 header);
1292 } 1299 }
1293 } 1300 }
1294 1301
1295 } // namespace internal 1302 } // namespace internal
1296 1303
1297 } // namespace webrtc 1304 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698