mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
audio{enc,dec}oder: Check if srcpad caps are a subset of the template caps
This commit is contained in:
parent
2fe94cad44
commit
5aa6748151
2 changed files with 19 additions and 0 deletions
|
@ -503,6 +503,7 @@ gst_audio_decoder_set_output_format (GstAudioDecoder * dec,
|
||||||
gboolean res = TRUE;
|
gboolean res = TRUE;
|
||||||
guint old_rate;
|
guint old_rate;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
GstCaps *templ_caps;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dec, "Setting output format");
|
GST_DEBUG_OBJECT (dec, "Setting output format");
|
||||||
|
|
||||||
|
@ -514,6 +515,15 @@ gst_audio_decoder_set_output_format (GstAudioDecoder * dec,
|
||||||
if (!caps)
|
if (!caps)
|
||||||
goto refuse_caps;
|
goto refuse_caps;
|
||||||
|
|
||||||
|
/* Only allow caps that are a subset of the template caps */
|
||||||
|
templ_caps = gst_pad_get_pad_template_caps (dec->srcpad);
|
||||||
|
if (!gst_caps_is_subset (caps, templ_caps)) {
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
gst_caps_unref (templ_caps);
|
||||||
|
goto refuse_caps;
|
||||||
|
}
|
||||||
|
gst_caps_unref (templ_caps);
|
||||||
|
|
||||||
/* adjust ts tracking to new sample rate */
|
/* adjust ts tracking to new sample rate */
|
||||||
old_rate = GST_AUDIO_INFO_RATE (&dec->priv->ctx.info);
|
old_rate = GST_AUDIO_INFO_RATE (&dec->priv->ctx.info);
|
||||||
if (GST_CLOCK_TIME_IS_VALID (dec->priv->base_ts) && old_rate) {
|
if (GST_CLOCK_TIME_IS_VALID (dec->priv->base_ts) && old_rate) {
|
||||||
|
|
|
@ -2183,12 +2183,21 @@ gboolean
|
||||||
gst_audio_encoder_set_output_format (GstAudioEncoder * enc, GstCaps * caps)
|
gst_audio_encoder_set_output_format (GstAudioEncoder * enc, GstCaps * caps)
|
||||||
{
|
{
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
|
GstCaps *templ_caps;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (enc, "Setting srcpad caps %" GST_PTR_FORMAT, caps);
|
GST_DEBUG_OBJECT (enc, "Setting srcpad caps %" GST_PTR_FORMAT, caps);
|
||||||
|
|
||||||
if (!gst_caps_is_fixed (caps))
|
if (!gst_caps_is_fixed (caps))
|
||||||
goto refuse_caps;
|
goto refuse_caps;
|
||||||
|
|
||||||
|
/* Only allow caps that are a subset of the template caps */
|
||||||
|
templ_caps = gst_pad_get_pad_template_caps (enc->srcpad);
|
||||||
|
if (!gst_caps_is_subset (caps, templ_caps)) {
|
||||||
|
gst_caps_unref (templ_caps);
|
||||||
|
goto refuse_caps;
|
||||||
|
}
|
||||||
|
gst_caps_unref (templ_caps);
|
||||||
|
|
||||||
res = gst_pad_set_caps (enc->srcpad, caps);
|
res = gst_pad_set_caps (enc->srcpad, caps);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
Loading…
Reference in a new issue