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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 // packets belonging to the same SSRC. | 68 // packets belonging to the same SSRC. |
69 struct LessThan { | 69 struct LessThan { |
70 template <typename S, typename T> | 70 template <typename S, typename T> |
71 bool operator() (const S& first, const T& second); | 71 bool operator() (const S& first, const T& second); |
72 }; | 72 }; |
73 | 73 |
74 uint32_t ssrc; | 74 uint32_t ssrc; |
75 uint16_t seq_num; | 75 uint16_t seq_num; |
76 }; | 76 }; |
77 | 77 |
78 // The received list parameter of DecodeFec() references structs of this type. | 78 // Used for the input to DecodeFec(). |
79 // | 79 // |
80 // TODO(holmer): Refactor into a proper class. | 80 // TODO(holmer): Refactor into a proper class. |
stefan-webrtc
2017/09/15 13:36:13
May want to just delete this TODO, it's been there
nisse-webrtc
2017/09/18 12:39:06
Done.
| |
81 // TODO(nisse): Or delete, instead passing |is_fec| and |pkt| as | |
82 // separate arguments. | |
81 class ReceivedPacket : public SortablePacket { | 83 class ReceivedPacket : public SortablePacket { |
82 public: | 84 public: |
83 ReceivedPacket(); | 85 ReceivedPacket(); |
84 ~ReceivedPacket(); | 86 ~ReceivedPacket(); |
85 | 87 |
86 bool is_fec; // Set to true if this is an FEC packet and false | 88 bool is_fec; // Set to true if this is an FEC packet and false |
87 // otherwise. | 89 // otherwise. |
88 rtc::scoped_refptr<Packet> pkt; // Pointer to the packet storage. | 90 rtc::scoped_refptr<Packet> pkt; // Pointer to the packet storage. |
89 }; | 91 }; |
90 | 92 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 uint32_t protected_ssrc; | 136 uint32_t protected_ssrc; |
135 uint16_t seq_num_base; | 137 uint16_t seq_num_base; |
136 size_t packet_mask_offset; // Relative start of FEC header. | 138 size_t packet_mask_offset; // Relative start of FEC header. |
137 size_t packet_mask_size; | 139 size_t packet_mask_size; |
138 size_t protection_length; | 140 size_t protection_length; |
139 // Raw data. | 141 // Raw data. |
140 rtc::scoped_refptr<ForwardErrorCorrection::Packet> pkt; | 142 rtc::scoped_refptr<ForwardErrorCorrection::Packet> pkt; |
141 }; | 143 }; |
142 | 144 |
143 using PacketList = std::list<std::unique_ptr<Packet>>; | 145 using PacketList = std::list<std::unique_ptr<Packet>>; |
144 using ReceivedPacketList = std::list<std::unique_ptr<ReceivedPacket>>; | |
145 using RecoveredPacketList = std::list<std::unique_ptr<RecoveredPacket>>; | 146 using RecoveredPacketList = std::list<std::unique_ptr<RecoveredPacket>>; |
146 using ReceivedFecPacketList = std::list<std::unique_ptr<ReceivedFecPacket>>; | 147 using ReceivedFecPacketList = std::list<std::unique_ptr<ReceivedFecPacket>>; |
147 | 148 |
148 ~ForwardErrorCorrection(); | 149 ~ForwardErrorCorrection(); |
149 | 150 |
150 // Creates a ForwardErrorCorrection tailored for a specific FEC scheme. | 151 // Creates a ForwardErrorCorrection tailored for a specific FEC scheme. |
151 static std::unique_ptr<ForwardErrorCorrection> CreateUlpfec(uint32_t ssrc); | 152 static std::unique_ptr<ForwardErrorCorrection> CreateUlpfec(uint32_t ssrc); |
152 static std::unique_ptr<ForwardErrorCorrection> CreateFlexfec( | 153 static std::unique_ptr<ForwardErrorCorrection> CreateFlexfec( |
153 uint32_t ssrc, | 154 uint32_t ssrc, |
154 uint32_t protected_media_ssrc); | 155 uint32_t protected_media_ssrc); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 // ReceivedPacket, belonging to a single | 212 // ReceivedPacket, belonging to a single |
212 // frame. At output the list will be empty, | 213 // frame. At output the list will be empty, |
213 // with packets either stored internally, | 214 // with packets either stored internally, |
214 // or accessible through the recovered list. | 215 // or accessible through the recovered list. |
215 // Output: recovered_packets List of recovered media packets, of type | 216 // Output: recovered_packets List of recovered media packets, of type |
216 // RecoveredPacket, belonging to a single | 217 // RecoveredPacket, belonging to a single |
217 // frame. The memory available through the | 218 // frame. The memory available through the |
218 // list will be valid until the next call to | 219 // list will be valid until the next call to |
219 // DecodeFec(). | 220 // DecodeFec(). |
220 // | 221 // |
221 // Returns 0 on success, -1 on failure. | 222 void DecodeFec(const ReceivedPacket& received_packet, |
222 // | 223 RecoveredPacketList* recovered_packets); |
223 int DecodeFec(ReceivedPacketList* received_packets, | |
224 RecoveredPacketList* recovered_packets); | |
225 | 224 |
226 // Get the number of generated FEC packets, given the number of media packets | 225 // Get the number of generated FEC packets, given the number of media packets |
227 // and the protection factor. | 226 // and the protection factor. |
228 static int NumFecPackets(int num_media_packets, int protection_factor); | 227 static int NumFecPackets(int num_media_packets, int protection_factor); |
229 | 228 |
230 // Gets the maximum size of the FEC headers in bytes, which must be | 229 // Gets the maximum size of the FEC headers in bytes, which must be |
231 // accounted for as packet overhead. | 230 // accounted for as packet overhead. |
232 size_t MaxPacketOverhead() const; | 231 size_t MaxPacketOverhead() const; |
233 | 232 |
234 // Reset internal states from last frame and clear |recovered_packets|. | 233 // Reset internal states from last frame and clear |recovered_packets|. |
(...skipping 24 matching lines...) Expand all Loading... | |
259 // Writes FEC payloads and some recovery fields in the FEC headers. | 258 // Writes FEC payloads and some recovery fields in the FEC headers. |
260 void GenerateFecPayloads(const PacketList& media_packets, | 259 void GenerateFecPayloads(const PacketList& media_packets, |
261 size_t num_fec_packets); | 260 size_t num_fec_packets); |
262 | 261 |
263 // Writes the FEC header fields that are not written by GenerateFecPayloads. | 262 // Writes the FEC header fields that are not written by GenerateFecPayloads. |
264 // This includes writing the packet masks. | 263 // This includes writing the packet masks. |
265 void FinalizeFecHeaders(size_t num_fec_packets, | 264 void FinalizeFecHeaders(size_t num_fec_packets, |
266 uint32_t media_ssrc, | 265 uint32_t media_ssrc, |
267 uint16_t seq_num_base); | 266 uint16_t seq_num_base); |
268 | 267 |
269 // Inserts the |received_packets| into the internal received FEC packet list | 268 // Inserts the |received_packet| into the internal received FEC packet list |
270 // or into |recovered_packets|. | 269 // or into |recovered_packets|. |
271 void InsertPackets(ReceivedPacketList* received_packets, | 270 void InsertPacket(const ReceivedPacket& received_packet, |
272 RecoveredPacketList* recovered_packets); | 271 RecoveredPacketList* recovered_packets); |
273 | 272 |
274 // Inserts the |received_packet| into |recovered_packets|. Deletes duplicates. | 273 // Inserts the |received_packet| into |recovered_packets|. Deletes duplicates. |
275 void InsertMediaPacket(RecoveredPacketList* recovered_packets, | 274 void InsertMediaPacket(RecoveredPacketList* recovered_packets, |
276 ReceivedPacket* received_packet); | 275 const ReceivedPacket& received_packet); |
277 | 276 |
278 // Assigns pointers to the recovered packet from all FEC packets which cover | 277 // Assigns pointers to the recovered packet from all FEC packets which cover |
279 // it. | 278 // it. |
280 // Note: This reduces the complexity when we want to try to recover a packet | 279 // Note: This reduces the complexity when we want to try to recover a packet |
281 // since we don't have to find the intersection between recovered packets and | 280 // since we don't have to find the intersection between recovered packets and |
282 // packets covered by the FEC packet. | 281 // packets covered by the FEC packet. |
283 void UpdateCoveringFecPackets(const RecoveredPacket& packet); | 282 void UpdateCoveringFecPackets(const RecoveredPacket& packet); |
284 | 283 |
285 // Insert |received_packet| into internal FEC list. Deletes duplicates. | 284 // Insert |received_packet| into internal FEC list. Deletes duplicates. |
286 void InsertFecPacket(const RecoveredPacketList& recovered_packets, | 285 void InsertFecPacket(const RecoveredPacketList& recovered_packets, |
287 ReceivedPacket* received_packet); | 286 const ReceivedPacket& received_packet); |
288 | 287 |
289 // Assigns pointers to already recovered packets covered by |fec_packet|. | 288 // Assigns pointers to already recovered packets covered by |fec_packet|. |
290 static void AssignRecoveredPackets( | 289 static void AssignRecoveredPackets( |
291 const RecoveredPacketList& recovered_packets, | 290 const RecoveredPacketList& recovered_packets, |
292 ReceivedFecPacket* fec_packet); | 291 ReceivedFecPacket* fec_packet); |
293 | 292 |
294 // Attempt to recover missing packets, using the internally stored | 293 // Attempt to recover missing packets, using the internally stored |
295 // received FEC packets. | 294 // received FEC packets. |
296 void AttemptRecovery(RecoveredPacketList* recovered_packets); | 295 void AttemptRecovery(RecoveredPacketList* recovered_packets); |
297 | 296 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 size_t max_packet_overhead); | 411 size_t max_packet_overhead); |
413 | 412 |
414 const size_t max_media_packets_; | 413 const size_t max_media_packets_; |
415 const size_t max_fec_packets_; | 414 const size_t max_fec_packets_; |
416 const size_t max_packet_overhead_; | 415 const size_t max_packet_overhead_; |
417 }; | 416 }; |
418 | 417 |
419 } // namespace webrtc | 418 } // namespace webrtc |
420 | 419 |
421 #endif // MODULES_RTP_RTCP_SOURCE_FORWARD_ERROR_CORRECTION_H_ | 420 #endif // MODULES_RTP_RTCP_SOURCE_FORWARD_ERROR_CORRECTION_H_ |
OLD | NEW |