| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| 62 FlexfecSender::FlexfecSender( | 62 FlexfecSender::FlexfecSender( |
| 63 int payload_type, | 63 int payload_type, |
| 64 uint32_t ssrc, | 64 uint32_t ssrc, |
| 65 uint32_t protected_media_ssrc, | 65 uint32_t protected_media_ssrc, |
| 66 const std::vector<RtpExtension>& rtp_header_extensions, | 66 const std::vector<RtpExtension>& rtp_header_extensions, |
| 67 rtc::ArrayView<const RtpExtensionSize> extension_sizes, | 67 rtc::ArrayView<const RtpExtensionSize> extension_sizes, |
| 68 const RtpState* rtp_state, |
| 68 Clock* clock) | 69 Clock* clock) |
| 69 : clock_(clock), | 70 : clock_(clock), |
| 70 random_(clock_->TimeInMicroseconds()), | 71 random_(clock_->TimeInMicroseconds()), |
| 71 last_generated_packet_ms_(-1), | 72 last_generated_packet_ms_(-1), |
| 72 payload_type_(payload_type), | 73 payload_type_(payload_type), |
| 73 // Initialize the timestamp offset and RTP sequence numbers randomly. | 74 // Reset RTP state if this is not the first time we are operating. |
| 74 // (This is not intended to be cryptographically strong.) | 75 // Otherwise, randomize the initial timestamp offset and RTP sequence |
| 75 timestamp_offset_(random_.Rand<uint32_t>()), | 76 // numbers. (This is not intended to be cryptographically strong.) |
| 77 timestamp_offset_(rtp_state ? rtp_state->start_timestamp |
| 78 : random_.Rand<uint32_t>()), |
| 76 ssrc_(ssrc), | 79 ssrc_(ssrc), |
| 77 protected_media_ssrc_(protected_media_ssrc), | 80 protected_media_ssrc_(protected_media_ssrc), |
| 78 seq_num_(random_.Rand(1, kMaxInitRtpSeqNumber)), | 81 seq_num_(rtp_state ? rtp_state->sequence_number |
| 82 : random_.Rand(1, kMaxInitRtpSeqNumber)), |
| 79 ulpfec_generator_(ForwardErrorCorrection::CreateFlexfec()), | 83 ulpfec_generator_(ForwardErrorCorrection::CreateFlexfec()), |
| 80 rtp_header_extension_map_(RegisterBweExtensions(rtp_header_extensions)), | 84 rtp_header_extension_map_(RegisterBweExtensions(rtp_header_extensions)), |
| 81 header_extensions_size_( | 85 header_extensions_size_( |
| 82 rtp_header_extension_map_.GetTotalLengthInBytes(extension_sizes)) { | 86 rtp_header_extension_map_.GetTotalLengthInBytes(extension_sizes)) { |
| 83 // This object should not have been instantiated if FlexFEC is disabled. | 87 // This object should not have been instantiated if FlexFEC is disabled. |
| 84 RTC_DCHECK_GE(payload_type, 0); | 88 RTC_DCHECK_GE(payload_type, 0); |
| 85 RTC_DCHECK_LE(payload_type, 127); | 89 RTC_DCHECK_LE(payload_type, 127); |
| 86 } | 90 } |
| 87 | 91 |
| 88 FlexfecSender::~FlexfecSender() = default; | 92 FlexfecSender::~FlexfecSender() = default; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 151 } |
| 148 | 152 |
| 149 return fec_packets_to_send; | 153 return fec_packets_to_send; |
| 150 } | 154 } |
| 151 | 155 |
| 152 // The overhead is BWE RTP header extensions and FlexFEC header. | 156 // The overhead is BWE RTP header extensions and FlexFEC header. |
| 153 size_t FlexfecSender::MaxPacketOverhead() const { | 157 size_t FlexfecSender::MaxPacketOverhead() const { |
| 154 return header_extensions_size_ + kFlexfecMaxHeaderSize; | 158 return header_extensions_size_ + kFlexfecMaxHeaderSize; |
| 155 } | 159 } |
| 156 | 160 |
| 161 RtpState FlexfecSender::GetRtpState() { |
| 162 RtpState rtp_state; |
| 163 rtp_state.sequence_number = seq_num_; |
| 164 rtp_state.start_timestamp = timestamp_offset_; |
| 165 return rtp_state; |
| 166 } |
| 167 |
| 157 } // namespace webrtc | 168 } // namespace webrtc |
| OLD | NEW |