UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
fec Struct Referenceabstract

#include <fec.h>

Inheritance diagram for fec:
Inheritance graph
Collaboration diagram for fec:
Collaboration graph

Public Member Functions

virtual ~fec ()
 
virtual bool decode (char *in, int in_len, char **out, int *out_len, const std::map< int, int > &)=0
 
virtual audio_frame2 encode (audio_frame2 const &)
 
virtual std::shared_ptr< video_frame > encode (std::shared_ptr< video_frame >)=0
 

Static Public Member Functions

static fec * create_from_config (const char *str, bool is_audio) noexcept
 
static fec * create_from_desc (struct fec_desc) noexcept
 
static enum fec_type fec_type_from_pt (int pt) throw ()
 
static int pt_from_fec_type (enum tx_media_type media_type, enum fec_type fec_type, bool encrypted) throw ()
 

Detailed Description

Definition at line 51 of file fec.h.

Constructor & Destructor Documentation

◆ ~fec()

virtual fec::~fec ( )
inlinevirtual

Definition at line 65 of file fec.h.

65{}

Member Function Documentation

◆ create_from_config()

fec * fec::create_from_config ( const char * str,
bool is_audio )
staticnoexcept

Definition at line 62 of file fec.cpp.

63{
64 try {
65 if (strncmp(c_str, "LDGM percents ", strlen("LDGM percents ")) == 0) {
66 char *str = strdup(c_str);
67 char *ptr = str + strlen("LDGM percents ");
68 char *save_ptr = nullptr;
69 char *item = nullptr;
70 item = strtok_r(ptr, " ", &save_ptr);
71 assert (item != nullptr);
72 int mtu_len = stoi(item);
73 assert(mtu_len > 0);
74 item = strtok_r(nullptr, " ", &save_ptr);
75 assert (item != nullptr);
76 int data_len = stoi(item);
77 assert(data_len > 0);
78 item = strtok_r(nullptr, " ", &save_ptr);
79 assert (item != nullptr);
80 double loss_pct = stof(item);
81 assert(loss_pct > 0.0);
82 fec *ret = new ldgm(mtu_len, data_len, loss_pct);
83 free(str);
84 return ret;
85 }
86 if (strncmp(c_str, "LDGM cfg ", strlen("LDGM cfg ")) == 0) {
87 return new ldgm(c_str + strlen("LDGM cfg "));
88 }
89 if (strncmp(c_str, "RS cfg ", strlen("RS cfg ")) == 0) {
90 return new rs(c_str + strlen("rs cfg "), is_audio);
91 }
92 throw ug_runtime_error("Unrecognized FEC configuration!");
93 } catch (string const &s) {
94 LOG(LOG_LEVEL_ERROR) << s << "\n";
95 } catch (exception const &e) {
96 LOG(LOG_LEVEL_ERROR) << e.what() << "\n";
97 } catch (int i) {
98 if (i != 0) {
99 LOG(LOG_LEVEL_ERROR) << "FEC initialization returned " << i << "\n";
100 }
101 } catch (...) {
102 LOG(LOG_LEVEL_ERROR) << "Unknown FEC error!\n";
103 }
104 return nullptr;
105}
#define LOG_LEVEL_ERROR
general errors
Definition debug.h:59
#define LOG(level)
Definition debug.h:313
Definition fec.h:51
Definition hd-rum.c:27
Definition ldgm.h:54
Definition rs.h:49

References LOG, and LOG_LEVEL_ERROR.

Referenced by audio_sender_process_message(), and rtp_video_rxtx::process_sender_message().

◆ create_from_desc()

fec * fec::create_from_desc ( struct fec_desc desc)
staticnoexcept

Definition at line 107 of file fec.cpp.

108{
109 try {
110 switch (desc.type) {
111 case FEC_LDGM:
112 return new ldgm(desc.k, desc.m, desc.c, desc.seed);
113 case FEC_RS:
114 return new rs(desc.k, desc.k + desc.m);
115 default:
116 abort();
117 }
118 } catch (string const &s) {
119 LOG(LOG_LEVEL_ERROR) << s << "\n";
120 } catch (exception const &e) {
121 LOG(LOG_LEVEL_ERROR) << e.what() << "\n";
122 } catch (int i) {
123 if (i != 0) {
124 LOG(LOG_LEVEL_ERROR) << "FEC initialization returned " << i << "\n";
125 }
126 } catch (...) {
127 LOG(LOG_LEVEL_ERROR) << "Unknown FEC error!\n";
128 }
129 return nullptr;
130
131}
struct video_desc desc
@ FEC_LDGM
Definition types.h:203
@ FEC_RS
Definition types.h:204

References desc, FEC_LDGM, FEC_RS, LOG, and LOG_LEVEL_ERROR.

Referenced by audio_fec_decode(), and fec_thread().

◆ decode()

virtual bool fec::decode ( char * in,
int in_len,
char ** out,
int * out_len,
const std::map< int, int > &  )
pure virtual
Return values
trueif whole frame was reconstructed
falseif decoder was unable to reconstruct the frame However, if it was reconstructed at least partially (or the code is a systematic one) and length can be read, set len to a non-zero value.

Implemented in ldgm, and rs.

Referenced by audio_fec_decode(), and fec_thread().

◆ encode() [1/2]

virtual audio_frame2 fec::encode ( audio_frame2 const & )
inlinevirtual

Reimplemented in rs.

Definition at line 53 of file fec.h.

53 {
54 throw std::logic_error("Selected FEC not implemented for audio!");
55 }

◆ encode() [2/2]

virtual std::shared_ptr< video_frame > fec::encode ( std::shared_ptr< video_frame > )
pure virtual

Implemented in ldgm, and rs.

Referenced by audio_sender_thread().

◆ fec_type_from_pt()

enum fec_type fec::fec_type_from_pt ( int pt)
throw ( )
static

Definition at line 157 of file fec.cpp.

158{
159 switch (pt) {
160 case PT_VIDEO:
161 case PT_ENCRYPT_VIDEO:
162 return FEC_NONE;
163 case PT_VIDEO_LDGM:
165 return FEC_LDGM;
166 case PT_VIDEO_RS:
168 return FEC_RS;
169 default:
170 abort();
171 }
172}
#define PT_ENCRYPT_VIDEO
Definition rtp_types.h:69
#define PT_ENCRYPT_VIDEO_RS
Definition rtp_types.h:74
#define PT_VIDEO
Definition rtp_types.h:66
#define PT_VIDEO_LDGM
Definition rtp_types.h:68
#define PT_VIDEO_RS
Definition rtp_types.h:72
#define PT_ENCRYPT_VIDEO_LDGM
Definition rtp_types.h:73
@ FEC_NONE
Definition types.h:201

References FEC_LDGM, FEC_NONE, FEC_RS, PT_ENCRYPT_VIDEO, PT_ENCRYPT_VIDEO_LDGM, PT_ENCRYPT_VIDEO_RS, PT_VIDEO, PT_VIDEO_LDGM, and PT_VIDEO_RS.

Referenced by decode_video_frame().

◆ pt_from_fec_type()

int fec::pt_from_fec_type ( enum tx_media_type media_type,
enum fec_type fec_type ,
bool encrypted )
throw ( )
static

Definition at line 133 of file fec.cpp.

134{
135 if (media_type == TX_MEDIA_VIDEO) {
136 switch (fec_type) {
137 case FEC_NONE:
138 return encrypted ? PT_ENCRYPT_VIDEO : PT_VIDEO;
139 case FEC_LDGM:
140 return encrypted ? PT_ENCRYPT_VIDEO_LDGM : PT_VIDEO_LDGM;
141 case FEC_RS:
142 return encrypted ? PT_ENCRYPT_VIDEO_RS : PT_VIDEO_RS;
143 default: break;
144 }
145 } else {
146 switch (fec_type) {
147 case FEC_NONE:
148 return encrypted ? PT_ENCRYPT_AUDIO : PT_AUDIO;
149 case FEC_RS:
150 return encrypted ? PT_ENCRYPT_AUDIO_RS : PT_AUDIO_RS;
151 default: break;
152 }
153 }
154 UG_ASSERT(0 && "Unsupported media/FEC type combination");
155}
#define UG_ASSERT(cond)
unconditional alternative to assert that is not affected by NDEBUG macro
Definition macros.h:78
#define PT_AUDIO
Definition rtp_types.h:67
#define PT_ENCRYPT_AUDIO_RS
Definition rtp_types.h:76
#define PT_AUDIO_RS
Definition rtp_types.h:75
#define PT_ENCRYPT_AUDIO
Definition rtp_types.h:70
@ TX_MEDIA_VIDEO
Definition types.h:365
fec_type
Definition types.h:200

References FEC_LDGM, FEC_NONE, FEC_RS, PT_AUDIO, PT_AUDIO_RS, PT_ENCRYPT_AUDIO, PT_ENCRYPT_AUDIO_RS, PT_ENCRYPT_VIDEO, PT_ENCRYPT_VIDEO_LDGM, PT_ENCRYPT_VIDEO_RS, PT_VIDEO, PT_VIDEO_LDGM, PT_VIDEO_RS, TX_MEDIA_VIDEO, and UG_ASSERT.

Referenced by fec_pt_from_fec_type().


The documentation for this struct was generated from the following files: