From 6e9904fa8a6ea55c911775f426fe8e4d024ed368 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 4 Sep 2009 17:32:34 +0200 Subject: [PATCH] siren: fix setting caps on the output pad Also set the caps on the output pad when the input buffers don't have caps. --- gst/siren/gstsirendec.c | 10 +++++++++- gst/siren/gstsirenenc.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gst/siren/gstsirendec.c b/gst/siren/gstsirendec.c index d6eb35ed6f..45cfe05b09 100644 --- a/gst/siren/gstsirendec.c +++ b/gst/siren/gstsirendec.c @@ -218,6 +218,7 @@ gst_siren_dec_chain (GstPad * pad, GstBuffer * buf) gboolean discont; GstClockTime timestamp; guint64 distance; + GstCaps *outcaps; dec = GST_SIREN_DEC (GST_PAD_PARENT (pad)); @@ -248,9 +249,16 @@ gst_siren_dec_chain (GstPad * pad, GstBuffer * buf) GST_LOG_OBJECT (dec, "we have %u frames, %u in, %u out", num_frames, in_size, out_size); + /* set output caps when needed */ + if ((outcaps = GST_PAD_CAPS (dec->srcpad)) == NULL) { + outcaps = gst_static_pad_template_get_caps (&srctemplate); + gst_pad_set_caps (dec->srcpad, outcaps); + gst_caps_unref (outcaps); + } + /* get a buffer */ ret = gst_pad_alloc_buffer_and_set_caps (dec->srcpad, -1, - out_size, GST_PAD_CAPS (dec->srcpad), &out_buf); + out_size, outcaps, &out_buf); if (ret != GST_FLOW_OK) goto alloc_failed; diff --git a/gst/siren/gstsirenenc.c b/gst/siren/gstsirenenc.c index 9b6a2a8b26..f42f16ee13 100644 --- a/gst/siren/gstsirenenc.c +++ b/gst/siren/gstsirenenc.c @@ -220,6 +220,7 @@ gst_siren_enc_chain (GstPad * pad, GstBuffer * buf) gboolean discont; GstClockTime timestamp; guint64 distance; + GstCaps *outcaps; enc = GST_SIREN_ENC (GST_PAD_PARENT (pad)); @@ -252,9 +253,16 @@ gst_siren_enc_chain (GstPad * pad, GstBuffer * buf) GST_LOG_OBJECT (enc, "we have %u frames, %u in, %u out", num_frames, in_size, out_size); + /* set output caps when needed */ + if ((outcaps = GST_PAD_CAPS (enc->srcpad)) == NULL) { + outcaps = gst_static_pad_template_get_caps (&srctemplate); + gst_pad_set_caps (enc->srcpad, outcaps); + gst_caps_unref (outcaps); + } + /* get a buffer */ ret = gst_pad_alloc_buffer_and_set_caps (enc->srcpad, -1, - out_size, GST_PAD_CAPS (enc->srcpad), &out_buf); + out_size, outcaps, &out_buf); if (ret != GST_FLOW_OK) goto alloc_failed;