mpegtsbase: Fix when applying new PMT with same program number
authorJan Schmidt <jan@centricular.com>
Mon, 11 Apr 2016 18:16:55 +0000 (04:16 +1000)
committerJan Schmidt <jan@centricular.com>
Tue, 12 Apr 2016 04:09:47 +0000 (14:09 +1000)
When the sub-class is delaying deactivation of the old program,
but it has the same program number as the new program, don't
overwrite the old program in the hash table and then steal
the new program back out of it. Instead, add the new program to
the hash table after handling removal of the old one.

gst/mpegtsdemux/mpegtsbase.c

index 293a32c..481695a 100644 (file)
@@ -886,8 +886,6 @@ mpegts_base_apply_pmt (MpegTSBase * base, GstMpegtsSection * section)
     old_program = mpegts_base_steal_program (base, program_number);
     program = mpegts_base_new_program (base, program_number, section->pid);
     program->patcount = old_program->patcount;
-    g_hash_table_insert (base->programs,
-        GINT_TO_POINTER (program_number), program);
 
     /* Desactivate the old program */
     /* FIXME : THIS IS BREAKING THE STREAM SWITCHING LOGIC !
@@ -901,6 +899,9 @@ mpegts_base_apply_pmt (MpegTSBase * base, GstMpegtsSection * section)
       g_hash_table_steal (base->programs,
           GINT_TO_POINTER ((gint) old_program->program_number));
     }
+    /* Add new program to the programs we track */
+    g_hash_table_insert (base->programs,
+        GINT_TO_POINTER (program_number), program);
     initial_program = FALSE;
   } else
     program = old_program;