audio/videodecoder: use gst_pad_peer_query_caps to make output caps
gst_pad_get_allowed_caps() will return NULL if the srcpad has no peer. In that case, use gst_pad_peer_query_caps() with template caps as filter to have negotiated output caps properly before forwarding GAP event. https://bugzilla.gnome.org/show_bug.cgi?id=761218
This commit is contained in:
parent
135c612550
commit
15df3c812b
@ -1950,7 +1950,7 @@ gst_audio_decoder_do_byte (GstAudioDecoder * dec)
|
|||||||
static gboolean
|
static gboolean
|
||||||
gst_audio_decoder_negotiate_default_caps (GstAudioDecoder * dec)
|
gst_audio_decoder_negotiate_default_caps (GstAudioDecoder * dec)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps, *templcaps;
|
||||||
gint i;
|
gint i;
|
||||||
gint channels = 0;
|
gint channels = 0;
|
||||||
gint rate;
|
gint rate;
|
||||||
@ -1958,10 +1958,21 @@ gst_audio_decoder_negotiate_default_caps (GstAudioDecoder * dec)
|
|||||||
gint caps_size;
|
gint caps_size;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
caps = gst_pad_get_allowed_caps (dec->srcpad);
|
templcaps = gst_pad_get_pad_template_caps (dec->srcpad);
|
||||||
|
caps = gst_pad_peer_query_caps (dec->srcpad, templcaps);
|
||||||
|
if (caps) {
|
||||||
|
gst_caps_unref (templcaps);
|
||||||
|
templcaps = NULL;
|
||||||
|
} else {
|
||||||
|
caps = templcaps;
|
||||||
|
templcaps = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!caps || gst_caps_is_empty (caps) || gst_caps_is_any (caps))
|
if (!caps || gst_caps_is_empty (caps) || gst_caps_is_any (caps))
|
||||||
goto caps_error;
|
goto caps_error;
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (dec, "peer caps %" GST_PTR_FORMAT, caps);
|
||||||
|
|
||||||
/* before fixating, try to use whatever upstream provided */
|
/* before fixating, try to use whatever upstream provided */
|
||||||
caps = gst_caps_make_writable (caps);
|
caps = gst_caps_make_writable (caps);
|
||||||
caps_size = gst_caps_get_size (caps);
|
caps_size = gst_caps_get_size (caps);
|
||||||
|
@ -1089,17 +1089,28 @@ _flush_events (GstPad * pad, GList * events)
|
|||||||
static gboolean
|
static gboolean
|
||||||
gst_video_decoder_negotiate_default_caps (GstVideoDecoder * decoder)
|
gst_video_decoder_negotiate_default_caps (GstVideoDecoder * decoder)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps, *templcaps;
|
||||||
GstVideoCodecState *state;
|
GstVideoCodecState *state;
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
gint i;
|
gint i;
|
||||||
gint caps_size;
|
gint caps_size;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
caps = gst_pad_get_allowed_caps (decoder->srcpad);
|
templcaps = gst_pad_get_pad_template_caps (decoder->srcpad);
|
||||||
|
caps = gst_pad_peer_query_caps (decoder->srcpad, templcaps);
|
||||||
|
if (caps) {
|
||||||
|
gst_caps_unref (templcaps);
|
||||||
|
templcaps = NULL;
|
||||||
|
} else {
|
||||||
|
caps = templcaps;
|
||||||
|
templcaps = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!caps || gst_caps_is_empty (caps) || gst_caps_is_any (caps))
|
if (!caps || gst_caps_is_empty (caps) || gst_caps_is_any (caps))
|
||||||
goto caps_error;
|
goto caps_error;
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (decoder, "peer caps %" GST_PTR_FORMAT, caps);
|
||||||
|
|
||||||
/* before fixating, try to use whatever upstream provided */
|
/* before fixating, try to use whatever upstream provided */
|
||||||
caps = gst_caps_make_writable (caps);
|
caps = gst_caps_make_writable (caps);
|
||||||
caps_size = gst_caps_get_size (caps);
|
caps_size = gst_caps_get_size (caps);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user