OLD | NEW |
---|---|
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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 uint32_t timestamp, | 584 uint32_t timestamp, |
585 int64_t capture_time_ms, | 585 int64_t capture_time_ms, |
586 int probe_cluster_id) { | 586 int probe_cluster_id) { |
587 // Always send full padding packets. This is accounted for by the | 587 // Always send full padding packets. This is accounted for by the |
588 // RtpPacketSender, | 588 // RtpPacketSender, |
589 // which will make sure we don't send too much padding even if a single packet | 589 // which will make sure we don't send too much padding even if a single packet |
590 // is larger than requested. | 590 // is larger than requested. |
591 size_t padding_bytes_in_packet = | 591 size_t padding_bytes_in_packet = |
592 std::min(MaxDataPayloadLength(), kMaxPaddingLength); | 592 std::min(MaxDataPayloadLength(), kMaxPaddingLength); |
593 size_t bytes_sent = 0; | 593 size_t bytes_sent = 0; |
594 bool using_transport_seq = rtp_header_extension_map_.IsRegistered( | 594 bool using_transport_seq = |
595 kRtpExtensionTransportSequenceNumber) && | 595 IsRtpHeaderExtensionRegistered(kRtpExtensionTransportSequenceNumber) && |
596 transport_sequence_number_allocator_; | 596 transport_sequence_number_allocator_; |
597 for (; bytes > 0; bytes -= padding_bytes_in_packet) { | 597 for (; bytes > 0; bytes -= padding_bytes_in_packet) { |
598 if (bytes < padding_bytes_in_packet) | 598 if (bytes < padding_bytes_in_packet) |
599 bytes = padding_bytes_in_packet; | 599 bytes = padding_bytes_in_packet; |
600 | 600 |
601 uint32_t ssrc; | 601 uint32_t ssrc; |
602 uint16_t sequence_number; | 602 uint16_t sequence_number; |
603 int payload_type; | 603 int payload_type; |
604 bool over_rtx; | 604 bool over_rtx; |
605 { | 605 { |
606 rtc::CritScope lock(&send_critsect_); | 606 rtc::CritScope lock(&send_critsect_); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 } | 640 } |
641 ssrc = ssrc_rtx_; | 641 ssrc = ssrc_rtx_; |
642 sequence_number = sequence_number_rtx_; | 642 sequence_number = sequence_number_rtx_; |
643 ++sequence_number_rtx_; | 643 ++sequence_number_rtx_; |
644 payload_type = rtx_payload_type_map_.begin()->second; | 644 payload_type = rtx_payload_type_map_.begin()->second; |
645 over_rtx = true; | 645 over_rtx = true; |
646 } | 646 } |
647 } | 647 } |
648 | 648 |
649 uint8_t padding_packet[IP_PACKET_SIZE]; | 649 uint8_t padding_packet[IP_PACKET_SIZE]; |
650 size_t header_length = | 650 size_t header_length = 0; |
651 CreateRtpHeader(padding_packet, payload_type, ssrc, false, timestamp, | 651 { |
652 sequence_number, std::vector<uint32_t>()); | 652 rtc::CritScope lock(&send_critsect_); |
653 header_length = | |
654 CreateRtpHeader(padding_packet, payload_type, ssrc, false, timestamp, | |
655 sequence_number, std::vector<uint32_t>()); | |
656 } | |
653 BuildPaddingPacket(padding_packet, header_length, padding_bytes_in_packet); | 657 BuildPaddingPacket(padding_packet, header_length, padding_bytes_in_packet); |
654 size_t length = padding_bytes_in_packet + header_length; | 658 size_t length = padding_bytes_in_packet + header_length; |
655 int64_t now_ms = clock_->TimeInMilliseconds(); | 659 int64_t now_ms = clock_->TimeInMilliseconds(); |
656 | 660 |
657 RtpUtility::RtpHeaderParser rtp_parser(padding_packet, length); | 661 RtpUtility::RtpHeaderParser rtp_parser(padding_packet, length); |
658 RTPHeader rtp_header; | 662 RTPHeader rtp_header; |
659 rtp_parser.Parse(&rtp_header); | 663 rtp_parser.Parse(&rtp_header); |
660 | 664 |
661 if (capture_time_ms > 0) { | 665 if (capture_time_ms > 0) { |
662 UpdateTransmissionTimeOffset( | 666 UpdateTransmissionTimeOffset( |
663 padding_packet, length, rtp_header, now_ms - capture_time_ms); | 667 padding_packet, length, rtp_header, now_ms - capture_time_ms); |
664 } | 668 } |
665 | 669 |
666 UpdateAbsoluteSendTime(padding_packet, length, rtp_header, now_ms); | 670 UpdateAbsoluteSendTime(padding_packet, length, rtp_header, now_ms); |
667 | 671 |
668 PacketOptions options; | 672 PacketOptions options; |
669 if (AllocateTransportSequenceNumber(&options.packet_id)) { | 673 if (IsRtpHeaderExtensionRegistered(kRtpExtensionTransportSequenceNumber) && |
674 AllocateTransportSequenceNumber(&options.packet_id)) { | |
670 if (UpdateTransportSequenceNumber(options.packet_id, padding_packet, | 675 if (UpdateTransportSequenceNumber(options.packet_id, padding_packet, |
671 length, rtp_header)) { | 676 length, rtp_header)) { |
672 if (transport_feedback_observer_) | 677 if (transport_feedback_observer_) |
673 transport_feedback_observer_->AddPacket(options.packet_id, length, | 678 transport_feedback_observer_->AddPacket(options.packet_id, length, |
674 probe_cluster_id); | 679 probe_cluster_id); |
675 } | 680 } |
676 } | 681 } |
677 | 682 |
678 if (!SendPacketToNetwork(padding_packet, length, options)) | 683 if (!SendPacketToNetwork(padding_packet, length, options)) |
679 break; | 684 break; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
852 buffer_to_send_ptr = data_buffer_rtx; | 857 buffer_to_send_ptr = data_buffer_rtx; |
853 } | 858 } |
854 | 859 |
855 int64_t now_ms = clock_->TimeInMilliseconds(); | 860 int64_t now_ms = clock_->TimeInMilliseconds(); |
856 int64_t diff_ms = now_ms - capture_time_ms; | 861 int64_t diff_ms = now_ms - capture_time_ms; |
857 UpdateTransmissionTimeOffset(buffer_to_send_ptr, length, rtp_header, | 862 UpdateTransmissionTimeOffset(buffer_to_send_ptr, length, rtp_header, |
858 diff_ms); | 863 diff_ms); |
859 UpdateAbsoluteSendTime(buffer_to_send_ptr, length, rtp_header, now_ms); | 864 UpdateAbsoluteSendTime(buffer_to_send_ptr, length, rtp_header, now_ms); |
860 | 865 |
861 PacketOptions options; | 866 PacketOptions options; |
862 if (AllocateTransportSequenceNumber(&options.packet_id)) { | 867 if (IsRtpHeaderExtensionRegistered(kRtpExtensionTransportSequenceNumber) && |
868 AllocateTransportSequenceNumber(&options.packet_id)) { | |
863 if (UpdateTransportSequenceNumber(options.packet_id, buffer_to_send_ptr, | 869 if (UpdateTransportSequenceNumber(options.packet_id, buffer_to_send_ptr, |
864 length, rtp_header)) { | 870 length, rtp_header)) { |
865 if (transport_feedback_observer_) | 871 if (transport_feedback_observer_) |
866 transport_feedback_observer_->AddPacket(options.packet_id, length, | 872 transport_feedback_observer_->AddPacket(options.packet_id, length, |
867 probe_cluster_id); | 873 probe_cluster_id); |
868 } | 874 } |
869 } | 875 } |
870 | 876 |
871 if (!is_retransmit && !send_over_rtx) { | 877 if (!is_retransmit && !send_over_rtx) { |
872 UpdateDelayStatistics(capture_time_ms, now_ms); | 878 UpdateDelayStatistics(capture_time_ms, now_ms); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
985 corrected_time_ms > last_capture_time_ms_sent_) { | 991 corrected_time_ms > last_capture_time_ms_sent_) { |
986 last_capture_time_ms_sent_ = corrected_time_ms; | 992 last_capture_time_ms_sent_ = corrected_time_ms; |
987 TRACE_EVENT_ASYNC_BEGIN1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), | 993 TRACE_EVENT_ASYNC_BEGIN1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
988 "PacedSend", corrected_time_ms, | 994 "PacedSend", corrected_time_ms, |
989 "capture_time_ms", corrected_time_ms); | 995 "capture_time_ms", corrected_time_ms); |
990 } | 996 } |
991 return 0; | 997 return 0; |
992 } | 998 } |
993 | 999 |
994 PacketOptions options; | 1000 PacketOptions options; |
995 if (AllocateTransportSequenceNumber(&options.packet_id)) { | 1001 if (IsRtpHeaderExtensionRegistered(kRtpExtensionTransportSequenceNumber) && |
1002 AllocateTransportSequenceNumber(&options.packet_id)) { | |
996 if (UpdateTransportSequenceNumber(options.packet_id, buffer, length, | 1003 if (UpdateTransportSequenceNumber(options.packet_id, buffer, length, |
997 rtp_header)) { | 1004 rtp_header)) { |
998 if (transport_feedback_observer_) | 1005 if (transport_feedback_observer_) |
999 transport_feedback_observer_->AddPacket(options.packet_id, length, | 1006 transport_feedback_observer_->AddPacket(options.packet_id, length, |
1000 PacketInfo::kNotAProbe); | 1007 PacketInfo::kNotAProbe); |
1001 } | 1008 } |
1002 } | 1009 } |
1003 UpdateDelayStatistics(capture_time_ms, now_ms); | 1010 UpdateDelayStatistics(capture_time_ms, now_ms); |
åsapersson
2016/07/28 09:36:10
The send delay statistics will now only be availab
stefan-webrtc
2016/07/28 09:49:52
Good point... I think we'll have to live with that
åsapersson
2016/07/28 10:44:50
Ok.
Maybe the allocation of the sequence number c
stefan-webrtc
2016/07/28 12:54:33
That's a good idea. Fixed.
| |
1004 UpdateOnSendPacket(options.packet_id, capture_time_ms, rtp_header.ssrc); | 1011 UpdateOnSendPacket(options.packet_id, capture_time_ms, rtp_header.ssrc); |
1005 | 1012 |
1006 bool sent = SendPacketToNetwork(buffer, length, options); | 1013 bool sent = SendPacketToNetwork(buffer, length, options); |
1007 | 1014 |
1008 // Mark the packet as sent in the history even if send failed. Dropping a | 1015 // Mark the packet as sent in the history even if send failed. Dropping a |
1009 // packet here should be treated as any other packet drop so we should be | 1016 // packet here should be treated as any other packet drop so we should be |
1010 // ready for a retransmission. | 1017 // ready for a retransmission. |
1011 packet_history_.SetSent(rtp_header.sequenceNumber); | 1018 packet_history_.SetSent(rtp_header.sequenceNumber); |
1012 | 1019 |
1013 if (!sent) | 1020 if (!sent) |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1884 rtc::CritScope lock(&send_critsect_); | 1891 rtc::CritScope lock(&send_critsect_); |
1885 | 1892 |
1886 RtpState state; | 1893 RtpState state; |
1887 state.sequence_number = sequence_number_rtx_; | 1894 state.sequence_number = sequence_number_rtx_; |
1888 state.start_timestamp = start_timestamp_; | 1895 state.start_timestamp = start_timestamp_; |
1889 | 1896 |
1890 return state; | 1897 return state; |
1891 } | 1898 } |
1892 | 1899 |
1893 } // namespace webrtc | 1900 } // namespace webrtc |
OLD | NEW |