aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/etisnoop.cpp59
-rw-r--r--src/fig1.cpp52
-rw-r--r--src/figs.hpp5
-rw-r--r--src/utils.cpp32
-rw-r--r--src/utils.hpp6
5 files changed, 109 insertions, 45 deletions
diff --git a/src/etisnoop.cpp b/src/etisnoop.cpp
index 1ebdf70..f41062a 100644
--- a/src/etisnoop.cpp
+++ b/src/etisnoop.cpp
@@ -117,6 +117,32 @@ int eti_analyse(eti_analyse_config_t &config);
const char *get_programme_type_str(size_t int_table_Id, size_t pty);
int sprintfMJD(char *dst, int mjd);
+static void print_fig_result(const fig_result_t& fig_result, const display_settings_t& disp)
+{
+ if (disp.print) {
+ for (const auto& msg : fig_result.msgs) {
+ std::string s;
+ for (int i = 0; i < msg.level; i++) {
+ s += " ";
+ }
+ s += msg.msg;
+ for (int i = 0; i < disp.indent; i++) {
+ printf("\t");
+ }
+ printf("%s\n", s.c_str());
+ }
+ if (not fig_result.errors.empty()) {
+ printf("ERRORS:\n");
+ for (const auto& err : fig_result.errors) {
+ for (int i = 0; i < disp.indent; i++) {
+ printf("\t");
+ }
+ printf("%s\n", err.c_str());
+ }
+ }
+ }
+}
+
#define no_argument 0
#define required_argument 1
#define optional_argument 2
@@ -603,7 +629,7 @@ int eti_analyse(eti_analyse_config_t &config)
else {
sprintf(sdesc, "id %d, len %d, not selected for decoding", i, stl[i]*8);
}
- if (get_verbosity() > 1) {
+ if (get_verbosity() > 2) {
printbuf("Stream Data", 1, streamdata, stl[i]*8, sdesc);
}
else {
@@ -696,26 +722,15 @@ void decodeFIG(
if (disp.print) {
sprintf(desc, "FIG %d/%d: C/N=%d OE=%d P/D=%d",
figtype, fig0.ext(), fig0.cn(), fig0.oe(), fig0.pd());
- printbuf(desc, disp.indent, f+1, figlen-1);
+ printfig(desc, disp, f+1, figlen-1);
}
figs.push_back(figtype, fig0.ext(), figlen);
auto fig_result = fig0_select(fig0, disp);
- for (const auto& msg : fig_result.msgs) {
- std::string s;
- for (int i = 0; i < msg.level; i++) {
- s += " ";
- }
- s += msg.msg;
- printbuf(s.c_str(), disp.indent+1, nullptr, 0);
- }
- if (not fig_result.errors.empty()) {
- printf("ERRORS:\n");
- for (const auto& err : fig_result.errors) {
- printbuf(err.c_str(), disp.indent+1, nullptr, 0);
- }
- }
+ fig_result.figtype = figtype;
+ fig_result.figext = fig0.ext();
+ print_fig_result(fig_result, disp+1);
rate_announce_fig(figtype, fig0.ext(), fig_result.complete);
}
@@ -726,11 +741,19 @@ void decodeFIG(
fig1_common_t fig1(f, figlen);
const display_settings_t disp(config.is_fig_to_be_printed(figtype, fig1.ext()), indent);
+ if (disp.print) {
+ sprintf(desc, "FIG %d/%d: OE=%d",
+ figtype, fig1.ext(), fig1.oe());
+ printfig(desc, disp, f+1, figlen-1);
+ }
figs.push_back(figtype, fig1.ext(), figlen);
- bool complete = fig1_select(fig1, disp);
- rate_announce_fig(figtype, fig1.ext(), complete);
+ auto fig_result = fig1_select(fig1, disp);
+ fig_result.figtype = figtype;
+ fig_result.figext = fig1.ext();
+ print_fig_result(fig_result, disp+1);
+ rate_announce_fig(figtype, fig1.ext(), fig_result.complete);
}
break;
case 2:
diff --git a/src/fig1.cpp b/src/fig1.cpp
index be2c2ba..bb2591c 100644
--- a/src/fig1.cpp
+++ b/src/fig1.cpp
@@ -1,6 +1,6 @@
/*
Copyright (C) 2014 CSP Innovazione nelle ICT s.c.a r.l. (http://www.csp.it/)
- Copyright (C) 2016 Matthias P. Braendli (http://www.opendigitalradio.org)
+ Copyright (C) 2017 Matthias P. Braendli (http://www.opendigitalradio.org)
Copyright (C) 2015 Data Path
This program is free software: you can redistribute it and/or modify
@@ -32,23 +32,19 @@
using namespace std;
// SHORT LABELS
-bool fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
+fig_result_t fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
{
- uint16_t ext,oe,charset;
+ uint16_t ext,charset;
uint16_t flag;
char label[17];
- char desc[256];
+ fig_result_t r;
uint8_t* f = fig1.f;
- const int figtype = 1;
charset = (f[0] & 0xF0) >> 4;
- oe = (f[0] & 0x08) >> 3;
+ //oe = (f[0] & 0x08) >> 3;
ext = f[0] & 0x07;
- sprintf(desc,
- "FIG %d/%d: OE=%d, Charset=%d",
- figtype, ext, oe, charset);
+ r.msgs.push_back(strprintf("Charset=%d", charset));
- printbuf(desc, disp, f+1, fig1.figlen-1);
memcpy(label, f+fig1.figlen-18, 16);
label[16] = 0x00;
flag = f[fig1.figlen-2] * 256 + \
@@ -59,8 +55,9 @@ bool fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
{ // ETSI EN 300 401 8.1.13
uint16_t eid;
eid = f[1] * 256 + f[2];
- sprintf(desc, "Ensemble ID 0x%04X label: \"%s\", Short label mask: 0x%04X", eid, label, flag);
- printinfo(desc, disp+1, 1);
+ r.msgs.push_back(strprintf("Ensemble ID: 0x%04X", eid));
+ r.msgs.push_back(strprintf("Label: \"%s\"", label));
+ r.msgs.push_back(strprintf("Short label mask: 0x%04X", flag));
}
break;
@@ -68,8 +65,9 @@ bool fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
{ // ETSI EN 300 401 8.1.14.1
uint16_t sid;
sid = f[1] * 256 + f[2];
- sprintf(desc, "Service ID 0x%X label: \"%s\", Short label mask: 0x%04X", sid, label, flag);
- printinfo(desc, disp+1, 1);
+ r.msgs.push_back(strprintf("Service ID: 0x%04X", sid));
+ r.msgs.push_back(strprintf("Label: \"%s\"", label));
+ r.msgs.push_back(strprintf("Short label mask: 0x%04X", flag));
}
break;
@@ -89,10 +87,10 @@ bool fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
f[4] * 256 + \
f[5];
}
- sprintf(desc,
- "Service ID 0x%X , Service Component ID 0x%04X Short, label: \"%s\", label mask: 0x%04X",
- sid, SCIdS, label, flag);
- printinfo(desc, disp+1, 1);
+ r.msgs.push_back(strprintf("Service ID: 0x%04X", sid));
+ r.msgs.push_back(strprintf("Service Component ID: 0x%04X", SCIdS));
+ r.msgs.push_back(strprintf("Label: \"%s\"", label));
+ r.msgs.push_back(strprintf("Short label mask: 0x%04X", flag));
}
break;
@@ -104,10 +102,9 @@ bool fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
f[3] * 256 + \
f[4];
- sprintf(desc,
- "Service ID 0x%X label: \"%s\", Short label mask: 0x%04X",
- sid, label, flag);
- printinfo(desc, disp+1, 1);
+ r.msgs.push_back(strprintf("Service ID: 0x%04X", sid));
+ r.msgs.push_back(strprintf("Label: \"%s\"", label));
+ r.msgs.push_back(strprintf("Short label mask: 0x%04X", flag));
}
break;
@@ -144,14 +141,17 @@ bool fig1_select(fig1_common_t& fig1, const display_settings_t &disp)
}
- sprintf(desc,"Service ID 0x%X , Service Component ID 0x%04X Short, X-PAD App %02X (%s), label: \"%s\", label mask: 0x%04X",
- sid, SCIdS, xpadapp, xpadappdesc.c_str(), label, flag);
- printbuf(desc,disp+1,NULL,0,"");
+ r.msgs.push_back(strprintf("Service ID: 0x%04X", sid));
+ r.msgs.push_back(strprintf("Service Component ID: 0x%04X", SCIdS));
+ r.msgs.push_back(strprintf("X-PAD App %02X (", xpadapp) + xpadappdesc + ")");
+ r.msgs.push_back(strprintf("Label: \"%s\"", label));
+ r.msgs.push_back(strprintf("Short label mask: 0x%04X", flag));
}
break;
}
// FIG1s always contain a complete set of information
- return true;
+ r.complete = true;
+ return r;
}
diff --git a/src/figs.hpp b/src/figs.hpp
index 5986f80..403970d 100644
--- a/src/figs.hpp
+++ b/src/figs.hpp
@@ -44,6 +44,9 @@ struct fig_result_t {
std::string msg;
};
+ int figtype = -1;
+ int figext = 0;
+
std::vector<msg_info_t> msgs;
std::vector<std::string> errors;
bool complete = false;
@@ -127,5 +130,5 @@ fig_result_t fig0_27(fig0_common_t& fig0, const display_settings_t &disp);
fig_result_t fig0_28(fig0_common_t& fig0, const display_settings_t &disp);
fig_result_t fig0_31(fig0_common_t& fig0, const display_settings_t &disp);
-bool fig1_select(fig1_common_t& fig1, const display_settings_t &disp);
+fig_result_t fig1_select(fig1_common_t& fig1, const display_settings_t &disp);
diff --git a/src/utils.cpp b/src/utils.cpp
index 75aa880..3e741c9 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -83,6 +83,38 @@ void printbuf(std::string header,
printbuf(header, disp, buffer, size, desc);
}
+void printfig(string header,
+ const display_settings_t &disp,
+ uint8_t* buffer,
+ size_t size,
+ string desc)
+{
+ if (disp.print) {
+ for (int i = 0; i < disp.indent; i++) {
+ printf("\t");
+ }
+
+ printf("%s", header.c_str());
+
+ if (verbosity > 1) {
+ if (size != 0) {
+ printf(": ");
+ }
+
+ for (size_t i = 0; i < size; i++) {
+ printf("%02x ", buffer[i]);
+ }
+ }
+
+ if (desc != "") {
+ printf(" [%s] ", desc.c_str());
+ }
+
+ printf("\n");
+ }
+}
+
+
void printbuf(string header,
const display_settings_t &disp,
uint8_t* buffer,
diff --git a/src/utils.hpp b/src/utils.hpp
index 8c72e8b..890bd50 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -54,6 +54,12 @@ void printbuf(std::string header,
size_t size,
std::string desc="");
+void printfig(std::string header,
+ const display_settings_t &disp,
+ uint8_t* buffer,
+ size_t size,
+ std::string desc="");
+
void printbuf(std::string header,
int indent,
uint8_t* buffer,