mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
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:
parent
7a98a4214b
commit
637e263504
4 changed files with 23 additions and 3 deletions
|
@ -118,6 +118,9 @@ gst_base_ts_mux_pad_reset (GstBaseTsMuxPad * pad)
|
||||||
g_free (pad->language);
|
g_free (pad->language);
|
||||||
pad->language = NULL;
|
pad->language = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pad->bitrate = 0;
|
||||||
|
pad->max_bitrate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GstAggregatorPad implementation */
|
/* GstAggregatorPad implementation */
|
||||||
|
@ -726,7 +729,8 @@ gst_base_ts_mux_create_or_update_stream (GstBaseTsMux * mux,
|
||||||
|
|
||||||
if (ts_pad->stream == NULL) {
|
if (ts_pad->stream == NULL) {
|
||||||
ts_pad->stream =
|
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)
|
if (ts_pad->stream == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -2080,6 +2084,8 @@ gst_base_ts_mux_sink_event (GstAggregator * agg, GstAggregatorPad * agg_pad,
|
||||||
case GST_EVENT_TAG:{
|
case GST_EVENT_TAG:{
|
||||||
GstTagList *list;
|
GstTagList *list;
|
||||||
gchar *lang = NULL;
|
gchar *lang = NULL;
|
||||||
|
guint bitrate = 0;
|
||||||
|
guint max_bitrate = 0;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (mux, "received tag event");
|
GST_DEBUG_OBJECT (mux, "received tag event");
|
||||||
gst_event_parse_tag (event, &list);
|
gst_event_parse_tag (event, &list);
|
||||||
|
@ -2101,6 +2107,14 @@ gst_base_ts_mux_sink_event (GstAggregator * agg, GstAggregatorPad * agg_pad,
|
||||||
g_free (lang);
|
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 */
|
/* handled this, don't want collectpads to forward it downstream */
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
forward = gst_tag_list_get_scope (list) == GST_TAG_SCOPE_GLOBAL;
|
forward = gst_tag_list_get_scope (list) == GST_TAG_SCOPE_GLOBAL;
|
||||||
|
|
|
@ -128,6 +128,8 @@ struct _GstBaseTsMuxPad
|
||||||
TsMuxProgram *prog;
|
TsMuxProgram *prog;
|
||||||
|
|
||||||
gchar *language;
|
gchar *language;
|
||||||
|
gint bitrate;
|
||||||
|
gint max_bitrate;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstBaseTsMuxPadClass
|
struct _GstBaseTsMuxPadClass
|
||||||
|
|
|
@ -714,7 +714,7 @@ tsmux_get_new_pid (TsMux * mux)
|
||||||
*/
|
*/
|
||||||
TsMuxStream *
|
TsMuxStream *
|
||||||
tsmux_create_stream (TsMux * mux, guint stream_type, guint16 pid,
|
tsmux_create_stream (TsMux * mux, guint stream_type, guint16 pid,
|
||||||
gchar * language)
|
gchar * language, guint bitrate, guint max_bitrate)
|
||||||
{
|
{
|
||||||
TsMuxStream *stream;
|
TsMuxStream *stream;
|
||||||
guint16 new_pid;
|
guint16 new_pid;
|
||||||
|
@ -744,6 +744,10 @@ tsmux_create_stream (TsMux * mux, guint stream_type, guint16 pid,
|
||||||
stream->language[0] = 0;
|
stream->language[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stream->max_bitrate = max_bitrate;
|
||||||
|
/* ignored if it's not audio */
|
||||||
|
stream->audio_bitrate = bitrate;
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@ gboolean tsmux_add_mpegts_si_section (TsMux * mux, GstMpegtsSection *
|
||||||
gboolean tsmux_send_section (TsMux *mux, GstMpegtsSection *section);
|
gboolean tsmux_send_section (TsMux *mux, GstMpegtsSection *section);
|
||||||
|
|
||||||
/* stream management */
|
/* 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);
|
TsMuxStream * tsmux_find_stream (TsMux *mux, guint16 pid);
|
||||||
gboolean tsmux_remove_stream (TsMux *mux, guint16 pid, TsMuxProgram *program);
|
gboolean tsmux_remove_stream (TsMux *mux, guint16 pid, TsMuxProgram *program);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue