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

Side by Side Diff: webrtc/video/rtp_stream_receiver.cc

Issue 2693123002: Make Call::OnRecoveredPacket parse RTP header and call OnRtpPacket. (Closed)
Patch Set: Comment capitalization. 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } else { 268 } else {
269 uint8_t* data = new uint8_t[packet.sizeBytes]; 269 uint8_t* data = new uint8_t[packet.sizeBytes];
270 memcpy(data, packet.dataPtr, packet.sizeBytes); 270 memcpy(data, packet.dataPtr, packet.sizeBytes);
271 packet.dataPtr = data; 271 packet.dataPtr = data;
272 } 272 }
273 273
274 packet_buffer_->InsertPacket(&packet); 274 packet_buffer_->InsertPacket(&packet);
275 return 0; 275 return 0;
276 } 276 }
277 277
278 // TODO(nisse): Try to delete this method. Obstacles: It is used by
279 // ParseAndHandleEncapsulatingHeader, for handling Rtx packets. And
280 // it's part of the RtpData interface which we implement.
278 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, 281 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet,
279 size_t rtp_packet_length) { 282 size_t rtp_packet_length) {
280 RTPHeader header; 283 RTPHeader header;
281 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { 284 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) {
282 return false; 285 return false;
283 } 286 }
284 header.payload_type_frequency = kVideoPayloadTypeFrequency; 287 header.payload_type_frequency = kVideoPayloadTypeFrequency;
285 bool in_order = IsPacketInOrder(header); 288 bool in_order = IsPacketInOrder(header);
286 return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); 289 return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order);
287 } 290 }
288 291
289 // TODO(pbos): Remove as soon as audio can handle a changing payload type 292 // TODO(pbos): Remove as soon as audio can handle a changing payload type
290 // without this callback. 293 // without this callback.
291 int32_t RtpStreamReceiver::OnInitializeDecoder( 294 int32_t RtpStreamReceiver::OnInitializeDecoder(
292 const int8_t payload_type, 295 const int8_t payload_type,
293 const char payload_name[RTP_PAYLOAD_NAME_SIZE], 296 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
294 const int frequency, 297 const int frequency,
295 const size_t channels, 298 const size_t channels,
296 const uint32_t rate) { 299 const uint32_t rate) {
297 RTC_NOTREACHED(); 300 RTC_NOTREACHED();
298 return 0; 301 return 0;
299 } 302 }
300 303
301 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) { 304 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) {
302 rtp_rtcp_->SetRemoteSSRC(ssrc); 305 rtp_rtcp_->SetRemoteSSRC(ssrc);
303 } 306 }
304 307
308 // This method handles both regular RTP packets and packets recovered
309 // via FlexFEC.
305 void RtpStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) { 310 void RtpStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) {
306 { 311 {
307 rtc::CritScope lock(&receive_cs_); 312 rtc::CritScope lock(&receive_cs_);
308 if (!receiving_) { 313 if (!receiving_) {
309 return; 314 return;
310 } 315 }
311 } 316 }
317 if (!packet.recovered()) {
318 int64_t now_ms = clock_->TimeInMilliseconds();
312 319
313 int64_t now_ms = clock_->TimeInMilliseconds(); 320 {
314 321 // Periodically log the RTP header of incoming packets.
315 { 322 rtc::CritScope lock(&receive_cs_);
316 // Periodically log the RTP header of incoming packets. 323 if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) {
317 rtc::CritScope lock(&receive_cs_); 324 std::stringstream ss;
318 if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) { 325 ss << "Packet received on SSRC: " << packet.Ssrc()
319 std::stringstream ss; 326 << " with payload type: " << static_cast<int>(packet.PayloadType())
320 ss << "Packet received on SSRC: " << packet.Ssrc() 327 << ", timestamp: " << packet.Timestamp()
321 << " with payload type: " << static_cast<int>(packet.PayloadType()) 328 << ", sequence number: " << packet.SequenceNumber()
322 << ", timestamp: " << packet.Timestamp() 329 << ", arrival time: " << packet.arrival_time_ms();
323 << ", sequence number: " << packet.SequenceNumber() 330 int32_t time_offset;
324 << ", arrival time: " << packet.arrival_time_ms(); 331 if (packet.GetExtension<TransmissionOffset>(&time_offset)) {
325 int32_t time_offset; 332 ss << ", toffset: " << time_offset;
326 if (packet.GetExtension<TransmissionOffset>(&time_offset)) { 333 }
327 ss << ", toffset: " << time_offset; 334 uint32_t send_time;
335 if (packet.GetExtension<AbsoluteSendTime>(&send_time)) {
336 ss << ", abs send time: " << send_time;
337 }
338 LOG(LS_INFO) << ss.str();
339 last_packet_log_ms_ = now_ms;
328 } 340 }
329 uint32_t send_time;
330 if (packet.GetExtension<AbsoluteSendTime>(&send_time)) {
331 ss << ", abs send time: " << send_time;
332 }
333 LOG(LS_INFO) << ss.str();
334 last_packet_log_ms_ = now_ms;
335 } 341 }
sprang_webrtc 2017/05/11 08:48:58 nit: can we clean up the extra scopes for locking
nisse-webrtc 2017/05/11 09:04:01 Done.
336 } 342 }
337 343
338 // TODO(nisse): Delete use of GetHeader, but needs refactoring of 344 // TODO(nisse): Delete use of GetHeader, but needs refactoring of
339 // ReceivePacket and IncomingPacket methods below. 345 // ReceivePacket and IncomingPacket methods below.
340 RTPHeader header; 346 RTPHeader header;
341 packet.GetHeader(&header); 347 packet.GetHeader(&header);
342 348
343 header.payload_type_frequency = kVideoPayloadTypeFrequency; 349 header.payload_type_frequency = kVideoPayloadTypeFrequency;
344 350
345 bool in_order = IsPacketInOrder(header); 351 bool in_order = IsPacketInOrder(header);
346 rtp_payload_registry_.SetIncomingPayloadType(header); 352 if (!packet.recovered()) {
353 // TODO(nisse): Why isn't this done for recovered packets?
sprang_webrtc 2017/05/11 08:48:58 Will the header here have the actual payload type,
nisse-webrtc 2017/05/11 09:04:01 No idea. At the moment I don't think rtx or ulpfec
354 rtp_payload_registry_.SetIncomingPayloadType(header);
355 }
347 ReceivePacket(packet.data(), packet.size(), header, in_order); 356 ReceivePacket(packet.data(), packet.size(), header, in_order);
348 // Update receive statistics after ReceivePacket. 357 // Update receive statistics after ReceivePacket.
349 // Receive statistics will be reset if the payload type changes (make sure 358 // Receive statistics will be reset if the payload type changes (make sure
350 // that the first packet is included in the stats). 359 // that the first packet is included in the stats).
351 rtp_receive_statistics_->IncomingPacket( 360 if (!packet.recovered()) {
352 header, packet.size(), IsPacketRetransmitted(header, in_order)); 361 // TODO(nisse): We should pass a recovered flag to stats, to aid
362 // fixing bug bugs.webrtc.org/6339.
363 rtp_receive_statistics_->IncomingPacket(
364 header, packet.size(), IsPacketRetransmitted(header, in_order));
365 }
353 } 366 }
354 367
355 int32_t RtpStreamReceiver::RequestKeyFrame() { 368 int32_t RtpStreamReceiver::RequestKeyFrame() {
356 return rtp_rtcp_->RequestKeyFrame(); 369 return rtp_rtcp_->RequestKeyFrame();
357 } 370 }
358 371
359 bool RtpStreamReceiver::IsUlpfecEnabled() const { 372 bool RtpStreamReceiver::IsUlpfecEnabled() const {
360 return config_.rtp.ulpfec.ulpfec_payload_type != -1; 373 return config_.rtp.ulpfec.ulpfec_payload_type != -1;
361 } 374 }
362 375
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 return; 662 return;
650 663
651 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) 664 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str()))
652 return; 665 return;
653 666
654 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), 667 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(),
655 sprop_decoder.pps_nalu()); 668 sprop_decoder.pps_nalu());
656 } 669 }
657 670
658 } // namespace webrtc 671 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698