summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiagoss@osg.samsung.com>2015-08-16 13:21:41 -0300
committerThiago Santos <thiagoss@osg.samsung.com>2015-08-16 14:30:57 -0300
commita00546e0783f825d73b173b2fd4434fe9dbc0e4a (patch)
tree986717446bceccbc1a484d6c168286b372929f9f
parent3553493d96b651f8954aa79c8f2608e79089dbfb (diff)
flacenc: implement proper accept-caps
Should just compare with what can be immediatelly accepted by the element. flacenc can't renegotiate so if it has a caps already it should only accept if it is that caps otherwise just use the template caps
-rw-r--r--ext/flac/gstflacenc.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/ext/flac/gstflacenc.c b/ext/flac/gstflacenc.c
index f18b1eee7..377699d9e 100644
--- a/ext/flac/gstflacenc.c
+++ b/ext/flac/gstflacenc.c
@@ -141,6 +141,8 @@ static GstFlowReturn gst_flac_enc_handle_frame (GstAudioEncoder * enc,
static GstCaps *gst_flac_enc_getcaps (GstAudioEncoder * enc, GstCaps * filter);
static gboolean gst_flac_enc_sink_event (GstAudioEncoder * enc,
GstEvent * event);
+static gboolean gst_flac_enc_sink_query (GstAudioEncoder * enc,
+ GstQuery * query);
static void gst_flac_enc_finalize (GObject * object);
@@ -359,6 +361,7 @@ gst_flac_enc_class_init (GstFlacEncClass * klass)
base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_flac_enc_handle_frame);
base_class->getcaps = GST_DEBUG_FUNCPTR (gst_flac_enc_getcaps);
base_class->sink_event = GST_DEBUG_FUNCPTR (gst_flac_enc_sink_event);
+ base_class->sink_query = GST_DEBUG_FUNCPTR (gst_flac_enc_sink_query);
}
static void
@@ -1267,6 +1270,40 @@ gst_flac_enc_sink_event (GstAudioEncoder * enc, GstEvent * event)
return ret;
}
+static gboolean
+gst_flac_enc_sink_query (GstAudioEncoder * enc, GstQuery * query)
+{
+ GstPad *pad = GST_AUDIO_ENCODER_SINK_PAD (enc);
+ gboolean ret = FALSE;
+
+ GST_DEBUG ("Received %s query on sinkpad, %" GST_PTR_FORMAT,
+ GST_QUERY_TYPE_NAME (query), query);
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_ACCEPT_CAPS:{
+ GstCaps *acceptable, *caps;
+
+ if (gst_pad_has_current_caps (pad)) {
+ acceptable = gst_pad_get_current_caps (pad);
+ } else {
+ acceptable = gst_pad_get_pad_template_caps (pad);
+ }
+
+ gst_query_parse_accept_caps (query, &caps);
+
+ gst_query_set_accept_caps_result (query,
+ gst_caps_is_subset (caps, acceptable));
+ gst_caps_unref (acceptable);
+ }
+ break;
+ default:
+ ret = GST_AUDIO_ENCODER_CLASS (parent_class)->sink_query (enc, query);
+ break;
+ }
+
+ return ret;
+}
+
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define READ_INT24 GST_READ_UINT24_LE
#else