diff options
author | Mathieu Duponchelle <mathieu@centricular.com> | 2019-02-20 11:26:01 +0100 |
---|---|---|
committer | Mathieu Duponchelle <mathieu@centricular.com> | 2019-02-20 16:22:33 +0100 |
commit | 7c767f3fcd5a7b40d205bb4d588dad6c6275c729 (patch) | |
tree | b607fc8e5a91ebe3abdfc3b182caa41aa6c2299b | |
parent | bdd64e1e3f895d3665ddcd677df61013351397c2 (diff) |
mpegtsmux: allow specifying the PID of the PCR stream
The structure passed through the prog-map can now contain a
PCR_<prog_id>=sink_<PID> key-value pair.
-rw-r--r-- | gst/mpegtsmux/mpegtsmux.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index 3e07f4bfd..a21316132 100644 --- a/gst/mpegtsmux/mpegtsmux.c +++ b/gst/mpegtsmux/mpegtsmux.c @@ -878,7 +878,6 @@ 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; } @@ -930,6 +929,7 @@ mpegtsmux_create_streams (MpegTsMux * mux) GstCollectData *c_data = (GstCollectData *) walk->data; MpegTsPadData *ts_data = (MpegTsPadData *) walk->data; gchar *name = NULL; + gchar *pcr_name; walk = g_slist_next (walk); @@ -956,6 +956,12 @@ 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) { @@ -974,11 +980,21 @@ mpegtsmux_create_streams (MpegTsMux * mux) tsmux_program_set_pcr_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; + tsmux_program_add_stream (ts_data->prog, ts_data->stream); + + /* Check for user-specified PCR PID */ + pcr_name = g_strdup_printf ("PCR_%d", ts_data->prog->pgm_number); + if (mux->prog_map && gst_structure_has_field (mux->prog_map, pcr_name)) { + const gchar *sink_name = + gst_structure_get_string (mux->prog_map, pcr_name); + + if (!g_strcmp0 (name, sink_name)) { + GST_DEBUG_OBJECT (mux, "User specified stream (pid=%d) as PCR for " + "program (prog_id = %d)", ts_data->pid, ts_data->prog->pgm_number); + tsmux_program_set_pcr_stream (ts_data->prog, ts_data->stream); + } } + g_free (pcr_name); } return GST_FLOW_OK; |