From ca7dd07261de50576590fea227c8fbf345282e1f Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 2 Aug 2014 12:28:19 +0200 Subject: Add the possibility to specify protection profile --- doc/example.mux | 15 ++++++++++++++- src/DabMux.cpp | 25 +++++++++++++++++++------ src/MuxElements.h | 1 - src/ParserCmdline.cpp | 1 - src/ParserConfigfile.cpp | 20 +++++++++++++++++--- src/utils.cpp | 2 -- 6 files changed, 50 insertions(+), 14 deletions(-) diff --git a/doc/example.mux b/doc/example.mux index f5a2476..65127d9 100644 --- a/doc/example.mux +++ b/doc/example.mux @@ -104,7 +104,20 @@ subchannels { nonblock false bitrate 128 id 10 - protection 5 + + ; type audio subchannels automatically use + ; UEP, unless the bitrate is 8, 16, 24, 40 or 144kbit/s + ; (EN 300 401 Clause 6.2.1) + ; this can be overridden with the option protection-profile + protection-profile EEP_A + ; supported options: UEP (use only for type audio!) + ; EEP_A (for all bitrates) + ; EEP_B (bitrates multiple of 32kbit/s) + + ; Set the protection level, possible values depend + ; on the protection profile: + ; UEP profile: 1 to 5; EEP profiles: 1 to 4 + protection 4 } sub-lu { type audio diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 6f826c0..655985f 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -308,7 +308,6 @@ int main(int argc, char *argv[]) unsigned long currentFrame; int returnCode = 0; - int result; int cur; unsigned char etiFrame[6144]; unsigned short index = 0; @@ -567,14 +566,14 @@ int main(int argc, char *argv[]) } // TODO Check errors - result = (*subchannel)->input->setBitrate( (*subchannel)->bitrate); - if (result <= 0) { + int subch_bitrate = (*subchannel)->input->setBitrate( (*subchannel)->bitrate); + if (subch_bitrate <= 0) { etiLog.log(error, "can't set bitrate for source %s\n", (*subchannel)->inputName); returnCode = -1; throw MuxInitException(); } - (*subchannel)->bitrate = result; + (*subchannel)->bitrate = subch_bitrate; /* Use EEP unless we find a UEP configuration * UEP is only used for MPEG audio, but some bitrates don't @@ -593,10 +592,24 @@ int main(int argc, char *argv[]) } } } + + /* EEP B can only be used for subchannels with bitrates + * multiple of 32kbit/s + */ + if ( protection->form == EEP && + protection->eep.profile == EEP_B && + subch_bitrate % 32 != 0 ) { + etiLog.level(error) << + "Cannot use EEP_B protection for subchannel " << + (*subchannel)->inputName << + ": bitrate not multiple of 32kbit/s"; + returnCode = -1; + throw MuxInitException(); + } } if (ensemble->subchannels.size() == 0) { - etiLog.log(error, "can't multiplexed no subchannel!\n"); + etiLog.log(error, "can't multiplex no subchannel!\n"); returnCode = -1; throw MuxInitException(); } @@ -1920,7 +1933,7 @@ int main(int argc, char *argv[]) TagESTn* tag = edi_subchannelToTag[*subchannel]; int sizeSubchannel = getSizeByte(*subchannel); - result = (*subchannel)->input->readFrame( + int result = (*subchannel)->input->readFrame( &etiFrame[index], sizeSubchannel); if (result < 0) { diff --git a/src/MuxElements.h b/src/MuxElements.h index f1097c0..6607c20 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -125,7 +125,6 @@ class dabEnsemble : public RemoteControllable { struct dabProtectionUEP { - unsigned char tableSwitch; unsigned char tableIndex; }; diff --git a/src/ParserCmdline.cpp b/src/ParserCmdline.cpp index 9768d20..6dcee55 100644 --- a/src/ParserCmdline.cpp +++ b/src/ParserCmdline.cpp @@ -402,7 +402,6 @@ bool parse_cmdline(char **argv, if (c == 'A') { protection->form = UEP; protection->level = 2; - protection->uep.tableSwitch = 0; protection->uep.tableIndex = 0; } else { protection->form = EEP; diff --git a/src/ParserConfigfile.cpp b/src/ParserConfigfile.cpp index 943e500..f4c1075 100644 --- a/src/ParserConfigfile.cpp +++ b/src/ParserConfigfile.cpp @@ -846,7 +846,6 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, if (type == "audio") { protection->form = UEP; protection->level = 2; - protection->uep.tableSwitch = 0; protection->uep.tableIndex = 0; } else { protection->level = 2; @@ -934,7 +933,22 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, } } - /* Get protection */ + /* Get optional protection profile */ + string profile = pt.get("protection-profile", ""); + + if (profile == "EEP_A") { + protection->form = EEP; + protection->eep.profile = EEP_A; + } + else if (profile == "EEP_B") { + protection->form = EEP; + protection->eep.profile = EEP_B; + } + else if (profile == "UEP") { + protection->form = UEP; + } + + /* Get protection level */ try { int level = pt.get("protection"); @@ -947,7 +961,7 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, throw runtime_error(ss.str()); } } - else { + else if (protection->form == EEP) { if ((level < 1) || (level > 4)) { stringstream ss; ss << "Subchannel with uid " << subchanuid << diff --git a/src/utils.cpp b/src/utils.cpp index 654759d..85f42d2 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -418,8 +418,6 @@ void printSubchannels(vector& subchannels) (*subchannel)->bitrate); if (protection->form == UEP) { etiLog.log(info, " protection: UEP %i", protection->level + 1); - etiLog.log(info, " switch: %i", - protection->uep.tableSwitch); etiLog.log(info, " index: %i", protection->uep.tableIndex); } -- cgit v1.2.3