Commit 88d66833 authored by Wim Taymans's avatar Wim Taymans
Browse files

gst/base/: Added is_seekable to BaseSrc

Original commit message from CVS:
* gst/base/Makefile.am:
* gst/base/gstbasesrc.c: (gst_basesrc_is_seekable),
(gst_basesrc_start):
* gst/base/gstbasesrc.h:
* gst/base/gstpushsrc.c: (gst_pushsrc_get_type),
(gst_pushsrc_base_init), (gst_pushsrc_class_init),
(gst_pushsrc_init), (gst_pushsrc_create):
* gst/base/gstpushsrc.h:
Added is_seekable to BaseSrc
Added simple PushSrc.
parent c9aaf466
2005-05-12 Wim Taymans <wim@fluendo.com>
* gst/base/Makefile.am:
* gst/base/gstbasesrc.c: (gst_basesrc_is_seekable),
(gst_basesrc_start):
* gst/base/gstbasesrc.h:
* gst/base/gstpushsrc.c: (gst_pushsrc_get_type),
(gst_pushsrc_base_init), (gst_pushsrc_class_init),
(gst_pushsrc_init), (gst_pushsrc_create):
* gst/base/gstpushsrc.h:
Added is_seekable to BaseSrc
Added simple PushSrc.
2005-05-11 Wim Taymans <wim@fluendo.com>
* gst/gstelement.c: (gst_element_add_pad), (gst_element_query):
......
......@@ -7,6 +7,7 @@ libgstbase_@GST_MAJORMINOR@_la_SOURCES = \
gstbasesrc.c \
gstbasetransform.c \
gstcollectpads.c \
gstpushsrc.c \
gsttypefindhelper.c
libgstbase_@GST_MAJORMINOR@_la_CFLAGS = $(GST_OBJ_CFLAGS)
......@@ -22,5 +23,6 @@ libgstbase_@GST_MAJORMINOR@include_HEADERS = \
gstbasesrc.h \
gstbasetransform.h \
gstcollectpads.h \
gstpushsrc.h \
gsttypefindhelper.h
......@@ -607,6 +607,22 @@ gst_basesrc_get_size (GstBaseSrc * basesrc, guint64 * size)
return result;
}
static gboolean
gst_basesrc_is_seekable (GstBaseSrc * basesrc)
{
GstBaseSrcClass *bclass;
bclass = GST_BASESRC_GET_CLASS (basesrc);
/* check if we can seek */
if (bclass->is_seekable)
basesrc->seekable = bclass->is_seekable (basesrc);
else
basesrc->seekable = FALSE;
return basesrc->seekable;
}
static gboolean
gst_basesrc_start (GstBaseSrc * basesrc)
{
......@@ -646,11 +662,8 @@ gst_basesrc_start (GstBaseSrc * basesrc)
/* we always run to the end */
basesrc->segment_end = -1;
/* check if we can seek */
if (bclass->is_seekable)
basesrc->seekable = bclass->is_seekable (basesrc);
else
basesrc->seekable = FALSE;
/* check if we can seek, updates ->seekable */
gst_basesrc_is_seekable (basesrc);
/* run typefind */
#if 0
......
......@@ -39,7 +39,7 @@ typedef enum {
GST_BASESRC_STARTED = GST_ELEMENT_FLAG_LAST,
GST_BASESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
} GstFileSrcFlags;
} GstBaseSrcFlags;
/* base class for random access sources
*
......@@ -52,6 +52,8 @@ typedef enum {
typedef struct _GstBaseSrc GstBaseSrc;
typedef struct _GstBaseSrcClass GstBaseSrcClass;
#define GST_BASESRC_PAD(obj) (GST_BASESRC (obj)->srcpad)
struct _GstBaseSrc {
GstElement element;
......@@ -104,7 +106,8 @@ struct _GstBaseSrcClass {
/* notify subclasses of an event */
gboolean (*event) (GstBaseSrc *src, GstEvent *event);
/* ask the subclass to create a buffer */
/* ask the subclass to create a buffer with offset and size */
GstFlowReturn (*create) (GstBaseSrc *src, guint64 offset, guint size,
GstBuffer **buf);
};
......
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000,2005 Wim Taymans <wim@fluendo.com>
*
* gstpushsrc.c:
*
* 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.
*/
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "gstpushsrc.h"
#include "gsttypefindhelper.h"
#include <gst/gstmarshal.h>
GST_DEBUG_CATEGORY_STATIC (gst_pushsrc_debug);
#define GST_CAT_DEFAULT gst_pushsrc_debug
/* PushSrc signals and args */
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum
{
PROP_0,
};
static GstElementClass *parent_class = NULL;
static void gst_pushsrc_base_init (gpointer g_class);
static void gst_pushsrc_class_init (GstPushSrcClass * klass);
static void gst_pushsrc_init (GstPushSrc * src, gpointer g_class);
GType
gst_pushsrc_get_type (void)
{
static GType pushsrc_type = 0;
if (!pushsrc_type) {
static const GTypeInfo pushsrc_info = {
sizeof (GstPushSrcClass),
(GBaseInitFunc) gst_pushsrc_base_init,
NULL,
(GClassInitFunc) gst_pushsrc_class_init,
NULL,
NULL,
sizeof (GstPushSrc),
0,
(GInstanceInitFunc) gst_pushsrc_init,
};
pushsrc_type = g_type_register_static (GST_TYPE_BASESRC,
"GstPushSrc", &pushsrc_info, G_TYPE_FLAG_ABSTRACT);
}
return pushsrc_type;
}
#if 0
static const GstEventMask *gst_pushsrc_get_event_mask (GstPad * pad);
#endif
static GstFlowReturn gst_pushsrc_create (GstBaseSrc * bsrc, guint64 offset,
guint length, GstBuffer ** ret);
static void
gst_pushsrc_base_init (gpointer g_class)
{
GST_DEBUG_CATEGORY_INIT (gst_pushsrc_debug, "pushsrc", 0, "pushsrc element");
}
static void
gst_pushsrc_class_init (GstPushSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSrcClass *gstbasesrc_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesrc_class = (GstBaseSrcClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_BASESRC);
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_pushsrc_create);
}
static void
gst_pushsrc_init (GstPushSrc * pushsrc, gpointer g_class)
{
}
static GstFlowReturn
gst_pushsrc_create (GstBaseSrc * bsrc, guint64 offset, guint length,
GstBuffer ** ret)
{
GstFlowReturn fret;
GstPushSrc *src;
GstPushSrcClass *pclass;
src = GST_PUSHSRC (bsrc);
pclass = GST_PUSHSRC_GET_CLASS (src);
if (pclass->create)
fret = pclass->create (src, ret);
else
fret = GST_FLOW_ERROR;
return fret;
}
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
* 2005 Wim Taymans <wim@fluendo.com>
*
* gstpushsrc.h:
*
* 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.
*/
#ifndef __GST_PUSHSRC_H__
#define __GST_PUSHSRC_H__
#include <gst/gst.h>
#include <gst/base/gstbasesrc.h>
G_BEGIN_DECLS
#define GST_TYPE_PUSHSRC (gst_pushsrc_get_type())
#define GST_PUSHSRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PUSHSRC,GstPushSrc))
#define GST_PUSHSRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PUSHSRC,GstPushSrcClass))
#define GST_PUSHSRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PUSHSRC, GstPushSrcClass))
#define GST_IS_PUSHSRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PUSHSRC))
#define GST_IS_PUSHSRC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PUSHSRC))
/* base class for block based sources
*
* This class is mostly usefull for elements that cannot do
* 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.
*/
typedef struct _GstPushSrc GstPushSrc;
typedef struct _GstPushSrcClass GstPushSrcClass;
struct _GstPushSrc {
GstBaseSrc parent;
};
struct _GstPushSrcClass {
GstBaseSrcClass parent_class;
/* ask the subclass to create a buffer */
GstFlowReturn (*create) (GstPushSrc *src, GstBuffer **buf);
};
GType gst_pushsrc_get_type(void);
G_END_DECLS
#endif /* __GST_PUSHSRC_H__ */
......@@ -7,6 +7,7 @@ libgstbase_@GST_MAJORMINOR@_la_SOURCES = \
gstbasesrc.c \
gstbasetransform.c \
gstcollectpads.c \
gstpushsrc.c \
gsttypefindhelper.c
libgstbase_@GST_MAJORMINOR@_la_CFLAGS = $(GST_OBJ_CFLAGS)
......@@ -22,5 +23,6 @@ libgstbase_@GST_MAJORMINOR@include_HEADERS = \
gstbasesrc.h \
gstbasetransform.h \
gstcollectpads.h \
gstpushsrc.h \
gsttypefindhelper.h
......@@ -607,6 +607,22 @@ gst_basesrc_get_size (GstBaseSrc * basesrc, guint64 * size)
return result;
}
static gboolean
gst_basesrc_is_seekable (GstBaseSrc * basesrc)
{
GstBaseSrcClass *bclass;
bclass = GST_BASESRC_GET_CLASS (basesrc);
/* check if we can seek */
if (bclass->is_seekable)
basesrc->seekable = bclass->is_seekable (basesrc);
else
basesrc->seekable = FALSE;
return basesrc->seekable;
}
static gboolean
gst_basesrc_start (GstBaseSrc * basesrc)
{
......@@ -646,11 +662,8 @@ gst_basesrc_start (GstBaseSrc * basesrc)
/* we always run to the end */
basesrc->segment_end = -1;
/* check if we can seek */
if (bclass->is_seekable)
basesrc->seekable = bclass->is_seekable (basesrc);
else
basesrc->seekable = FALSE;
/* check if we can seek, updates ->seekable */
gst_basesrc_is_seekable (basesrc);
/* run typefind */
#if 0
......
......@@ -39,7 +39,7 @@ typedef enum {
GST_BASESRC_STARTED = GST_ELEMENT_FLAG_LAST,
GST_BASESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
} GstFileSrcFlags;
} GstBaseSrcFlags;
/* base class for random access sources
*
......@@ -52,6 +52,8 @@ typedef enum {
typedef struct _GstBaseSrc GstBaseSrc;
typedef struct _GstBaseSrcClass GstBaseSrcClass;
#define GST_BASESRC_PAD(obj) (GST_BASESRC (obj)->srcpad)
struct _GstBaseSrc {
GstElement element;
......@@ -104,7 +106,8 @@ struct _GstBaseSrcClass {
/* notify subclasses of an event */
gboolean (*event) (GstBaseSrc *src, GstEvent *event);
/* ask the subclass to create a buffer */
/* ask the subclass to create a buffer with offset and size */
GstFlowReturn (*create) (GstBaseSrc *src, guint64 offset, guint size,
GstBuffer **buf);
};
......
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000,2005 Wim Taymans <wim@fluendo.com>
*
* gstpushsrc.c:
*
* 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.
*/
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "gstpushsrc.h"
#include "gsttypefindhelper.h"
#include <gst/gstmarshal.h>
GST_DEBUG_CATEGORY_STATIC (gst_pushsrc_debug);
#define GST_CAT_DEFAULT gst_pushsrc_debug
/* PushSrc signals and args */
enum
{
/* FILL ME */
LAST_SIGNAL
};
enum
{
PROP_0,
};
static GstElementClass *parent_class = NULL;
static void gst_pushsrc_base_init (gpointer g_class);
static void gst_pushsrc_class_init (GstPushSrcClass * klass);
static void gst_pushsrc_init (GstPushSrc * src, gpointer g_class);
GType
gst_pushsrc_get_type (void)
{
static GType pushsrc_type = 0;
if (!pushsrc_type) {
static const GTypeInfo pushsrc_info = {
sizeof (GstPushSrcClass),
(GBaseInitFunc) gst_pushsrc_base_init,
NULL,
(GClassInitFunc) gst_pushsrc_class_init,
NULL,
NULL,
sizeof (GstPushSrc),
0,
(GInstanceInitFunc) gst_pushsrc_init,
};
pushsrc_type = g_type_register_static (GST_TYPE_BASESRC,
"GstPushSrc", &pushsrc_info, G_TYPE_FLAG_ABSTRACT);
}
return pushsrc_type;
}
#if 0
static const GstEventMask *gst_pushsrc_get_event_mask (GstPad * pad);
#endif
static GstFlowReturn gst_pushsrc_create (GstBaseSrc * bsrc, guint64 offset,
guint length, GstBuffer ** ret);
static void
gst_pushsrc_base_init (gpointer g_class)
{
GST_DEBUG_CATEGORY_INIT (gst_pushsrc_debug, "pushsrc", 0, "pushsrc element");
}
static void
gst_pushsrc_class_init (GstPushSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSrcClass *gstbasesrc_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesrc_class = (GstBaseSrcClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_BASESRC);
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_pushsrc_create);
}
static void
gst_pushsrc_init (GstPushSrc * pushsrc, gpointer g_class)
{
}
static GstFlowReturn
gst_pushsrc_create (GstBaseSrc * bsrc, guint64 offset, guint length,
GstBuffer ** ret)
{
GstFlowReturn fret;
GstPushSrc *src;
GstPushSrcClass *pclass;
src = GST_PUSHSRC (bsrc);
pclass = GST_PUSHSRC_GET_CLASS (src);
if (pclass->create)
fret = pclass->create (src, ret);
else
fret = GST_FLOW_ERROR;
return fret;
}
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
* 2005 Wim Taymans <wim@fluendo.com>
*
* gstpushsrc.h:
*
* 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.
*/
#ifndef __GST_PUSHSRC_H__
#define __GST_PUSHSRC_H__
#include <gst/gst.h>
#include <gst/base/gstbasesrc.h>
G_BEGIN_DECLS
#define GST_TYPE_PUSHSRC (gst_pushsrc_get_type())
#define GST_PUSHSRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PUSHSRC,GstPushSrc))
#define GST_PUSHSRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PUSHSRC,GstPushSrcClass))
#define GST_PUSHSRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PUSHSRC, GstPushSrcClass))
#define GST_IS_PUSHSRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PUSHSRC))
#define GST_IS_PUSHSRC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PUSHSRC))
/* base class for block based sources
*
* This class is mostly usefull for elements that cannot do
* 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.
*/
typedef struct _GstPushSrc GstPushSrc;
typedef struct _GstPushSrcClass GstPushSrcClass;
struct _GstPushSrc {
GstBaseSrc parent;
};
struct _GstPushSrcClass {
GstBaseSrcClass parent_class;
/* ask the subclass to create a buffer */
GstFlowReturn (*create) (GstPushSrc *src, GstBuffer **buf);
};
GType gst_pushsrc_get_type(void);
G_END_DECLS
#endif /* __GST_PUSHSRC_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment