From dcf8a55ea3d46776f0ba32f28e7e936b92bf6e86 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli (think)" Date: Tue, 28 Aug 2012 16:03:53 +0200 Subject: crc-dabmux: configuration file: added shortlabel support --- configure | 9 +++--- doc/example.config | 10 +++++- src/ParserConfigfile.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++++--- src/ParserConfigfile.h | 2 ++ 4 files changed, 95 insertions(+), 10 deletions(-) diff --git a/configure b/configure index 3d75383..bb8af15 100755 --- a/configure +++ b/configure @@ -4511,9 +4511,9 @@ fi # Checks for libraries. -# FIXME: Replace `main' with a function in `-lfec': + #AC_CHECK_LIB([fec], [init_rs_char], [], AC_MSG_ERROR([libfec is required])) -# FIXME: Replace `main' with a function in `-lpthread': + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } @@ -4602,7 +4602,7 @@ fi if test "x$want_boost" = "xyes"; then - boost_lib_version_req=1.50.0 + boost_lib_version_req=1.41.0 boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([0-9]*\.[0-9]*\)'` boost_lib_version_req_major=`expr $boost_lib_version_req : '\([0-9]*\)'` boost_lib_version_req_minor=`expr $boost_lib_version_req : '[0-9]*\.\([0-9]*\)'` @@ -4812,7 +4812,7 @@ $as_echo "$as_me: We could not detect the boost libraries (version $boost_lib_ve $as_echo "$as_me: Your boost libraries seems to old (version $_version)." >&6;} fi # execute ACTION-IF-NOT-FOUND (if present): - as_fn_error $? "BOOST 1.42 or later is required" "$LINENO" 5 + as_fn_error $? "BOOST 1.41 or later is required" "$LINENO" 5 else @@ -4828,7 +4828,6 @@ $as_echo "#define HAVE_BOOST /**/" >>confdefs.h fi -#AC_CHECK_LIB([boost_system], [main], [], [AC_MSG_ERROR([library boost_system is missing])]) # Checks for header files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OS type" >&5 diff --git a/doc/example.config b/doc/example.config index 028919f..0b309eb 100644 --- a/doc/example.config +++ b/doc/example.config @@ -39,6 +39,7 @@ ensemble { id 20479 ecc 1249 ; Extended Country Code (decimal) label "TuxMux" + shortlabel "Tux" } ; Definition of DAB services @@ -47,13 +48,14 @@ services { ; only used throughout the configuration file funk { label "Funk" + shortlabel "Fu" pty 0 language 0 ; also supports id } luschtig { label "Luschtig" - ; pty, language and id can be omitted, and will take default values + ; pty, language, shortlabel and id can be omitted, and will take default values } } @@ -67,6 +69,7 @@ subchannels { nonblock false bitrate 128 id 10 + protection 5 } luschtig { type audio @@ -74,6 +77,7 @@ subchannels { nonblock false bitrate 128 id 3 + ;protection 5 } } @@ -82,11 +86,15 @@ components { ; the component unique identifiers are not used anywhere, but ; are useful to disambiguate different components. funky { + label funk + shortlabel fu service funk subchannel funk } luschtigy { + label luschtig + shortlabel lu service luschtig subchannel luschtig } diff --git a/src/ParserConfigfile.cpp b/src/ParserConfigfile.cpp index 24b9f22..13fe80d 100644 --- a/src/ParserConfigfile.cpp +++ b/src/ParserConfigfile.cpp @@ -99,6 +99,44 @@ typedef DWORD32 uint32_t; using namespace std; +void set_short_label(dabLabel& label, std::string& slabel, const char* applies_to) +{ + char* end; + const char* lab; + label.flag = strtoul(slabel.c_str(), &end, 0); + if (*end != 0) { + lab = slabel.c_str(); + label.flag = 0; + for (int i = 0; i < 32; ++i) { + if (*lab == label.text[i]) { + label.flag |= 0x8000 >> i; + if (*(++lab) == 0) { + break; + } + } + } + if (*lab != 0) { + stringstream ss; + ss << "Error : " << applies_to << " short label '" << slabel << + "'!\n" << "Not in label '" << label.text << "' !\n"; + throw runtime_error(ss.str()); + } + } + int count = 0; + for (int i = 0; i < 16; ++i) { + if (label.flag & (1 << i)) { + ++count; + } + } + if (count > 8) { + stringstream ss; + ss << applies_to << " '" << slabel << "' short label too long!\n" + "Must be < 8 characters.\n"; + throw runtime_error(ss.str()); + } + +} + void parse_configfile(string configuration_file, vector &outputs, dabEnsemble* ensemble, @@ -158,6 +196,13 @@ void parse_configfile(string configuration_file, label.copy(ensemble->label.text, 16); ensemble->label.flag = 0xff00; + try { + string label = pt_ensemble.get("shortlabel"); + set_short_label(ensemble->label, label, "Ensemble"); + } + catch (ptree_error &e) { } + + /******************** READ SERVICES PARAMETERS *************/ map allservices; @@ -185,6 +230,16 @@ void parse_configfile(string configuration_file, } service->label.flag = 0xe01f; + try { + string label = pt_service.get("shortlabel"); + set_short_label(service->label, label, "Service"); + } + catch (ptree_error &e) { + etiLog.printHeader(TcpLog::WARNING, + "Service with uid %s has no short label.\n", serviceuid.c_str()); + } + + service->id = pt_service.get("id", DEFAULT_SERVICE_ID + ensemble->services.size()); service->pty = pt_service.get("pty", 0); service->language = pt_service.get("language", 0); @@ -219,7 +274,7 @@ void parse_configfile(string configuration_file, } catch (runtime_error &e) { etiLog.printHeader(TcpLog::ERR, - "%s", e.what()); + "%s\n", e.what()); throw e; } @@ -286,6 +341,27 @@ void parse_configfile(string configuration_file, component->subchId = subchannel->id; component->SCIdS = SCIdS_per_service[service]++; + try { + string label = pt_comp.get("label"); + + memset(component->label.text, 0, 16); + label.copy(component->label.text, 16); + component->label.flag = 0xff00; + } + catch (ptree_error &e) { + etiLog.printHeader(TcpLog::WARNING, + "Service with uid %s has no label.\n", componentuid.c_str()); + } + + try { + string label = pt_comp.get("shortlabel"); + set_short_label(component->label, label, "Component"); + } + catch (ptree_error &e) { + etiLog.printHeader(TcpLog::WARNING, + "Component with uid %s has no short label.\n", componentuid.c_str()); + } + ensemble->components.push_back(component); } @@ -628,13 +704,13 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, /* Get protection */ try { - int level = pt.get("protection"); + int level = pt.get("protection") - 1; if (protection->form == 0) { if ((level < 0) || (level > 4)) { stringstream ss; ss << "Subchannel with uid " << subchanuid << - "protection level must be between " + ": protection level must be between " "1 to 5 inclusively (current = " << level << " )"; throw runtime_error(ss.str()); } @@ -643,7 +719,7 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, if ((level < 0) || (level > 3)) { stringstream ss; ss << "Subchannel with uid " << subchanuid << - "protection level must be between " + ": protection level must be between " "1 to 4 inclusively (current = " << level << " )"; throw runtime_error(ss.str()); } diff --git a/src/ParserConfigfile.h b/src/ParserConfigfile.h index ef63eb2..a09d1fc 100644 --- a/src/ParserConfigfile.h +++ b/src/ParserConfigfile.h @@ -33,6 +33,8 @@ #include "MuxElements.h" #include +void set_short_label(dabLabel& label, std::string& slabel, const char* applies_to); + void parse_configfile(std::string configuration_file, vector &outputs, dabEnsemble* ensemble, -- cgit v1.2.3