| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 last_recovered_packet_ms_(-1) { | 42 last_recovered_packet_ms_(-1) { |
| 43 // It's OK to create this object on a different thread/task queue than | 43 // It's OK to create this object on a different thread/task queue than |
| 44 // the one used during main operation. | 44 // the one used during main operation. |
| 45 sequence_checker_.Detach(); | 45 sequence_checker_.Detach(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 FlexfecReceiver::~FlexfecReceiver() = default; | 48 FlexfecReceiver::~FlexfecReceiver() = default; |
| 49 | 49 |
| 50 bool FlexfecReceiver::AddAndProcessReceivedPacket(const uint8_t* packet, | 50 bool FlexfecReceiver::AddAndProcessReceivedPacket(const uint8_t* packet, |
| 51 size_t packet_length) { | 51 size_t packet_length) { |
| 52 RTC_DCHECK(sequence_checker_.CalledSequentially()); | 52 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); |
| 53 | |
| 54 if (!AddReceivedPacket(packet, packet_length)) { | 53 if (!AddReceivedPacket(packet, packet_length)) { |
| 55 return false; | 54 return false; |
| 56 } | 55 } |
| 57 return ProcessReceivedPackets(); | 56 return ProcessReceivedPackets(); |
| 58 } | 57 } |
| 59 | 58 |
| 60 FecPacketCounter FlexfecReceiver::GetPacketCounter() const { | 59 FecPacketCounter FlexfecReceiver::GetPacketCounter() const { |
| 61 RTC_DCHECK(sequence_checker_.CalledSequentially()); | 60 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); |
| 62 return packet_counter_; | 61 return packet_counter_; |
| 63 } | 62 } |
| 64 | 63 |
| 65 bool FlexfecReceiver::AddReceivedPacket(const uint8_t* packet, | 64 bool FlexfecReceiver::AddReceivedPacket(const uint8_t* packet, |
| 66 size_t packet_length) { | 65 size_t packet_length) { |
| 67 RTC_DCHECK(sequence_checker_.CalledSequentially()); | 66 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); |
| 68 | 67 |
| 69 // RTP packets with a full base header (12 bytes), but without payload, | 68 // RTP packets with a full base header (12 bytes), but without payload, |
| 70 // could conceivably be useful in the decoding. Therefore we check | 69 // could conceivably be useful in the decoding. Therefore we check |
| 71 // with a strict inequality here. | 70 // with a strict inequality here. |
| 72 if (packet_length < kRtpHeaderSize) { | 71 if (packet_length < kRtpHeaderSize) { |
| 73 LOG(LS_WARNING) << "Truncated packet, discarding."; | 72 LOG(LS_WARNING) << "Truncated packet, discarding."; |
| 74 return false; | 73 return false; |
| 75 } | 74 } |
| 76 | 75 |
| 77 // TODO(brandtr): Consider how to handle received FlexFEC packets and | 76 // TODO(brandtr): Consider how to handle received FlexFEC packets and |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // Note that the implementation of this member function and the implementation | 122 // Note that the implementation of this member function and the implementation |
| 124 // in UlpfecReceiver::ProcessReceivedFec() are slightly different. | 123 // in UlpfecReceiver::ProcessReceivedFec() are slightly different. |
| 125 // This implementation only returns _recovered_ media packets through the | 124 // This implementation only returns _recovered_ media packets through the |
| 126 // callback, whereas the implementation in UlpfecReceiver returns _all inserted_ | 125 // callback, whereas the implementation in UlpfecReceiver returns _all inserted_ |
| 127 // media packets through the callback. The latter behaviour makes sense | 126 // media packets through the callback. The latter behaviour makes sense |
| 128 // for ULPFEC, since the ULPFEC receiver is owned by the RtpStreamReceiver. | 127 // for ULPFEC, since the ULPFEC receiver is owned by the RtpStreamReceiver. |
| 129 // Here, however, the received media pipeline is more decoupled from the | 128 // Here, however, the received media pipeline is more decoupled from the |
| 130 // FlexFEC decoder, and we therefore do not interfere with the reception | 129 // FlexFEC decoder, and we therefore do not interfere with the reception |
| 131 // of non-recovered media packets. | 130 // of non-recovered media packets. |
| 132 bool FlexfecReceiver::ProcessReceivedPackets() { | 131 bool FlexfecReceiver::ProcessReceivedPackets() { |
| 133 RTC_DCHECK(sequence_checker_.CalledSequentially()); | 132 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); |
| 134 | 133 |
| 135 // Decode. | 134 // Decode. |
| 136 if (!received_packets_.empty()) { | 135 if (!received_packets_.empty()) { |
| 137 if (erasure_code_->DecodeFec(&received_packets_, &recovered_packets_) != | 136 if (erasure_code_->DecodeFec(&received_packets_, &recovered_packets_) != |
| 138 0) { | 137 0) { |
| 139 return false; | 138 return false; |
| 140 } | 139 } |
| 141 } | 140 } |
| 142 // Return recovered packets through callback. | 141 // Return recovered packets through callback. |
| 143 for (const auto& recovered_packet : recovered_packets_) { | 142 for (const auto& recovered_packet : recovered_packets_) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 157 ForwardErrorCorrection::ParseSsrc(recovered_packet->pkt->data); | 156 ForwardErrorCorrection::ParseSsrc(recovered_packet->pkt->data); |
| 158 LOG(LS_INFO) << "Recovered media packet with SSRC: " << media_ssrc | 157 LOG(LS_INFO) << "Recovered media packet with SSRC: " << media_ssrc |
| 159 << " from FlexFEC stream with SSRC: " << ssrc_ << "."; | 158 << " from FlexFEC stream with SSRC: " << ssrc_ << "."; |
| 160 last_recovered_packet_ms_ = now_ms; | 159 last_recovered_packet_ms_ = now_ms; |
| 161 } | 160 } |
| 162 } | 161 } |
| 163 return true; | 162 return true; |
| 164 } | 163 } |
| 165 | 164 |
| 166 } // namespace webrtc | 165 } // namespace webrtc |
| OLD | NEW |