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
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* Classes extending this base class will usually be scheduled
|
|
|
|
* in a push based mode. It the peer accepts to operate without
|
|
|
|
* offsets and withing the limits of the allowed block size, this
|
|
|
|
* class can operate in getrange based mode automatically.
|
|
|
|
*
|
|
|
|
* The subclass should extend the methods from the baseclass in
|
|
|
|
* addition to the create method.
|
|
|
|
*
|
|
|
|
* Seeking, flushing, scheduling and sync is all handled by this
|
|
|
|
* base class.
|
|
|
|
*/
|
2005-05-12 10:43:14 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstpushsrc.h"
|
|
|
|
#include "gsttypefindhelper.h"
|
|
|
|
#include <gst/gstmarshal.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
|
|
|
|
|
|
|
/* PushSrc signals and args */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
2005-07-14 09:35:12 +00:00
|
|
|
static void gst_push_src_base_init (gpointer g_class);
|
|
|
|
static void gst_push_src_class_init (GstPushSrcClass * klass);
|
|
|
|
static void gst_push_src_init (GstPushSrc * src, gpointer g_class);
|
2005-05-12 10:43:14 +00:00
|
|
|
|
|
|
|
GType
|
2005-07-14 09:35:12 +00:00
|
|
|
gst_push_src_get_type (void)
|
2005-05-12 10:43:14 +00:00
|
|
|
{
|
2005-07-14 09:35:12 +00:00
|
|
|
static GType push_src_type = 0;
|
2005-05-12 10:43:14 +00:00
|
|
|
|
2005-07-14 09:35:12 +00:00
|
|
|
if (!push_src_type) {
|
|
|
|
static const GTypeInfo push_src_info = {
|
2005-05-12 10:43:14 +00:00
|
|
|
sizeof (GstPushSrcClass),
|
2005-07-14 09:35:12 +00:00
|
|
|
(GBaseInitFunc) gst_push_src_base_init,
|
2005-05-12 10:43:14 +00:00
|
|
|
NULL,
|
2005-07-14 09:35:12 +00:00
|
|
|
(GClassInitFunc) gst_push_src_class_init,
|
2005-05-12 10:43:14 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstPushSrc),
|
|
|
|
0,
|
2005-07-14 09:35:12 +00:00
|
|
|
(GInstanceInitFunc) gst_push_src_init,
|
2005-05-12 10:43:14 +00:00
|
|
|
};
|
|
|
|
|
2005-07-14 09:35:12 +00:00
|
|
|
push_src_type = g_type_register_static (GST_TYPE_BASE_SRC,
|
|
|
|
"GstPushSrc", &push_src_info, G_TYPE_FLAG_ABSTRACT);
|
2005-05-12 10:43:14 +00:00
|
|
|
}
|
2005-07-14 09:35:12 +00:00
|
|
|
return push_src_type;
|
2005-05-12 10:43:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2005-07-14 09:35:12 +00:00
|
|
|
static const GstEventMask *gst_push_src_get_event_mask (GstPad * pad);
|
2005-05-12 10:43:14 +00:00
|
|
|
#endif
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
static void
|
2005-07-14 09:35:12 +00:00
|
|
|
gst_push_src_base_init (gpointer g_class)
|
2005-05-12 10:43:14 +00:00
|
|
|
{
|
2005-07-14 09:35:12 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_push_src_debug, "pushsrc", 0, "pushsrc element");
|
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
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
GstBaseSrcClass *gstbasesrc_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
|
|
|
gstbasesrc_class = (GstBaseSrcClass *) klass;
|
|
|
|
|
2005-07-05 16:38:13 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_BASE_SRC);
|
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);
|
2005-05-12 10:43:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-07-14 09:35:12 +00:00
|
|
|
gst_push_src_init (GstPushSrc * pushsrc, gpointer g_class)
|
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
|
|
|
|
fret = GST_FLOW_ERROR;
|
|
|
|
|
|
|
|
return fret;
|
|
|
|
}
|