| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // The range is between 0 and 255, where 255 corresponds to 100% overhead | 42 // The range is between 0 and 255, where 255 corresponds to 100% overhead |
| 43 // (relative to the number of protected media packets). | 43 // (relative to the number of protected media packets). |
| 44 constexpr uint8_t kHighProtectionThreshold = 80; | 44 constexpr uint8_t kHighProtectionThreshold = 80; |
| 45 | 45 |
| 46 // This threshold is used to adapt the |kMinMediaPackets| threshold, based | 46 // This threshold is used to adapt the |kMinMediaPackets| threshold, based |
| 47 // on the average number of packets per frame seen so far. When there are few | 47 // on the average number of packets per frame seen so far. When there are few |
| 48 // packets per frame (as given by this threshold), at least | 48 // packets per frame (as given by this threshold), at least |
| 49 // |kMinMediaPackets| + 1 packets are sent to the FEC code. | 49 // |kMinMediaPackets| + 1 packets are sent to the FEC code. |
| 50 constexpr float kMinMediaPacketsAdaptationThreshold = 2.0f; | 50 constexpr float kMinMediaPacketsAdaptationThreshold = 2.0f; |
| 51 | 51 |
| 52 // At construction time, we don't know the SSRC that is used for the generated |
| 53 // FEC packets, but we still need to give it to the ForwardErrorCorrection ctor |
| 54 // to be used in the decoding. |
| 55 // TODO(brandtr): Get rid of this awkwardness by splitting |
| 56 // ForwardErrorCorrection in two objects -- one encoder and one decoder. |
| 57 constexpr uint32_t kUnknownSsrc = 0; |
| 58 |
| 52 } // namespace | 59 } // namespace |
| 53 | 60 |
| 54 RedPacket::RedPacket(size_t length) | 61 RedPacket::RedPacket(size_t length) |
| 55 : data_(new uint8_t[length]), length_(length), header_length_(0) {} | 62 : data_(new uint8_t[length]), length_(length), header_length_(0) {} |
| 56 | 63 |
| 57 void RedPacket::CreateHeader(const uint8_t* rtp_header, | 64 void RedPacket::CreateHeader(const uint8_t* rtp_header, |
| 58 size_t header_length, | 65 size_t header_length, |
| 59 int red_payload_type, | 66 int red_payload_type, |
| 60 int payload_type) { | 67 int payload_type) { |
| 61 RTC_DCHECK_LE(header_length + kRedForFecHeaderLength, length_); | 68 RTC_DCHECK_LE(header_length + kRedForFecHeaderLength, length_); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 87 | 94 |
| 88 uint8_t* RedPacket::data() const { | 95 uint8_t* RedPacket::data() const { |
| 89 return data_.get(); | 96 return data_.get(); |
| 90 } | 97 } |
| 91 | 98 |
| 92 size_t RedPacket::length() const { | 99 size_t RedPacket::length() const { |
| 93 return length_; | 100 return length_; |
| 94 } | 101 } |
| 95 | 102 |
| 96 UlpfecGenerator::UlpfecGenerator() | 103 UlpfecGenerator::UlpfecGenerator() |
| 97 : UlpfecGenerator(ForwardErrorCorrection::CreateUlpfec()) {} | 104 : UlpfecGenerator(ForwardErrorCorrection::CreateUlpfec(kUnknownSsrc)) {} |
| 98 | 105 |
| 99 UlpfecGenerator::UlpfecGenerator(std::unique_ptr<ForwardErrorCorrection> fec) | 106 UlpfecGenerator::UlpfecGenerator(std::unique_ptr<ForwardErrorCorrection> fec) |
| 100 : fec_(std::move(fec)), | 107 : fec_(std::move(fec)), |
| 101 num_protected_frames_(0), | 108 num_protected_frames_(0), |
| 102 min_num_media_packets_(1) { | 109 min_num_media_packets_(1) { |
| 103 memset(¶ms_, 0, sizeof(params_)); | 110 memset(¶ms_, 0, sizeof(params_)); |
| 104 memset(&new_params_, 0, sizeof(new_params_)); | 111 memset(&new_params_, 0, sizeof(new_params_)); |
| 105 } | 112 } |
| 106 | 113 |
| 107 UlpfecGenerator::~UlpfecGenerator() = default; | 114 UlpfecGenerator::~UlpfecGenerator() = default; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 return (num_fec_packets << 8) / media_packets_.size(); | 249 return (num_fec_packets << 8) / media_packets_.size(); |
| 243 } | 250 } |
| 244 | 251 |
| 245 void UlpfecGenerator::ResetState() { | 252 void UlpfecGenerator::ResetState() { |
| 246 media_packets_.clear(); | 253 media_packets_.clear(); |
| 247 generated_fec_packets_.clear(); | 254 generated_fec_packets_.clear(); |
| 248 num_protected_frames_ = 0; | 255 num_protected_frames_ = 0; |
| 249 } | 256 } |
| 250 | 257 |
| 251 } // namespace webrtc | 258 } // namespace webrtc |
| OLD | NEW |