Commit a9ce2377 authored by Christophe Massiot's avatar Christophe Massiot

* ALL: Change the API to allow for different types of print (esp. XML).

parent 98bc2a54
...@@ -21,6 +21,11 @@ extern "C" ...@@ -21,6 +21,11 @@ extern "C"
{ {
#endif #endif
typedef enum print_type_t {
PRINT_TEXT,
PRINT_XML
} print_type_t;
typedef void (*f_print)(void *, const char *, ...); typedef void (*f_print)(void *, const char *, ...);
typedef char * (*f_iconv)(void *, const char *, char *, size_t); typedef char * (*f_iconv)(void *, const char *, char *, size_t);
......
This diff is collapsed.
This diff is collapsed.
...@@ -62,6 +62,7 @@ static PSI_TABLE_DECLARE(pp_next_sdt_sections); ...@@ -62,6 +62,7 @@ static PSI_TABLE_DECLARE(pp_next_sdt_sections);
static const char *psz_native_encoding = "UTF-8"; static const char *psz_native_encoding = "UTF-8";
static const char *psz_current_encoding = ""; static const char *psz_current_encoding = "";
static iconv_t iconv_handle = (iconv_t)-1; static iconv_t iconv_handle = (iconv_t)-1;
static print_type_t i_print_type = PRINT_TEXT;
/***************************************************************************** /*****************************************************************************
* print_wrapper * print_wrapper
...@@ -146,7 +147,13 @@ static void handle_pat(void) ...@@ -146,7 +147,13 @@ static void handle_pat(void)
} }
if (!pat_table_validate(pp_next_pat_sections)) { if (!pat_table_validate(pp_next_pat_sections)) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"invalid_pat\"/>\n");
break;
default:
printf("invalid PAT received\n"); printf("invalid PAT received\n");
}
psi_table_free(pp_next_pat_sections); psi_table_free(pp_next_pat_sections);
psi_table_init(pp_next_pat_sections); psi_table_init(pp_next_pat_sections);
return; return;
...@@ -170,7 +177,7 @@ static void handle_pat(void) ...@@ -170,7 +177,7 @@ static void handle_pat(void)
if (i_sid == 0) { if (i_sid == 0) {
if (i_pid != NIT_PID) if (i_pid != NIT_PID)
printf( fprintf(stderr,
"NIT is carried on PID %hu which isn't DVB compliant\n", "NIT is carried on PID %hu which isn't DVB compliant\n",
i_pid); i_pid);
continue; /* NIT */ continue; /* NIT */
...@@ -237,13 +244,19 @@ static void handle_pat(void) ...@@ -237,13 +244,19 @@ static void handle_pat(void)
psi_table_free(pp_old_pat_sections); psi_table_free(pp_old_pat_sections);
} }
pat_table_print( pp_current_pat_sections, print_wrapper, NULL ); pat_table_print(pp_current_pat_sections, print_wrapper, NULL, i_print_type);
} }
static void handle_pat_section(uint16_t i_pid, uint8_t *p_section) static void handle_pat_section(uint16_t i_pid, uint8_t *p_section)
{ {
if (i_pid != PAT_PID || !pat_validate(p_section)) { if (i_pid != PAT_PID || !pat_validate(p_section)) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"invalid_pat_section\"/>\n");
break;
default:
printf("invalid PAT section received on PID %hu\n", i_pid); printf("invalid PAT section received on PID %hu\n", i_pid);
}
free(p_section); free(p_section);
return; return;
} }
...@@ -265,7 +278,14 @@ static void handle_pmt(uint16_t i_pid, uint8_t *p_pmt) ...@@ -265,7 +278,14 @@ static void handle_pmt(uint16_t i_pid, uint8_t *p_pmt)
/* we do this before checking the service ID */ /* we do this before checking the service ID */
if (!pmt_validate(p_pmt)) { if (!pmt_validate(p_pmt)) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"invalid_pmt_section\" pid=\"%hu\"/>\n",
i_pid);
break;
default:
printf("invalid PMT section received on PID %hu\n", i_pid); printf("invalid PMT section received on PID %hu\n", i_pid);
}
free(p_pmt); free(p_pmt);
return; return;
} }
...@@ -275,7 +295,15 @@ static void handle_pmt(uint16_t i_pid, uint8_t *p_pmt) ...@@ -275,7 +295,15 @@ static void handle_pmt(uint16_t i_pid, uint8_t *p_pmt)
break; break;
if (i == i_nb_sids) { if (i == i_nb_sids) {
printf("ghost PMT for service %hu carried on PID %hu\n", i_sid, i_pid); switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"ghost_pmt\" program=\"%hu\n pid=\"%hu\"/>\n",
i_sid, i_pid);
break;
default:
printf("ghost PMT for service %hu carried on PID %hu\n", i_sid,
i_pid);
}
p_sid = malloc(sizeof(sid_t)); p_sid = malloc(sizeof(sid_t));
pp_sids = realloc(pp_sids, ++i_nb_sids * sizeof(sid_t *)); pp_sids = realloc(pp_sids, ++i_nb_sids * sizeof(sid_t *));
pp_sids[i] = p_sid; pp_sids[i] = p_sid;
...@@ -284,10 +312,18 @@ static void handle_pmt(uint16_t i_pid, uint8_t *p_pmt) ...@@ -284,10 +312,18 @@ static void handle_pmt(uint16_t i_pid, uint8_t *p_pmt)
p_sid->p_current_pmt = NULL; p_sid->p_current_pmt = NULL;
} else { } else {
p_sid = pp_sids[i]; p_sid = pp_sids[i];
if (i_pid != p_sid->i_pmt_pid) if (i_pid != p_sid->i_pmt_pid) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"ghost_pmt\" program=\"%hu\n pid=\"%hu\"/>\n",
i_sid, i_pid);
break;
default:
printf("ghost PMT for service %hu carried on PID %hu\n", i_sid, printf("ghost PMT for service %hu carried on PID %hu\n", i_sid,
i_pid); i_pid);
} }
}
}
if (p_sid->p_current_pmt != NULL && if (p_sid->p_current_pmt != NULL &&
psi_get_version(p_sid->p_current_pmt) == psi_get_version(p_pmt)) { psi_get_version(p_sid->p_current_pmt) == psi_get_version(p_pmt)) {
...@@ -299,7 +335,7 @@ static void handle_pmt(uint16_t i_pid, uint8_t *p_pmt) ...@@ -299,7 +335,7 @@ static void handle_pmt(uint16_t i_pid, uint8_t *p_pmt)
free(p_sid->p_current_pmt); free(p_sid->p_current_pmt);
p_sid->p_current_pmt = p_pmt; p_sid->p_current_pmt = p_pmt;
pmt_print(p_pmt, print_wrapper, NULL, iconv_wrapper, NULL); pmt_print(p_pmt, print_wrapper, NULL, iconv_wrapper, NULL, i_print_type);
} }
/***************************************************************************** /*****************************************************************************
...@@ -317,7 +353,13 @@ static void handle_nit(void) ...@@ -317,7 +353,13 @@ static void handle_nit(void)
} }
if (!nit_table_validate(pp_next_nit_sections)) { if (!nit_table_validate(pp_next_nit_sections)) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"invalid_nit\"/>\n");
break;
default:
printf("invalid NIT received\n"); printf("invalid NIT received\n");
}
psi_table_free( pp_next_nit_sections ); psi_table_free( pp_next_nit_sections );
psi_table_init( pp_next_nit_sections ); psi_table_init( pp_next_nit_sections );
return; return;
...@@ -329,13 +371,20 @@ static void handle_nit(void) ...@@ -329,13 +371,20 @@ static void handle_nit(void)
psi_table_init(pp_next_nit_sections); psi_table_init(pp_next_nit_sections);
nit_table_print(pp_current_nit_sections, print_wrapper, NULL, nit_table_print(pp_current_nit_sections, print_wrapper, NULL,
iconv_wrapper, NULL); iconv_wrapper, NULL, i_print_type);
} }
static void handle_nit_section(uint16_t i_pid, uint8_t *p_section) static void handle_nit_section(uint16_t i_pid, uint8_t *p_section)
{ {
if (i_pid != NIT_PID || !nit_validate(p_section)) { if (i_pid != NIT_PID || !nit_validate(p_section)) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"invalid_nit_section\" pid=\"%hu\"/>\n",
i_pid);
break;
default:
printf("invalid NIT section received on PID %hu\n", i_pid); printf("invalid NIT section received on PID %hu\n", i_pid);
}
free(p_section); free(p_section);
return; return;
} }
...@@ -361,7 +410,13 @@ static void handle_sdt(void) ...@@ -361,7 +410,13 @@ static void handle_sdt(void)
} }
if (!sdt_table_validate(pp_next_sdt_sections)) { if (!sdt_table_validate(pp_next_sdt_sections)) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"invalid_sdt\"/>\n");
break;
default:
printf("invalid SDT received\n"); printf("invalid SDT received\n");
}
psi_table_free(pp_next_sdt_sections); psi_table_free(pp_next_sdt_sections);
psi_table_init(pp_next_sdt_sections); psi_table_init(pp_next_sdt_sections);
return; return;
...@@ -373,13 +428,20 @@ static void handle_sdt(void) ...@@ -373,13 +428,20 @@ static void handle_sdt(void)
psi_table_init(pp_next_sdt_sections); psi_table_init(pp_next_sdt_sections);
sdt_table_print(pp_current_sdt_sections, print_wrapper, NULL, sdt_table_print(pp_current_sdt_sections, print_wrapper, NULL,
iconv_wrapper, NULL); iconv_wrapper, NULL, i_print_type);
} }
static void handle_sdt_section(uint16_t i_pid, uint8_t *p_section) static void handle_sdt_section(uint16_t i_pid, uint8_t *p_section)
{ {
if (i_pid != SDT_PID || !sdt_validate(p_section)) { if (i_pid != SDT_PID || !sdt_validate(p_section)) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"invalid_sdt_section\" pid=\"%hu\"/>\n",
i_pid);
break;
default:
printf("invalid SDT section received on PID %hu\n", i_pid); printf("invalid SDT section received on PID %hu\n", i_pid);
}
free(p_section); free(p_section);
return; return;
} }
...@@ -396,7 +458,14 @@ static void handle_sdt_section(uint16_t i_pid, uint8_t *p_section) ...@@ -396,7 +458,14 @@ static void handle_sdt_section(uint16_t i_pid, uint8_t *p_section)
static void handle_eit_section(uint16_t i_pid, uint8_t *p_eit) static void handle_eit_section(uint16_t i_pid, uint8_t *p_eit)
{ {
if (i_pid != EIT_PID || !eit_validate(p_eit)) { if (i_pid != EIT_PID || !eit_validate(p_eit)) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"invalid_eit_section\" pid=\"%hu\"/>\n",
i_pid);
break;
default:
printf("invalid EIT section received on PID %hu\n", i_pid); printf("invalid EIT section received on PID %hu\n", i_pid);
}
free(p_eit); free(p_eit);
return; return;
} }
...@@ -412,7 +481,13 @@ static void handle_section(uint16_t i_pid, uint8_t *p_section) ...@@ -412,7 +481,13 @@ static void handle_section(uint16_t i_pid, uint8_t *p_section)
uint8_t i_table_id = psi_get_tableid(p_section); uint8_t i_table_id = psi_get_tableid(p_section);
if (!psi_validate(p_section)) { if (!psi_validate(p_section)) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"invalid_section\" pid=\"%hu\"/>\n", i_pid);
break;
default:
printf("invalid section on PID %hu\n", i_pid); printf("invalid section on PID %hu\n", i_pid);
}
free(p_section); free(p_section);
return; return;
} }
...@@ -491,15 +566,30 @@ static void handle_psi_packet(uint8_t *p_ts) ...@@ -491,15 +566,30 @@ static void handle_psi_packet(uint8_t *p_ts)
/***************************************************************************** /*****************************************************************************
* Main loop * Main loop
*****************************************************************************/ *****************************************************************************/
static void usage(const char *psz)
{
fprintf(stderr, "usage: %s [-x xml] < <input file> [> <output>]\n", psz);
exit(EXIT_FAILURE);
}
int main(int i_argc, char **ppsz_argv) int main(int i_argc, char **ppsz_argv)
{ {
int i; int i;
if (ppsz_argv[1] != NULL && if (ppsz_argv[1] != NULL &&
(!strcmp(ppsz_argv[1], "-h") || !strcmp(ppsz_argv[1], "--help"))) { (!strcmp(ppsz_argv[1], "-h") || !strcmp(ppsz_argv[1], "--help")))
fprintf(stderr, "usage: %s < <input file> [> <output>]\n", usage(ppsz_argv[0]);
ppsz_argv[0]);
return EXIT_FAILURE; if (ppsz_argv[1] != NULL &&
(!strcmp(ppsz_argv[1], "-x") || !strcmp(ppsz_argv[1], "--print"))) {
if (ppsz_argv[2] == NULL)
usage(ppsz_argv[0]);
if (!strcmp(ppsz_argv[2], "text"))
i_print_type = PRINT_TEXT;
else if (!strcmp(ppsz_argv[2], "xml"))
i_print_type = PRINT_XML;
else
usage(ppsz_argv[0]);
} }
memset(p_pids, 0, sizeof(p_pids)); memset(p_pids, 0, sizeof(p_pids));
...@@ -515,13 +605,28 @@ int main(int i_argc, char **ppsz_argv) ...@@ -515,13 +605,28 @@ int main(int i_argc, char **ppsz_argv)
p_pids[SDT_PID].i_psi_refcount++; p_pids[SDT_PID].i_psi_refcount++;
p_pids[EIT_PID].i_psi_refcount++; p_pids[EIT_PID].i_psi_refcount++;
switch (i_print_type) {
case PRINT_XML:
printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
printf("<TS>\n");
break;
default:
break;
}
while (!feof(stdin) && !ferror(stdin)) { while (!feof(stdin) && !ferror(stdin)) {
uint8_t p_ts[TS_SIZE]; uint8_t p_ts[TS_SIZE];
size_t i_ret = fread(p_ts, sizeof(p_ts), 1, stdin); size_t i_ret = fread(p_ts, sizeof(p_ts), 1, stdin);
if (i_ret != 1) continue; if (i_ret != 1) continue;
if (!ts_validate(p_ts)) if (!ts_validate(p_ts)) {
switch (i_print_type) {
case PRINT_XML:
printf("<ERROR type=\"invalid_ts\"/>\n");
break;
default:
printf("invalid TS packet\n"); printf("invalid TS packet\n");
else { }
} else {
uint16_t i_pid = ts_get_pid(p_ts); uint16_t i_pid = ts_get_pid(p_ts);
ts_pid_t *p_pid = &p_pids[i_pid]; ts_pid_t *p_pid = &p_pids[i_pid];
if (p_pid->i_psi_refcount) if (p_pid->i_psi_refcount)
...@@ -530,5 +635,13 @@ int main(int i_argc, char **ppsz_argv) ...@@ -530,5 +635,13 @@ int main(int i_argc, char **ppsz_argv)
} }
} }
switch (i_print_type) {
case PRINT_XML:
printf("</TS>\n");
break;
default:
break;
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
...@@ -54,10 +54,63 @@ static inline uint8_t desc_get_length(const uint8_t *p_desc) ...@@ -54,10 +54,63 @@ static inline uint8_t desc_get_length(const uint8_t *p_desc)
return p_desc[1]; return p_desc[1];
} }
static inline void desc_print_begin(const uint8_t *p_desc, f_print pf_print,
void *opaque, print_type_t i_print_type)
{
switch (i_print_type) {
case PRINT_XML:
{
uint8_t i, i_length = desc_get_length(p_desc);
char psz_value[2 * i_length + 1];
for (i = 0; i < i_length; i++)
sprintf(psz_value + 2 * i, "%2.2hhx", p_desc[2 + i]);
psz_value[2 * i] = '\0';
pf_print(opaque, "<DESC id=\"%hhu\" value=\"%s\">",
desc_get_tag(p_desc), psz_value);
break;
}
default:
break;
}
}
static inline void desc_print_end(const uint8_t *p_desc, f_print pf_print,
void *opaque, print_type_t i_print_type)
{
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "</DESC>");
break;
default:
break;
}
}
static inline void desc_print_error(const uint8_t *p_desc, f_print pf_print,
void *opaque, print_type_t i_print_type)
{
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "<INVALID_DESC />");
break;
default:
pf_print(opaque, "desc %2.2hhx invalid", desc_get_tag(p_desc));
}
}
static inline void desc_print(const uint8_t *p_desc, f_print pf_print, static inline void desc_print(const uint8_t *p_desc, f_print pf_print,
void *opaque) void *opaque, print_type_t i_print_type)
{ {
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "<UNKNOWN_DESC />");
break;
default:
pf_print(opaque, " - desc %2.2hhx unknown", desc_get_tag(p_desc)); pf_print(opaque, " - desc %2.2hhx unknown", desc_get_tag(p_desc));
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -90,10 +143,17 @@ static inline bool desc05_validate(const uint8_t *p_desc) ...@@ -90,10 +143,17 @@ static inline bool desc05_validate(const uint8_t *p_desc)
} }
static inline void desc05_print(const uint8_t *p_desc, f_print pf_print, static inline void desc05_print(const uint8_t *p_desc, f_print pf_print,
void *opaque) void *opaque, print_type_t i_print_type)
{ {
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "<REGISTRATION_DESC identifier=\"%4.4s\"/>",
desc05_get_identifier(p_desc));
break;
default:
pf_print(opaque, " - desc 05 identifier=%4.4s", pf_print(opaque, " - desc 05 identifier=%4.4s",
desc05_get_identifier(p_desc)); desc05_get_identifier(p_desc));
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -117,10 +177,17 @@ static inline bool desc09_validate(const uint8_t *p_desc) ...@@ -117,10 +177,17 @@ static inline bool desc09_validate(const uint8_t *p_desc)
} }
static inline void desc09_print(const uint8_t *p_desc, f_print pf_print, static inline void desc09_print(const uint8_t *p_desc, f_print pf_print,
void *opaque) void *opaque, print_type_t i_print_type)
{ {
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "<CA_DESC sysid=\"0x%hx\" pid=\"%hu\"/>",
desc09_get_sysid(p_desc), desc09_get_pid(p_desc));
break;
default:
pf_print(opaque, " - desc 09 sysid=0x%hx pid=%hu", pf_print(opaque, " - desc 09 sysid=0x%hx pid=%hu",
desc09_get_sysid(p_desc), desc09_get_pid(p_desc)); desc09_get_sysid(p_desc), desc09_get_pid(p_desc));
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -171,17 +238,25 @@ static inline bool desc0a_validate(const uint8_t *p_desc) ...@@ -171,17 +238,25 @@ static inline bool desc0a_validate(const uint8_t *p_desc)
} }
static inline void desc0a_print(uint8_t *p_desc, f_print pf_print, static inline void desc0a_print(uint8_t *p_desc, f_print pf_print,
void *opaque) void *opaque, print_type_t i_print_type)
{ {
uint8_t j = 0; uint8_t j = 0;
uint8_t *p_desc_n; uint8_t *p_desc_n;
while ((p_desc_n = desc0a_get_language(p_desc, j)) != NULL) { while ((p_desc_n = desc0a_get_language(p_desc, j)) != NULL) {
j++; j++;
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "<AUDIO_LANGUAGE_DESC language=\"%3.3s\" audiotype=\"0x%hhx\"/>",
(const char *)desc0an_get_code(p_desc_n),
desc0an_get_audiotype(p_desc_n));
break;
default:
pf_print(opaque, " - desc 0a language=%3.3s audiotype=0x%hhx", pf_print(opaque, " - desc 0a language=%3.3s audiotype=0x%hhx",
(const char *)desc0an_get_code(p_desc_n), (const char *)desc0an_get_code(p_desc_n),
desc0an_get_audiotype(p_desc_n)); desc0an_get_audiotype(p_desc_n));
} }
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -836,15 +911,24 @@ static inline bool pat_table_validate(uint8_t **pp_sections) ...@@ -836,15 +911,24 @@ static inline bool pat_table_validate(uint8_t **pp_sections)
} }
static inline void pat_table_print(uint8_t **pp_sections, f_print pf_print, static inline void pat_table_print(uint8_t **pp_sections, f_print pf_print,
void *opaque) void *opaque, print_type_t i_print_type)
{ {
uint8_t i_last_section = psi_table_get_lastsection(pp_sections); uint8_t i_last_section = psi_table_get_lastsection(pp_sections);
uint8_t i; uint8_t i;
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "<PAT tsid=\"%hu\" version=\"%hhu\" current_next=\"%d\">",
psi_table_get_tableidext(pp_sections),
psi_table_get_version(pp_sections),
!psi_table_get_current(pp_sections) ? 0 : 1);
break;
default:
pf_print(opaque, "new PAT tsid=%hu version=%hhu%s", pf_print(opaque, "new PAT tsid=%hu version=%hhu%s",
psi_table_get_tableidext(pp_sections), psi_table_get_tableidext(pp_sections),
psi_table_get_version(pp_sections), psi_table_get_version(pp_sections),
!psi_table_get_current(pp_sections) ? " (next)" : ""); !psi_table_get_current(pp_sections) ? " (next)" : "");
}
for (i = 0; i <= i_last_section; i++) { for (i = 0; i <= i_last_section; i++) {
uint8_t *p_section = psi_table_get_section(pp_sections, i); uint8_t *p_section = psi_table_get_section(pp_sections, i);
...@@ -855,6 +939,12 @@ static inline void pat_table_print(uint8_t **pp_sections, f_print pf_print, ...@@ -855,6 +939,12 @@ static inline void pat_table_print(uint8_t **pp_sections, f_print pf_print,
uint16_t i_program = patn_get_program(p_program); uint16_t i_program = patn_get_program(p_program);
uint16_t i_pid = patn_get_pid(p_program); uint16_t i_pid = patn_get_pid(p_program);
j++; j++;
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "<PROGRAM number=\"%hu\" pid=\"%hu\"/>",
i_program, i_pid);
break;
default:
if (i_program == 0) if (i_program == 0)
pf_print(opaque, " * NIT pid=%hu", i_pid); pf_print(opaque, " * NIT pid=%hu", i_pid);
else else
...@@ -862,8 +952,16 @@ static inline void pat_table_print(uint8_t **pp_sections, f_print pf_print, ...@@ -862,8 +952,16 @@ static inline void pat_table_print(uint8_t **pp_sections, f_print pf_print,
i_program, i_pid); i_program, i_pid);
} }
} }
}
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque, "</PAT>");
break;
default:
pf_print(opaque, "end PAT"); pf_print(opaque, "end PAT");
}
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -36,27 +36,60 @@ extern "C" ...@@ -36,27 +36,60 @@ extern "C"
*****************************************************************************/ *****************************************************************************/
static inline void pmt_print(uint8_t *p_pmt, static inline void pmt_print(uint8_t *p_pmt,
f_print pf_print, void *print_opaque, f_print pf_print, void *print_opaque,
f_iconv pf_iconv, void *iconv_opaque) f_iconv pf_iconv, void *iconv_opaque,
print_type_t i_print_type)
{ {
uint8_t *p_es; uint8_t *p_es;
uint8_t j = 0; uint8_t j = 0;
switch (i_print_type) {
case PRINT_XML:
pf_print(print_opaque, "<PMT program=\"%hu\" version=\"%hhu\" current_next=\"%d\" pcrpid=\"%hu\">",
pmt_get_program(p_pmt), psi_get_version(p_pmt),
!psi_get_current(p_pmt) ? 0 : 1,
pmt_get_pcrpid(p_pmt));
break;
default:
pf_print(print_opaque, "new PMT program=%hu version=%hhu%s pcrpid=%hu", pf_print(print_opaque, "new PMT program=%hu version=%hhu%s pcrpid=%hu",
pmt_get_program(p_pmt), psi_get_version(p_pmt), pmt_get_program(p_pmt), psi_get_version(p_pmt),
!psi_get_current(p_pmt) ? " (next)" : "", !psi_get_current(p_pmt) ? " (next)" : "",
pmt_get_pcrpid(p_pmt)); pmt_get_pcrpid(p_pmt));
}
descs_print(pmt_get_descs(p_pmt), pf_print, print_opaque, descs_print(pmt_get_descs(p_pmt), pf_print, print_opaque,
pf_iconv, iconv_opaque); pf_iconv, iconv_opaque, i_print_type);
while ((p_es = pmt_get_es(p_pmt, j)) != NULL) { while ((p_es = pmt_get_es(p_pmt, j)) != NULL) {
j++; j++;
switch (i_print_type) {
case PRINT_XML:
pf_print(print_opaque, "<ES pid=\"%hu\" streamtype=\"0x%hx\">", pmtn_get_pid(p_es),
pmtn_get_streamtype(p_es));
break;
default:
pf_print(print_opaque, " * ES pid=%hu streamtype=0x%hx", pmtn_get_pid(p_es), pf_print(print_opaque, " * ES pid=%hu streamtype=0x%hx", pmtn_get_pid(p_es),
pmtn_get_streamtype(p_es)); pmtn_get_streamtype(p_es));
}
descs_print(pmtn_get_descs(p_es), pf_print, print_opaque, descs_print(pmtn_get_descs(p_es), pf_print, print_opaque,
pf_iconv, iconv_opaque); pf_iconv, iconv_opaque, i_print_type);
switch (i_print_type) {
case PRINT_XML:
pf_print(print_opaque, "</ES>");
break;
default:
break;
}
} }
switch (i_print_type) {
case PRINT_XML:
pf_print(print_opaque, "</PMT>");
break;
default:
pf_print(print_opaque, "end PMT"); pf_print(print_opaque, "end PMT");
}
} }
#ifdef __cplusplus #ifdef __cplusplus
......
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