mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-09 05:38:58 +00:00
flvmux: Store incoming bitrate tags and send in the metadata
Apparently the Microsoft Azure RTMP server requires that the videodatarate and audiodatarate metadata be provided, so set those, even if it's to 0. Use the actual input bitrate tags if available.
This commit is contained in:
parent
b38e24995b
commit
db2967125b
2 changed files with 33 additions and 2 deletions
|
@ -280,23 +280,37 @@ gst_flv_mux_handle_src_event (GstPad * pad, GstObject * parent,
|
||||||
return gst_pad_event_default (pad, parent, event);
|
return gst_pad_event_default (pad, parent, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Extract per-codec relevant tags for
|
||||||
|
* insertion into the metadata later - ie bitrate,
|
||||||
|
* but maybe others in the future */
|
||||||
|
static void
|
||||||
|
gst_flv_mux_store_codec_tags (GstFlvMux * mux,
|
||||||
|
GstFlvPad * flvpad, GstTagList * list)
|
||||||
|
{
|
||||||
|
/* Look for a bitrate as either nominal or actual bitrate tag */
|
||||||
|
if (gst_tag_list_get_uint (list, GST_TAG_NOMINAL_BITRATE, &flvpad->bitrate) ||
|
||||||
|
gst_tag_list_get_uint (list, GST_TAG_BITRATE, &flvpad->bitrate)) {
|
||||||
|
GST_DEBUG_OBJECT (mux, "Stored bitrate for pad %" GST_PTR_FORMAT " = %u",
|
||||||
|
flvpad, flvpad->bitrate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_flv_mux_handle_sink_event (GstCollectPads * pads, GstCollectData * data,
|
gst_flv_mux_handle_sink_event (GstCollectPads * pads, GstCollectData * data,
|
||||||
GstEvent * event, gpointer user_data)
|
GstEvent * event, gpointer user_data)
|
||||||
{
|
{
|
||||||
GstFlvMux *mux = GST_FLV_MUX (user_data);
|
GstFlvMux *mux = GST_FLV_MUX (user_data);
|
||||||
|
GstFlvPad *flvpad = (GstFlvPad *) data;
|
||||||
gboolean ret = TRUE;
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
case GST_EVENT_CAPS:
|
case GST_EVENT_CAPS:
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstFlvPad *flvpad;
|
|
||||||
|
|
||||||
gst_event_parse_caps (event, &caps);
|
gst_event_parse_caps (event, &caps);
|
||||||
|
|
||||||
/* find stream data */
|
/* find stream data */
|
||||||
flvpad = (GstFlvPad *) data;
|
|
||||||
g_assert (flvpad);
|
g_assert (flvpad);
|
||||||
|
|
||||||
if (flvpad->video) {
|
if (flvpad->video) {
|
||||||
|
@ -316,6 +330,7 @@ gst_flv_mux_handle_sink_event (GstCollectPads * pads, GstCollectData * data,
|
||||||
|
|
||||||
gst_event_parse_tag (event, &list);
|
gst_event_parse_tag (event, &list);
|
||||||
gst_tag_setter_merge_tags (setter, list, mode);
|
gst_tag_setter_merge_tags (setter, list, mode);
|
||||||
|
gst_flv_mux_store_codec_tags (mux, flvpad, list);
|
||||||
mux->new_tags = TRUE;
|
mux->new_tags = TRUE;
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
|
@ -888,6 +903,13 @@ tags:
|
||||||
script_tag = gst_buffer_append (script_tag, tmp);
|
script_tag = gst_buffer_append (script_tag, tmp);
|
||||||
tags_written++;
|
tags_written++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (mux, "putting videodatarate %u KB/s in the metadata",
|
||||||
|
cpad->bitrate / 1024);
|
||||||
|
tmp = gst_flv_mux_create_number_script_value ("videodatarate",
|
||||||
|
cpad->bitrate / 1024);
|
||||||
|
script_tag = gst_buffer_append (script_tag, tmp);
|
||||||
|
tags_written++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,6 +934,13 @@ tags:
|
||||||
cpad->audio_codec);
|
cpad->audio_codec);
|
||||||
script_tag = gst_buffer_append (script_tag, tmp);
|
script_tag = gst_buffer_append (script_tag, tmp);
|
||||||
tags_written++;
|
tags_written++;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (mux, "putting audiodatarate %u KB/s in the metadata",
|
||||||
|
cpad->bitrate / 1024);
|
||||||
|
tmp = gst_flv_mux_create_number_script_value ("audiodatarate",
|
||||||
|
cpad->bitrate / 1024);
|
||||||
|
script_tag = gst_buffer_append (script_tag, tmp);
|
||||||
|
tags_written++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ typedef struct
|
||||||
guint video_codec;
|
guint video_codec;
|
||||||
GstBuffer *video_codec_data;
|
GstBuffer *video_codec_data;
|
||||||
|
|
||||||
|
guint bitrate;
|
||||||
|
|
||||||
GstClockTime last_timestamp;
|
GstClockTime last_timestamp;
|
||||||
gint64 pts;
|
gint64 pts;
|
||||||
gint64 dts;
|
gint64 dts;
|
||||||
|
|
Loading…
Reference in a new issue