mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-04 16:39:39 +00:00
qtdemux: improve reset of internal status
Reset different variables on state changes to ready and when handling a flush-stop. For handling flush stops we should check if there is an upstream adaptive demuxer driving the pipeline as this means that qtdemux will get a new moov atom. For 'standard' isomedia streams this isn't true and qtdemux should keep the previous moov information around. Conflicts: gst/isomp4/qtdemux.c
This commit is contained in:
parent
6c69e59677
commit
cca2f555d1
1 changed files with 105 additions and 54 deletions
|
@ -445,6 +445,7 @@ static gboolean qtdemux_parse_samples (GstQTDemux * qtdemux,
|
|||
static GstFlowReturn qtdemux_expose_streams (GstQTDemux * qtdemux);
|
||||
static void gst_qtdemux_stream_free (GstQTDemux * qtdemux,
|
||||
QtDemuxStream * stream);
|
||||
static void gst_qtdemux_stream_clear (QtDemuxStream * stream);
|
||||
static GstFlowReturn qtdemux_prepare_streams (GstQTDemux * qtdemux);
|
||||
|
||||
static void
|
||||
|
@ -1723,54 +1724,87 @@ gst_qtdemux_setcaps (GstQTDemux * demux, GstCaps * caps)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_qtdemux_reset (GstQTDemux * qtdemux)
|
||||
gst_qtdemux_reset (GstQTDemux * qtdemux, gboolean hard)
|
||||
{
|
||||
gint n;
|
||||
|
||||
qtdemux->state = QTDEMUX_STATE_INITIAL;
|
||||
qtdemux->neededbytes = 16;
|
||||
qtdemux->todrop = 0;
|
||||
qtdemux->pullbased = FALSE;
|
||||
qtdemux->posted_redirect = FALSE;
|
||||
qtdemux->offset = 0;
|
||||
qtdemux->first_mdat = -1;
|
||||
qtdemux->header_size = 0;
|
||||
qtdemux->got_moov = FALSE;
|
||||
qtdemux->mdatoffset = GST_CLOCK_TIME_NONE;
|
||||
if (qtdemux->mdatbuffer)
|
||||
gst_buffer_unref (qtdemux->mdatbuffer);
|
||||
qtdemux->mdatbuffer = NULL;
|
||||
if (qtdemux->comp_brands)
|
||||
gst_buffer_unref (qtdemux->comp_brands);
|
||||
qtdemux->comp_brands = NULL;
|
||||
if (qtdemux->tag_list)
|
||||
gst_mini_object_unref (GST_MINI_OBJECT_CAST (qtdemux->tag_list));
|
||||
qtdemux->tag_list = NULL;
|
||||
#if 0
|
||||
if (qtdemux->element_index)
|
||||
gst_object_unref (qtdemux->element_index);
|
||||
qtdemux->element_index = NULL;
|
||||
#endif
|
||||
gst_adapter_clear (qtdemux->adapter);
|
||||
for (n = 0; n < qtdemux->n_streams; n++) {
|
||||
gst_qtdemux_stream_free (qtdemux, qtdemux->streams[n]);
|
||||
qtdemux->streams[n] = NULL;
|
||||
}
|
||||
qtdemux->major_brand = 0;
|
||||
qtdemux->n_streams = 0;
|
||||
qtdemux->n_video_streams = 0;
|
||||
qtdemux->n_audio_streams = 0;
|
||||
qtdemux->n_sub_streams = 0;
|
||||
gst_segment_init (&qtdemux->segment, GST_FORMAT_TIME);
|
||||
qtdemux->requested_seek_time = GST_CLOCK_TIME_NONE;
|
||||
qtdemux->seek_offset = 0;
|
||||
qtdemux->upstream_seekable = FALSE;
|
||||
qtdemux->upstream_size = 0;
|
||||
GST_DEBUG_OBJECT (qtdemux, "Resetting demux");
|
||||
gst_pad_stop_task (qtdemux->sinkpad);
|
||||
|
||||
gst_caps_replace (&qtdemux->media_caps, NULL);
|
||||
qtdemux->mss_mode = FALSE;
|
||||
qtdemux->exposed = FALSE;
|
||||
qtdemux->base_timestamp = GST_CLOCK_TIME_NONE;
|
||||
if (hard || qtdemux->mss_mode) {
|
||||
qtdemux->state = QTDEMUX_STATE_INITIAL;
|
||||
qtdemux->neededbytes = 16;
|
||||
qtdemux->todrop = 0;
|
||||
qtdemux->pullbased = FALSE;
|
||||
qtdemux->posted_redirect = FALSE;
|
||||
qtdemux->first_mdat = -1;
|
||||
qtdemux->header_size = 0;
|
||||
qtdemux->mdatoffset = GST_CLOCK_TIME_NONE;
|
||||
if (qtdemux->mdatbuffer)
|
||||
gst_buffer_unref (qtdemux->mdatbuffer);
|
||||
qtdemux->mdatbuffer = NULL;
|
||||
qtdemux->mdatleft = 0;
|
||||
if (qtdemux->comp_brands)
|
||||
gst_buffer_unref (qtdemux->comp_brands);
|
||||
qtdemux->comp_brands = NULL;
|
||||
if (qtdemux->moov_node)
|
||||
g_node_destroy (qtdemux->moov_node);
|
||||
qtdemux->moov_node = NULL;
|
||||
qtdemux->moov_node_compressed = NULL;
|
||||
if (qtdemux->tag_list)
|
||||
gst_mini_object_unref (GST_MINI_OBJECT_CAST (qtdemux->tag_list));
|
||||
qtdemux->tag_list = NULL;
|
||||
#if 0
|
||||
if (qtdemux->element_index)
|
||||
gst_object_unref (qtdemux->element_index);
|
||||
qtdemux->element_index = NULL;
|
||||
#endif
|
||||
}
|
||||
qtdemux->offset = 0;
|
||||
gst_adapter_clear (qtdemux->adapter);
|
||||
|
||||
if (hard) {
|
||||
for (n = 0; n < qtdemux->n_streams; n++) {
|
||||
gst_qtdemux_stream_free (qtdemux, qtdemux->streams[n]);
|
||||
qtdemux->streams[n] = NULL;
|
||||
}
|
||||
qtdemux->n_streams = 0;
|
||||
qtdemux->n_video_streams = 0;
|
||||
qtdemux->n_audio_streams = 0;
|
||||
qtdemux->n_sub_streams = 0;
|
||||
qtdemux->exposed = FALSE;
|
||||
qtdemux->fragmented = FALSE;
|
||||
qtdemux->mss_mode = FALSE;
|
||||
gst_caps_replace (&qtdemux->media_caps, NULL);
|
||||
qtdemux->timescale = 0;
|
||||
qtdemux->got_moov = FALSE;
|
||||
} else if (qtdemux->mss_mode) {
|
||||
for (n = 0; n < qtdemux->n_streams; n++)
|
||||
gst_qtdemux_stream_clear (qtdemux->streams[n]);
|
||||
} else {
|
||||
for (n = 0; n < qtdemux->n_streams; n++) {
|
||||
qtdemux->streams[n]->last_ret = GST_FLOW_OK;
|
||||
qtdemux->streams[n]->sent_eos = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (hard || qtdemux->mss_mode) {
|
||||
qtdemux->major_brand = 0;
|
||||
gst_segment_init (&qtdemux->segment, GST_FORMAT_TIME);
|
||||
if (qtdemux->pending_newsegment)
|
||||
gst_object_unref (qtdemux->pending_newsegment);
|
||||
qtdemux->pending_newsegment = NULL;
|
||||
qtdemux->upstream_newsegment = TRUE;
|
||||
qtdemux->requested_seek_time = GST_CLOCK_TIME_NONE;
|
||||
qtdemux->seek_offset = 0;
|
||||
qtdemux->upstream_seekable = FALSE;
|
||||
qtdemux->upstream_size = 0;
|
||||
|
||||
qtdemux->base_timestamp = GST_CLOCK_TIME_NONE;
|
||||
qtdemux->duration = 0;
|
||||
qtdemux->mfra_offset = 0;
|
||||
qtdemux->moof_offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -1885,7 +1919,7 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstObject * parent,
|
|||
}
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
{
|
||||
gst_qtdemux_reset (demux);
|
||||
gst_qtdemux_reset (demux, FALSE);
|
||||
break;
|
||||
}
|
||||
case GST_EVENT_EOS:
|
||||
|
@ -1983,7 +2017,7 @@ gst_qtdemux_stbl_free (QtDemuxStream * stream)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_qtdemux_stream_free (GstQTDemux * qtdemux, QtDemuxStream * stream)
|
||||
gst_qtdemux_stream_clear (QtDemuxStream * stream)
|
||||
{
|
||||
if (stream->allocator)
|
||||
gst_object_unref (stream->allocator);
|
||||
|
@ -1991,17 +2025,36 @@ gst_qtdemux_stream_free (GstQTDemux * qtdemux, QtDemuxStream * stream)
|
|||
gst_buffer_unref (GST_BUFFER_CAST (stream->buffers->data));
|
||||
stream->buffers = g_slist_delete_link (stream->buffers, stream->buffers);
|
||||
}
|
||||
if (stream->pad)
|
||||
gst_element_remove_pad (GST_ELEMENT_CAST (qtdemux), stream->pad);
|
||||
g_free (stream->samples);
|
||||
if (stream->caps)
|
||||
gst_caps_unref (stream->caps);
|
||||
stream->samples = NULL;
|
||||
g_free (stream->segments);
|
||||
stream->segments = NULL;
|
||||
if (stream->pending_tags)
|
||||
gst_tag_list_unref (stream->pending_tags);
|
||||
stream->pending_tags = NULL;
|
||||
g_free (stream->redirect_uri);
|
||||
stream->redirect_uri = NULL;
|
||||
/* free stbl sub-atoms */
|
||||
gst_qtdemux_stbl_free (stream);
|
||||
|
||||
stream->last_ret = GST_FLOW_OK;
|
||||
stream->sent_eos = FALSE;
|
||||
stream->segment_index = -1;
|
||||
stream->time_position = 0;
|
||||
stream->sample_index = -1;
|
||||
stream->stbl_index = -1;
|
||||
stream->n_samples = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_qtdemux_stream_free (GstQTDemux * qtdemux, QtDemuxStream * stream)
|
||||
{
|
||||
gst_qtdemux_stream_clear (stream);
|
||||
if (stream->caps)
|
||||
gst_caps_unref (stream->caps);
|
||||
stream->caps = NULL;
|
||||
if (stream->pad)
|
||||
gst_element_remove_pad (GST_ELEMENT_CAST (qtdemux), stream->pad);
|
||||
g_free (stream);
|
||||
}
|
||||
|
||||
|
@ -2022,7 +2075,7 @@ gst_qtdemux_change_state (GstElement * element, GstStateChange transition)
|
|||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:{
|
||||
gst_qtdemux_reset (qtdemux);
|
||||
gst_qtdemux_reset (qtdemux, TRUE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -4668,9 +4721,7 @@ gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf)
|
|||
/* initial newsegment sent here after having added pads,
|
||||
* possible others in sink_event */
|
||||
if (G_UNLIKELY (demux->pending_newsegment)) {
|
||||
gst_qtdemux_push_event (demux, demux->pending_newsegment);
|
||||
demux->pending_newsegment = NULL;
|
||||
demux->upstream_newsegment = FALSE;
|
||||
gst_qtdemux_push_pending_newsegment (demux);
|
||||
/* clear to send tags on all streams */
|
||||
for (i = 0; i < demux->n_streams; i++) {
|
||||
gst_qtdemux_push_tags (demux, demux->streams[i]);
|
||||
|
|
Loading…
Reference in a new issue