aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Paul Saman <jean-paul.saman@m2x.nl>2013-10-30 14:36:20 (GMT)
committerJean-Paul Saman <jpsaman@videolan.org>2013-11-05 08:00:56 (GMT)
commitbd1b007bec268d8db3ad4ce063e3a5e6863f994d (patch)
treeb8a28bce718d868089cb7e51fb3cd07f1e1491c0
parent560d877d3ca342a78a29d8d7ab50cac157667673 (diff)
PAT: check for invalid PMT pid numbers (closes #9695)
Some streams generate invalid program entries in the first PAT. Ignore these programs and the PAT they are in and reset the PAT decoder. This way the next PAT (even when the version number has not been incremented) will be handled by libdvbpsi library. (cherry picked from commit c1e330b75ad06471498f6f97c52df92d45897f4e) Signed-off-by: Jean-Paul Saman <jpsaman@videolan.org>
-rw-r--r--src/tables/pat.c36
-rw-r--r--src/tables/pat_private.h2
2 files changed, 23 insertions, 15 deletions
diff --git a/src/tables/pat.c b/src/tables/pat.c
index 84f8c67..0ad625c 100644
--- a/src/tables/pat.c
+++ b/src/tables/pat.c
@@ -161,6 +161,11 @@ dvbpsi_pat_program_t* dvbpsi_pat_program_add(dvbpsi_pat_t* p_pat,
{
dvbpsi_pat_program_t* p_program;
+ /* PID = 0 is invalid for programs
+ * FIXME: check for other fixed PIDs too. */
+ if (i_pid == 0)
+ return NULL;
+
p_program = (dvbpsi_pat_program_t*) malloc(sizeof(dvbpsi_pat_program_t));
if (p_program == NULL)
return NULL;
@@ -328,32 +333,32 @@ void dvbpsi_pat_sections_gather(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sect
/* Save the current information */
p_pat_decoder->current_pat = *p_pat_decoder->p_building_pat;
- p_pat_decoder->b_current_valid = true;
/* Decode the sections */
- dvbpsi_pat_sections_decode(p_pat_decoder->p_building_pat,
- p_pat_decoder->p_sections);
-
- /* Delete the sections */
- dvbpsi_DeletePSISections(p_pat_decoder->p_sections);
- p_pat_decoder->p_sections = NULL;
+ if (dvbpsi_pat_sections_decode(p_pat_decoder->p_building_pat,
+ p_pat_decoder->p_sections))
+ p_pat_decoder->b_current_valid = true;
/* signal the new PAT */
- p_pat_decoder->pf_pat_callback(p_pat_decoder->p_cb_data,
- p_pat_decoder->p_building_pat);
+ if (p_pat_decoder->b_current_valid)
+ p_pat_decoder->pf_pat_callback(p_pat_decoder->p_cb_data,
+ p_pat_decoder->p_building_pat);
- /* Reinitialize the structures */
- dvbpsi_ReInitPAT(p_pat_decoder, false);
+ /* Delete sectioins and Reinitialize the structures */
+ dvbpsi_ReInitPAT(p_pat_decoder, !p_pat_decoder->b_current_valid);
+ assert(p_pat_decoder->p_sections == NULL);
}
}
/*****************************************************************************
* dvbpsi_DecodePATSection
*****************************************************************************
- * PAT decoder.
+ * Decode sections into a PAT table. The function returns 'true' on success,
+ * 'false' otherwise.
*****************************************************************************/
-void dvbpsi_pat_sections_decode(dvbpsi_pat_t* p_pat, dvbpsi_psi_section_t* p_section)
+bool dvbpsi_pat_sections_decode(dvbpsi_pat_t* p_pat, dvbpsi_psi_section_t* p_section)
{
+ bool b_valid = false;
while (p_section)
{
for (uint8_t *p_byte = p_section->p_payload_start;
@@ -362,11 +367,14 @@ void dvbpsi_pat_sections_decode(dvbpsi_pat_t* p_pat, dvbpsi_psi_section_t* p_sec
{
uint16_t i_program_number = ((uint16_t)(p_byte[0]) << 8) | p_byte[1];
uint16_t i_pid = ((uint16_t)(p_byte[2] & 0x1f) << 8) | p_byte[3];
- dvbpsi_pat_program_add(p_pat, i_program_number, i_pid);
+ dvbpsi_pat_program_t* p_program = dvbpsi_pat_program_add(p_pat, i_program_number, i_pid);
+ if (p_program)
+ b_valid = true;
}
p_section = p_section->p_next;
}
+ return b_valid;
}
/*****************************************************************************
diff --git a/src/tables/pat_private.h b/src/tables/pat_private.h
index fc8fea0..434a202 100644
--- a/src/tables/pat_private.h
+++ b/src/tables/pat_private.h
@@ -57,7 +57,7 @@ void dvbpsi_pat_sections_gather(dvbpsi_t* p_dvbpsi, dvbpsi_psi_section_t* p_sect
*****************************************************************************
* PAT decoder.
*****************************************************************************/
-void dvbpsi_pat_sections_decode(dvbpsi_pat_t* p_pat,
+bool dvbpsi_pat_sections_decode(dvbpsi_pat_t* p_pat,
dvbpsi_psi_section_t* p_section);
#else

Privacy Policy