guint8 color_spec = 0;
const gchar *stream_format = NULL;
const char *interlace_mode = NULL;
+ gchar *pmt_name;
GST_DEBUG_OBJECT (ts_pad,
"%s stream with PID 0x%04x for caps %" GST_PTR_FORMAT,
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");
gst_structure_get_int (s, "rate", &ts_pad->stream->audio_sampling);
gst_structure_get_int (s, "channels", &ts_pad->stream->audio_channels);
{
GPtrArray *streams;
guint i;
- gint array_index = -1 /* append */ ;
+ gint pmt_index, array_index = -1 /* append */ ;
guint16 pid;
g_return_if_fail (program != NULL);
g_return_if_fail (stream != NULL);
streams = program->streams;
+ pmt_index = stream->pmt_index;
pid = tsmux_stream_get_pid (stream);
- /* Insert sorted by PID */
- for (i = 0; i < streams->len; i++) {
- TsMuxStream *s = g_ptr_array_index (streams, i);
+ if (pmt_index >= 0) {
+ /* Insert into streams with known indices */
+ for (i = 0; i < streams->len; i++) {
+ TsMuxStream *s = g_ptr_array_index (streams, i);
- if (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;
+ if (s->pmt_index < 0 || pmt_index < s->pmt_index) {
+ array_index = i;
+ GST_DEBUG ("PID 0x%04x: Using known-order index %d/%u",
+ pid, array_index, streams->len);
+ 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;
+ }
}
}