Merge remote-tracking branch 'origin/master' into 0.11
[platform/upstream/gstreamer.git] / gst / playback / gstplaysinkconvertbin.c
1 /* GStreamer
2  * Copyright (C) <2011> Sebastian Dröge <sebastian.droege@collabora.co.uk>
3  * Copyright (C) <2011> Vincent Penquerch <vincent.penquerch@collabora.co.uk>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include "gstplaysinkconvertbin.h"
26
27 #include <gst/pbutils/pbutils.h>
28 #include <gst/gst-i18n-plugin.h>
29 #include "gst/glib-compat-private.h"
30
31 GST_DEBUG_CATEGORY_STATIC (gst_play_sink_convert_bin_debug);
32 #define GST_CAT_DEFAULT gst_play_sink_convert_bin_debug
33
34 #define parent_class gst_play_sink_convert_bin_parent_class
35
36 static gboolean gst_play_sink_convert_bin_sink_setcaps (GstPlaySinkConvertBin *
37     self, GstCaps * caps);
38
39 G_DEFINE_TYPE (GstPlaySinkConvertBin, gst_play_sink_convert_bin, GST_TYPE_BIN);
40
41 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
42     GST_PAD_SRC,
43     GST_PAD_ALWAYS,
44     GST_STATIC_CAPS_ANY);
45
46 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
47     GST_PAD_SINK,
48     GST_PAD_ALWAYS,
49     GST_STATIC_CAPS_ANY);
50
51 static gboolean
52 is_raw_caps (GstCaps * caps, gboolean audio)
53 {
54   gint i, n;
55   GstStructure *s;
56   const gchar *name;
57   const gchar *prefix = audio ? "audio/x-raw-" : "video/x-raw-";
58
59   n = gst_caps_get_size (caps);
60   for (i = 0; i < n; i++) {
61     s = gst_caps_get_structure (caps, i);
62     name = gst_structure_get_name (s);
63     if (!g_str_has_prefix (name, prefix))
64       return FALSE;
65   }
66
67   return TRUE;
68 }
69
70 static void
71 gst_play_sink_convert_bin_post_missing_element_message (GstPlaySinkConvertBin *
72     self, const gchar * name)
73 {
74   GstMessage *msg;
75
76   msg = gst_missing_element_message_new (GST_ELEMENT_CAST (self), name);
77   gst_element_post_message (GST_ELEMENT_CAST (self), msg);
78 }
79
80 static void
81 distribute_running_time (GstElement * element, const GstSegment * segment)
82 {
83   GstEvent *event;
84   GstPad *pad;
85
86   pad = gst_element_get_static_pad (element, "sink");
87
88   gst_pad_send_event (pad, gst_event_new_flush_start ());
89   gst_pad_send_event (pad, gst_event_new_flush_stop (FALSE));
90
91   if (segment->format != GST_FORMAT_UNDEFINED) {
92     event = gst_event_new_segment (segment);
93     gst_pad_send_event (pad, event);
94   }
95
96   gst_object_unref (pad);
97 }
98
99 void
100 gst_play_sink_convert_bin_add_conversion_element (GstPlaySinkConvertBin * self,
101     GstElement * el)
102 {
103   self->conversion_elements = g_list_append (self->conversion_elements, el);
104   gst_bin_add (GST_BIN (self), gst_object_ref (el));
105 }
106
107 GstElement *
108 gst_play_sink_convert_bin_add_conversion_element_factory (GstPlaySinkConvertBin
109     * self, const char *factory, const char *name)
110 {
111   GstElement *el;
112
113   el = gst_element_factory_make (factory, name);
114   if (el == NULL) {
115     gst_play_sink_convert_bin_post_missing_element_message (self, factory);
116     GST_ELEMENT_WARNING (self, CORE, MISSING_PLUGIN,
117         (_("Missing element '%s' - check your GStreamer installation."),
118             factory),
119         (self->audio ? "audio rendering might fail" :
120             "video rendering might fail"));
121   } else {
122     gst_play_sink_convert_bin_add_conversion_element (self, el);
123   }
124   return el;
125 }
126
127 void
128 gst_play_sink_convert_bin_add_identity (GstPlaySinkConvertBin * self)
129 {
130   if (self->identity)
131     return;
132
133   self->identity = gst_element_factory_make ("identity", "identity");
134   if (self->identity == NULL) {
135     gst_play_sink_convert_bin_post_missing_element_message (self, "identity");
136     GST_ELEMENT_WARNING (self, CORE, MISSING_PLUGIN,
137         (_("Missing element '%s' - check your GStreamer installation."),
138             "identity"), (self->audio ?
139             "audio rendering might fail" : "video rendering might fail")
140
141         );
142   } else {
143     g_object_set (self->identity, "silent", TRUE, "signal-handoffs", FALSE,
144         NULL);
145     gst_bin_add (GST_BIN_CAST (self), self->identity);
146   }
147 }
148
149 static void
150 gst_play_sink_convert_bin_set_targets (GstPlaySinkConvertBin * self,
151     gboolean passthrough)
152 {
153   GstPad *pad;
154   GstElement *head, *tail;
155
156   GST_DEBUG_OBJECT (self, "Setting pad targets with passthrough %d",
157       passthrough);
158   if (self->conversion_elements == NULL || passthrough) {
159     GST_DEBUG_OBJECT (self, "no conversion elements, using identity (%p) as "
160         "head/tail", self->identity);
161     if (!passthrough) {
162       GST_WARNING_OBJECT (self,
163           "Doing passthrough as no converter elements were added");
164     }
165     head = tail = self->identity;
166   } else {
167     head = GST_ELEMENT (g_list_first (self->conversion_elements)->data);
168     tail = GST_ELEMENT (g_list_last (self->conversion_elements)->data);
169     GST_DEBUG_OBJECT (self, "conversion elements in use, picking "
170         "head:%s and tail:%s", GST_OBJECT_NAME (head), GST_OBJECT_NAME (tail));
171   }
172
173   g_return_if_fail (head != NULL);
174   g_return_if_fail (tail != NULL);
175
176   pad = gst_element_get_static_pad (head, "sink");
177   GST_DEBUG_OBJECT (self, "Ghosting bin sink pad to %" GST_PTR_FORMAT, pad);
178   gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->sinkpad), pad);
179   gst_object_unref (pad);
180
181   pad = gst_element_get_static_pad (tail, "src");
182   GST_DEBUG_OBJECT (self, "Ghosting bin src pad to %" GST_PTR_FORMAT, pad);
183   gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->srcpad), pad);
184   gst_object_unref (pad);
185 }
186
187 static void
188 gst_play_sink_convert_bin_remove_element (GstElement * element,
189     GstPlaySinkConvertBin * self)
190 {
191   gst_element_set_state (element, GST_STATE_NULL);
192   gst_bin_remove (GST_BIN_CAST (self), element);
193 }
194
195 static void
196 gst_play_sink_convert_bin_on_element_added (GstElement * element,
197     GstPlaySinkConvertBin * self)
198 {
199   gst_element_sync_state_with_parent (element);
200   distribute_running_time (element, &self->segment);
201 }
202
203 static GstPadProbeReturn
204 pad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
205 {
206   GstPlaySinkConvertBin *self = user_data;
207   GstPad *peer;
208   GstCaps *caps;
209   gboolean raw;
210
211   GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
212   GST_DEBUG_OBJECT (self, "Pad blocked");
213
214   /* There must be a peer at this point */
215   peer = gst_pad_get_peer (self->sinkpad);
216   caps = gst_pad_get_current_caps (peer);
217   if (!caps)
218     caps = gst_pad_query_caps (peer, NULL);
219   gst_object_unref (peer);
220
221   raw = is_raw_caps (caps, self->audio);
222   GST_DEBUG_OBJECT (self, "Caps %" GST_PTR_FORMAT " are raw: %d", caps, raw);
223   gst_caps_unref (caps);
224
225   if (raw == self->raw)
226     goto unblock;
227   self->raw = raw;
228
229   gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->sinkpad), NULL);
230   gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->srcpad), NULL);
231
232   if (raw) {
233     GST_DEBUG_OBJECT (self, "Switching to raw conversion pipeline");
234
235     if (self->conversion_elements)
236       g_list_foreach (self->conversion_elements,
237           (GFunc) gst_play_sink_convert_bin_on_element_added, self);
238   } else {
239
240     GST_DEBUG_OBJECT (self, "Switch to passthrough pipeline");
241
242     gst_play_sink_convert_bin_on_element_added (self->identity, self);
243   }
244
245   gst_play_sink_convert_bin_set_targets (self, !raw);
246
247 unblock:
248   self->sink_proxypad_block_id = 0;
249   GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
250
251   return GST_PAD_PROBE_REMOVE;
252 }
253
254 static gboolean
255 gst_play_sink_convert_bin_sink_event (GstPad * pad, GstObject * parent,
256     GstEvent * event)
257 {
258   GstPlaySinkConvertBin *self = GST_PLAY_SINK_CONVERT_BIN (parent);
259   gboolean ret;
260
261   switch (GST_EVENT_TYPE (event)) {
262     case GST_EVENT_CAPS:
263     {
264       GstCaps *caps;
265
266       gst_event_parse_caps (event, &caps);
267       ret = gst_play_sink_convert_bin_sink_setcaps (self, caps);
268       break;
269     }
270     default:
271       break;
272   }
273
274   ret = gst_proxy_pad_event_default (pad, parent, gst_event_ref (event));
275
276   if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
277     GstSegment seg;
278
279     GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
280     gst_event_copy_segment (event, &seg);
281
282     GST_DEBUG_OBJECT (self, "Segment before %" GST_SEGMENT_FORMAT,
283         &self->segment);
284     self->segment = seg;
285     GST_DEBUG_OBJECT (self, "Segment after %" GST_SEGMENT_FORMAT,
286         &self->segment);
287     GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
288   } else if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP) {
289     GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
290     GST_DEBUG_OBJECT (self, "Resetting segment");
291     gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED);
292     GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
293   }
294
295   gst_event_unref (event);
296
297   return ret;
298 }
299
300 static void
301 block_proxypad (GstPlaySinkConvertBin * self)
302 {
303   if (self->sink_proxypad_block_id == 0) {
304     self->sink_proxypad_block_id =
305         gst_pad_add_probe (self->sink_proxypad,
306         GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM, pad_blocked_cb,
307         gst_object_ref (self), (GDestroyNotify) gst_object_unref);
308   }
309 }
310
311 static void
312 unblock_proxypad (GstPlaySinkConvertBin * self)
313 {
314   if (self->sink_proxypad_block_id != 0) {
315     gst_pad_remove_probe (self->sink_proxypad, self->sink_proxypad_block_id);
316     self->sink_proxypad_block_id = 0;
317   }
318 }
319
320 static gboolean
321 gst_play_sink_convert_bin_sink_setcaps (GstPlaySinkConvertBin * self,
322     GstCaps * caps)
323 {
324   GstStructure *s;
325   const gchar *name;
326   gboolean reconfigure = FALSE;
327   gboolean raw;
328
329   GST_DEBUG_OBJECT (self, "setcaps");
330   GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
331   s = gst_caps_get_structure (caps, 0);
332   name = gst_structure_get_name (s);
333
334   if (self->audio) {
335     raw = g_str_has_prefix (name, "audio/x-raw-");
336   } else {
337     raw = g_str_has_prefix (name, "video/x-raw-");
338   }
339
340   GST_DEBUG_OBJECT (self, "raw %d, self->raw %d, blocked %d",
341       raw, self->raw, gst_pad_is_blocked (self->sink_proxypad));
342
343   if (raw) {
344     if (!gst_pad_is_blocked (self->sink_proxypad)) {
345       GstPad *target = gst_ghost_pad_get_target (GST_GHOST_PAD (self->sinkpad));
346
347       if (!self->raw || (target && !gst_pad_query_accept_caps (target, caps))) {
348         if (!self->raw)
349           GST_DEBUG_OBJECT (self, "Changing caps from non-raw to raw");
350         else
351           GST_DEBUG_OBJECT (self, "Changing caps in an incompatible way");
352
353         reconfigure = TRUE;
354         block_proxypad (self);
355       }
356
357       if (target)
358         gst_object_unref (target);
359     }
360   } else {
361     if (self->raw && !gst_pad_is_blocked (self->sink_proxypad)) {
362       GST_DEBUG_OBJECT (self, "Changing caps from raw to non-raw");
363       reconfigure = TRUE;
364       block_proxypad (self);
365     }
366   }
367
368   /* Otherwise the setcaps below fails */
369   if (reconfigure) {
370     gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->sinkpad), NULL);
371     gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->srcpad), NULL);
372   }
373
374   GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
375
376   GST_DEBUG_OBJECT (self, "Setting sink caps %" GST_PTR_FORMAT, caps);
377
378   return TRUE;
379 }
380
381 static GstCaps *
382 gst_play_sink_convert_bin_getcaps (GstPad * pad, GstCaps * filter)
383 {
384   GstPlaySinkConvertBin *self =
385       GST_PLAY_SINK_CONVERT_BIN (gst_pad_get_parent (pad));
386   GstCaps *ret;
387   GstPad *otherpad, *peer;
388
389   GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
390   if (pad == self->srcpad) {
391     otherpad = self->sinkpad;
392   } else if (pad == self->sinkpad) {
393     otherpad = self->srcpad;
394   } else {
395     GST_ERROR_OBJECT (pad, "Not one of our pads");
396     otherpad = NULL;
397   }
398
399   if (otherpad) {
400     peer = gst_pad_get_peer (otherpad);
401     if (peer) {
402       GstCaps *peer_caps = gst_pad_query_caps (peer, filter);
403       gst_object_unref (peer);
404       if (self->converter_caps && is_raw_caps (peer_caps, self->audio)) {
405         peer_caps = gst_caps_make_writable (peer_caps);
406         gst_caps_merge (peer_caps, gst_caps_ref (self->converter_caps));
407         ret = peer_caps;
408       } else {
409         ret = peer_caps;
410       }
411     } else {
412       ret = gst_caps_ref (self->converter_caps);
413     }
414   } else {
415     ret = gst_caps_new_any ();
416   }
417   GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
418
419   gst_object_unref (self);
420
421   GST_DEBUG_OBJECT (pad, "Returning caps %" GST_PTR_FORMAT, ret);
422
423   return ret;
424 }
425
426 static gboolean
427 gst_play_sink_convert_bin_acceptcaps (GstPad * pad, GstCaps * caps)
428 {
429   GstCaps *allowed_caps;
430   gboolean ret;
431
432   allowed_caps = gst_pad_query_caps (pad, NULL);
433   /* FIXME 0.11: Should be a subset check now */
434   ret = gst_caps_can_intersect (caps, allowed_caps);
435   gst_caps_unref (allowed_caps);
436
437   return ret;
438 }
439
440 static gboolean
441 gst_play_sink_convert_bin_query (GstPad * pad, GstObject * parent,
442     GstQuery * query)
443 {
444   gboolean res = FALSE;
445
446   switch (GST_QUERY_TYPE (query)) {
447     case GST_QUERY_ACCEPT_CAPS:
448     {
449       GstCaps *caps;
450
451       gst_query_parse_accept_caps (query, &caps);
452       gst_query_set_accept_caps_result (query,
453           gst_play_sink_convert_bin_acceptcaps (pad, caps));
454       res = TRUE;
455       break;
456     }
457     case GST_QUERY_CAPS:
458     {
459       GstCaps *filter, *caps;
460
461       gst_query_parse_caps (query, &filter);
462       caps = gst_play_sink_convert_bin_getcaps (pad, filter);
463       gst_query_set_caps_result (query, caps);
464       gst_caps_unref (caps);
465       res = TRUE;
466       break;
467     }
468     default:
469       res = gst_pad_query_default (pad, parent, query);
470       break;
471   }
472   return res;
473 }
474
475 void
476 gst_play_sink_convert_bin_remove_elements (GstPlaySinkConvertBin * self)
477 {
478   if (self->conversion_elements) {
479     g_list_foreach (self->conversion_elements,
480         (GFunc) gst_play_sink_convert_bin_remove_element, self);
481     g_list_free (self->conversion_elements);
482     self->conversion_elements = NULL;
483   }
484   if (self->converter_caps) {
485     gst_caps_unref (self->converter_caps);
486     self->converter_caps = NULL;
487   }
488 }
489
490 static void
491 gst_play_sink_convert_bin_dispose (GObject * object)
492 {
493   GstPlaySinkConvertBin *self = GST_PLAY_SINK_CONVERT_BIN_CAST (object);
494
495   gst_play_sink_convert_bin_remove_elements (self);
496
497   G_OBJECT_CLASS (parent_class)->dispose (object);
498 }
499
500 static void
501 gst_play_sink_convert_bin_finalize (GObject * object)
502 {
503   GstPlaySinkConvertBin *self = GST_PLAY_SINK_CONVERT_BIN_CAST (object);
504
505   gst_object_unref (self->sink_proxypad);
506   g_mutex_free (self->lock);
507
508   G_OBJECT_CLASS (parent_class)->finalize (object);
509 }
510
511 void
512 gst_play_sink_convert_bin_cache_converter_caps (GstPlaySinkConvertBin * self)
513 {
514   GstElement *head;
515   GstPad *pad;
516
517   if (self->converter_caps) {
518     gst_caps_unref (self->converter_caps);
519     self->converter_caps = NULL;
520   }
521
522   if (!self->conversion_elements) {
523     GST_WARNING_OBJECT (self, "No conversion elements");
524     return;
525   }
526
527   head = GST_ELEMENT (g_list_first (self->conversion_elements)->data);
528   pad = gst_element_get_static_pad (head, "sink");
529   if (!pad) {
530     GST_WARNING_OBJECT (self, "No sink pad found");
531     return;
532   }
533
534   self->converter_caps = gst_pad_query_caps (pad, NULL);
535   GST_INFO_OBJECT (self, "Converter caps: %" GST_PTR_FORMAT,
536       self->converter_caps);
537
538   gst_object_unref (pad);
539 }
540
541 static GstStateChangeReturn
542 gst_play_sink_convert_bin_change_state (GstElement * element,
543     GstStateChange transition)
544 {
545   GstStateChangeReturn ret;
546   GstPlaySinkConvertBin *self = GST_PLAY_SINK_CONVERT_BIN_CAST (element);
547
548   switch (transition) {
549     case GST_STATE_CHANGE_PAUSED_TO_READY:
550       GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
551       unblock_proxypad (self);
552       GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
553       break;
554     case GST_STATE_CHANGE_READY_TO_PAUSED:
555       GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
556       gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED);
557       gst_play_sink_convert_bin_set_targets (self, TRUE);
558       self->raw = FALSE;
559       GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
560       break;
561     default:
562       break;
563   }
564
565   ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
566   if (ret == GST_STATE_CHANGE_FAILURE)
567     return ret;
568
569   switch (transition) {
570     case GST_STATE_CHANGE_PAUSED_TO_READY:
571       GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
572       gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED);
573       gst_play_sink_convert_bin_set_targets (self, TRUE);
574       self->raw = FALSE;
575       GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
576       break;
577     case GST_STATE_CHANGE_READY_TO_PAUSED:
578       GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
579       unblock_proxypad (self);
580       GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
581       break;
582     default:
583       break;
584   }
585
586   return ret;
587 }
588
589 static void
590 gst_play_sink_convert_bin_class_init (GstPlaySinkConvertBinClass * klass)
591 {
592   GObjectClass *gobject_class;
593   GstElementClass *gstelement_class;
594
595   GST_DEBUG_CATEGORY_INIT (gst_play_sink_convert_bin_debug,
596       "playsinkconvertbin", 0, "play bin");
597
598   gobject_class = (GObjectClass *) klass;
599   gstelement_class = (GstElementClass *) klass;
600
601   gobject_class->dispose = gst_play_sink_convert_bin_dispose;
602   gobject_class->finalize = gst_play_sink_convert_bin_finalize;
603
604   gst_element_class_add_pad_template (gstelement_class,
605       gst_static_pad_template_get (&srctemplate));
606   gst_element_class_add_pad_template (gstelement_class,
607       gst_static_pad_template_get (&sinktemplate));
608   gst_element_class_set_details_simple (gstelement_class,
609       "Player Sink Converter Bin", "Bin/Converter",
610       "Convenience bin for audio/video conversion",
611       "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
612
613   gstelement_class->change_state =
614       GST_DEBUG_FUNCPTR (gst_play_sink_convert_bin_change_state);
615 }
616
617 static void
618 gst_play_sink_convert_bin_init (GstPlaySinkConvertBin * self)
619 {
620   GstPadTemplate *templ;
621
622   self->lock = g_mutex_new ();
623   gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED);
624
625   templ = gst_static_pad_template_get (&sinktemplate);
626   self->sinkpad = gst_ghost_pad_new_no_target_from_template ("sink", templ);
627   gst_pad_set_event_function (self->sinkpad,
628       GST_DEBUG_FUNCPTR (gst_play_sink_convert_bin_sink_event));
629   gst_pad_set_query_function (self->sinkpad,
630       GST_DEBUG_FUNCPTR (gst_play_sink_convert_bin_query));
631
632   self->sink_proxypad =
633       GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD (self->sinkpad)));
634
635   gst_element_add_pad (GST_ELEMENT_CAST (self), self->sinkpad);
636   gst_object_unref (templ);
637
638   templ = gst_static_pad_template_get (&srctemplate);
639   self->srcpad = gst_ghost_pad_new_no_target_from_template ("src", templ);
640   gst_pad_set_query_function (self->srcpad,
641       GST_DEBUG_FUNCPTR (gst_play_sink_convert_bin_query));
642   gst_element_add_pad (GST_ELEMENT_CAST (self), self->srcpad);
643   gst_object_unref (templ);
644
645   gst_play_sink_convert_bin_add_identity (self);
646 }