diff --git a/dvb/si/tdt_print.h b/dvb/si/tdt_print.h new file mode 100644 index 0000000..87b0c72 --- /dev/null +++ b/dvb/si/tdt_print.h @@ -0,0 +1,69 @@ +/***************************************************************************** + * tdt_print.h: ETSI EN 300 468 Time and Date Table (TDT) (printing) + ***************************************************************************** + * Copyright (C) 2011 Unix Solutions Ltd. + * + * Authors: Georgi Chorbadzhiyski + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +#ifndef __BITSTREAM_DVB_TDT_PRINT_H__ +#define __BITSTREAM_DVB_TDT_PRINT_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/***************************************************************************** + * Time and Date Table + *****************************************************************************/ +static inline void tdt_print(uint8_t *p_tdt, + f_print pf_print, void *print_opaque, + f_iconv pf_iconv, void *iconv_opaque, + print_type_t i_print_type) +{ + time_t ts; + char ts_str[24]; + + ts = dvb_time_format_UTC(tdt_get_utc(p_tdt), NULL, ts_str); + + switch (i_print_type) { + case PRINT_XML: + pf_print(print_opaque, "", + ts, ts_str); + break; + default: + pf_print(print_opaque, "new TDT time=%ld time_dec=\"%s\"", + ts, ts_str); + pf_print(print_opaque, "end TDT"); + } +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dvb/si_print.h b/dvb/si_print.h index 06a2f53..8b442ba 100644 --- a/dvb/si_print.h +++ b/dvb/si_print.h @@ -32,5 +32,6 @@ #include #include #include +#include #endif diff --git a/examples/dvb_print_si.c b/examples/dvb_print_si.c index ccaefc8..5282ef2 100644 --- a/examples/dvb_print_si.c +++ b/examples/dvb_print_si.c @@ -547,6 +547,29 @@ static void handle_eit_section(uint16_t i_pid, uint8_t *p_eit) free(p_eit); } +/***************************************************************************** + * handle_tdt + *****************************************************************************/ +static void handle_tdt_section(uint16_t i_pid, uint8_t *p_tdt) +{ + if (i_pid != TDT_PID || !tdt_validate(p_tdt)) { + switch (i_print_type) { + case PRINT_XML: + printf("\n", + i_pid); + break; + default: + printf("invalid TDT section received on PID %hu\n", i_pid); + } + free(p_tdt); + return; + } + + tdt_print(p_tdt, print_wrapper, NULL, iconv_wrapper, NULL, i_print_type); + + free(p_tdt); +} + /***************************************************************************** * handle_section *****************************************************************************/ @@ -587,6 +610,10 @@ static void handle_section(uint16_t i_pid, uint8_t *p_section) handle_sdt_section(i_pid, p_section); break; + case TDT_TABLE_ID: + handle_tdt_section(i_pid, p_section); + break; + default: if (i_table_id == EIT_TABLE_ID_PF_ACTUAL || (i_table_id >= EIT_TABLE_ID_SCHED_ACTUAL_FIRST && @@ -685,6 +712,7 @@ int main(int i_argc, char **ppsz_argv) p_pids[NIT_PID].i_psi_refcount++; p_pids[SDT_PID].i_psi_refcount++; p_pids[EIT_PID].i_psi_refcount++; + p_pids[TDT_PID].i_psi_refcount++; switch (i_print_type) { case PRINT_XML: