Skip to content

Commit a49aa71

Browse files
committed
print received FEC configuration and display in 'i'
(in the keycontrol mode when 'i' is pressed)
1 parent 4ab52a4 commit a49aa71

4 files changed

Lines changed: 61 additions & 1 deletion

File tree

src/keyboard_control.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,18 @@ void keyboard_control::impl::info()
807807
<< response_get_text(r) << "\n";
808808
}
809809
free_response(r);
810+
811+
m = (struct msg_universal *) new_message(
812+
sizeof(struct msg_universal));
813+
strcpy(m->text, "get_fec");
814+
r = send_message_sync(
815+
m_root, "receiver.decoder", (struct message *) m, 100,
816+
SEND_MESSAGE_FLAG_QUIET | SEND_MESSAGE_FLAG_NO_STORE);
817+
if (response_get_status(r) == RESPONSE_OK) {
818+
col() << TBOLD("Received video FEC: ")
819+
<< response_get_text(r) << "\n";
820+
}
821+
free_response(r);
810822
}
811823

812824
{

src/rtp/fec.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#include "ug_runtime_error.hpp"
5555
#include "utils/macros.h"
5656

57+
#define MOD_NAME "[fec] "
58+
5759
using std::exception;
5860
using std::stof;
5961
using std::stoi;
@@ -104,8 +106,40 @@ fec *fec::create_from_config(const char *c_str, bool is_audio) noexcept
104106
return nullptr;
105107
}
106108

109+
static const char *
110+
get_fec_name(enum fec_type type)
111+
{
112+
switch (type) {
113+
case FEC_NONE:
114+
return "(none)";
115+
case FEC_MULT:
116+
return "mult";
117+
case FEC_LDGM:
118+
return "LDGM";
119+
case FEC_RS:
120+
return "Reed-Solomon";
121+
}
122+
abort();
123+
}
124+
125+
const char *get_fec_desc(struct fec_desc desc, size_t buflen, char *buf)
126+
{
127+
if (desc.type == FEC_NONE) {
128+
return "none or multiplication";
129+
}
130+
int ret =
131+
snprintf(buf, buflen, "type=%s, k=%u, m=%u, c=%u, seed=%u, ss=%u",
132+
get_fec_name(desc.type), desc.k, desc.m, desc.c, desc.seed,
133+
desc.symbol_size);
134+
assert(ret < (int) buflen);
135+
return buf;
136+
}
137+
107138
fec *fec::create_from_desc(struct fec_desc desc) noexcept
108139
{
140+
char buf[STR_LEN];
141+
MSG(INFO, "Receiving FEC - %s\n", get_fec_desc(desc, sizeof buf, buf));
142+
109143
try {
110144
switch (desc.type) {
111145
case FEC_LDGM:

src/rtp/fec.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author Martin Pulec <pulec@cesnet.cz>
44
*/
55
/*
6-
* Copyright (c) 2014-2021 CESNET z.s.p.o.
6+
* Copyright (c) 2014-2026 CESNET, zájmové sdružení právnických osob
77
* All rights reserved.
88
*
99
* Redistribution and use in source and binary forms, with or without
@@ -72,9 +72,14 @@ struct fec {
7272
#endif // __cplusplus
7373

7474
#ifdef __cplusplus
75+
#include <cstddef>
7576
extern "C" {
77+
#else
78+
#include <stddef.h>
7679
#endif
80+
7781
int fec_pt_from_fec_type(enum tx_media_type media_type, enum fec_type fec_type, bool encrypted);
82+
const char *get_fec_desc(struct fec_desc desc, size_t buflen, char *buf);
7883
#ifdef __cplusplus
7984
}
8085
#endif

src/rtp/video_decoders.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ struct state_video_decoder
353353
thread decompress_thread_id,
354354
fec_thread_id;
355355
struct video_desc received_vid_desc = {}; ///< description of the network video
356+
struct fec_desc received_vid_fec = {};
356357
struct pixfmt_desc received_int_desc = {}; ///< compression int desc
357358
struct video_desc display_desc = {}; ///< description of the mode that display is currently configured to
358359

@@ -448,6 +449,8 @@ static void *fec_thread(void *args) {
448449
exit_uv(1);
449450
goto cleanup;
450451
}
452+
unique_lock<mutex> lk(decoder->lock);
453+
decoder->received_vid_fec = desc;
451454
}
452455
}
453456

@@ -1874,6 +1877,12 @@ static void decoder_process_message(struct module *m)
18741877
string video_desc = s->received_vid_desc;
18751878
s->lock.unlock();
18761879
r = new_response(RESPONSE_OK, video_desc.c_str());
1880+
} else if (strcmp(m_univ->text, "get_fec") == 0) {
1881+
unique_lock<mutex> lk(s->lock);
1882+
char buf[STR_LEN];
1883+
r = new_response(
1884+
RESPONSE_OK,
1885+
get_fec_desc(s->received_vid_fec, sizeof buf, buf));
18771886
} else {
18781887
r = new_response(RESPONSE_NOT_FOUND, NULL);
18791888
}

0 commit comments

Comments
 (0)