[libdvbpsi-devel] [Git][videolan/libdvbpsi][master] 2 commits: really identify duplicates

Jean-Paul Saman gitlab at videolan.org
Wed Aug 8 11:40:18 CEST 2018


Jean-Paul Saman pushed to branch master at VideoLAN / libdvbpsi


Commits:
89f23e87 by Francois Cartegnie at 2018-08-07T18:05:20+02:00
really identify duplicates

- - - - -
9f2289a6 by Francois Cartegnie at 2018-08-07T18:05:21+02:00
really reset packet counter

- - - - -


2 changed files:

- src/dvbpsi.c
- src/dvbpsi.h


Changes:

=====================================
src/dvbpsi.c
=====================================
--- a/src/dvbpsi.c
+++ b/src/dvbpsi.c
@@ -98,6 +98,7 @@ void *dvbpsi_decoder_new(dvbpsi_callback_gather_t pf_gather,
     p_decoder->i_section_max_size = i_section_max_size;
     p_decoder->b_discontinuity = b_discontinuity;
     p_decoder->i_continuity_counter = DVBPSI_INVALID_CC;
+    p_decoder->prevpacket[0] = 0;
     p_decoder->p_current_section = NULL;
     p_decoder->b_current_valid = false;
 
@@ -119,6 +120,9 @@ void dvbpsi_decoder_reset(dvbpsi_decoder_t* p_decoder, const bool b_force)
     if (b_force)
         p_decoder->b_current_valid = false;
 
+    p_decoder->i_continuity_counter = DVBPSI_INVALID_CC;
+    p_decoder->prevpacket[0] = 0;
+
     /* Clear the section array */
     dvbpsi_DeletePSISections(p_decoder->p_sections);
     p_decoder->p_sections = NULL;
@@ -293,11 +297,19 @@ bool dvbpsi_packet_push(dvbpsi_t *p_dvbpsi, const uint8_t* p_data)
         if (i_expected_counter == ((p_decoder->i_continuity_counter + 1) & 0xf)
             && !p_decoder->b_discontinuity)
         {
-            dvbpsi_error(p_dvbpsi, "PSI decoder",
-                     "TS duplicate (received %d, expected %d) for PID %d",
-                     p_decoder->i_continuity_counter, i_expected_counter,
-                     ((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
-            return false;
+            if(!memcmp(p_decoder->prevpacket, p_data, 188))
+            {
+                dvbpsi_debug(p_dvbpsi, "PSI decoder",
+                             "TS duplicate (received %d, expected %d) for PID %d",
+                             p_decoder->i_continuity_counter, i_expected_counter,
+                             ((uint16_t)(p_data[1] & 0x1f) << 8) | p_data[2]);
+                return false;
+            }
+            else /* Fake duplicate */
+            {
+                /* force discontinuity */
+                i_expected_counter = p_decoder->i_continuity_counter + 1;
+            }
         }
 
         if (i_expected_counter != p_decoder->i_continuity_counter)
@@ -315,6 +327,8 @@ bool dvbpsi_packet_push(dvbpsi_t *p_dvbpsi, const uint8_t* p_data)
         }
     }
 
+    memcpy(p_decoder->prevpacket, p_data, 188);
+
     /* Return if no payload in the TS packet */
     if (!(p_data[3] & 0x10))
         return false;


=====================================
src/dvbpsi.h
=====================================
--- a/src/dvbpsi.h
+++ b/src/dvbpsi.h
@@ -264,6 +264,7 @@ typedef void (*dvbpsi_callback_del_t)(dvbpsi_t *p_dvbpsi,   /*!< pointer to dvbp
     bool     b_discontinuity;      /*!< Discontinuity flag */                     \
     bool     b_current_valid;      /*!< Current valid indicator */                \
     uint8_t  i_continuity_counter; /*!< Continuity counter */                     \
+    uint8_t  prevpacket[188];      /*!< Previous packet data */                   \
     uint8_t  i_last_section_number;/*!< Last received section number */           \
     dvbpsi_psi_section_t *p_current_section; /*!< Current section */              \
     dvbpsi_psi_section_t *p_sections; /*!< List of received PSI sections */       \



View it on GitLab: https://code.videolan.org/videolan/libdvbpsi/compare/311cd26e0014aa8b42d3ef1b82b595abcb45b58f...9f2289a6ad82c10050f3817d91711c596f6200e1

-- 
View it on GitLab: https://code.videolan.org/videolan/libdvbpsi/compare/311cd26e0014aa8b42d3ef1b82b595abcb45b58f...9f2289a6ad82c10050f3817d91711c596f6200e1
You're receiving this email because of your account on code.videolan.org.


More information about the libdvbpsi-devel mailing list