2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000,2005 Wim Taymans <wim@fluendo.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
31 #include "gstbasesrc.h"
32 #include "gsttypefindhelper.h"
33 #include <gst/gstmarshal.h>
35 #define DEFAULT_BLOCKSIZE 4096
37 GST_DEBUG_CATEGORY_STATIC (gst_base_src_debug);
38 #define GST_CAT_DEFAULT gst_base_src_debug
40 /* BaseSrc signals and args */
55 static GstElementClass *parent_class = NULL;
57 static void gst_base_src_base_init (gpointer g_class);
58 static void gst_base_src_class_init (GstBaseSrcClass * klass);
59 static void gst_base_src_init (GstBaseSrc * src, gpointer g_class);
60 static void gst_base_src_finalize (GObject * object);
64 gst_base_src_get_type (void)
66 static GType base_src_type = 0;
69 static const GTypeInfo base_src_info = {
70 sizeof (GstBaseSrcClass),
71 (GBaseInitFunc) gst_base_src_base_init,
73 (GClassInitFunc) gst_base_src_class_init,
78 (GInstanceInitFunc) gst_base_src_init,
81 base_src_type = g_type_register_static (GST_TYPE_ELEMENT,
82 "GstBaseSrc", &base_src_info, G_TYPE_FLAG_ABSTRACT);
86 static GstCaps *gst_base_src_getcaps (GstPad * pad);
87 static gboolean gst_base_src_setcaps (GstPad * pad, GstCaps * caps);
89 static gboolean gst_base_src_activate_push (GstPad * pad, gboolean active);
90 static gboolean gst_base_src_activate_pull (GstPad * pad, gboolean active);
91 static void gst_base_src_set_property (GObject * object, guint prop_id,
92 const GValue * value, GParamSpec * pspec);
93 static void gst_base_src_get_property (GObject * object, guint prop_id,
94 GValue * value, GParamSpec * pspec);
95 static gboolean gst_base_src_event_handler (GstPad * pad, GstEvent * event);
97 static gboolean gst_base_src_query (GstPad * pad, GstQuery * query);
100 static const GstEventMask *gst_base_src_get_event_mask (GstPad * pad);
102 static gboolean gst_base_src_default_negotiate (GstBaseSrc * basesrc);
104 static gboolean gst_base_src_unlock (GstBaseSrc * basesrc);
105 static gboolean gst_base_src_get_size (GstBaseSrc * basesrc, guint64 * size);
106 static gboolean gst_base_src_start (GstBaseSrc * basesrc);
107 static gboolean gst_base_src_stop (GstBaseSrc * basesrc);
109 static GstElementStateReturn gst_base_src_change_state (GstElement * element);
111 static void gst_base_src_set_dataflow_funcs (GstBaseSrc * this);
112 static void gst_base_src_loop (GstPad * pad);
113 static gboolean gst_base_src_check_get_range (GstPad * pad);
114 static GstFlowReturn gst_base_src_get_range (GstPad * pad, guint64 offset,
115 guint length, GstBuffer ** buf);
118 gst_base_src_base_init (gpointer g_class)
120 GST_DEBUG_CATEGORY_INIT (gst_base_src_debug, "basesrc", 0, "basesrc element");
124 gst_base_src_class_init (GstBaseSrcClass * klass)
126 GObjectClass *gobject_class;
127 GstElementClass *gstelement_class;
129 gobject_class = (GObjectClass *) klass;
130 gstelement_class = (GstElementClass *) klass;
132 parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
134 gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_base_src_finalize);
135 gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_base_src_set_property);
136 gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_base_src_get_property);
138 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BLOCKSIZE,
139 g_param_spec_ulong ("blocksize", "Block size",
140 "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE,
143 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_HAS_LOOP,
144 g_param_spec_boolean ("has-loop", "Has loop function",
145 "True if the element should expose a loop function", TRUE,
146 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
148 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_HAS_GETRANGE,
149 g_param_spec_boolean ("has-getrange", "Has getrange function",
150 "True if the element should expose a getrange function", TRUE,
151 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
153 gstelement_class->change_state =
154 GST_DEBUG_FUNCPTR (gst_base_src_change_state);
156 klass->negotiate = gst_base_src_default_negotiate;
160 gst_base_src_init (GstBaseSrc * basesrc, gpointer g_class)
163 GstPadTemplate *pad_template;
165 basesrc->is_live = FALSE;
166 basesrc->live_lock = g_mutex_new ();
167 basesrc->live_cond = g_cond_new ();
170 gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src");
171 g_return_if_fail (pad_template != NULL);
173 pad = gst_pad_new_from_template (pad_template, "src");
175 gst_pad_set_activatepush_function (pad, gst_base_src_activate_push);
176 gst_pad_set_activatepull_function (pad, gst_base_src_activate_pull);
177 gst_pad_set_event_function (pad, gst_base_src_event_handler);
178 gst_pad_set_query_function (pad, gst_base_src_query);
179 gst_pad_set_checkgetrange_function (pad, gst_base_src_check_get_range);
180 gst_pad_set_getcaps_function (pad, gst_base_src_getcaps);
181 gst_pad_set_setcaps_function (pad, gst_base_src_setcaps);
183 /* hold ref to pad */
184 basesrc->srcpad = pad;
185 gst_element_add_pad (GST_ELEMENT (basesrc), pad);
187 basesrc->segment_start = -1;
188 basesrc->segment_end = -1;
189 basesrc->blocksize = DEFAULT_BLOCKSIZE;
190 basesrc->clock_id = NULL;
192 GST_FLAG_UNSET (basesrc, GST_BASE_SRC_STARTED);
196 gst_base_src_finalize (GObject * object)
200 basesrc = GST_BASE_SRC (object);
202 g_mutex_free (basesrc->live_lock);
203 g_cond_free (basesrc->live_cond);
205 G_OBJECT_CLASS (parent_class)->finalize (object);
209 gst_base_src_set_live (GstBaseSrc * src, gboolean live)
213 GST_LIVE_UNLOCK (src);
217 gst_base_src_is_live (GstBaseSrc * src)
222 result = src->is_live;
223 GST_LIVE_UNLOCK (src);
229 gst_base_src_set_dataflow_funcs (GstBaseSrc * this)
231 GST_DEBUG ("updating dataflow functions");
233 if (this->has_getrange)
234 gst_pad_set_getrange_function (this->srcpad, gst_base_src_get_range);
236 gst_pad_set_getrange_function (this->srcpad, NULL);
240 gst_base_src_setcaps (GstPad * pad, GstCaps * caps)
242 GstBaseSrcClass *bclass;
246 bsrc = GST_BASE_SRC (GST_PAD_PARENT (pad));
247 bclass = GST_BASE_SRC_GET_CLASS (bsrc);
249 if (bclass->set_caps)
250 res = bclass->set_caps (bsrc, caps);
256 gst_base_src_getcaps (GstPad * pad)
258 GstBaseSrcClass *bclass;
260 GstCaps *caps = NULL;
262 bsrc = GST_BASE_SRC (GST_PAD_PARENT (pad));
263 bclass = GST_BASE_SRC_GET_CLASS (bsrc);
264 if (bclass->get_caps)
265 caps = bclass->get_caps (bsrc);
268 GstPadTemplate *pad_template;
271 gst_element_class_get_pad_template (GST_ELEMENT_CLASS (bclass), "src");
272 if (pad_template != NULL) {
273 caps = gst_caps_ref (gst_pad_template_get_caps (pad_template));
280 gst_base_src_query (GstPad * pad, GstQuery * query)
287 src = GST_BASE_SRC (GST_PAD_PARENT (pad));
289 switch (GST_QUERY_TYPE (query)) {
290 case GST_QUERY_POSITION:
294 gst_query_parse_position (query, &format, NULL, NULL);
296 case GST_FORMAT_DEFAULT:
297 case GST_FORMAT_BYTES:
298 b = gst_base_src_get_size (src, &ui64);
299 /* better to make get_size take an int64 */
300 i64 = b ? (gint64) ui64 : -1;
301 gst_query_set_position (query, GST_FORMAT_BYTES, src->offset, i64);
303 case GST_FORMAT_PERCENT:
304 b = gst_base_src_get_size (src, &ui64);
305 i64 = GST_FORMAT_PERCENT_MAX;
306 i64 *= b ? (src->offset / (gdouble) ui64) : 1.0;
307 gst_query_set_position (query, GST_FORMAT_PERCENT,
308 i64, GST_FORMAT_PERCENT_MAX);
315 case GST_QUERY_SEEKING:
316 gst_query_set_seeking (query, GST_FORMAT_BYTES,
317 src->seekable, src->segment_start, src->segment_end);
320 case GST_QUERY_FORMATS:
321 gst_query_set_formats (query, 3, GST_FORMAT_DEFAULT,
322 GST_FORMAT_BYTES, GST_FORMAT_PERCENT);
325 case GST_QUERY_LATENCY:
326 case GST_QUERY_JITTER:
328 case GST_QUERY_CONVERT:
330 return gst_pad_query_default (pad, query);
335 static const GstEventMask *
336 gst_base_src_get_event_mask (GstPad * pad)
338 static const GstEventMask masks[] = {
339 {GST_EVENT_SEEK, GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_SET |
340 GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH |
341 GST_SEEK_FLAG_SEGMENT_LOOP},
342 {GST_EVENT_FLUSH, 0},
351 gst_base_src_do_seek (GstBaseSrc * src, GstEvent * event)
356 format = GST_EVENT_SEEK_FORMAT (event);
358 /* get seek format */
359 if (format == GST_FORMAT_DEFAULT)
360 format = GST_FORMAT_BYTES;
361 /* we can only seek bytes */
362 if (format != GST_FORMAT_BYTES)
365 /* get seek positions */
366 offset = GST_EVENT_SEEK_OFFSET (event);
367 src->segment_loop = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP;
369 switch (GST_EVENT_SEEK_METHOD (event)) {
370 case GST_SEEK_METHOD_SET:
373 src->offset = MIN (offset, src->size);
374 src->segment_start = src->offset;
375 src->segment_end = MIN (GST_EVENT_SEEK_ENDOFFSET (event), src->size);
376 GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT,
379 case GST_SEEK_METHOD_CUR:
380 offset += src->offset;
381 src->offset = CLAMP (offset, 0, src->size);
382 src->segment_start = src->offset;
383 src->segment_end = GST_EVENT_SEEK_ENDOFFSET (event);
384 GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT,
387 case GST_SEEK_METHOD_END:
390 offset = src->size + offset;
391 src->offset = MAX (0, offset);
392 src->segment_start = src->offset;
393 src->segment_end = GST_EVENT_SEEK_ENDOFFSET (event);
394 GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT,
401 /* send flush start */
402 gst_pad_push_event (src->srcpad, gst_event_new_flush (FALSE));
404 /* unblock streaming thread */
405 gst_base_src_unlock (src);
407 /* grab streaming lock */
408 GST_STREAM_LOCK (src->srcpad);
411 gst_pad_push_event (src->srcpad, gst_event_new_flush (TRUE));
413 /* now send discont */
417 event = gst_event_new_discontinuous (1.0,
419 (gint64) src->segment_start, (gint64) src->segment_end, NULL);
421 gst_pad_push_event (src->srcpad, event);
424 /* and restart the task */
425 gst_pad_start_task (src->srcpad, (GstTaskFunction) gst_base_src_loop,
427 GST_STREAM_UNLOCK (src->srcpad);
429 gst_event_unref (event);
436 GST_DEBUG_OBJECT (src, "seek error");
437 gst_event_unref (event);
443 gst_base_src_event_handler (GstPad * pad, GstEvent * event)
446 GstBaseSrcClass *bclass;
449 src = GST_BASE_SRC (GST_PAD_PARENT (pad));
450 bclass = GST_BASE_SRC_GET_CLASS (src);
453 result = bclass->event (src, event);
455 switch (GST_EVENT_TYPE (event)) {
457 return gst_base_src_do_seek (src, event);
462 format = GST_EVENT_SIZE_FORMAT (event);
463 if (format == GST_FORMAT_DEFAULT)
464 format = GST_FORMAT_BYTES;
465 /* we can only accept bytes */
466 if (format != GST_FORMAT_BYTES)
469 src->blocksize = GST_EVENT_SIZE_VALUE (event);
470 g_object_notify (G_OBJECT (src), "blocksize");
473 case GST_EVENT_FLUSH:
474 /* cancel any blocking getrange */
475 if (!GST_EVENT_FLUSH_DONE (event))
476 gst_base_src_unlock (src);
481 gst_event_unref (event);
487 gst_base_src_set_property (GObject * object, guint prop_id,
488 const GValue * value, GParamSpec * pspec)
492 src = GST_BASE_SRC (object);
496 src->blocksize = g_value_get_ulong (value);
499 src->has_loop = g_value_get_boolean (value);
500 gst_base_src_set_dataflow_funcs (src);
502 case PROP_HAS_GETRANGE:
503 src->has_getrange = g_value_get_boolean (value);
504 gst_base_src_set_dataflow_funcs (src);
507 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
513 gst_base_src_get_property (GObject * object, guint prop_id, GValue * value,
518 src = GST_BASE_SRC (object);
522 g_value_set_ulong (value, src->blocksize);
525 g_value_set_boolean (value, src->has_loop);
527 case PROP_HAS_GETRANGE:
528 g_value_set_boolean (value, src->has_getrange);
531 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
537 gst_base_src_get_range (GstPad * pad, guint64 offset, guint length,
542 GstBaseSrcClass *bclass;
544 src = GST_BASE_SRC (GST_OBJECT_PARENT (pad));
545 bclass = GST_BASE_SRC_GET_CLASS (src);
549 while (!src->live_running) {
550 GST_DEBUG ("live source signal waiting");
551 GST_LIVE_SIGNAL (src);
552 GST_DEBUG ("live source waiting for running state");
554 GST_DEBUG ("live source unlocked");
557 GST_LIVE_UNLOCK (src);
559 if (!GST_FLAG_IS_SET (src, GST_BASE_SRC_STARTED))
566 if (src->size != -1) {
567 if (offset > src->size)
568 goto unexpected_length;
570 if (offset + length > src->size) {
571 if (bclass->get_size)
572 bclass->get_size (src, &src->size);
574 if (offset + length > src->size) {
575 length = src->size - offset;
580 goto unexpected_length;
582 ret = bclass->create (src, offset, length, buf);
589 GST_DEBUG_OBJECT (src, "getrange but not started");
590 return GST_FLOW_WRONG_STATE;
594 GST_DEBUG_OBJECT (src, "no create function");
595 return GST_FLOW_ERROR;
599 GST_DEBUG_OBJECT (src, "unexpected length %u", length);
600 return GST_FLOW_UNEXPECTED;
605 gst_base_src_check_get_range (GstPad * pad)
609 src = GST_BASE_SRC (GST_OBJECT_PARENT (pad));
611 if (!GST_FLAG_IS_SET (src, GST_BASE_SRC_STARTED)) {
612 gst_base_src_start (src);
613 gst_base_src_stop (src);
616 return src->seekable;
620 gst_base_src_loop (GstPad * pad)
623 GstBuffer *buf = NULL;
626 src = GST_BASE_SRC (GST_OBJECT_PARENT (pad));
628 ret = gst_base_src_get_range (pad, src->offset, src->blocksize, &buf);
629 if (ret != GST_FLOW_OK)
635 src->offset += GST_BUFFER_SIZE (buf);
637 ret = gst_pad_push (pad, buf);
638 if (ret != GST_FLOW_OK)
645 GST_DEBUG_OBJECT (src, "going to EOS");
646 gst_pad_pause_task (pad);
647 gst_pad_push_event (pad, gst_event_new (GST_EVENT_EOS));
652 GST_DEBUG_OBJECT (src, "pausing task");
653 gst_pad_pause_task (pad);
658 GST_DEBUG_OBJECT (src, "got error, pausing task");
659 gst_pad_pause_task (pad);
660 gst_pad_push_event (pad, gst_event_new (GST_EVENT_EOS));
666 gst_base_src_unlock (GstBaseSrc * basesrc)
668 GstBaseSrcClass *bclass;
669 gboolean result = FALSE;
671 GST_DEBUG ("unlock");
672 /* unblock whatever the subclass is doing */
673 bclass = GST_BASE_SRC_GET_CLASS (basesrc);
675 result = bclass->unlock (basesrc);
677 GST_DEBUG ("unschedule clock");
678 /* and unblock the clock as well, if any */
680 if (basesrc->clock_id) {
681 gst_clock_id_unschedule (basesrc->clock_id);
683 GST_UNLOCK (basesrc);
685 GST_DEBUG ("unlock done");
691 gst_base_src_get_size (GstBaseSrc * basesrc, guint64 * size)
693 GstBaseSrcClass *bclass;
694 gboolean result = FALSE;
696 bclass = GST_BASE_SRC_GET_CLASS (basesrc);
697 if (bclass->get_size)
698 result = bclass->get_size (basesrc, size);
701 basesrc->size = *size;
707 gst_base_src_is_seekable (GstBaseSrc * basesrc)
709 GstBaseSrcClass *bclass;
711 bclass = GST_BASE_SRC_GET_CLASS (basesrc);
713 /* check if we can seek */
714 if (bclass->is_seekable)
715 basesrc->seekable = bclass->is_seekable (basesrc);
717 basesrc->seekable = FALSE;
719 return basesrc->seekable;
723 gst_base_src_default_negotiate (GstBaseSrc * basesrc)
726 GstCaps *caps = NULL;
727 GstCaps *peercaps = NULL;
728 gboolean result = FALSE;
730 thiscaps = gst_pad_get_caps (GST_BASE_SRC_PAD (basesrc));
731 GST_DEBUG ("caps of src: %" GST_PTR_FORMAT, thiscaps);
732 if (thiscaps == NULL || gst_caps_is_any (thiscaps))
735 peercaps = gst_pad_peer_get_caps (GST_BASE_SRC_PAD (basesrc));
736 GST_DEBUG ("caps of peer: %" GST_PTR_FORMAT, peercaps);
740 icaps = gst_caps_intersect (thiscaps, peercaps);
741 GST_DEBUG ("intersect: %" GST_PTR_FORMAT, icaps);
742 gst_caps_unref (thiscaps);
743 gst_caps_unref (peercaps);
745 caps = gst_caps_copy_nth (icaps, 0);
746 gst_caps_unref (icaps);
752 caps = gst_caps_make_writable (caps);
753 gst_pad_fixate_caps (GST_BASE_SRC_PAD (basesrc), caps);
754 GST_DEBUG ("fixated to: %" GST_PTR_FORMAT, caps);
756 if (gst_caps_is_any (caps)) {
757 gst_caps_unref (caps);
759 } else if (gst_caps_is_fixed (caps)) {
760 gst_pad_set_caps (GST_BASE_SRC_PAD (basesrc), caps);
761 gst_caps_unref (caps);
769 GST_DEBUG ("no negotiation needed");
771 gst_caps_unref (thiscaps);
777 gst_base_src_negotiate (GstBaseSrc * basesrc)
779 GstBaseSrcClass *bclass;
780 gboolean result = TRUE;
782 bclass = GST_BASE_SRC_GET_CLASS (basesrc);
784 if (bclass->negotiate)
785 result = bclass->negotiate (basesrc);
791 gst_base_src_start (GstBaseSrc * basesrc)
793 GstBaseSrcClass *bclass;
796 if (GST_FLAG_IS_SET (basesrc, GST_BASE_SRC_STARTED))
799 bclass = GST_BASE_SRC_GET_CLASS (basesrc);
801 result = bclass->start (basesrc);
806 goto could_not_start;
808 GST_FLAG_SET (basesrc, GST_BASE_SRC_STARTED);
810 /* start in the beginning */
812 basesrc->segment_start = 0;
814 /* figure out the size */
815 if (bclass->get_size) {
816 result = bclass->get_size (basesrc, &basesrc->size);
824 GST_DEBUG ("size %d %lld", result, basesrc->size);
826 /* we always run to the end */
827 basesrc->segment_end = -1;
829 /* check if we can seek, updates ->seekable */
830 gst_base_src_is_seekable (basesrc);
834 if (basesrc->seekable) {
837 caps = gst_type_find_helper (basesrc->srcpad, basesrc->size);
838 gst_pad_set_caps (basesrc->srcpad, caps);
839 gst_caps_unref (caps);
843 if (!gst_base_src_negotiate (basesrc))
844 goto could_not_negotiate;
851 GST_DEBUG_OBJECT (basesrc, "could not start");
856 GST_DEBUG_OBJECT (basesrc, "could not negotiate, stopping");
857 gst_base_src_stop (basesrc);
863 gst_base_src_stop (GstBaseSrc * basesrc)
865 GstBaseSrcClass *bclass;
866 gboolean result = TRUE;
868 if (!GST_FLAG_IS_SET (basesrc, GST_BASE_SRC_STARTED))
871 bclass = GST_BASE_SRC_GET_CLASS (basesrc);
873 result = bclass->stop (basesrc);
876 GST_FLAG_UNSET (basesrc, GST_BASE_SRC_STARTED);
882 gst_base_src_deactivate (GstBaseSrc * basesrc, GstPad * pad)
886 GST_LIVE_LOCK (basesrc);
887 basesrc->live_running = TRUE;
888 GST_LIVE_SIGNAL (basesrc);
889 GST_LIVE_UNLOCK (basesrc);
891 /* step 1, unblock clock sync (if any) */
892 gst_base_src_unlock (basesrc);
894 /* step 2, make sure streaming finishes */
895 result = gst_pad_stop_task (pad);
901 gst_base_src_activate_push (GstPad * pad, gboolean active)
905 basesrc = GST_BASE_SRC (GST_OBJECT_PARENT (pad));
907 /* prepare subclass first */
909 if (!gst_base_src_start (basesrc))
912 return gst_pad_start_task (pad, (GstTaskFunction) gst_base_src_loop, pad);
914 return gst_base_src_deactivate (basesrc, pad);
919 GST_DEBUG_OBJECT (basesrc, "failed to start");
925 gst_base_src_activate_pull (GstPad * pad, gboolean active)
929 basesrc = GST_BASE_SRC (GST_OBJECT_PARENT (pad));
931 /* prepare subclass first */
933 if (!gst_base_src_start (basesrc))
936 if (!basesrc->seekable) {
937 gst_base_src_stop (basesrc);
943 return gst_base_src_deactivate (basesrc, pad);
948 GST_DEBUG_OBJECT (basesrc, "failed to start");
953 static GstElementStateReturn
954 gst_base_src_change_state (GstElement * element)
957 GstElementStateReturn result = GST_STATE_SUCCESS;
958 GstElementStateReturn presult;
959 GstElementState transition;
961 basesrc = GST_BASE_SRC (element);
963 transition = GST_STATE_TRANSITION (element);
965 switch (transition) {
966 case GST_STATE_NULL_TO_READY:
968 case GST_STATE_READY_TO_PAUSED:
969 GST_LIVE_LOCK (element);
970 if (basesrc->is_live) {
971 result = GST_STATE_NO_PREROLL;
972 basesrc->live_running = FALSE;
974 GST_LIVE_UNLOCK (element);
976 case GST_STATE_PAUSED_TO_PLAYING:
977 GST_LIVE_LOCK (element);
978 if (basesrc->is_live) {
979 basesrc->live_running = TRUE;
980 GST_LIVE_SIGNAL (element);
982 GST_LIVE_UNLOCK (element);
988 if ((presult = GST_ELEMENT_CLASS (parent_class)->change_state (element)) !=
992 switch (transition) {
993 case GST_STATE_PLAYING_TO_PAUSED:
994 GST_LIVE_LOCK (element);
995 if (basesrc->is_live) {
996 result = GST_STATE_NO_PREROLL;
997 basesrc->live_running = FALSE;
999 GST_LIVE_UNLOCK (element);
1001 case GST_STATE_PAUSED_TO_READY:
1002 if (!gst_base_src_stop (basesrc))
1003 result = GST_STATE_FAILURE;
1005 case GST_STATE_READY_TO_NULL: