| Index: webrtc/modules/rtp_rtcp/source/forward_error_correction.h
|
| diff --git a/webrtc/modules/rtp_rtcp/source/forward_error_correction.h b/webrtc/modules/rtp_rtcp/source/forward_error_correction.h
|
| index 873de34aa66d03be849d3181db9e22241a65e2c9..5ccfe789bc223800b445f7d5b6a7f4fe4eebcba4 100644
|
| --- a/webrtc/modules/rtp_rtcp/source/forward_error_correction.h
|
| +++ b/webrtc/modules/rtp_rtcp/source/forward_error_correction.h
|
| @@ -21,9 +21,6 @@
|
|
|
| namespace webrtc {
|
|
|
| -// Forward declaration.
|
| -class FecPacket;
|
| -
|
| // Performs codec-independent forward error correction (FEC), based on RFC 5109.
|
| // Option exists to enable unequal protection (UEP) across packets.
|
| // This is not to be confused with protection within packets
|
| @@ -59,9 +56,13 @@ class ForwardErrorCorrection {
|
| // TODO(holmer): Refactor into a proper class.
|
| class SortablePacket {
|
| public:
|
| - // True if first is <= than second.
|
| - static bool LessThan(const SortablePacket* first,
|
| - const SortablePacket* second);
|
| + // Functor which returns true if the sequence number of |first|
|
| + // is < the sequence number of |second|.
|
| + class LessThan {
|
| + public:
|
| + template <typename S, typename T>
|
| + bool operator() (const S& first, const T& second);
|
| + };
|
|
|
| uint16_t seq_num;
|
| };
|
| @@ -85,8 +86,8 @@ class ForwardErrorCorrection {
|
| // TODO(holmer): Refactor into a proper class.
|
| class ReceivedPacket : public SortablePacket {
|
| public:
|
| - ReceivedPacket();
|
| - ~ReceivedPacket();
|
| + ReceivedPacket() = default;
|
| + ~ReceivedPacket() = default;
|
|
|
| uint32_t ssrc; // SSRC of the current frame. Must be set for FEC
|
| // packets, but not required for media packets.
|
| @@ -100,8 +101,8 @@ class ForwardErrorCorrection {
|
| // TODO(holmer): Refactor into a proper class.
|
| class RecoveredPacket : public SortablePacket {
|
| public:
|
| - RecoveredPacket();
|
| - ~RecoveredPacket();
|
| + RecoveredPacket() = default;
|
| + ~RecoveredPacket() = default;
|
|
|
| bool was_recovered; // Will be true if this packet was recovered by
|
| // the FEC. Otherwise it was a media packet passed in
|
| @@ -113,9 +114,9 @@ class ForwardErrorCorrection {
|
| rtc::scoped_refptr<Packet> pkt; // Pointer to the packet storage.
|
| };
|
|
|
| - typedef std::list<Packet*> PacketList;
|
| - typedef std::list<ReceivedPacket*> ReceivedPacketList;
|
| - typedef std::list<RecoveredPacket*> RecoveredPacketList;
|
| + typedef std::list<std::unique_ptr<Packet>> PacketList;
|
| + typedef std::list<std::unique_ptr<ReceivedPacket>> ReceivedPacketList;
|
| + typedef std::list<std::unique_ptr<RecoveredPacket>> RecoveredPacketList;
|
|
|
| ForwardErrorCorrection();
|
| virtual ~ForwardErrorCorrection();
|
| @@ -159,7 +160,7 @@ class ForwardErrorCorrection {
|
| int32_t GenerateFEC(const PacketList& media_packet_list,
|
| uint8_t protection_factor, int num_important_packets,
|
| bool use_unequal_protection, FecMaskType fec_mask_type,
|
| - PacketList* fec_packet_list);
|
| + std::list<Packet*>* fec_packet_list);
|
|
|
| /**
|
| * Decodes a list of media and FEC packets. It will parse the input received
|
| @@ -206,7 +207,30 @@ class ForwardErrorCorrection {
|
| void ResetState(RecoveredPacketList* recovered_packet_list);
|
|
|
| private:
|
| - typedef std::list<FecPacket*> FecPacketList;
|
| + // Forward declarations.
|
| + class ProtectedPacket;
|
| + class ReceivedFecPacket;
|
| +
|
| + typedef std::list<std::unique_ptr<ProtectedPacket>> ProtectedPacketList;
|
| + typedef std::list<std::unique_ptr<ReceivedFecPacket>> ReceivedFecPacketList;
|
| +
|
| + // Used to link media packets to their protecting FEC packets.
|
| + //
|
| + // TODO(holmer): Refactor into a proper class.
|
| + class ProtectedPacket : public ForwardErrorCorrection::SortablePacket {
|
| + public:
|
| + rtc::scoped_refptr<ForwardErrorCorrection::Packet> pkt;
|
| + };
|
| +
|
| + // Used for internal storage of received FEC packets in a list.
|
| + //
|
| + // TODO(holmer): Refactor into a proper class.
|
| + class ReceivedFecPacket : public ForwardErrorCorrection::SortablePacket {
|
| + public:
|
| + ProtectedPacketList protected_pkt_list;
|
| + uint32_t ssrc; // SSRC of the current frame.
|
| + rtc::scoped_refptr<ForwardErrorCorrection::Packet> pkt;
|
| + };
|
|
|
| // Analyzes |media_packets| for holes in the sequence and inserts zero columns
|
| // into the |packet_mask| where those holes are found. Zero columns means that
|
| @@ -268,7 +292,8 @@ class ForwardErrorCorrection {
|
|
|
| // Assigns pointers to already recovered packets covered by this FEC packet.
|
| static void AssignRecoveredPackets(
|
| - FecPacket* fec_packet, const RecoveredPacketList* recovered_packets);
|
| + ReceivedFecPacket* fec_packet,
|
| + const RecoveredPacketList* recovered_packets);
|
|
|
| // Insert into recovered list in correct position.
|
| void InsertRecoveredPacket(RecoveredPacket* rec_packet_to_insert,
|
| @@ -278,7 +303,7 @@ class ForwardErrorCorrection {
|
| void AttemptRecover(RecoveredPacketList* recovered_packet_list);
|
|
|
| // Initializes the packet recovery using the FEC packet.
|
| - static bool StartPacketRecovery(const FecPacket* fec_packet,
|
| + static bool StartPacketRecovery(const ReceivedFecPacket* fec_packet,
|
| RecoveredPacket* recovered);
|
|
|
| // Performs XOR between |src_packet| and |dst_packet| and stores the result
|
| @@ -289,21 +314,21 @@ class ForwardErrorCorrection {
|
| static bool FinishPacketRecovery(RecoveredPacket* recovered);
|
|
|
| // Recover a missing packet.
|
| - bool RecoverPacket(const FecPacket* fec_packet,
|
| + bool RecoverPacket(const ReceivedFecPacket* fec_packet,
|
| RecoveredPacket* rec_packet_to_insert);
|
|
|
| // Get the number of missing media packets which are covered by this
|
| // FEC packet. An FEC packet can recover at most one packet, and if zero
|
| // packets are missing the FEC packet can be discarded.
|
| // This function returns 2 when two or more packets are missing.
|
| - static int NumCoveredPacketsMissing(const FecPacket* fec_packet);
|
| + static int NumCoveredPacketsMissing(const ReceivedFecPacket* fec_packet);
|
|
|
| - static void DiscardFECPacket(FecPacket* fec_packet);
|
| - static void DiscardOldPackets(RecoveredPacketList* recovered_packet_list);
|
| + static void DiscardOldRecoveredPackets(
|
| + RecoveredPacketList* recovered_packet_list);
|
| static uint16_t ParseSequenceNumber(uint8_t* packet);
|
|
|
| - std::vector<Packet> generated_fec_packets_;
|
| - FecPacketList fec_packet_list_;
|
| + std::vector<Packet> generated_fec_packet_list_;
|
| + ReceivedFecPacketList received_fec_packet_list_;
|
| };
|
| } // namespace webrtc
|
| #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_FORWARD_ERROR_CORRECTION_H_
|
|
|