Chromium Code Reviews

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

Issue 2177523002: Fix issues with RestartingSendStreamPreservesRtpStatesWithRtx (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 832 matching lines...)
843 TRACE_EVENT_ASYNC_END0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PacedSend", 843 TRACE_EVENT_ASYNC_END0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PacedSend",
844 capture_time_ms); 844 capture_time_ms);
845 } 845 }
846 846
847 TRACE_EVENT_INSTANT2( 847 TRACE_EVENT_INSTANT2(
848 TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PrepareAndSendPacket", 848 TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PrepareAndSendPacket",
849 "timestamp", rtp_header.timestamp, "seqnum", rtp_header.sequenceNumber); 849 "timestamp", rtp_header.timestamp, "seqnum", rtp_header.sequenceNumber);
850 850
851 uint8_t data_buffer_rtx[IP_PACKET_SIZE]; 851 uint8_t data_buffer_rtx[IP_PACKET_SIZE];
852 if (send_over_rtx) { 852 if (send_over_rtx) {
853 BuildRtxPacket(buffer, &length, data_buffer_rtx); 853 if (!BuildRtxPacket(buffer, &length, data_buffer_rtx))
854 return false;
854 buffer_to_send_ptr = data_buffer_rtx; 855 buffer_to_send_ptr = data_buffer_rtx;
855 } 856 }
856 857
857 int64_t now_ms = clock_->TimeInMilliseconds(); 858 int64_t now_ms = clock_->TimeInMilliseconds();
858 int64_t diff_ms = now_ms - capture_time_ms; 859 int64_t diff_ms = now_ms - capture_time_ms;
859 UpdateTransmissionTimeOffset(buffer_to_send_ptr, length, rtp_header, 860 UpdateTransmissionTimeOffset(buffer_to_send_ptr, length, rtp_header,
860 diff_ms); 861 diff_ms);
861 UpdateAbsoluteSendTime(buffer_to_send_ptr, length, rtp_header, now_ms); 862 UpdateAbsoluteSendTime(buffer_to_send_ptr, length, rtp_header, now_ms);
862 863
863 PacketOptions options; 864 PacketOptions options;
(...skipping 283 matching lines...)
1147 capture_timestamp, capture_time_ms); 1148 capture_timestamp, capture_time_ms);
1148 } 1149 }
1149 1150
1150 int32_t RTPSender::BuildRtpHeader(uint8_t* data_buffer, 1151 int32_t RTPSender::BuildRtpHeader(uint8_t* data_buffer,
1151 int8_t payload_type, 1152 int8_t payload_type,
1152 bool marker_bit, 1153 bool marker_bit,
1153 uint32_t capture_timestamp, 1154 uint32_t capture_timestamp,
1154 int64_t capture_time_ms) { 1155 int64_t capture_time_ms) {
1155 assert(payload_type >= 0); 1156 assert(payload_type >= 0);
1156 rtc::CritScope lock(&send_critsect_); 1157 rtc::CritScope lock(&send_critsect_);
1158 if (!sending_media_)
1159 return -1;
1157 1160
1158 timestamp_ = start_timestamp_ + capture_timestamp; 1161 timestamp_ = start_timestamp_ + capture_timestamp;
1159 last_timestamp_time_ms_ = clock_->TimeInMilliseconds(); 1162 last_timestamp_time_ms_ = clock_->TimeInMilliseconds();
1160 uint32_t sequence_number = sequence_number_++; 1163 uint32_t sequence_number = sequence_number_++;
1161 capture_time_ms_ = capture_time_ms; 1164 capture_time_ms_ = capture_time_ms;
1162 last_packet_marker_bit_ = marker_bit; 1165 last_packet_marker_bit_ = marker_bit;
1163 return CreateRtpHeader(data_buffer, payload_type, ssrc_, marker_bit, 1166 return CreateRtpHeader(data_buffer, payload_type, ssrc_, marker_bit,
1164 timestamp_, sequence_number, csrcs_); 1167 timestamp_, sequence_number, csrcs_);
1165 } 1168 }
1166 1169
(...skipping 619 matching lines...)
1786 int32_t RTPSender::SetFecParameters( 1789 int32_t RTPSender::SetFecParameters(
1787 const FecProtectionParams *delta_params, 1790 const FecProtectionParams *delta_params,
1788 const FecProtectionParams *key_params) { 1791 const FecProtectionParams *key_params) {
1789 if (audio_configured_) { 1792 if (audio_configured_) {
1790 return -1; 1793 return -1;
1791 } 1794 }
1792 video_->SetFecParameters(delta_params, key_params); 1795 video_->SetFecParameters(delta_params, key_params);
1793 return 0; 1796 return 0;
1794 } 1797 }
1795 1798
1796 void RTPSender::BuildRtxPacket(uint8_t* buffer, size_t* length, 1799 bool RTPSender::BuildRtxPacket(uint8_t* buffer,
1800 size_t* length,
1797 uint8_t* buffer_rtx) { 1801 uint8_t* buffer_rtx) {
1798 rtc::CritScope lock(&send_critsect_); 1802 rtc::CritScope lock(&send_critsect_);
1803 if (!sending_media_)
1804 return false;
1799 uint8_t* data_buffer_rtx = buffer_rtx; 1805 uint8_t* data_buffer_rtx = buffer_rtx;
1800 // Add RTX header. 1806 // Add RTX header.
1801 RtpUtility::RtpHeaderParser rtp_parser( 1807 RtpUtility::RtpHeaderParser rtp_parser(
1802 reinterpret_cast<const uint8_t*>(buffer), *length); 1808 reinterpret_cast<const uint8_t*>(buffer), *length);
1803 1809
1804 RTPHeader rtp_header; 1810 RTPHeader rtp_header;
1805 rtp_parser.Parse(&rtp_header); 1811 rtp_parser.Parse(&rtp_header);
1806 1812
1807 // Add original RTP header. 1813 // Add original RTP header.
1808 memcpy(data_buffer_rtx, buffer, rtp_header.headerLength); 1814 memcpy(data_buffer_rtx, buffer, rtp_header.headerLength);
(...skipping 20 matching lines...)
1829 1835
1830 // Add OSN (original sequence number). 1836 // Add OSN (original sequence number).
1831 ptr = data_buffer_rtx + rtp_header.headerLength; 1837 ptr = data_buffer_rtx + rtp_header.headerLength;
1832 ByteWriter<uint16_t>::WriteBigEndian(ptr, rtp_header.sequenceNumber); 1838 ByteWriter<uint16_t>::WriteBigEndian(ptr, rtp_header.sequenceNumber);
1833 ptr += 2; 1839 ptr += 2;
1834 1840
1835 // Add original payload data. 1841 // Add original payload data.
1836 memcpy(ptr, buffer + rtp_header.headerLength, 1842 memcpy(ptr, buffer + rtp_header.headerLength,
1837 *length - rtp_header.headerLength); 1843 *length - rtp_header.headerLength);
1838 *length += 2; 1844 *length += 2;
1845 return true;
1839 } 1846 }
1840 1847
1841 void RTPSender::RegisterRtpStatisticsCallback( 1848 void RTPSender::RegisterRtpStatisticsCallback(
1842 StreamDataCountersCallback* callback) { 1849 StreamDataCountersCallback* callback) {
1843 rtc::CritScope cs(&statistics_crit_); 1850 rtc::CritScope cs(&statistics_crit_);
1844 rtp_stats_callback_ = callback; 1851 rtp_stats_callback_ = callback;
1845 } 1852 }
1846 1853
1847 StreamDataCountersCallback* RTPSender::GetRtpStatisticsCallback() const { 1854 StreamDataCountersCallback* RTPSender::GetRtpStatisticsCallback() const {
1848 rtc::CritScope cs(&statistics_crit_); 1855 rtc::CritScope cs(&statistics_crit_);
(...skipping 38 matching lines...)
1887 rtc::CritScope lock(&send_critsect_); 1894 rtc::CritScope lock(&send_critsect_);
1888 1895
1889 RtpState state; 1896 RtpState state;
1890 state.sequence_number = sequence_number_rtx_; 1897 state.sequence_number = sequence_number_rtx_;
1891 state.start_timestamp = start_timestamp_; 1898 state.start_timestamp = start_timestamp_;
1892 1899
1893 return state; 1900 return state;
1894 } 1901 }
1895 1902
1896 } // namespace webrtc 1903 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc » ('j') | no next file with comments »

Powered by Google App Engine