mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:16:13 +00:00
flvdemux: Only set caps once if they don't change
Previously we were setting new caps with the same content for every H264 or AAC codec_data we found in the stream, spamming everything and causing renegotiations.
This commit is contained in:
parent
c9b42951fe
commit
ac0141b6a0
1 changed files with 38 additions and 20 deletions
|
@ -663,7 +663,7 @@ static gboolean
|
||||||
gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
|
gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
|
||||||
guint32 rate, guint32 channels, guint32 width)
|
guint32 rate, guint32 channels, guint32 width)
|
||||||
{
|
{
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL, *old_caps;
|
||||||
gchar *codec_name = NULL;
|
gchar *codec_name = NULL;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
guint adjusted_rate = rate;
|
guint adjusted_rate = rate;
|
||||||
|
@ -814,17 +814,25 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
|
||||||
demux->audio_codec_data, NULL);
|
demux->audio_codec_data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_id =
|
old_caps = gst_pad_get_current_caps (demux->audio_pad);
|
||||||
gst_pad_create_stream_id (demux->audio_pad, GST_ELEMENT_CAST (demux),
|
if (!old_caps) {
|
||||||
"audio");
|
stream_id =
|
||||||
|
gst_pad_create_stream_id (demux->audio_pad, GST_ELEMENT_CAST (demux),
|
||||||
|
"audio");
|
||||||
|
|
||||||
event = gst_event_new_stream_start (stream_id);
|
event = gst_event_new_stream_start (stream_id);
|
||||||
if (have_group_id (demux))
|
if (have_group_id (demux))
|
||||||
gst_event_set_group_id (event, demux->group_id);
|
gst_event_set_group_id (event, demux->group_id);
|
||||||
gst_pad_push_event (demux->audio_pad, event);
|
gst_pad_push_event (demux->audio_pad, event);
|
||||||
g_free (stream_id);
|
g_free (stream_id);
|
||||||
|
}
|
||||||
|
if (!old_caps || !gst_caps_is_equal (old_caps, caps))
|
||||||
|
ret = gst_pad_set_caps (demux->audio_pad, caps);
|
||||||
|
else
|
||||||
|
ret = TRUE;
|
||||||
|
|
||||||
ret = gst_pad_set_caps (demux->audio_pad, caps);
|
if (old_caps)
|
||||||
|
gst_caps_unref (old_caps);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (G_LIKELY (ret)) {
|
if (G_LIKELY (ret)) {
|
||||||
|
@ -1234,7 +1242,7 @@ static gboolean
|
||||||
gst_flv_demux_video_negotiate (GstFlvDemux * demux, guint32 codec_tag)
|
gst_flv_demux_video_negotiate (GstFlvDemux * demux, guint32 codec_tag)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL, *old_caps;
|
||||||
gchar *codec_name = NULL;
|
gchar *codec_name = NULL;
|
||||||
GstEvent *event;
|
GstEvent *event;
|
||||||
gchar *stream_id;
|
gchar *stream_id;
|
||||||
|
@ -1301,16 +1309,26 @@ gst_flv_demux_video_negotiate (GstFlvDemux * demux, guint32 codec_tag)
|
||||||
demux->video_codec_data, NULL);
|
demux->video_codec_data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_id =
|
old_caps = gst_pad_get_current_caps (demux->video_pad);
|
||||||
gst_pad_create_stream_id (demux->video_pad, GST_ELEMENT_CAST (demux),
|
if (!old_caps) {
|
||||||
"video");
|
stream_id =
|
||||||
event = gst_event_new_stream_start (stream_id);
|
gst_pad_create_stream_id (demux->video_pad, GST_ELEMENT_CAST (demux),
|
||||||
g_free (stream_id);
|
"video");
|
||||||
|
event = gst_event_new_stream_start (stream_id);
|
||||||
|
g_free (stream_id);
|
||||||
|
|
||||||
if (have_group_id (demux))
|
if (have_group_id (demux))
|
||||||
gst_event_set_group_id (event, demux->group_id);
|
gst_event_set_group_id (event, demux->group_id);
|
||||||
gst_pad_push_event (demux->video_pad, event);
|
gst_pad_push_event (demux->video_pad, event);
|
||||||
ret = gst_pad_set_caps (demux->video_pad, caps);
|
}
|
||||||
|
|
||||||
|
if (!old_caps || !gst_caps_is_equal (old_caps, caps))
|
||||||
|
ret = gst_pad_set_caps (demux->video_pad, caps);
|
||||||
|
else
|
||||||
|
ret = TRUE;
|
||||||
|
|
||||||
|
if (old_caps)
|
||||||
|
gst_caps_unref (old_caps);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (G_LIKELY (ret)) {
|
if (G_LIKELY (ret)) {
|
||||||
|
|
Loading…
Reference in a new issue