2005-05-12 10:43:14 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000,2005 Wim Taymans <wim@fluendo.com>
|
|
|
|
*
|
2005-07-14 09:35:12 +00:00
|
|
|
* gstpushsrc.c:
|
2005-05-12 10:43:14 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2005-05-12 10:43:14 +00:00
|
|
|
*/
|
|
|
|
|
2005-08-03 13:30:18 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstpushsrc
|
|
|
|
* @short_description: Base class for push based source elements
|
2005-08-03 15:59:11 +00:00
|
|
|
* @see_also: #GstBaseSrc
|
2005-08-03 13:30:18 +00:00
|
|
|
*
|
2005-10-13 15:27:40 +00:00
|
|
|
* This class is mostly useful for elements that cannot do
|
2005-08-03 13:30:18 +00:00
|
|
|
* random access, or at least very slowly. The source usually
|
|
|
|
* prefers to push out a fixed size buffer.
|
|
|
|
*
|
libs/gst/: Documentation updates.
Original commit message from CVS:
* libs/gst/base/gstadapter.c:
* libs/gst/base/gstadapter.h:
* libs/gst/base/gstbasesink.c: (gst_base_sink_class_init),
(gst_base_sink_get_position):
* libs/gst/base/gstbasesink.h:
* libs/gst/base/gstbasesrc.c: (gst_base_src_class_init),
(gst_base_src_default_query), (gst_base_src_default_do_seek),
(gst_base_src_do_seek), (gst_base_src_perform_seek),
(gst_base_src_send_event), (gst_base_src_update_length),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_start):
* libs/gst/base/gstbasesrc.h:
* libs/gst/base/gstbasetransform.h:
* libs/gst/base/gstcollectpads.h:
* libs/gst/base/gstpushsrc.c:
* libs/gst/base/gstpushsrc.h:
* libs/gst/dataprotocol/dataprotocol.c:
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/net/gstnetclientclock.h:
* libs/gst/net/gstnettimeprovider.h:
Documentation updates.
2005-12-18 16:04:41 +00:00
|
|
|
* Subclasses usually operate in a format that is different from the
|
|
|
|
* default GST_FORMAT_BYTES format of #GstBaseSrc.
|
|
|
|
*
|
2005-08-03 13:30:18 +00:00
|
|
|
* Classes extending this base class will usually be scheduled
|
2005-12-12 14:43:57 +00:00
|
|
|
* in a push based mode. If the peer accepts to operate without
|
2006-07-05 18:20:58 +00:00
|
|
|
* offsets and within the limits of the allowed block size, this
|
|
|
|
* class can operate in getrange based mode automatically. To make
|
2011-06-05 17:11:22 +00:00
|
|
|
* this possible, the subclass should implement and override the
|
|
|
|
* SCHEDULING query.
|
2005-08-03 13:30:18 +00:00
|
|
|
*
|
|
|
|
* The subclass should extend the methods from the baseclass in
|
2006-07-05 18:20:58 +00:00
|
|
|
* addition to the ::create method.
|
2005-08-03 13:30:18 +00:00
|
|
|
*
|
|
|
|
* Seeking, flushing, scheduling and sync is all handled by this
|
|
|
|
* base class.
|
2006-07-05 18:20:58 +00:00
|
|
|
*
|
|
|
|
* Last reviewed on 2006-07-04 (0.10.9)
|
2005-08-03 13:30:18 +00:00
|
|
|
*/
|
2005-05-12 10:43:14 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2006-05-04 15:20:14 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2005-05-12 10:43:14 +00:00
|
|
|
#include "gstpushsrc.h"
|
|
|
|
#include "gsttypefindhelper.h"
|
|
|
|
|
2005-07-14 09:35:12 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_push_src_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_push_src_debug
|
2005-05-12 10:43:14 +00:00
|
|
|
|
2011-04-18 15:32:17 +00:00
|
|
|
#define _do_init \
|
2005-11-05 15:14:33 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_push_src_debug, "pushsrc", 0, \
|
|
|
|
"pushsrc element");
|
2005-05-12 10:43:14 +00:00
|
|
|
|
2011-04-18 15:32:17 +00:00
|
|
|
#define gst_push_src_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstPushSrc, gst_push_src, GST_TYPE_BASE_SRC, _do_init);
|
2005-05-12 10:43:14 +00:00
|
|
|
|
2011-05-24 15:36:24 +00:00
|
|
|
static gboolean gst_push_src_query (GstBaseSrc * src, GstQuery * query);
|
2005-07-14 09:35:12 +00:00
|
|
|
static GstFlowReturn gst_push_src_create (GstBaseSrc * bsrc, guint64 offset,
|
2005-05-12 10:43:14 +00:00
|
|
|
guint length, GstBuffer ** ret);
|
2011-11-10 12:36:10 +00:00
|
|
|
static GstFlowReturn gst_push_src_alloc (GstBaseSrc * bsrc, guint64 offset,
|
|
|
|
guint length, GstBuffer ** ret);
|
2011-06-13 10:07:03 +00:00
|
|
|
static GstFlowReturn gst_push_src_fill (GstBaseSrc * bsrc, guint64 offset,
|
|
|
|
guint length, GstBuffer * ret);
|
2005-05-12 10:43:14 +00:00
|
|
|
|
|
|
|
static void
|
2005-07-14 09:35:12 +00:00
|
|
|
gst_push_src_class_init (GstPushSrcClass * klass)
|
2005-05-12 10:43:14 +00:00
|
|
|
{
|
2005-11-05 15:14:33 +00:00
|
|
|
GstBaseSrcClass *gstbasesrc_class = (GstBaseSrcClass *) klass;
|
2005-05-12 10:43:14 +00:00
|
|
|
|
2005-07-14 09:35:12 +00:00
|
|
|
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_push_src_create);
|
2011-11-10 12:36:10 +00:00
|
|
|
gstbasesrc_class->alloc = GST_DEBUG_FUNCPTR (gst_push_src_alloc);
|
2011-06-13 10:07:03 +00:00
|
|
|
gstbasesrc_class->fill = GST_DEBUG_FUNCPTR (gst_push_src_fill);
|
2011-05-24 15:36:24 +00:00
|
|
|
gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_push_src_query);
|
2005-05-12 10:43:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-04-18 15:32:17 +00:00
|
|
|
gst_push_src_init (GstPushSrc * pushsrc)
|
2005-05-12 10:43:14 +00:00
|
|
|
{
|
2005-11-05 15:14:33 +00:00
|
|
|
/* nop */
|
2005-05-12 10:43:14 +00:00
|
|
|
}
|
|
|
|
|
2006-03-07 09:28:44 +00:00
|
|
|
static gboolean
|
2011-05-24 15:36:24 +00:00
|
|
|
gst_push_src_query (GstBaseSrc * src, GstQuery * query)
|
2006-03-07 09:28:44 +00:00
|
|
|
{
|
2011-05-24 15:36:24 +00:00
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_SCHEDULING:
|
|
|
|
{
|
|
|
|
/* a pushsrc can by default never operate in pull mode override
|
|
|
|
* if you want something different. */
|
2011-11-18 16:27:16 +00:00
|
|
|
gst_query_set_scheduling (query, GST_SCHEDULING_FLAG_SEQUENTIAL, 1, -1,
|
|
|
|
0);
|
|
|
|
gst_query_add_scheduling_mode (query, GST_PAD_MODE_PUSH);
|
|
|
|
|
2011-05-24 15:36:24 +00:00
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-05-26 12:14:13 +00:00
|
|
|
ret = GST_BASE_SRC_CLASS (parent_class)->query (src, query);
|
2011-05-24 15:36:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
2006-03-07 09:28:44 +00:00
|
|
|
}
|
|
|
|
|
2011-05-24 15:36:24 +00:00
|
|
|
|
2005-05-12 10:43:14 +00:00
|
|
|
static GstFlowReturn
|
2005-07-14 09:35:12 +00:00
|
|
|
gst_push_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
|
2005-05-12 10:43:14 +00:00
|
|
|
GstBuffer ** ret)
|
|
|
|
{
|
|
|
|
GstFlowReturn fret;
|
|
|
|
GstPushSrc *src;
|
|
|
|
GstPushSrcClass *pclass;
|
|
|
|
|
2005-07-14 09:35:12 +00:00
|
|
|
src = GST_PUSH_SRC (bsrc);
|
|
|
|
pclass = GST_PUSH_SRC_GET_CLASS (src);
|
2005-05-12 10:43:14 +00:00
|
|
|
if (pclass->create)
|
|
|
|
fret = pclass->create (src, ret);
|
|
|
|
else
|
2011-06-13 10:07:03 +00:00
|
|
|
fret =
|
|
|
|
GST_BASE_SRC_CLASS (parent_class)->create (bsrc, offset, length, ret);
|
|
|
|
|
|
|
|
return fret;
|
|
|
|
}
|
|
|
|
|
2011-11-10 12:36:10 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_push_src_alloc (GstBaseSrc * bsrc, guint64 offset, guint length,
|
|
|
|
GstBuffer ** ret)
|
|
|
|
{
|
|
|
|
GstFlowReturn fret;
|
|
|
|
GstPushSrc *src;
|
|
|
|
GstPushSrcClass *pclass;
|
|
|
|
|
|
|
|
src = GST_PUSH_SRC (bsrc);
|
|
|
|
pclass = GST_PUSH_SRC_GET_CLASS (src);
|
|
|
|
if (pclass->alloc)
|
|
|
|
fret = pclass->alloc (src, ret);
|
|
|
|
else
|
|
|
|
fret = GST_BASE_SRC_CLASS (parent_class)->alloc (bsrc, offset, length, ret);
|
|
|
|
|
|
|
|
return fret;
|
|
|
|
}
|
|
|
|
|
2011-06-13 10:07:03 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_push_src_fill (GstBaseSrc * bsrc, guint64 offset, guint length,
|
|
|
|
GstBuffer * ret)
|
|
|
|
{
|
|
|
|
GstFlowReturn fret;
|
|
|
|
GstPushSrc *src;
|
|
|
|
GstPushSrcClass *pclass;
|
|
|
|
|
|
|
|
src = GST_PUSH_SRC (bsrc);
|
|
|
|
pclass = GST_PUSH_SRC_GET_CLASS (src);
|
|
|
|
if (pclass->fill)
|
|
|
|
fret = pclass->fill (src, ret);
|
|
|
|
else
|
|
|
|
fret = GST_BASE_SRC_CLASS (parent_class)->fill (bsrc, offset, length, ret);
|
2005-05-12 10:43:14 +00:00
|
|
|
|
|
|
|
return fret;
|
|
|
|
}
|