src/libtsduck/dtv/descriptors/tsExtendedEventDescriptor.cpp
void ts::ExtendedEventDescriptor::NormalizeNumbering(uint8_t* desc_base, size_t desc_size, const DVBCharset* charset)
{
    typedef std::map<UString, size_t> SizeMap; // key=language_code
    SizeMap desc_last;
    SizeMap desc_index;

    // Count the number of ExtendedEventDescriptor per language in the list
    uint8_t* data = desc_base;
    size_t size = desc_size;
    while (size >= 2) {
        uint8_t tag = data[0];
        uint8_t len = data[1];
        data += 2; size -= 2;
        if (len > size) {
            len = uint8_t(size);
        }
        if (tag == MY_DID && len >= 4) {
            const UString lang(DeserializeLanguageCode(data + 1));
            SizeMap::iterator it(desc_last.find(lang));
            if (it == desc_last.end()) {
                desc_last[lang] = 0;
                desc_index[lang] = 0;
            }
            else {
                it->second++;
            }
        }
        data += len; size -= len;
    }

    // Then, update all ExtendedEventDescriptor in the list
    data = desc_base;
    size = desc_size;
    while (size >= 2) {
        uint8_t tag = data[0];
        uint8_t len = data[1];
        data += 2; size -= 2;
        if (len > size) {
            len = uint8_t(size);
        }
        if (tag == MY_DID && len >= 4) {
            const UString lang(DeserializeLanguageCode(data + 1));
            data[0] = uint8_t((desc_index[lang] & 0x0F) << 4) | (desc_last[lang] & 0x0F);
            desc_index[lang]++;
        }
        data += len; size -= len;
    }
}
//----------------------------------------------------------------------------
// Normalize all ExtendedEventDescriptor in a descriptor list.
// Update all descriptor_number and last_descriptor_number.
//----------------------------------------------------------------------------
Normalize all ExtendedEventDescriptor in a descriptor list.
Normalize all ExtendedEventDescriptor in a descriptor list .
void ts::ExtendedEventDescriptor::NormalizeNumbering(uint8_t* desc_base, size_t desc_size, const DVBCharset* charset)
{
    typedef std::map<UString, size_t> SizeMap; 
    SizeMap desc_last;
    SizeMap desc_index;
    uint8_t* data = desc_base;
    size_t size = desc_size;
    while (size >= 2) {
        uint8_t tag = data[0];
        uint8_t len = data[1];
        data += 2; size -= 2;
        if (len > size) {
            len = uint8_t(size);
        }
        if (tag == MY_DID && len >= 4) {
            const UString lang(DeserializeLanguageCode(data + 1));
            SizeMap::iterator it(desc_last.find(lang));
            if (it == desc_last.end()) {
                desc_last[lang] = 0;
                desc_index[lang] = 0;
            }
            else {
                it->second++;
            }
        }
        data += len; size -= len;
    }
    data = desc_base;
    size = desc_size;
    while (size >= 2) {
        uint8_t tag = data[0];
        uint8_t len = data[1];
        data += 2; size -= 2;
        if (len > size) {
            len = uint8_t(size);
        }
        if (tag == MY_DID && len >= 4) {
            const UString lang(DeserializeLanguageCode(data + 1));
            data[0] = uint8_t((desc_index[lang] & 0x0F) << 4) | (desc_last[lang] & 0x0F);
            desc_index[lang]++;
        }
        data += len; size -= len;
    }
}
void ts :: ExtendedEventDescriptor :: NormalizeNumbering ( uint8_t * desc_base , size_t desc_size , const DVBCharset * charset ) { typedef std :: map < UString , size_t > SizeMap ; SizeMap desc_last ; SizeMap desc_index ; uint8_t * data = desc_base ; size_t size = desc_size ; while ( size >= 2 ) { uint8_t tag = data [ 0 ] ; uint8_t len = data [ 1 ] ; data += 2 ; size -= 2 ; if ( len > size ) { len = uint8_t ( size ) ; } if ( tag == MY_DID && len >= 4 ) { const UString lang ( DeserializeLanguageCode ( data + 1 ) ) ; SizeMap :: iterator it ( desc_last . find ( lang ) ) ; if ( it == desc_last . end ( ) ) { desc_last [ lang ] = 0 ; desc_index [ lang ] = 0 ; } else { it -> second ++ ; } } data += len ; size -= len ; } data = desc_base ; size = desc_size ; while ( size >= 2 ) { uint8_t tag = data [ 0 ] ; uint8_t len = data [ 1 ] ; data += 2 ; size -= 2 ; if ( len > size ) { len = uint8_t ( size ) ; } if ( tag == MY_DID && len >= 4 ) { const UString lang ( DeserializeLanguageCode ( data + 1 ) ) ; data [ 0 ] = uint8_t ( ( desc_index [ lang ] & 0x0F ) << 4 ) | ( desc_last [ lang ] & 0x0F ) ; desc_index [ lang ] ++ ; } data += len ; size -= len ; } }
Normalize all ExtendedEventDescriptor in a descriptor list.
Normalize all ExtendedEventDescriptor in a descriptor list .
// key=language_code // Count the number of ExtendedEventDescriptor per language in the list // Then, update all ExtendedEventDescriptor in the list