From 37ba86ca9323a888bda51fcbfdf348480499a9e2 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 18 Jul 2015 22:34:47 +0200 Subject: Combine FIG0/2 Data and Prog --- src/fig/FIG0.cpp | 67 +++++++++++++++++++--------- src/fig/FIG0.h | 2 +- src/fig/FIGCarousel.cpp | 113 +----------------------------------------------- 3 files changed, 49 insertions(+), 133 deletions(-) (limited to 'src') diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp index 09dff4d..70d1f93 100644 --- a/src/fig/FIG0.cpp +++ b/src/fig/FIG0.cpp @@ -152,7 +152,7 @@ size_t FIG0_1::fill(uint8_t *buf, size_t max_size) FIG0_2::FIG0_2(FIGRuntimeInformation *rti) : m_rti(rti) { - serviceProgFIG0_2 = m_rti->ensemble->services.end(); + serviceFIG0_2 = m_rti->ensemble->services.end(); } size_t FIG0_2::fill(uint8_t *buf, size_t max_size) @@ -163,17 +163,21 @@ size_t FIG0_2::fill(uint8_t *buf, size_t max_size) // Rotate through the subchannels until there is no more // space - if (serviceProgFIG0_2 == m_rti->ensemble->services.end()) { - serviceProgFIG0_2 = m_rti->ensemble->services.begin(); + if (serviceFIG0_2 == m_rti->ensemble->services.end()) { + serviceFIG0_2 = m_rti->ensemble->services.begin(); } - for (; serviceProgFIG0_2 != m_rti->ensemble->services.end(); - ++serviceProgFIG0_2) { - if ((*serviceProgFIG0_2)->nbComponent(m_rti->ensemble->components) == 0) { + for (; serviceFIG0_2 != m_rti->ensemble->services.end(); + ++serviceFIG0_2) { + + // filter out services which have no components + if ((*serviceFIG0_2)->nbComponent(m_rti->ensemble->components) == 0) { continue; } - if ((*serviceProgFIG0_2)->getType(m_rti->ensemble) != Audio) { + // Exclude Fidc type services, TODO why ? + auto type = (*serviceFIG0_2)->getType(m_rti->ensemble); + if (type == Fidc) { continue; } @@ -186,35 +190,56 @@ size_t FIG0_2::fill(uint8_t *buf, size_t max_size) fig0_2->Length = 1; fig0_2->CN = 0; fig0_2->OE = 0; - fig0_2->PD = 0; + fig0_2->PD = (type == Audio) ? 0 : 1; fig0_2->Extension = 2; buf += 2; remaining -= 2; } - if (remaining < 3 + 2 * - (*serviceProgFIG0_2)->nbComponent(m_rti->ensemble->components)) { + if (type == Audio and + remaining < 3 + 2 * + (*serviceFIG0_2)->nbComponent(m_rti->ensemble->components)) { + break; + } + + if (type != Audio and + remaining < 5 + 2 * + (*serviceFIG0_2)->nbComponent(m_rti->ensemble->components)) { break; } - FIGtype0_2_Service *fig0_2serviceAudio = (FIGtype0_2_Service*)buf; + if (type == Audio) { + auto fig0_2serviceAudio = (FIGtype0_2_Service*)buf; - fig0_2serviceAudio->SId = htons((*serviceProgFIG0_2)->id); - fig0_2serviceAudio->Local_flag = 0; - fig0_2serviceAudio->CAId = 0; - fig0_2serviceAudio->NbServiceComp = - (*serviceProgFIG0_2)->nbComponent(m_rti->ensemble->components); - buf += 3; - fig0_2->Length += 3; - remaining -= 3; + fig0_2serviceAudio->SId = htons((*serviceFIG0_2)->id); + fig0_2serviceAudio->Local_flag = 0; + fig0_2serviceAudio->CAId = 0; + fig0_2serviceAudio->NbServiceComp = + (*serviceFIG0_2)->nbComponent(m_rti->ensemble->components); + buf += 3; + fig0_2->Length += 3; + remaining -= 3; + } + else { + auto fig0_2serviceData = (FIGtype0_2_Service_data*)buf; + + fig0_2serviceData->SId = htonl((*serviceFIG0_2)->id); + fig0_2serviceData->Local_flag = 0; + fig0_2serviceData->CAId = 0; + fig0_2serviceData->NbServiceComp = + (*serviceFIG0_2)->nbComponent(m_rti->ensemble->components); + buf += 5; + fig0_2->Length += 5; + remaining -= 5; + } int curCpnt = 0; for (auto component = getComponent( - m_rti->ensemble->components, (*serviceProgFIG0_2)->id ); + m_rti->ensemble->components, (*serviceFIG0_2)->id ); component != m_rti->ensemble->components.end(); component = getComponent( m_rti->ensemble->components, - (*serviceProgFIG0_2)->id, + (*serviceFIG0_2)->id, component ) ) { auto subchannel = getSubchannel( diff --git a/src/fig/FIG0.h b/src/fig/FIG0.h index 248b501..625e2ae 100644 --- a/src/fig/FIG0.h +++ b/src/fig/FIG0.h @@ -78,7 +78,7 @@ class FIG0_2 : public IFIG private: FIGRuntimeInformation *m_rti; - std::vector >::iterator serviceProgFIG0_2; + std::vector >::iterator serviceFIG0_2; }; #endif // __FIG0_H_ diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp index eb78269..b1377e4 100644 --- a/src/fig/FIGCarousel.cpp +++ b/src/fig/FIGCarousel.cpp @@ -165,117 +165,8 @@ void fib0 { break; case 3: - fig0_2 = NULL; - cur = 0; - - if (serviceDataFIG0_2 == ensemble->services.end()) { - serviceDataFIG0_2 = ensemble->services.begin(); - } - for (; serviceDataFIG0_2 != ensemble->services.end(); - ++serviceDataFIG0_2) { - if (!(*serviceDataFIG0_2)->nbComponent(ensemble->components)) { - continue; - } - - unsigned char type = (*serviceDataFIG0_2)->getType(ensemble); - if ((type == 0) || (type == 2)) { - continue; - } - - ++cur; - - if (fig0_2 == NULL) { - fig0_2 = (FIGtype0_2 *) & etiFrame[index]; - - fig0_2->FIGtypeNumber = 0; - fig0_2->Length = 1; - fig0_2->CN = 0; - fig0_2->OE = 0; - fig0_2->PD = 1; - fig0_2->Extension = 2; - index = index + 2; - figSize += 2; - } - - if (figSize + 5 - + (*serviceDataFIG0_2)->nbComponent(ensemble->components) - * 2 > 30) { - break; - } - - fig0_2serviceData = - (FIGtype0_2_Service_data*) &etiFrame[index]; - - fig0_2serviceData->SId = htonl((*serviceDataFIG0_2)->id); - fig0_2serviceData->Local_flag = 0; - fig0_2serviceData->CAId = 0; - fig0_2serviceData->NbServiceComp = - (*serviceDataFIG0_2)->nbComponent(ensemble->components); - fig0_2->Length += 5; - index += 5; - figSize += 5; - - int curCpnt = 0; - for (component = getComponent(ensemble->components, - (*serviceDataFIG0_2)->id); - component != ensemble->components.end(); - component = getComponent(ensemble->components, - (*serviceDataFIG0_2)->id, component)) { - subchannel = getSubchannel(ensemble->subchannels, - (*component)->subchId); - if (subchannel == ensemble->subchannels.end()) { - etiLog.log(error, - "Subchannel %i does not exist for component " - "of service %i\n", - (*component)->subchId, (*component)->serviceId); - throw MuxInitException(); - } - - switch ((*subchannel)->type) { - case Audio: - audio_description = - (FIGtype0_2_audio_component*)&etiFrame[index]; - audio_description->TMid = 0; - audio_description->ASCTy = (*component)->type; - audio_description->SubChId = (*subchannel)->id; - audio_description->PS = ((curCpnt == 0) ? 1 : 0); - audio_description->CA_flag = 0; - break; - case DataDmb: - data_description = - (FIGtype0_2_data_component*)&etiFrame[index]; - data_description->TMid = 1; - data_description->DSCTy = (*component)->type; - data_description->SubChId = (*subchannel)->id; - data_description->PS = ((curCpnt == 0) ? 1 : 0); - data_description->CA_flag = 0; - break; - case Packet: - packet_description = - (FIGtype0_2_packet_component*)&etiFrame[index]; - packet_description->TMid = 3; - packet_description->setSCId((*component)->packet.id); - packet_description->PS = ((curCpnt == 0) ? 1 : 0); - packet_description->CA_flag = 0; - break; - default: - etiLog.log(error, - "Component type not supported\n"); - throw MuxInitException(); - } - index += 2; - fig0_2->Length += 2; - figSize += 2; - if (figSize > 30) { - etiLog.log(error, - "Sorry, no place left in FIG 0/2 to insert " - "component %i of data service %i.\n", - curCpnt, cur); - throw MuxInitException(); - } - ++curCpnt; - } - } + // FIG type 0/2 for Data + // ERASED break; case 5: -- cgit v1.2.3