Commit 86401f89 authored by Georgi Chorbadzhiyski's avatar Georgi Chorbadzhiyski

dvb/si: Complete support for TDT (Time and Date Table).

Add support for tdt_print() and examples/dvb_print_si support.
parent 8672abdc
/*****************************************************************************
* tdt_print.h: ETSI EN 300 468 Time and Date Table (TDT) (printing)
*****************************************************************************
* Copyright (C) 2011 Unix Solutions Ltd.
*
* Authors: Georgi Chorbadzhiyski <georgi@unixsol.org>
*
* 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 <bitstream/common.h>
#include <bitstream/dvb/si/datetime.h>
#include <bitstream/dvb/si/tdt.h>
#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, "<TDT time=\"%ld\" time_dec=\"%s\"/>",
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
......@@ -32,5 +32,6 @@
#include <bitstream/dvb/si/nit_print.h>
#include <bitstream/dvb/si/sdt_print.h>
#include <bitstream/dvb/si/eit_print.h>
#include <bitstream/dvb/si/tdt_print.h>
#endif
......@@ -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("<ERROR type=\"invalid_tdt_section\" pid=\"%hu\"/>\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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment