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