3d59ec74a7c964cb1a9aafeed11a1d8dfbc6fdc8
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-good / gst / multifile / gstimagesequencesrc.c
1 /* GStreamer
2  * Copyright (C) 2006 David A. Schleef ds@schleef.org
3  * Copyright (C) 2019 Cesar Fabian Orccon Chipana
4  * Copyright (C) 2020 Thibault Saunier <tsaunier@igalia.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
19  * Boston, MA 02110-1335, USA.
20  */
21
22 /**
23  * SECTION:element-imagesequencesrc
24  *
25  * Stream image sequences from image files.
26  *
27  * ```
28  * gst-launch-1.0 imagesequencesrc location=image-%05d.jpg start-index=1 stop-index=50 framerate=24/1 ! decodebin ! videoconvert ! autovideosink
29  * ```
30  *
31  * This elements implements the #GstURIHandler interface meaning that you can use it with playbin,
32  * (make sure to quote the URI for the filename pattern, like: `%2505d` instead of the `%05d` you would use
33  * when dealing with the location).
34  *
35  * Note that you can pass the #imagesequencesrc:framerate, #imagesequencesrc:start-index and #imagesequencesrc:stop-index
36  * properties directly in the URI using its 'query' component, for example:
37  *
38  * ```
39  * gst-launch-1.0 playbin uri="imagesequence://path/to/image-%2505d.jpeg?start-index=0&framerate=30/1"
40  * ```
41  */
42
43 #ifdef HAVE_CONFIG_H
44 #  include "config.h"
45 #endif
46
47 #include <gst/gst.h>
48 #include <gst/base/gsttypefindhelper.h>
49
50 #include "gstimagesequencesrc.h"
51
52 #define LOCK(self) (g_rec_mutex_lock (&self->fields_lock))
53 #define UNLOCK(self) (g_rec_mutex_unlock (&self->fields_lock))
54
55 static GstFlowReturn gst_image_sequence_src_create (GstPushSrc * src,
56     GstBuffer ** buffer);
57
58
59 static void gst_image_sequence_src_set_property (GObject * object,
60     guint prop_id, const GValue * value, GParamSpec * pspec);
61 static void gst_image_sequence_src_get_property (GObject * object,
62     guint prop_id, GValue * value, GParamSpec * pspec);
63 static GstCaps *gst_image_sequence_src_getcaps (GstBaseSrc * src,
64     GstCaps * filter);
65 static gboolean gst_image_sequence_src_query (GstBaseSrc * src,
66     GstQuery * query);
67 static void gst_image_sequence_src_set_caps (GstImageSequenceSrc * self,
68     GstCaps * caps);
69 static void gst_image_sequence_src_set_duration (GstImageSequenceSrc * self);
70 static gint gst_image_sequence_src_count_frames (GstImageSequenceSrc * self,
71     gboolean can_read);
72
73
74 static GstStaticPadTemplate gst_image_sequence_src_pad_template =
75 GST_STATIC_PAD_TEMPLATE ("src",
76     GST_PAD_SRC,
77     GST_PAD_ALWAYS,
78     GST_STATIC_CAPS_ANY);
79
80 GST_DEBUG_CATEGORY_STATIC (gst_image_sequence_src_debug);
81 #define GST_CAT_DEFAULT gst_image_sequence_src_debug
82
83 enum
84 {
85   PROP_0,
86   PROP_LOCATION,
87   PROP_START_INDEX,
88   PROP_STOP_INDEX,
89   PROP_FRAMERATE
90 };
91
92 #define DEFAULT_LOCATION "%05d"
93 #define DEFAULT_START_INDEX 0
94 #define DEFAULT_STOP_INDEX -1
95 #define DEFAULT_FRAMERATE 30
96
97 /* Call with LOCK taken */
98 static gboolean
99 gst_image_sequence_src_set_location (GstImageSequenceSrc * self,
100     const gchar * location)
101 {
102   g_free (self->path);
103   if (location != NULL)
104     self->path = g_strdup (location);
105   else
106     self->path = NULL;
107
108   return TRUE;
109 }
110
111 /*** GSTURIHANDLER INTERFACE *************************************************/
112
113 static GstURIType
114 gst_image_sequence_src_uri_get_type (GType type)
115 {
116   return GST_URI_SRC;
117 }
118
119 static const gchar *const *
120 gst_image_sequence_src_uri_get_protocols (GType type)
121 {
122   static const gchar *protocols[] = { "imagesequence", NULL };
123
124   return protocols;
125 }
126
127 static gchar *
128 gst_image_sequence_src_uri_get_uri (GstURIHandler * handler)
129 {
130   GstImageSequenceSrc *self = GST_IMAGE_SEQUENCE_SRC (handler);
131   gchar *uri = NULL;
132
133   LOCK (self);
134   if (self->uri)
135     uri = gst_uri_to_string (self->uri);
136   else if (self->path)
137     uri = gst_uri_construct ("imagesequence", self->path);
138   UNLOCK (self);
139
140   return uri;
141 }
142
143 static gboolean
144 gst_image_sequence_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
145     GError ** err)
146 {
147   gchar *hostname = NULL, *location = NULL, *path, *tmp;
148   gboolean ret = FALSE;
149   GstImageSequenceSrc *self = GST_IMAGE_SEQUENCE_SRC (handler);
150   GstUri *ruri = gst_uri_from_string (uri);
151   GHashTable *query = NULL;
152
153   if (!ruri) {
154     g_set_error (err, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
155         "imagesequencesrc URI is invalid: '%s'", uri);
156     goto beach;
157   }
158
159
160   LOCK (self);
161   g_clear_pointer (&self->uri, gst_uri_unref);
162   self->uri = ruri;
163   path = gst_uri_get_path (ruri);
164   tmp = gst_filename_to_uri (path, err);
165   location = g_filename_from_uri (tmp, &hostname, err);
166   g_free (tmp);
167   g_free (path);
168   query = gst_uri_get_query_table (ruri);
169   if (!location || (err != NULL && *err != NULL)) {
170     GST_WARNING_OBJECT (self, "Invalid URI '%s' for imagesequencesrc: %s", uri,
171         (err != NULL && *err != NULL) ? (*err)->message : "unknown error");
172     goto beach;
173   }
174
175   if (hostname && strcmp (hostname, "localhost")) {
176     /* Only 'localhost' is permitted */
177     GST_WARNING_OBJECT (self, "Invalid hostname '%s' for filesrc", hostname);
178     g_set_error (err, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
179         "File URI with invalid hostname '%s'", hostname);
180     goto beach;
181   }
182 #ifdef G_OS_WIN32
183   /* Unfortunately, g_filename_from_uri() doesn't handle some UNC paths
184    * correctly on windows, it leaves them with an extra backslash
185    * at the start if they're of the mozilla-style file://///host/path/file
186    * form. Correct this.
187    */
188   if (location[0] == '\\' && location[1] == '\\' && location[2] == '\\')
189     memmove (location, location + 1, strlen (location + 1) + 1);
190 #endif
191
192   ret = gst_image_sequence_src_set_location (self, location);
193
194   if (query) {
195     GHashTableIter iter;
196     gpointer key, value;
197
198     g_hash_table_iter_init (&iter, query);
199     while (g_hash_table_iter_next (&iter, &key, &value)) {
200       GST_INFO_OBJECT (self, "Setting property from URI: %s=%s", (gchar *) key,
201           (gchar *) value);
202       gst_util_set_object_arg (G_OBJECT (self), key, value);
203     }
204   }
205
206 beach:
207   UNLOCK (self);
208
209   g_free (location);
210   g_free (hostname);
211   g_clear_pointer (&query, g_hash_table_unref);
212
213   return ret;
214 }
215
216 static void
217 gst_image_sequence_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
218 {
219   GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
220
221   iface->get_type = gst_image_sequence_src_uri_get_type;
222   iface->get_protocols = gst_image_sequence_src_uri_get_protocols;
223   iface->get_uri = gst_image_sequence_src_uri_get_uri;
224   iface->set_uri = gst_image_sequence_src_uri_set_uri;
225 }
226
227 #define gst_image_sequence_src_parent_class parent_class
228 #define _do_init \
229   G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_image_sequence_src_uri_handler_init); \
230   GST_DEBUG_CATEGORY_INIT (gst_image_sequence_src_debug, "imagesequencesrc", \
231       0, "imagesequencesrc element");
232 G_DEFINE_TYPE_WITH_CODE (GstImageSequenceSrc, gst_image_sequence_src,
233     GST_TYPE_PUSH_SRC, _do_init);
234 GST_ELEMENT_REGISTER_DEFINE (imagesequencesrc, "imagesequencesrc",
235     GST_RANK_NONE, gst_image_sequence_src_get_type ());
236
237 static gboolean
238 is_seekable (GstBaseSrc * src)
239 {
240   GstImageSequenceSrc *self = GST_IMAGE_SEQUENCE_SRC (src);
241
242   if ((self->n_frames != 0) && (self->fps_n) && (self->fps_d))
243     return TRUE;
244   return FALSE;
245 }
246
247
248 static gboolean
249 do_seek (GstBaseSrc * bsrc, GstSegment * segment)
250 {
251   GstImageSequenceSrc *self;
252
253   self = GST_IMAGE_SEQUENCE_SRC (bsrc);
254
255   self->reverse = segment->rate < 0;
256   if (self->reverse) {
257     segment->time = segment->start;
258   }
259
260   self->index =
261       self->start_index +
262       segment->position * self->fps_n / (self->fps_d * GST_SECOND);
263
264   return TRUE;
265 }
266
267 static void
268 gst_image_sequence_src_finalize (GObject * object)
269 {
270   GstImageSequenceSrc *self = GST_IMAGE_SEQUENCE_SRC (object);
271
272   g_clear_pointer (&self->path, g_free);
273   g_rec_mutex_clear (&self->fields_lock);
274
275   G_OBJECT_CLASS (parent_class)->finalize (object);
276 }
277
278 static void
279 gst_image_sequence_src_dispose (GObject * object)
280 {
281   GstImageSequenceSrc *self = GST_IMAGE_SEQUENCE_SRC (object);
282
283   gst_clear_caps (&self->caps);
284   g_clear_pointer (&self->uri, gst_uri_unref);
285
286   G_OBJECT_CLASS (parent_class)->dispose (object);
287 }
288
289 static void
290 gst_image_sequence_src_class_init (GstImageSequenceSrcClass * klass)
291 {
292   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
293   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
294   GstPushSrcClass *gstpushsrc_class = GST_PUSH_SRC_CLASS (klass);
295   GstBaseSrcClass *gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
296
297   gobject_class->set_property = gst_image_sequence_src_set_property;
298   gobject_class->get_property = gst_image_sequence_src_get_property;
299
300
301   g_object_class_install_property (gobject_class, PROP_LOCATION,
302       g_param_spec_string ("location", "File Location",
303           "Pattern to create file names of input files.  File names are "
304           "created by calling sprintf() with the pattern and the current "
305           "index.", DEFAULT_LOCATION,
306           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
307   g_object_class_install_property (gobject_class, PROP_START_INDEX,
308       g_param_spec_int ("start-index", "Start Index",
309           "Start value of index.  The initial value of index can be set "
310           "either by setting index or start-index.  When the end of the loop "
311           "is reached, the index will be set to the value start-index.",
312           0, INT_MAX, DEFAULT_START_INDEX,
313           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
314   g_object_class_install_property (gobject_class, PROP_STOP_INDEX,
315       g_param_spec_int ("stop-index", "Stop Index",
316           "Stop value of index.  The special value -1 means no stop.",
317           -1, INT_MAX, DEFAULT_STOP_INDEX,
318           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
319   g_object_class_install_property (gobject_class, PROP_FRAMERATE,
320       gst_param_spec_fraction ("framerate", "Framerate",
321           "The output framerate.",
322           1, 1, G_MAXINT, 1, DEFAULT_FRAMERATE, 1,
323           G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
324
325   gobject_class->finalize = gst_image_sequence_src_finalize;
326   gobject_class->dispose = gst_image_sequence_src_dispose;
327
328   gstbasesrc_class->get_caps = gst_image_sequence_src_getcaps;
329   gstbasesrc_class->query = gst_image_sequence_src_query;
330   gstbasesrc_class->is_seekable = is_seekable;
331   gstbasesrc_class->do_seek = do_seek;
332
333   gstpushsrc_class->create = gst_image_sequence_src_create;
334
335   gst_element_class_add_static_pad_template (gstelement_class,
336       &gst_image_sequence_src_pad_template);
337   gst_element_class_set_static_metadata (gstelement_class,
338       "Image Sequence Source", "Source/File/Video",
339       "Create a video stream from a sequence of image files",
340       "Cesar Fabian Orccon Chipana <cfoch.fabian@gmail.com>\n"
341       "Thibault Saunier <tsaunier@igalia.com>");
342 }
343
344 static void
345 gst_image_sequence_src_init (GstImageSequenceSrc * self)
346 {
347   GstBaseSrc *bsrc;
348
349   GST_DEBUG_CATEGORY_INIT (gst_image_sequence_src_debug, "imagesequencesrc", 0,
350       "imagesequencesrc element");
351
352   bsrc = GST_BASE_SRC (self);
353   gst_base_src_set_format (bsrc, GST_FORMAT_TIME);
354
355   g_rec_mutex_init (&self->fields_lock);
356   self->start_index = DEFAULT_START_INDEX;
357   self->index = 0;
358   self->stop_index = DEFAULT_STOP_INDEX;
359   self->path = g_strdup (DEFAULT_LOCATION);
360   self->caps = NULL;
361   self->n_frames = 0;
362   self->fps_n = 30;
363   self->fps_d = 1;
364 }
365
366 static GstCaps *
367 gst_image_sequence_src_getcaps (GstBaseSrc * src, GstCaps * filter)
368 {
369   GstImageSequenceSrc *self = GST_IMAGE_SEQUENCE_SRC (src);
370
371   GST_DEBUG_OBJECT (self, "returning %" GST_PTR_FORMAT, self->caps);
372
373   if (filter) {
374     if (self->caps)
375       return gst_caps_intersect_full (filter, self->caps,
376           GST_CAPS_INTERSECT_FIRST);
377     else
378       return gst_caps_ref (filter);
379   }
380
381   return gst_caps_new_any ();
382 }
383
384 static gboolean
385 gst_image_sequence_src_query (GstBaseSrc * bsrc, GstQuery * query)
386 {
387   gboolean ret;
388   GstImageSequenceSrc *self;
389
390   self = GST_IMAGE_SEQUENCE_SRC (bsrc);
391
392   switch (GST_QUERY_TYPE (query)) {
393     case GST_QUERY_DURATION:
394     {
395       GstFormat format;
396
397       gst_query_parse_duration (query, &format, NULL);
398
399       switch (format) {
400         case GST_FORMAT_TIME:
401           LOCK (self);
402           if (self->n_frames <= 0) {
403             gst_image_sequence_src_count_frames (self, FALSE);
404             gst_image_sequence_src_set_duration (self);
405           }
406
407           if (self->n_frames > 0)
408             gst_query_set_duration (query, format, self->duration);
409           UNLOCK (self);
410
411           ret = TRUE;
412           break;
413         default:
414           ret = GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);
415       }
416       break;
417     }
418     default:
419       ret = GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);
420       break;
421   }
422
423   return ret;
424 }
425
426 static void
427 gst_image_sequence_src_set_property (GObject * object, guint prop_id,
428     const GValue * value, GParamSpec * pspec)
429 {
430   GstImageSequenceSrc *self = GST_IMAGE_SEQUENCE_SRC (object);
431
432   LOCK (self);
433   switch (prop_id) {
434     case PROP_LOCATION:
435       gst_image_sequence_src_set_location (self, g_value_get_string (value));
436       break;
437     case PROP_START_INDEX:
438       self->start_index = g_value_get_int (value);
439       gst_image_sequence_src_count_frames (self, FALSE);
440       break;
441     case PROP_STOP_INDEX:
442       self->stop_index = g_value_get_int (value);
443       gst_image_sequence_src_count_frames (self, FALSE);
444       break;
445     case PROP_FRAMERATE:
446       self->fps_n = gst_value_get_fraction_numerator (value);
447       self->fps_d = gst_value_get_fraction_denominator (value);
448       break;
449     default:
450       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
451       break;
452   }
453   UNLOCK (self);
454 }
455
456 static void
457 gst_image_sequence_src_get_property (GObject * object, guint prop_id,
458     GValue * value, GParamSpec * pspec)
459 {
460   GstImageSequenceSrc *self = GST_IMAGE_SEQUENCE_SRC (object);
461
462   LOCK (self);
463   switch (prop_id) {
464     case PROP_LOCATION:
465       g_value_set_string (value, self->path);
466       break;
467     case PROP_START_INDEX:
468       g_value_set_int (value, self->start_index);
469       break;
470     case PROP_STOP_INDEX:
471       g_value_set_int (value, self->stop_index);
472       break;
473     case PROP_FRAMERATE:
474       self->fps_n = gst_value_get_fraction_numerator (value);
475       self->fps_d = gst_value_get_fraction_denominator (value);
476       GST_DEBUG_OBJECT (self, "Set (framerate) property to (%d/%d)",
477           self->fps_n, self->fps_d);
478       break;
479     default:
480       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
481       break;
482   }
483   UNLOCK (self);
484 }
485
486 /* Call with LOCK */
487 static gint
488 gst_image_sequence_src_count_frames (GstImageSequenceSrc * self,
489     gboolean can_read)
490 {
491   if (can_read && self->stop_index < 0 && self->path) {
492     gint i;
493
494     for (i = self->start_index;; i++) {
495       gchar *filename = g_strdup_printf (self->path, i);
496
497       if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
498         i--;
499         g_free (filename);
500         break;
501       }
502
503       g_free (filename);
504     }
505     if (i > self->start_index)
506       self->stop_index = i;
507   }
508
509   if (self->stop_index >= self->start_index)
510     self->n_frames = self->stop_index - self->start_index + 1;
511   return self->n_frames;
512 }
513
514 static void
515 gst_image_sequence_src_set_caps (GstImageSequenceSrc * self, GstCaps * caps)
516 {
517   GstCaps *new_caps;
518
519   g_assert (caps != NULL);
520   new_caps = gst_caps_copy (caps);
521
522   if (self->n_frames > 0) {
523     GValue fps = G_VALUE_INIT;
524     g_value_init (&fps, GST_TYPE_FRACTION);
525     gst_value_set_fraction (&fps, self->fps_n, self->fps_d);
526     gst_caps_set_value (new_caps, "framerate", &fps);
527     g_value_unset (&fps);
528   }
529
530   gst_caps_replace (&self->caps, new_caps);
531   gst_pad_set_caps (GST_BASE_SRC_PAD (self), new_caps);
532
533   GST_DEBUG_OBJECT (self, "Setting new caps: %" GST_PTR_FORMAT, new_caps);
534
535   gst_caps_unref (new_caps);
536 }
537
538 /* Call with LOCK */
539 static void
540 gst_image_sequence_src_set_duration (GstImageSequenceSrc * self)
541 {
542   GstClockTime old_duration = self->duration;
543
544   if (self->n_frames <= 0)
545     return;
546
547   /* Calculate duration */
548   self->duration =
549       gst_util_uint64_scale (GST_SECOND * self->n_frames, self->fps_d,
550       self->fps_n);
551
552   if (self->duration != old_duration) {
553     UNLOCK (self);
554     gst_element_post_message (GST_ELEMENT (self),
555         gst_message_new_duration_changed (GST_OBJECT (self)));
556     LOCK (self);
557   }
558 }
559
560 /* Call with LOCK */
561 static gchar *
562 gst_image_sequence_src_get_filename (GstImageSequenceSrc * self)
563 {
564   gchar *filename;
565
566   GST_DEBUG ("Reading filename at index %d.", self->index);
567   filename = g_strdup_printf (self->path, self->index);
568
569   return filename;
570 }
571
572 static GstFlowReturn
573 gst_image_sequence_src_create (GstPushSrc * src, GstBuffer ** buffer)
574 {
575   GstImageSequenceSrc *self;
576   gsize size;
577   gchar *data;
578   gchar *filename;
579   GstBuffer *buf;
580   gboolean ret;
581   GError *error = NULL;
582   gint fps_n, fps_d, start_index, stop_index;
583
584   self = GST_IMAGE_SEQUENCE_SRC (src);
585
586   LOCK (self);
587   start_index = self->start_index;
588   stop_index = self->stop_index;
589   if (self->index > stop_index && stop_index > 0) {
590     UNLOCK (self);
591
592     return GST_FLOW_EOS;
593   }
594
595   if (self->index < self->start_index)
596     self->index = self->start_index;
597
598   g_assert (start_index <= self->index &&
599       (self->index <= stop_index || stop_index <= 0));
600
601   filename = gst_image_sequence_src_get_filename (self);
602   fps_n = self->fps_n;
603   fps_d = self->fps_d;
604   UNLOCK (self);
605
606   if (!filename)
607     goto handle_error;
608
609   ret = g_file_get_contents (filename, &data, &size, &error);
610   if (!ret)
611     goto handle_error;
612
613   buf = gst_buffer_new_wrapped (data, size);
614
615   if (!self->caps) {
616     GstCaps *caps;
617     caps = gst_type_find_helper_for_buffer (NULL, buf, NULL);
618     if (!caps) {
619       GST_ELEMENT_ERROR (self, STREAM, TYPE_NOT_FOUND, (NULL),
620           ("Could not determine image type."));
621
622       return GST_FLOW_NOT_SUPPORTED;
623     }
624
625     LOCK (self);
626     gst_image_sequence_src_count_frames (self, TRUE);
627     gst_image_sequence_src_set_duration (self);
628     UNLOCK (self);
629
630     gst_image_sequence_src_set_caps (self, caps);
631     gst_caps_unref (caps);
632   }
633
634   GST_BUFFER_PTS (buf) =
635       gst_util_uint64_scale_ceil ((self->index - start_index) * GST_SECOND,
636       fps_d, fps_n);
637   GST_BUFFER_DURATION (buf) = gst_util_uint64_scale (GST_SECOND, fps_d, fps_n);
638   GST_BUFFER_OFFSET (buf) = self->index - start_index;
639   GST_LOG_OBJECT (self, "index: %d, %s - %" GST_PTR_FORMAT, self->index,
640       filename, buf);
641
642   g_free (filename);
643   *buffer = buf;
644
645   self->index += self->reverse ? -1 : 1;
646   return GST_FLOW_OK;
647
648 handle_error:
649   {
650     if (error != NULL) {
651       GST_ELEMENT_ERROR (self, RESOURCE, READ,
652           ("Error while reading from file \"%s\".", filename),
653           ("%s", error->message));
654       g_error_free (error);
655     } else {
656       GST_ELEMENT_ERROR (self, RESOURCE, READ,
657           ("Error while reading from file \"%s\".", filename),
658           ("%s", g_strerror (errno)));
659     }
660     g_free (filename);
661     return GST_FLOW_ERROR;
662   }
663 }