tsmux: Parse bitrate from tags into the stream

Instead of parsing a hardcoded zero and always writing the highest
limit.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4681>
This commit is contained in:
Vivia Nikolaidou 2023-05-19 16:21:15 +03:00 committed by Edward Hervey
parent 7a98a4214b
commit 637e263504
4 changed files with 23 additions and 3 deletions

View file

@ -118,6 +118,9 @@ gst_base_ts_mux_pad_reset (GstBaseTsMuxPad * pad)
g_free (pad->language);
pad->language = NULL;
}
pad->bitrate = 0;
pad->max_bitrate = 0;
}
/* GstAggregatorPad implementation */
@ -726,7 +729,8 @@ gst_base_ts_mux_create_or_update_stream (GstBaseTsMux * mux,
if (ts_pad->stream == NULL) {
ts_pad->stream =
tsmux_create_stream (mux->tsmux, st, ts_pad->pid, ts_pad->language);
tsmux_create_stream (mux->tsmux, st, ts_pad->pid, ts_pad->language,
ts_pad->bitrate, ts_pad->max_bitrate);
if (ts_pad->stream == NULL)
goto error;
}
@ -2080,6 +2084,8 @@ gst_base_ts_mux_sink_event (GstAggregator * agg, GstAggregatorPad * agg_pad,
case GST_EVENT_TAG:{
GstTagList *list;
gchar *lang = NULL;
guint bitrate = 0;
guint max_bitrate = 0;
GST_DEBUG_OBJECT (mux, "received tag event");
gst_event_parse_tag (event, &list);
@ -2101,6 +2107,14 @@ gst_base_ts_mux_sink_event (GstAggregator * agg, GstAggregatorPad * agg_pad,
g_free (lang);
}
if (gst_tag_list_get_uint (list, GST_TAG_BITRATE, &bitrate)) {
ts_pad->bitrate = bitrate;
}
if (gst_tag_list_get_uint (list, GST_TAG_MAXIMUM_BITRATE, &max_bitrate)) {
ts_pad->max_bitrate = bitrate;
}
/* handled this, don't want collectpads to forward it downstream */
res = TRUE;
forward = gst_tag_list_get_scope (list) == GST_TAG_SCOPE_GLOBAL;

View file

@ -128,6 +128,8 @@ struct _GstBaseTsMuxPad
TsMuxProgram *prog;
gchar *language;
gint bitrate;
gint max_bitrate;
};
struct _GstBaseTsMuxPadClass

View file

@ -714,7 +714,7 @@ tsmux_get_new_pid (TsMux * mux)
*/
TsMuxStream *
tsmux_create_stream (TsMux * mux, guint stream_type, guint16 pid,
gchar * language)
gchar * language, guint bitrate, guint max_bitrate)
{
TsMuxStream *stream;
guint16 new_pid;
@ -744,6 +744,10 @@ tsmux_create_stream (TsMux * mux, guint stream_type, guint16 pid,
stream->language[0] = 0;
}
stream->max_bitrate = max_bitrate;
/* ignored if it's not audio */
stream->audio_bitrate = bitrate;
return stream;
}

View file

@ -228,7 +228,7 @@ gboolean tsmux_add_mpegts_si_section (TsMux * mux, GstMpegtsSection *
gboolean tsmux_send_section (TsMux *mux, GstMpegtsSection *section);
/* stream management */
TsMuxStream * tsmux_create_stream (TsMux *mux, guint stream_type, guint16 pid, gchar *language);
TsMuxStream * tsmux_create_stream (TsMux *mux, guint stream_type, guint16 pid, gchar *language, guint bitrate, guint max_bitrate);
TsMuxStream * tsmux_find_stream (TsMux *mux, guint16 pid);
gboolean tsmux_remove_stream (TsMux *mux, guint16 pid, TsMuxProgram *program);