mpegtsbase: Remove programs on EOS

Allows subclasses to properly flush out pending data.
This commit is contained in:
Edward Hervey 2011-08-01 15:46:12 +02:00
parent 57279cdd24
commit adfb090b59

View file

@ -212,6 +212,10 @@ mpegts_base_reset (MpegTSBase * base)
gst_segment_init (&base->segment, GST_FORMAT_UNDEFINED); gst_segment_init (&base->segment, GST_FORMAT_UNDEFINED);
base->mode = BASE_MODE_STREAMING;
base->seen_pat = FALSE;
base->first_pat_offset = -1;
if (klass->reset) if (klass->reset)
klass->reset (base); klass->reset (base);
} }
@ -236,15 +240,10 @@ mpegts_base_init (MpegTSBase * base, MpegTSBaseClass * klass)
base->is_pes = g_new0 (guint8, 1024); base->is_pes = g_new0 (guint8, 1024);
base->known_psi = g_new0 (guint8, 1024); base->known_psi = g_new0 (guint8, 1024);
mpegts_base_reset (base);
base->program_size = sizeof (MpegTSBaseProgram); base->program_size = sizeof (MpegTSBaseProgram);
base->stream_size = sizeof (MpegTSBaseStream); base->stream_size = sizeof (MpegTSBaseStream);
base->mode = BASE_MODE_STREAMING; mpegts_base_reset (base);
base->seen_pat = FALSE;
base->first_pat_offset = -1;
gst_segment_init (&base->segment, GST_FORMAT_UNDEFINED);
} }
static void static void
@ -1135,6 +1134,23 @@ mpegts_base_get_tags_from_eit (MpegTSBase * base, GstStructure * eit_info)
} }
} }
static void
remove_each_program (gpointer key, MpegTSBaseProgram * program,
MpegTSBase * base)
{
/* First deactivate it */
mpegts_base_deactivate_program (base, program);
/* Then remove it */
mpegts_base_remove_program (base, program->program_number);
}
static gboolean
gst_mpegts_base_handle_eos (MpegTSBase * base)
{
g_hash_table_foreach (base->programs, (GHFunc) remove_each_program, base);
/* finally remove */
return TRUE;
}
static gboolean static gboolean
mpegts_base_sink_event (GstPad * pad, GstEvent * event) mpegts_base_sink_event (GstPad * pad, GstEvent * event)
@ -1166,6 +1182,9 @@ mpegts_base_sink_event (GstPad * pad, GstEvent * event)
gst_event_unref (event); gst_event_unref (event);
} }
break; break;
case GST_EVENT_EOS:
res = gst_mpegts_base_handle_eos (base);
break;
case GST_EVENT_FLUSH_START: case GST_EVENT_FLUSH_START:
gst_segment_init (&base->segment, GST_FORMAT_UNDEFINED); gst_segment_init (&base->segment, GST_FORMAT_UNDEFINED);
mpegts_packetizer_flush (base->packetizer); mpegts_packetizer_flush (base->packetizer);