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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_sender.cc

Issue 1376673004: Add a PacketOptions struct to webrtc::Transport. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comment added Created 5 years, 2 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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 RTPHeader rtp_header; 655 RTPHeader rtp_header;
656 rtp_parser.Parse(rtp_header); 656 rtp_parser.Parse(rtp_header);
657 657
658 if (capture_time_ms > 0) { 658 if (capture_time_ms > 0) {
659 UpdateTransmissionTimeOffset( 659 UpdateTransmissionTimeOffset(
660 padding_packet, length, rtp_header, now_ms - capture_time_ms); 660 padding_packet, length, rtp_header, now_ms - capture_time_ms);
661 } 661 }
662 662
663 UpdateAbsoluteSendTime(padding_packet, length, rtp_header, now_ms); 663 UpdateAbsoluteSendTime(padding_packet, length, rtp_header, now_ms);
664 664
665 uint16_t transport_seq = 0; 665 PacketOptions options;
666 if (using_transport_seq) { 666 if (using_transport_seq) {
667 transport_seq = 667 options.packet_id =
668 UpdateTransportSequenceNumber(padding_packet, length, rtp_header); 668 UpdateTransportSequenceNumber(padding_packet, length, rtp_header);
669 } 669 }
670 670
671 if (!SendPacketToNetwork(padding_packet, length)) 671 if (!SendPacketToNetwork(padding_packet, length, options))
672 break; 672 break;
673 673
674 if (using_transport_seq && transport_feedback_observer_) { 674 if (using_transport_seq && transport_feedback_observer_) {
675 transport_feedback_observer_->OnPacketSent( 675 transport_feedback_observer_->OnPacketSent(PacketInfo(
676 PacketInfo(0, now_ms, transport_seq, length, true)); 676 0, now_ms, options.packet_id, length, true));
677 } 677 }
678 678
679 bytes_sent += padding_bytes_in_packet; 679 bytes_sent += padding_bytes_in_packet;
680 UpdateRtpStats(padding_packet, length, rtp_header, over_rtx, false); 680 UpdateRtpStats(padding_packet, length, rtp_header, over_rtx, false);
681 } 681 }
682 682
683 return bytes_sent; 683 return bytes_sent;
684 } 684 }
685 685
686 void RTPSender::SetStorePacketsStatus(bool enable, uint16_t number_to_store) { 686 void RTPSender::SetStorePacketsStatus(bool enable, uint16_t number_to_store) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 CriticalSectionScoped lock(send_critsect_.get()); 725 CriticalSectionScoped lock(send_critsect_.get());
726 rtx = rtx_; 726 rtx = rtx_;
727 } 727 }
728 if (!PrepareAndSendPacket(data_buffer, length, capture_time_ms, 728 if (!PrepareAndSendPacket(data_buffer, length, capture_time_ms,
729 (rtx & kRtxRetransmitted) > 0, true)) { 729 (rtx & kRtxRetransmitted) > 0, true)) {
730 return -1; 730 return -1;
731 } 731 }
732 return static_cast<int32_t>(length); 732 return static_cast<int32_t>(length);
733 } 733 }
734 734
735 bool RTPSender::SendPacketToNetwork(const uint8_t *packet, size_t size) { 735 bool RTPSender::SendPacketToNetwork(const uint8_t* packet,
736 size_t size,
737 const PacketOptions& options) {
736 int bytes_sent = -1; 738 int bytes_sent = -1;
737 if (transport_) { 739 if (transport_) {
738 bytes_sent = 740 bytes_sent = transport_->SendRtp(packet, size, options)
739 transport_->SendRtp(packet, size) ? static_cast<int>(size) : -1; 741 ? static_cast<int>(size)
742 : -1;
740 } 743 }
741 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 744 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
742 "RTPSender::SendPacketToNetwork", "size", size, "sent", 745 "RTPSender::SendPacketToNetwork", "size", size, "sent",
743 bytes_sent); 746 bytes_sent);
744 // TODO(pwestin): Add a separate bitrate for sent bitrate after pacer. 747 // TODO(pwestin): Add a separate bitrate for sent bitrate after pacer.
745 if (bytes_sent <= 0) { 748 if (bytes_sent <= 0) {
746 LOG(LS_WARNING) << "Transport failed to send packet"; 749 LOG(LS_WARNING) << "Transport failed to send packet";
747 return false; 750 return false;
748 } 751 }
749 return true; 752 return true;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 BuildRtxPacket(buffer, &length, data_buffer_rtx); 912 BuildRtxPacket(buffer, &length, data_buffer_rtx);
910 buffer_to_send_ptr = data_buffer_rtx; 913 buffer_to_send_ptr = data_buffer_rtx;
911 } 914 }
912 915
913 int64_t now_ms = clock_->TimeInMilliseconds(); 916 int64_t now_ms = clock_->TimeInMilliseconds();
914 int64_t diff_ms = now_ms - capture_time_ms; 917 int64_t diff_ms = now_ms - capture_time_ms;
915 UpdateTransmissionTimeOffset(buffer_to_send_ptr, length, rtp_header, 918 UpdateTransmissionTimeOffset(buffer_to_send_ptr, length, rtp_header,
916 diff_ms); 919 diff_ms);
917 UpdateAbsoluteSendTime(buffer_to_send_ptr, length, rtp_header, now_ms); 920 UpdateAbsoluteSendTime(buffer_to_send_ptr, length, rtp_header, now_ms);
918 921
919 uint16_t transport_seq = 0;
920 // TODO(sprang): Potentially too much overhead in IsRegistered()? 922 // TODO(sprang): Potentially too much overhead in IsRegistered()?
921 bool using_transport_seq = rtp_header_extension_map_.IsRegistered( 923 bool using_transport_seq = rtp_header_extension_map_.IsRegistered(
922 kRtpExtensionTransportSequenceNumber) && 924 kRtpExtensionTransportSequenceNumber) &&
923 transport_sequence_number_allocator_ && 925 transport_sequence_number_allocator_ &&
924 !is_retransmit; 926 !is_retransmit;
927 PacketOptions options;
925 if (using_transport_seq) { 928 if (using_transport_seq) {
926 transport_seq = 929 options.packet_id =
927 UpdateTransportSequenceNumber(buffer_to_send_ptr, length, rtp_header); 930 UpdateTransportSequenceNumber(buffer_to_send_ptr, length, rtp_header);
928 } 931 }
929 932
930 bool ret = SendPacketToNetwork(buffer_to_send_ptr, length); 933 bool ret = SendPacketToNetwork(buffer_to_send_ptr, length, options);
931 if (ret) { 934 if (ret) {
932 CriticalSectionScoped lock(send_critsect_.get()); 935 CriticalSectionScoped lock(send_critsect_.get());
933 media_has_been_sent_ = true; 936 media_has_been_sent_ = true;
934 } 937 }
935 if (using_transport_seq && transport_feedback_observer_) { 938 if (using_transport_seq && transport_feedback_observer_) {
936 transport_feedback_observer_->OnPacketSent( 939 transport_feedback_observer_->OnPacketSent(
937 PacketInfo(0, now_ms, transport_seq, length, true)); 940 PacketInfo(0, now_ms, options.packet_id, length, true));
938 } 941 }
939 UpdateRtpStats(buffer_to_send_ptr, length, rtp_header, send_over_rtx, 942 UpdateRtpStats(buffer_to_send_ptr, length, rtp_header, send_over_rtx,
940 is_retransmit); 943 is_retransmit);
941 return ret; 944 return ret;
942 } 945 }
943 946
944 void RTPSender::UpdateRtpStats(const uint8_t* buffer, 947 void RTPSender::UpdateRtpStats(const uint8_t* buffer,
945 size_t packet_length, 948 size_t packet_length,
946 const RTPHeader& header, 949 const RTPHeader& header,
947 bool is_rtx, 950 bool is_rtx,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 // We can't send the packet right now. 1054 // We can't send the packet right now.
1052 // We will be called when it is time. 1055 // We will be called when it is time.
1053 return 0; 1056 return 0;
1054 } 1057 }
1055 } 1058 }
1056 if (capture_time_ms > 0) { 1059 if (capture_time_ms > 0) {
1057 UpdateDelayStatistics(capture_time_ms, now_ms); 1060 UpdateDelayStatistics(capture_time_ms, now_ms);
1058 } 1061 }
1059 1062
1060 size_t length = payload_length + rtp_header_length; 1063 size_t length = payload_length + rtp_header_length;
1061 bool sent = SendPacketToNetwork(buffer, length); 1064 bool sent = SendPacketToNetwork(buffer, length, PacketOptions());
1062 1065
1063 if (storage != kDontStore) { 1066 if (storage != kDontStore) {
1064 // Mark the packet as sent in the history even if send failed. Dropping a 1067 // Mark the packet as sent in the history even if send failed. Dropping a
1065 // packet here should be treated as any other packet drop so we should be 1068 // packet here should be treated as any other packet drop so we should be
1066 // ready for a retransmission. 1069 // ready for a retransmission.
1067 packet_history_.SetSent(rtp_header.sequenceNumber); 1070 packet_history_.SetSent(rtp_header.sequenceNumber);
1068 } 1071 }
1069 if (!sent) 1072 if (!sent)
1070 return -1; 1073 return -1;
1071 1074
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 CriticalSectionScoped lock(send_critsect_.get()); 1904 CriticalSectionScoped lock(send_critsect_.get());
1902 1905
1903 RtpState state; 1906 RtpState state;
1904 state.sequence_number = sequence_number_rtx_; 1907 state.sequence_number = sequence_number_rtx_;
1905 state.start_timestamp = start_timestamp_; 1908 state.start_timestamp = start_timestamp_;
1906 1909
1907 return state; 1910 return state;
1908 } 1911 }
1909 1912
1910 } // namespace webrtc 1913 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698