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

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

Issue 2886813002: Delete RtpData::OnRecoveredPacket, use RecoveredPacketReceiver instead. (Closed)
Patch Set: 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 278 // TODO(nisse): Try to delete this method. Obstacles: It is used by
279 // ParseAndHandleEncapsulatingHeader, for handling Rtx packets. And 279 // ParseAndHandleEncapsulatingHeader, for handling Rtx packets, and
280 // it's part of the RtpData interface which we implement. 280 // for callbacks from |ulpfec_receiver_|.
281 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, 281 void RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet,
282 size_t rtp_packet_length) { 282 size_t rtp_packet_length) {
283 RTPHeader header; 283 RTPHeader header;
284 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { 284 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) {
285 return false; 285 return;
286 } 286 }
287 header.payload_type_frequency = kVideoPayloadTypeFrequency; 287 header.payload_type_frequency = kVideoPayloadTypeFrequency;
288 bool in_order = IsPacketInOrder(header); 288 bool in_order = IsPacketInOrder(header);
289 return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); 289 ReceivePacket(rtp_packet, rtp_packet_length, header, in_order);
290 } 290 }
291 291
292 // 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
293 // without this callback. 293 // without this callback.
294 int32_t RtpStreamReceiver::OnInitializeDecoder( 294 int32_t RtpStreamReceiver::OnInitializeDecoder(
295 const int8_t payload_type, 295 const int8_t payload_type,
296 const char payload_name[RTP_PAYLOAD_NAME_SIZE], 296 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
297 const int frequency, 297 const int frequency,
298 const size_t channels, 298 const size_t channels,
299 const uint32_t rate) { 299 const uint32_t rate) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 last_seq_num_for_pic_id_[rtp_frame->picture_id] = rtp_frame->last_seq_num(); 405 last_seq_num_for_pic_id_[rtp_frame->picture_id] = rtp_frame->last_seq_num();
406 } 406 }
407 complete_frame_callback_->OnCompleteFrame(std::move(frame)); 407 complete_frame_callback_->OnCompleteFrame(std::move(frame));
408 } 408 }
409 409
410 void RtpStreamReceiver::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 410 void RtpStreamReceiver::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
411 if (nack_module_) 411 if (nack_module_)
412 nack_module_->UpdateRtt(max_rtt_ms); 412 nack_module_->UpdateRtt(max_rtt_ms);
413 } 413 }
414 414
415 // TODO(nisse): Drop return value. 415 void RtpStreamReceiver::ReceivePacket(const uint8_t* packet,
416 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet,
417 size_t packet_length, 416 size_t packet_length,
418 const RTPHeader& header, 417 const RTPHeader& header,
419 bool in_order) { 418 bool in_order) {
420 if (rtp_payload_registry_.IsEncapsulated(header)) { 419 if (rtp_payload_registry_.IsEncapsulated(header)) {
421 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); 420 ParseAndHandleEncapsulatingHeader(packet, packet_length, header);
421 return;
422 } 422 }
423 const uint8_t* payload = packet + header.headerLength; 423 const uint8_t* payload = packet + header.headerLength;
424 assert(packet_length >= header.headerLength); 424 assert(packet_length >= header.headerLength);
425 size_t payload_length = packet_length - header.headerLength; 425 size_t payload_length = packet_length - header.headerLength;
426 PayloadUnion payload_specific; 426 PayloadUnion payload_specific;
427 if (!rtp_payload_registry_.GetPayloadSpecifics(header.payloadType, 427 if (!rtp_payload_registry_.GetPayloadSpecifics(header.payloadType,
428 &payload_specific)) { 428 &payload_specific)) {
429 return false; 429 return;
430 } 430 }
431 return rtp_receiver_->IncomingRtpPacket(header, payload, payload_length, 431 rtp_receiver_->IncomingRtpPacket(header, payload, payload_length,
432 payload_specific, in_order); 432 payload_specific, in_order);
433 } 433 }
434 434
435 bool RtpStreamReceiver::ParseAndHandleEncapsulatingHeader( 435 void RtpStreamReceiver::ParseAndHandleEncapsulatingHeader(
436 const uint8_t* packet, size_t packet_length, const RTPHeader& header) { 436 const uint8_t* packet, size_t packet_length, const RTPHeader& header) {
437 if (rtp_payload_registry_.IsRed(header)) { 437 if (rtp_payload_registry_.IsRed(header)) {
438 int8_t ulpfec_pt = rtp_payload_registry_.ulpfec_payload_type(); 438 int8_t ulpfec_pt = rtp_payload_registry_.ulpfec_payload_type();
439 if (packet[header.headerLength] == ulpfec_pt) { 439 if (packet[header.headerLength] == ulpfec_pt) {
440 rtp_receive_statistics_->FecPacketReceived(header, packet_length); 440 rtp_receive_statistics_->FecPacketReceived(header, packet_length);
441 // Notify video_receiver about received FEC packets to avoid NACKing these 441 // Notify video_receiver about received FEC packets to avoid NACKing these
442 // packets. 442 // packets.
443 NotifyReceiverOfFecPacket(header); 443 NotifyReceiverOfFecPacket(header);
444 } 444 }
445 if (ulpfec_receiver_->AddReceivedRedPacket(header, packet, packet_length, 445 if (ulpfec_receiver_->AddReceivedRedPacket(header, packet, packet_length,
446 ulpfec_pt) != 0) { 446 ulpfec_pt) != 0) {
447 return false; 447 return;
448 } 448 }
449 return ulpfec_receiver_->ProcessReceivedFec() == 0; 449 ulpfec_receiver_->ProcessReceivedFec();
450 } else if (rtp_payload_registry_.IsRtx(header)) { 450 } else if (rtp_payload_registry_.IsRtx(header)) {
451 if (header.headerLength + header.paddingLength == packet_length) { 451 if (header.headerLength + header.paddingLength == packet_length) {
452 // This is an empty packet and should be silently dropped before trying to 452 // This is an empty packet and should be silently dropped before trying to
453 // parse the RTX header. 453 // parse the RTX header.
454 return true; 454 return;
455 } 455 }
456 // Remove the RTX header and parse the original RTP header. 456 // Remove the RTX header and parse the original RTP header.
457 if (packet_length < header.headerLength) 457 if (packet_length < header.headerLength)
458 return false; 458 return;
459 if (packet_length > sizeof(restored_packet_)) 459 if (packet_length > sizeof(restored_packet_))
460 return false; 460 return;
461 rtc::CritScope lock(&receive_cs_); 461 rtc::CritScope lock(&receive_cs_);
462 if (restored_packet_in_use_) { 462 if (restored_packet_in_use_) {
463 LOG(LS_WARNING) << "Multiple RTX headers detected, dropping packet."; 463 LOG(LS_WARNING) << "Multiple RTX headers detected, dropping packet.";
464 return false; 464 return;
465 } 465 }
466 if (!rtp_payload_registry_.RestoreOriginalPacket( 466 if (!rtp_payload_registry_.RestoreOriginalPacket(
467 restored_packet_, packet, &packet_length, rtp_receiver_->SSRC(), 467 restored_packet_, packet, &packet_length, rtp_receiver_->SSRC(),
468 header)) { 468 header)) {
469 LOG(LS_WARNING) << "Incoming RTX packet: Invalid RTP header ssrc: " 469 LOG(LS_WARNING) << "Incoming RTX packet: Invalid RTP header ssrc: "
470 << header.ssrc << " payload type: " 470 << header.ssrc << " payload type: "
471 << static_cast<int>(header.payloadType); 471 << static_cast<int>(header.payloadType);
472 return false; 472 return;
473 } 473 }
474 restored_packet_in_use_ = true; 474 restored_packet_in_use_ = true;
475 bool ret = OnRecoveredPacket(restored_packet_, packet_length); 475 OnRecoveredPacket(restored_packet_, packet_length);
476 restored_packet_in_use_ = false; 476 restored_packet_in_use_ = false;
477 return ret;
478 } 477 }
479 return false;
480 } 478 }
481 479
482 void RtpStreamReceiver::NotifyReceiverOfFecPacket(const RTPHeader& header) { 480 void RtpStreamReceiver::NotifyReceiverOfFecPacket(const RTPHeader& header) {
483 int8_t last_media_payload_type = 481 int8_t last_media_payload_type =
484 rtp_payload_registry_.last_received_media_payload_type(); 482 rtp_payload_registry_.last_received_media_payload_type();
485 if (last_media_payload_type < 0) { 483 if (last_media_payload_type < 0) {
486 LOG(LS_WARNING) << "Failed to get last media payload type."; 484 LOG(LS_WARNING) << "Failed to get last media payload type.";
487 return; 485 return;
488 } 486 }
489 // Fake an empty media packet. 487 // Fake an empty media packet.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 return; 658 return;
661 659
662 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) 660 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str()))
663 return; 661 return;
664 662
665 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), 663 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(),
666 sprop_decoder.pps_nalu()); 664 sprop_decoder.pps_nalu());
667 } 665 }
668 666
669 } // namespace webrtc 667 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698