/********************************************************************* * * AUTHORIZATION TO USE AND DISTRIBUTE * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: * * (1) source code distributions retain this paragraph in its entirety, * * (2) distributions including binary code include this paragraph in * its entirety in the documentation or other materials provided * with the distribution, and * * (3) all advertising materials mentioning features or use of this * software display the following acknowledgment: * * "This product includes software written and developed * by Brian Adamson and Joe Macker of the Naval Research * Laboratory (NRL)." * * The name of NRL, the name(s) of NRL employee(s), or any entity * of the United States Government may not be used to endorse or * promote products derived from this software, nor does the * inclusion of the NRL written and developed software directly or * indirectly suggest NRL or United States Government endorsement * of this product. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ********************************************************************/ #ifndef _NORM_ENCODER #define _NORM_ENCODER #include "protokit.h" // protolib stuff class NormTelemetryContext { public: virtual ~NormTelemetryContext() {} virtual double GetGrtt() const = 0; virtual double GetTxRate() const = 0; virtual unsigned int GetGroupSize() const = 0; virtual double GetCurrentTime() const = 0; }; class NormEncoder { public: virtual ~NormEncoder(); virtual bool Init(unsigned int numData, unsigned int numParity, UINT16 vectorSize) = 0; virtual void Destroy() = 0; virtual void Encode(unsigned int segmentId, const char *dataVector, char **parityVectorList) = 0; // Rateless codes generate parity symbols on demand. Unlike the block-oriented // Encode() above, EncodeParity() is handed the block's source symbol vectors so a // fountain/rateless encoder can synthesize the "parityId"-th (innovative) repair // symbol without having to cache source state across calls. virtual void EncodeParity(unsigned int parityId, const char** sourceVectorList, unsigned int numData, char* parityVector) { (void)parityId; (void)sourceVectorList; (void)numData; (void)parityVector; } virtual bool IsRateless() const { return false; } virtual UINT16 CalculateProactiveParity(unsigned int blockId, UINT16 numData, const NormTelemetryContext& context) { return 0; } virtual UINT16 CalculateReactiveParity(unsigned int blockId, UINT16 requestedErasures, const NormTelemetryContext& context) { return requestedErasures; } }; // end class NormEncoder class NormDecoder { public: virtual ~NormDecoder(); virtual bool Init(unsigned int numData, unsigned int numParity, UINT16 vectorSize) = 0; virtual void Destroy() = 0; // Decode in place, filling any erased source symbol vectors in "vectorList". // For ideal (MDS) codes (e.g. Reed-Solomon) the return value is unused by the // receiver, which assumes success whenever it holds >= erasureCount repair symbols. // For rateless/non-ideal codes the return value MUST be the number of source // symbol erasures that could NOT be recovered (0 == fully decoded); the receiver // uses this to keep the block pending and NACK for additional repair symbols. virtual int Decode(char** vectorList, unsigned int numData, unsigned int erasureCount, unsigned int* erasureLocs) = 0; }; // end class NormDecoder #endif // _NORM_ENCODER