From 479b106611539785a92cd77bbf3124c26501fce2 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 17 Mar 2014 20:48:42 +0100 Subject: Add component iterator for FIG0/13 insertion --- src/DabMux.cpp | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 4c92d90..5fbc035 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -272,6 +272,7 @@ int main(int argc, char *argv[]) vector::iterator serviceFIG0_17; vector::iterator component = ensemble->components.end(); vector::iterator componentProgFIG0_8; + vector::iterator componentFIG0_13; vector::iterator componentDataFIG0_8; vector::iterator subchannel = ensemble->subchannels.end(); vector::iterator subchannelFIG0_1; @@ -619,6 +620,7 @@ int main(int argc, char *argv[]) serviceProgFIG0_2 = ensemble->services.end(); serviceDataFIG0_2 = ensemble->services.end(); componentProgFIG0_8 = ensemble->components.end(); + componentFIG0_13 = ensemble->components.end(); componentDataFIG0_8 = ensemble->components.end(); serviceFIG0_17 = ensemble->services.end(); subchannelFIG0_1 = ensemble->subchannels.end(); @@ -1476,16 +1478,21 @@ int main(int argc, char *argv[]) // FIG 0 / 13 fig0 = NULL; - for (component = ensemble->components.begin(); - component != ensemble->components.end(); - ++component) { + if (componentFIG0_13 == ensemble->components.end()) { + componentFIG0_13 = ensemble->components.begin(); + } + + for (; componentFIG0_13 != ensemble->components.end(); + ++componentFIG0_13) { + subchannel = getSubchannel(ensemble->subchannels, - (*component)->subchId); + (*componentFIG0_13)->subchId); if (subchannel == ensemble->subchannels.end()) { etiLog.log(error, "Subchannel %i does not exist for component " "of service %i\n", - (*component)->subchId, (*component)->serviceId); + (*componentFIG0_13)->subchId, + (*componentFIG0_13)->serviceId); returnCode = -1; goto EXIT; } @@ -1503,10 +1510,14 @@ int main(int argc, char *argv[]) figSize += 2; } + if (figSize > 30 - (5+4+11)) { + break; + } + FIG0_13_longAppInfo* info = (FIG0_13_longAppInfo*)&etiFrame[index]; - info->SId = htonl((*component)->serviceId); - info->SCIdS = (*component)->SCIdS; + info->SId = htonl((*componentFIG0_13)->serviceId); + info->SCIdS = (*componentFIG0_13)->SCIdS; info->No = 1; index += 5; figSize += 5; @@ -1532,7 +1543,7 @@ int main(int argc, char *argv[]) fig0->Length += 2 + app->length; } else if ((*subchannel)->type == 3 && // packet - (*component)->packet.appType != 0xffff) { + (*componentFIG0_13)->packet.appType != 0xffff) { if (fig0 == NULL) { fig0 = (FIGtype0*)&etiFrame[index]; @@ -1546,17 +1557,21 @@ int main(int argc, char *argv[]) figSize += 2; } + if (figSize > 30 - (5+2)) { + break; + } + FIG0_13_longAppInfo* info = (FIG0_13_longAppInfo*)&etiFrame[index]; - info->SId = htonl((*component)->serviceId); - info->SCIdS = (*component)->SCIdS; + info->SId = htonl((*componentFIG0_13)->serviceId); + info->SCIdS = (*componentFIG0_13)->SCIdS; info->No = 1; index += 5; figSize += 5; fig0->Length += 5; FIG0_13_app* app = (FIG0_13_app*)&etiFrame[index]; - app->setType((*component)->packet.appType); + app->setType((*componentFIG0_13)->packet.appType); app->length = 0; index += 2; figSize += 2; -- cgit v1.2.3