[libdvbpsi-devel] SIS: handle multiple PSI sections.

Jean-Paul Saman git at videolan.org
Wed Jun 27 14:29:01 CEST 2012


libdvbpsi | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Wed Jun 13 15:56:49 2012 +0200| [b8303d17f53345bd0f640457a8e1ccc31623008a] | committer: Jean-Paul Saman

SIS: handle multiple PSI sections.

> http://git.videolan.org/gitweb.cgi/libdvbpsi.git/?a=commit;h=b8303d17f53345bd0f640457a8e1ccc31623008a
---

 src/tables/sis.c |   41 ++++++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/src/tables/sis.c b/src/tables/sis.c
index 1e195ab..ce4fac2 100644
--- a/src/tables/sis.c
+++ b/src/tables/sis.c
@@ -94,6 +94,11 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
     p_sis_decoder->pf_sis_callback = pf_callback;
     p_sis_decoder->p_cb_data = p_cb_data;
 
+    /* SIS decoder initial state */
+    p_sis_decoder->b_current_valid = false;
+    p_sis_decoder->p_building_sis = NULL;
+    for (unsigned int i = 0; i <= 255; i++)
+        p_sis_decoder->ap_sections[i] = NULL;
     return true;
 }
 
@@ -122,6 +127,23 @@ void dvbpsi_DetachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
         return;
     }
 
+    assert(p_subdec->p_decoder);
+
+    dvbpsi_sis_decoder_t* p_sis_decoder;
+    p_sis_decoder = (dvbpsi_sis_decoder_t*)p_subdec->p_decoder;
+    if (p_sis_decoder->p_building_sis)
+        dvbpsi_DeleteSIS(p_sis_decoder->p_building_sis);
+    p_sis_decoder->p_building_sis = NULL;
+
+    for (unsigned int i = 0; i <= 255; i++)
+    {
+        if (p_sis_decoder->ap_sections[i])
+        {
+            dvbpsi_DeletePSISections(p_sis_decoder->ap_sections[i]);
+            p_sis_decoder->ap_sections[i] = NULL;
+        }
+    }
+
     dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
     dvbpsi_DeleteDemuxSubDecoder(p_subdec);
 }
@@ -237,11 +259,13 @@ static void dvbpsi_ReInitSIS(dvbpsi_sis_decoder_t* p_decoder, const bool b_force
 
     /* Force redecoding */
     if (b_force)
+    {
         p_decoder->b_current_valid = false;
 
-    /* Free structures */
-    if (p_decoder->p_building_sis)
-        free(p_decoder->p_building_sis);
+        /* Free structures */
+        if (p_decoder->p_building_sis)
+            dvbpsi_DeleteSIS(p_decoder->p_building_sis);
+    }
     p_decoder->p_building_sis = NULL;
 
     /* Clear the section array */
@@ -255,13 +279,12 @@ static void dvbpsi_ReInitSIS(dvbpsi_sis_decoder_t* p_decoder, const bool b_force
     }
 }
 
-static bool dvbpsi_CheckSIS(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
+static bool dvbpsi_CheckSIS(dvbpsi_t *p_dvbpsi, dvbpsi_sis_decoder_t* p_sis_decoder,
+                            dvbpsi_psi_section_t *p_section)
 {
     bool b_reinit = false;
-    assert(p_dvbpsi->p_private);
-
-    dvbpsi_sis_decoder_t* p_sis_decoder;
-    p_sis_decoder = (dvbpsi_sis_decoder_t *)p_dvbpsi->p_private;
+    assert(p_dvbpsi);
+    assert(p_sis_decoder);
 
     if (p_sis_decoder->p_building_sis->i_protocol_version != 0)
     {
@@ -385,7 +408,7 @@ void dvbpsi_GatherSISSections(dvbpsi_t *p_dvbpsi,
         /* Perform a few sanity checks */
         if (p_sis_decoder->p_building_sis)
         {
-            if (dvbpsi_CheckSIS(p_dvbpsi, p_section))
+            if (dvbpsi_CheckSIS(p_dvbpsi, p_sis_decoder, p_section))
                 dvbpsi_ReInitSIS(p_sis_decoder, true);
         }
         else



More information about the libdvbpsi-devel mailing list