mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-19 20:46:22 +00:00
tsmux: Allow specifying PMT order via the prog-map
Look for an entry `PMT_<PID>` in the `prog-map`, which specifies the relative index of the stream in the PMT. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1510>
This commit is contained in:
parent
22fb7b7b71
commit
2f7ec968f4
4 changed files with 34 additions and 9 deletions
|
@ -388,6 +388,7 @@ gst_base_ts_mux_create_or_update_stream (GstBaseTsMux * mux,
|
||||||
guint8 color_spec = 0;
|
guint8 color_spec = 0;
|
||||||
const gchar *stream_format = NULL;
|
const gchar *stream_format = NULL;
|
||||||
const char *interlace_mode = NULL;
|
const char *interlace_mode = NULL;
|
||||||
|
gchar *pmt_name;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (ts_pad,
|
GST_DEBUG_OBJECT (ts_pad,
|
||||||
"%s stream with PID 0x%04x for caps %" GST_PTR_FORMAT,
|
"%s stream with PID 0x%04x for caps %" GST_PTR_FORMAT,
|
||||||
|
@ -693,6 +694,12 @@ gst_base_ts_mux_create_or_update_stream (GstBaseTsMux * mux,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pmt_name = g_strdup_printf ("PMT_%d", ts_pad->pid);
|
||||||
|
if (mux->prog_map && gst_structure_has_field (mux->prog_map, pmt_name)) {
|
||||||
|
gst_structure_get_int (mux->prog_map, pmt_name, &ts_pad->stream->pmt_index);
|
||||||
|
}
|
||||||
|
g_free (pmt_name);
|
||||||
|
|
||||||
interlace_mode = gst_structure_get_string (s, "interlace-mode");
|
interlace_mode = gst_structure_get_string (s, "interlace-mode");
|
||||||
gst_structure_get_int (s, "rate", &ts_pad->stream->audio_sampling);
|
gst_structure_get_int (s, "rate", &ts_pad->stream->audio_sampling);
|
||||||
gst_structure_get_int (s, "channels", &ts_pad->stream->audio_channels);
|
gst_structure_get_int (s, "channels", &ts_pad->stream->audio_channels);
|
||||||
|
|
|
@ -611,24 +611,39 @@ tsmux_program_add_stream (TsMuxProgram * program, TsMuxStream * stream)
|
||||||
{
|
{
|
||||||
GPtrArray *streams;
|
GPtrArray *streams;
|
||||||
guint i;
|
guint i;
|
||||||
gint array_index = -1 /* append */ ;
|
gint pmt_index, array_index = -1 /* append */ ;
|
||||||
guint16 pid;
|
guint16 pid;
|
||||||
|
|
||||||
g_return_if_fail (program != NULL);
|
g_return_if_fail (program != NULL);
|
||||||
g_return_if_fail (stream != NULL);
|
g_return_if_fail (stream != NULL);
|
||||||
|
|
||||||
streams = program->streams;
|
streams = program->streams;
|
||||||
|
pmt_index = stream->pmt_index;
|
||||||
pid = tsmux_stream_get_pid (stream);
|
pid = tsmux_stream_get_pid (stream);
|
||||||
|
|
||||||
/* Insert sorted by PID */
|
if (pmt_index >= 0) {
|
||||||
for (i = 0; i < streams->len; i++) {
|
/* Insert into streams with known indices */
|
||||||
TsMuxStream *s = g_ptr_array_index (streams, i);
|
for (i = 0; i < streams->len; i++) {
|
||||||
|
TsMuxStream *s = g_ptr_array_index (streams, i);
|
||||||
|
|
||||||
if (pid < tsmux_stream_get_pid (s)) {
|
if (s->pmt_index < 0 || pmt_index < s->pmt_index) {
|
||||||
array_index = i;
|
array_index = i;
|
||||||
GST_DEBUG ("PID 0x%04x: Using PID-order index %d/%u",
|
GST_DEBUG ("PID 0x%04x: Using known-order index %d/%u",
|
||||||
pid, array_index, streams->len);
|
pid, array_index, streams->len);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Insert after streams with known indices, sorted by PID */
|
||||||
|
for (i = 0; i < streams->len; i++) {
|
||||||
|
TsMuxStream *s = g_ptr_array_index (streams, i);
|
||||||
|
|
||||||
|
if (s->pmt_index < 0 && pid < tsmux_stream_get_pid (s)) {
|
||||||
|
array_index = i;
|
||||||
|
GST_DEBUG ("PID 0x%04x: Using PID-order index %d/%u",
|
||||||
|
pid, array_index, streams->len);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,7 @@ tsmux_stream_new (guint16 pid, guint stream_type)
|
||||||
stream->pes_payload_size = 0;
|
stream->pes_payload_size = 0;
|
||||||
stream->cur_pes_payload_size = 0;
|
stream->cur_pes_payload_size = 0;
|
||||||
stream->pes_bytes_written = 0;
|
stream->pes_bytes_written = 0;
|
||||||
|
stream->pmt_index = -1;
|
||||||
|
|
||||||
switch (stream_type) {
|
switch (stream_type) {
|
||||||
case TSMUX_ST_VIDEO_MPEG1:
|
case TSMUX_ST_VIDEO_MPEG1:
|
||||||
|
|
|
@ -150,6 +150,8 @@ struct TsMuxStream {
|
||||||
guint8 id;
|
guint8 id;
|
||||||
/* extended stream id (13818-1 Amdt 2) */
|
/* extended stream id (13818-1 Amdt 2) */
|
||||||
guint8 id_extended;
|
guint8 id_extended;
|
||||||
|
/* requested index in the PMT */
|
||||||
|
gint pmt_index;
|
||||||
|
|
||||||
gboolean is_video_stream;
|
gboolean is_video_stream;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue