From 91c76b085173b06974e3b7caa4a604dfee1abcb7 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Wed, 27 Feb 2019 18:47:09 +0100 Subject: mpegtsmux: restore stream creation order In 7c767f3fcd5a7b40d205bb4d588dad6c6275c729 , stream creation was refactored to occur before potential program creation. This created issues with pipelines such as: gst-launch-1.0 videotestsrc ! video/x-raw, format=I420, width=640, height=640, framerate=25/1 ! \ x264enc ! hlssink2 target-duration=1 eg.: gst_buffer_copy_into: assertion 'bufsize >= offset + size' failed As this reordering was actually not needed for the purpose of allowing to specify a PCR stream, this reverts the reordering part of the initial commit. --- gst/mpegtsmux/mpegtsmux.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index a21316132..58b1009bf 100644 --- a/gst/mpegtsmux/mpegtsmux.c +++ b/gst/mpegtsmux/mpegtsmux.c @@ -878,6 +878,7 @@ mpegtsmux_create_stream (MpegTsMux * mux, MpegTsPadData * ts_data) ts_data->stream->opus_channel_config_code = opus_channel_config_code; tsmux_stream_set_buffer_release_func (ts_data->stream, release_buffer_cb); + tsmux_program_add_stream (ts_data->prog, ts_data->stream); ret = GST_FLOW_OK; } @@ -956,12 +957,6 @@ mpegtsmux_create_streams (MpegTsMux * mux) } } - if (ts_data->stream == NULL) { - ret = mpegtsmux_create_stream (mux, ts_data); - if (ret != GST_FLOW_OK) - goto no_stream; - } - ts_data->prog = g_hash_table_lookup (mux->programs, GINT_TO_POINTER (ts_data->prog_id)); if (ts_data->prog == NULL) { @@ -980,7 +975,11 @@ mpegtsmux_create_streams (MpegTsMux * mux) tsmux_program_set_pcr_stream (ts_data->prog, ts_data->stream); } - tsmux_program_add_stream (ts_data->prog, ts_data->stream); + if (ts_data->stream == NULL) { + ret = mpegtsmux_create_stream (mux, ts_data); + if (ret != GST_FLOW_OK) + goto no_stream; + } /* Check for user-specified PCR PID */ pcr_name = g_strdup_printf ("PCR_%d", ts_data->prog->pgm_number); -- cgit v1.2.3