[FFmpeg-devel] [PATCH] Add optional NIT table generation

Ubaldo Porcheddu ubaldo at eja.it
Fri May 14 18:04:40 EEST 2021


Hola David,

thank you for clarifying it, maybe we leave 0x28 by default and add a 
"nit_private" option for: none, NorDig, UK ?

Here is the function so far:

+static void mpegts_write_nit(AVFormatContext *s)
+{
+    int i, lcn_count=0;
+    MpegTSWrite *ts = s->priv_data;
+    uint8_t data[SECTION_LENGTH], *q, *desc_len_ptr, *loop_len_ptr, 
*lcn_len_ptr;
+    AVDictionaryEntry *logical_channel;
+    AVProgram *program;
+
+    q = data;
+
+    //network name
+    put16(&q, 0xf000 | ts->provider_name[0]);
+    *q++ = 0x40;
+    putbuf(&q, ts->provider_name, ts->provider_name[0]+1);
+
+    //TS loop
+    loop_len_ptr = q;
+    q += 2;
+    put16(&q, ts->transport_stream_id);
+    put16(&q, ts->original_network_id);
+
+    //transport descriptor
+    desc_len_ptr = q;
+    q += 2;
+
+    //service list descriptor
+    *q++ = 0x41;
+    *q++ = 3 * ts->nb_services;
+    for(i = 0; i < ts->nb_services; i++) {
+        put16(&q, ts->services[i]->sid);
+        *q++ = ts->service_type;
+        program = s->programs[i];
+        if (av_dict_get(program->metadata, "logical_channel_number", 
NULL, 0))
+            lcn_count++;
+    }
+
+    if (lcn_count > 0) {
+        //logical channel descriptor
+        *q++ = 0x83;
+        lcn_len_ptr = q++;
+        for (i = 0; i < ts->nb_services; i++) {
+            program = s->programs[i];
+            logical_channel = av_dict_get(program->metadata, 
"logical_channel_number", NULL, 0);
+            if (logical_channel) {
+                put16(&q, ts->services[i]->sid);
+                put16(&q, 0xfc00 | atoi(logical_channel->value));
+            }
+        }
+        *lcn_len_ptr = lcn_count * 4;
+        //private data specifier descriptor
+        *q++ = 0x5F;
+        *q++ = 0x04;
+        put16(&q, 0x00);
+        put16(&q, 0x28);
+    }
+
+    //calculate lengths
+    put16(&desc_len_ptr, 0xf000 | q - (desc_len_ptr+2));
+    put16(&loop_len_ptr, 0xf000 | q - (loop_len_ptr+2));
+
+    mpegts_write_section1(&ts->nit, NIT_TID, ts->original_network_id, 
ts->tables_version, 0, 0,
+                          data, q - data);
+}


> Hi,
> 
>> Hi Marton,
>> 
>> Il 2021-05-12 19:18 Marton Balint ha scritto:
>> > On Wed, 12 May 2021, Ubaldo Porcheddu wrote:
>> >
>> >> Hi Marton,
>> >>
>> >>>> +    }
>> >>>> +
>> >>>> +    //private data
>> >>>> +    desc_len += 6 + 2;
>> >>>> +    *q++ = 0x5F;
>> >>>> +    *q++ = 4;
>> >>>> +    *q++ = 0x00;
>> >>>> +    *q++ = 0x00;
>> >>>> +    put16(&q, 40);
>> >>>
>> >>> What are these?
>> >>
>> >> I didn't find any official document about it but this seems to be the
>> >> way many national (FR,IT,UK) broadcasters are writing the virtual
>> >> channel private data header and the one recognized by many popular tv
>> >> on the market.
>> >
>> > But this looks like a separate descriptor from the virtual channels
>> > (logical_channel_descriptor).
>> 
>> I think it is better to remove it until it is more clear what it does,
>> or maybe we add an extra mpegts flag like "nit_lcn_extra" ?
>> 
> 
> The private data specifier descriptor is needed for the TV to
> correctly process the LCN descriptor. When it is needed, you have to
> include both or none.
> Also, in the Scandinavian countries, that use the NORDIG spec, the LCN
> descriptor has a different format, though I think the European format
> may still be understood.
> 
> Specs can be found here for NORDIG :
> https://nordig.org/wp-content/uploads/2017/03/NorDig-Unified_ver_2_6.pdf
> 
> Specs for the European LCN can be found here, it's the French spec,
> but the rest are the same:
> https://www.csa.fr/web/index.php/content/download/253685/723620/version/1/file/CSA-Signalling-Profilev3.4.pdf
> 
> Specs for the Australian LCN descriptor can be found here:
> https://www.freetv.com.au/wp-content/uploads/2019/08/OP-41-LCN-Descriptor-Issue-8-July-2016.pdf
> 
> The rules, as far as I know them are:
> 
> NORDIG --> Private Data Specifier = 0x00000029,  LCN Descriptor Tag =
> 0x83 (legacy), 0x87 (Nordig version)
> United Kingdom --> Private Data Specifier = 0x0000233A,  LCN
> Descriptor Tag = 0x83
> Rest of Europe + Most of the World --> Private Data Specifier =
> 0x00000028,  LCN Descriptor Tag = 0x83
> Australia --> _Do_not_include_Private_data_specifier_descriptor_ , LCN
> Descriptor Tag = 0x83
> 
> My suggestion would be to add an "LCN_mode" parameters, with values:
> NO_LCN, Australia,UK,Nordig, etc
> 
> Regards
> 
> David
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list