Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: modules/rtp_rtcp/source/forward_error_correction.h

Issue 3012243002: Change ForwardErrorCorrection class to accept one received packet at a time. (Closed)
Patch Set: Rebased. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(nisse): Delete class, instead passing |is_fec| and |pkt| as separate
81 // arguments.
81 class ReceivedPacket : public SortablePacket { 82 class ReceivedPacket : public SortablePacket {
82 public: 83 public:
83 ReceivedPacket(); 84 ReceivedPacket();
84 ~ReceivedPacket(); 85 ~ReceivedPacket();
85 86
86 bool is_fec; // Set to true if this is an FEC packet and false 87 bool is_fec; // Set to true if this is an FEC packet and false
87 // otherwise. 88 // otherwise.
88 rtc::scoped_refptr<Packet> pkt; // Pointer to the packet storage. 89 rtc::scoped_refptr<Packet> pkt; // Pointer to the packet storage.
89 }; 90 };
90 91
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 uint32_t protected_ssrc; 135 uint32_t protected_ssrc;
135 uint16_t seq_num_base; 136 uint16_t seq_num_base;
136 size_t packet_mask_offset; // Relative start of FEC header. 137 size_t packet_mask_offset; // Relative start of FEC header.
137 size_t packet_mask_size; 138 size_t packet_mask_size;
138 size_t protection_length; 139 size_t protection_length;
139 // Raw data. 140 // Raw data.
140 rtc::scoped_refptr<ForwardErrorCorrection::Packet> pkt; 141 rtc::scoped_refptr<ForwardErrorCorrection::Packet> pkt;
141 }; 142 };
142 143
143 using PacketList = std::list<std::unique_ptr<Packet>>; 144 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>>; 145 using RecoveredPacketList = std::list<std::unique_ptr<RecoveredPacket>>;
146 using ReceivedFecPacketList = std::list<std::unique_ptr<ReceivedFecPacket>>; 146 using ReceivedFecPacketList = std::list<std::unique_ptr<ReceivedFecPacket>>;
147 147
148 ~ForwardErrorCorrection(); 148 ~ForwardErrorCorrection();
149 149
150 // Creates a ForwardErrorCorrection tailored for a specific FEC scheme. 150 // Creates a ForwardErrorCorrection tailored for a specific FEC scheme.
151 static std::unique_ptr<ForwardErrorCorrection> CreateUlpfec(uint32_t ssrc); 151 static std::unique_ptr<ForwardErrorCorrection> CreateUlpfec(uint32_t ssrc);
152 static std::unique_ptr<ForwardErrorCorrection> CreateFlexfec( 152 static std::unique_ptr<ForwardErrorCorrection> CreateFlexfec(
153 uint32_t ssrc, 153 uint32_t ssrc,
154 uint32_t protected_media_ssrc); 154 uint32_t protected_media_ssrc);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // ReceivedPacket, belonging to a single 211 // ReceivedPacket, belonging to a single
212 // frame. At output the list will be empty, 212 // frame. At output the list will be empty,
213 // with packets either stored internally, 213 // with packets either stored internally,
214 // or accessible through the recovered list. 214 // or accessible through the recovered list.
215 // Output: recovered_packets List of recovered media packets, of type 215 // Output: recovered_packets List of recovered media packets, of type
216 // RecoveredPacket, belonging to a single 216 // RecoveredPacket, belonging to a single
217 // frame. The memory available through the 217 // frame. The memory available through the
218 // list will be valid until the next call to 218 // list will be valid until the next call to
219 // DecodeFec(). 219 // DecodeFec().
220 // 220 //
221 // Returns 0 on success, -1 on failure. 221 void DecodeFec(const ReceivedPacket& received_packet,
222 // 222 RecoveredPacketList* recovered_packets);
223 int DecodeFec(ReceivedPacketList* received_packets,
224 RecoveredPacketList* recovered_packets);
225 223
226 // Get the number of generated FEC packets, given the number of media packets 224 // Get the number of generated FEC packets, given the number of media packets
227 // and the protection factor. 225 // and the protection factor.
228 static int NumFecPackets(int num_media_packets, int protection_factor); 226 static int NumFecPackets(int num_media_packets, int protection_factor);
229 227
230 // Gets the maximum size of the FEC headers in bytes, which must be 228 // Gets the maximum size of the FEC headers in bytes, which must be
231 // accounted for as packet overhead. 229 // accounted for as packet overhead.
232 size_t MaxPacketOverhead() const; 230 size_t MaxPacketOverhead() const;
233 231
234 // Reset internal states from last frame and clear |recovered_packets|. 232 // Reset internal states from last frame and clear |recovered_packets|.
(...skipping 24 matching lines...) Expand all
259 // Writes FEC payloads and some recovery fields in the FEC headers. 257 // Writes FEC payloads and some recovery fields in the FEC headers.
260 void GenerateFecPayloads(const PacketList& media_packets, 258 void GenerateFecPayloads(const PacketList& media_packets,
261 size_t num_fec_packets); 259 size_t num_fec_packets);
262 260
263 // Writes the FEC header fields that are not written by GenerateFecPayloads. 261 // Writes the FEC header fields that are not written by GenerateFecPayloads.
264 // This includes writing the packet masks. 262 // This includes writing the packet masks.
265 void FinalizeFecHeaders(size_t num_fec_packets, 263 void FinalizeFecHeaders(size_t num_fec_packets,
266 uint32_t media_ssrc, 264 uint32_t media_ssrc,
267 uint16_t seq_num_base); 265 uint16_t seq_num_base);
268 266
269 // Inserts the |received_packets| into the internal received FEC packet list 267 // Inserts the |received_packet| into the internal received FEC packet list
270 // or into |recovered_packets|. 268 // or into |recovered_packets|.
271 void InsertPackets(ReceivedPacketList* received_packets, 269 void InsertPacket(const ReceivedPacket& received_packet,
272 RecoveredPacketList* recovered_packets); 270 RecoveredPacketList* recovered_packets);
273 271
274 // Inserts the |received_packet| into |recovered_packets|. Deletes duplicates. 272 // Inserts the |received_packet| into |recovered_packets|. Deletes duplicates.
275 void InsertMediaPacket(RecoveredPacketList* recovered_packets, 273 void InsertMediaPacket(RecoveredPacketList* recovered_packets,
276 ReceivedPacket* received_packet); 274 const ReceivedPacket& received_packet);
277 275
278 // Assigns pointers to the recovered packet from all FEC packets which cover 276 // Assigns pointers to the recovered packet from all FEC packets which cover
279 // it. 277 // it.
280 // Note: This reduces the complexity when we want to try to recover a packet 278 // 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 279 // since we don't have to find the intersection between recovered packets and
282 // packets covered by the FEC packet. 280 // packets covered by the FEC packet.
283 void UpdateCoveringFecPackets(const RecoveredPacket& packet); 281 void UpdateCoveringFecPackets(const RecoveredPacket& packet);
284 282
285 // Insert |received_packet| into internal FEC list. Deletes duplicates. 283 // Insert |received_packet| into internal FEC list. Deletes duplicates.
286 void InsertFecPacket(const RecoveredPacketList& recovered_packets, 284 void InsertFecPacket(const RecoveredPacketList& recovered_packets,
287 ReceivedPacket* received_packet); 285 const ReceivedPacket& received_packet);
288 286
289 // Assigns pointers to already recovered packets covered by |fec_packet|. 287 // Assigns pointers to already recovered packets covered by |fec_packet|.
290 static void AssignRecoveredPackets( 288 static void AssignRecoveredPackets(
291 const RecoveredPacketList& recovered_packets, 289 const RecoveredPacketList& recovered_packets,
292 ReceivedFecPacket* fec_packet); 290 ReceivedFecPacket* fec_packet);
293 291
294 // Attempt to recover missing packets, using the internally stored 292 // Attempt to recover missing packets, using the internally stored
295 // received FEC packets. 293 // received FEC packets.
296 void AttemptRecovery(RecoveredPacketList* recovered_packets); 294 void AttemptRecovery(RecoveredPacketList* recovered_packets);
297 295
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 size_t max_packet_overhead); 410 size_t max_packet_overhead);
413 411
414 const size_t max_media_packets_; 412 const size_t max_media_packets_;
415 const size_t max_fec_packets_; 413 const size_t max_fec_packets_;
416 const size_t max_packet_overhead_; 414 const size_t max_packet_overhead_;
417 }; 415 };
418 416
419 } // namespace webrtc 417 } // namespace webrtc
420 418
421 #endif // MODULES_RTP_RTCP_SOURCE_FORWARD_ERROR_CORRECTION_H_ 419 #endif // MODULES_RTP_RTCP_SOURCE_FORWARD_ERROR_CORRECTION_H_
OLDNEW
« no previous file with comments | « modules/rtp_rtcp/source/flexfec_receiver_unittest.cc ('k') | modules/rtp_rtcp/source/forward_error_correction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698