Small cleanups, more descriptive properties

Original commit message from CVS:
Small cleanups, more descriptive properties
This commit is contained in:
Wim Taymans 2002-11-21 23:52:30 +00:00
parent 774edda66b
commit 12490346d0
14 changed files with 258 additions and 250 deletions

View file

@ -116,13 +116,13 @@ gst_fakesink_class_init (GstFakeSinkClass *klass)
NULL, G_PARAM_READABLE)); NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "Sync on the clock", g_param_spec_boolean ("sync", "Sync", "Sync on the clock",
FALSE, G_PARAM_READWRITE)); /* CHECKME */ FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
gst_element_class_install_std_props ( g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
GST_ELEMENT_CLASS (klass), FALSE, G_PARAM_READWRITE));
"silent", ARG_SILENT, G_PARAM_READWRITE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
"dump", ARG_DUMP, G_PARAM_READWRITE, g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout",
NULL); FALSE, G_PARAM_READWRITE));
gst_fakesink_signals[SIGNAL_HANDOFF] = gst_fakesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -140,6 +140,7 @@ static void
gst_fakesink_init (GstFakeSink *fakesink) gst_fakesink_init (GstFakeSink *fakesink)
{ {
GstPad *pad; GstPad *pad;
pad = gst_pad_new ("sink", GST_PAD_SINK); pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (fakesink), pad); gst_element_add_pad (GST_ELEMENT (fakesink), pad);
gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_chain)); gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_chain));
@ -259,6 +260,15 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
if (GST_IS_EVENT (buf)) { if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf); GstEvent *event = GST_EVENT (buf);
if (!fakesink->silent) {
g_free (fakesink->last_message);
fakesink->last_message = g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p",
GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event);
g_object_notify (G_OBJECT (fakesink), "last_message");
}
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_DISCONTINUOUS:
if (fakesink->sync && fakesink->clock) { if (fakesink->sync && fakesink->clock) {

View file

@ -26,6 +26,9 @@
#include <gstfakesrc.h> #include <gstfakesrc.h>
#define DEFAULT_SIZEMIN 0
#define DEFAULT_SIZEMAX 4096
#define DEFAULT_PARENTSIZE 4096*10
GstElementDetails gst_fakesrc_details = { GstElementDetails gst_fakesrc_details = {
"Fake Source", "Fake Source",
@ -215,13 +218,13 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
GST_TYPE_FAKESRC_SIZETYPE, FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE)); GST_TYPE_FAKESRC_SIZETYPE, FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN,
g_param_spec_int ("sizemin","sizemin","Minimum buffer size", g_param_spec_int ("sizemin","sizemin","Minimum buffer size",
0, G_MAXINT, 0, G_PARAM_READWRITE)); 0, G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX,
g_param_spec_int ("sizemax","sizemax","Maximum buffer size", g_param_spec_int ("sizemax","sizemax","Maximum buffer size",
0, G_MAXINT, 4096, G_PARAM_READWRITE)); 0, G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE,
g_param_spec_int ("parentsize","parentsize","Size of parent buffer for sub-buffered allocation", g_param_spec_int ("parentsize","parentsize","Size of parent buffer for sub-buffered allocation",
0, G_MAXINT, 4096 * 10, G_PARAM_READWRITE)); 0, G_MAXINT, DEFAULT_PARENTSIZE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE,
g_param_spec_enum ("filltype", "filltype", "How to fill the buffer, if at all", g_param_spec_enum ("filltype", "filltype", "How to fill the buffer, if at all",
GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE)); GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
@ -237,12 +240,12 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", "The last status message", g_param_spec_string ("last-message", "last-message", "The last status message",
NULL, G_PARAM_READABLE)); NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
gst_element_class_install_std_props ( g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
GST_ELEMENT_CLASS (klass), FALSE, G_PARAM_READWRITE));
"silent", ARG_SILENT, G_PARAM_READWRITE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
"dump", ARG_DUMP, G_PARAM_READWRITE, g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
NULL); FALSE, G_PARAM_READWRITE));
gst_fakesrc_signals[SIGNAL_HANDOFF] = gst_fakesrc_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -282,10 +285,10 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
fakesrc->data = FAKESRC_DATA_ALLOCATE; fakesrc->data = FAKESRC_DATA_ALLOCATE;
fakesrc->sizetype = FAKESRC_SIZETYPE_NULL; fakesrc->sizetype = FAKESRC_SIZETYPE_NULL;
fakesrc->filltype = FAKESRC_FILLTYPE_NOTHING; fakesrc->filltype = FAKESRC_FILLTYPE_NOTHING;
fakesrc->sizemin = 0; fakesrc->sizemin = DEFAULT_SIZEMIN;
fakesrc->sizemax = 4096; fakesrc->sizemax = DEFAULT_SIZEMAX;
fakesrc->parent = NULL; fakesrc->parent = NULL;
fakesrc->parentsize = 4096 * 10; fakesrc->parentsize = DEFAULT_PARENTSIZE;
fakesrc->last_message = NULL; fakesrc->last_message = NULL;
} }

View file

@ -90,10 +90,9 @@ gst_fdsink_class_init (GstFdSinkClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_element_class_install_std_props ( g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
GST_ELEMENT_CLASS (klass), g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
"fd", ARG_FD, G_PARAM_READWRITE, 0, G_MAXINT, 1, G_PARAM_READWRITE));
NULL);
gobject_class->set_property = gst_fdsink_set_property; gobject_class->set_property = gst_fdsink_set_property;
gobject_class->get_property = gst_fdsink_get_property; gobject_class->get_property = gst_fdsink_get_property;

View file

@ -29,8 +29,10 @@
#include <gstfdsrc.h> #include <gstfdsrc.h>
#define DEFAULT_BLOCKSIZE 4096
GstElementDetails gst_fdsrc_details = { GstElementDetails gst_fdsrc_details =
{
"Disk Source", "Disk Source",
"Source/File", "Source/File",
"LGPL", "LGPL",
@ -49,10 +51,8 @@ enum {
enum { enum {
ARG_0, ARG_0,
ARG_LOCATION,
ARG_BYTESPERREAD,
ARG_OFFSET,
ARG_FD, ARG_FD,
ARG_BLOCKSIZE,
}; };
@ -77,7 +77,8 @@ gst_fdsrc_get_type (void)
if (!fdsrc_type) { if (!fdsrc_type) {
static const GTypeInfo fdsrc_info = { static const GTypeInfo fdsrc_info = {
sizeof(GstFdSrcClass), NULL, sizeof(GstFdSrcClass),
NULL,
NULL, NULL,
(GClassInitFunc)gst_fdsrc_class_init, (GClassInitFunc)gst_fdsrc_class_init,
NULL, NULL,
@ -100,16 +101,12 @@ gst_fdsrc_class_init (GstFdSrcClass *klass)
parent_class = g_type_class_ref(GST_TYPE_ELEMENT); parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
gst_element_class_install_std_props (
GST_ELEMENT_CLASS (klass),
"location", ARG_LOCATION, G_PARAM_WRITABLE,
"bytesperread", ARG_BYTESPERREAD, G_PARAM_READWRITE,
"offset", ARG_OFFSET, G_PARAM_READABLE,
NULL);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
g_param_spec_int ("fd", "fd", "An open file descriptor to read from", g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
0, G_MAXINT, 0, G_PARAM_READWRITE)); 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer",
1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE));
gobject_class->set_property = gst_fdsrc_set_property; gobject_class->set_property = gst_fdsrc_set_property;
gobject_class->get_property = gst_fdsrc_get_property; gobject_class->get_property = gst_fdsrc_get_property;
@ -122,7 +119,7 @@ static void gst_fdsrc_init(GstFdSrc *fdsrc) {
fdsrc->fd = 0; fdsrc->fd = 0;
fdsrc->curoffset = 0; fdsrc->curoffset = 0;
fdsrc->bytes_per_read = 4096; fdsrc->blocksize = DEFAULT_BLOCKSIZE;
fdsrc->seq = 0; fdsrc->seq = 0;
} }
@ -131,7 +128,6 @@ static void
gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{ {
GstFdSrc *src; GstFdSrc *src;
int fd;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSRC (object)); g_return_if_fail (GST_IS_FDSRC (object));
@ -139,25 +135,11 @@ gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GPa
src = GST_FDSRC (object); src = GST_FDSRC (object);
switch (prop_id) { switch (prop_id) {
case ARG_LOCATION:
/* the element must not be playing in order to do this */
g_return_if_fail (GST_STATE (src) < GST_STATE_PLAYING);
/* if we get a NULL, consider it to be a fd of 0 */
if (g_value_get_string (value) == NULL) {
gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
src->fd = 0;
/* otherwise set the new filename */
} else {
if (sscanf (g_value_get_string (value), "%d", &fd))
src->fd = fd;
}
break;
case ARG_FD: case ARG_FD:
src->fd = g_value_get_int (value); src->fd = g_value_get_int (value);
break; break;
case ARG_BYTESPERREAD: case ARG_BLOCKSIZE:
src->bytes_per_read = g_value_get_int (value); src->blocksize = g_value_get_ulong (value);
break; break;
default: default:
break; break;
@ -175,11 +157,8 @@ gst_fdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
src = GST_FDSRC (object); src = GST_FDSRC (object);
switch (prop_id) { switch (prop_id) {
case ARG_BYTESPERREAD: case ARG_BLOCKSIZE:
g_value_set_int (value, src->bytes_per_read); g_value_set_ulong (value, src->blocksize);
break;
case ARG_OFFSET:
g_value_set_int64 (value, src->curoffset);
break; break;
case ARG_FD: case ARG_FD:
g_value_set_int (value, src->fd); g_value_set_int (value, src->fd);
@ -206,11 +185,11 @@ gst_fdsrc_get(GstPad *pad)
g_return_val_if_fail (buf, NULL); g_return_val_if_fail (buf, NULL);
/* allocate the space for the buffer data */ /* allocate the space for the buffer data */
GST_BUFFER_DATA(buf) = g_malloc(src->bytes_per_read); GST_BUFFER_DATA(buf) = g_malloc(src->blocksize);
g_return_val_if_fail(GST_BUFFER_DATA(buf) != NULL, NULL); g_return_val_if_fail(GST_BUFFER_DATA(buf) != NULL, NULL);
/* read it in from the file */ /* read it in from the file */
readbytes = read(src->fd,GST_BUFFER_DATA(buf),src->bytes_per_read); readbytes = read(src->fd,GST_BUFFER_DATA(buf),src->blocksize);
/* if nothing was read, we're in eos */ /* if nothing was read, we're in eos */
if (readbytes == 0) { if (readbytes == 0) {
gst_element_set_eos (GST_ELEMENT (src)); gst_element_set_eos (GST_ELEMENT (src));

View file

@ -57,7 +57,7 @@ struct _GstFdSrc {
gint fd; gint fd;
gulong curoffset; /* current offset in file */ gulong curoffset; /* current offset in file */
gulong bytes_per_read; /* bytes per read */ gulong blocksize; /* bytes per read */
gulong seq; /* buffer sequence number */ gulong seq; /* buffer sequence number */
}; };

View file

@ -112,14 +112,12 @@ gst_filesink_class_init (GstFileSinkClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_element_class_install_std_props ( g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
GST_ELEMENT_CLASS (klass), g_param_spec_string ("location", "File Location", "Location of the file to write",
"location", ARG_LOCATION, G_PARAM_READWRITE, NULL, G_PARAM_READWRITE));
NULL);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAXFILESIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAXFILESIZE,
g_param_spec_int("maxfilesize","MaxFileSize","Maximum Size Per File", g_param_spec_int ("maxfilesize", "MaxFileSize", "Maximum Size Per File in MB (-1 == no limit)",
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); -1, G_MAXINT, -1, G_PARAM_READWRITE));
gst_filesink_signals[SIGNAL_HANDOFF] = gst_filesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,

View file

@ -79,6 +79,9 @@ GstElementDetails gst_filesrc_details = {
"(C) 1999", "(C) 1999",
}; };
#define DEFAULT_BLOCKSIZE 4*1024
#define DEFAULT_MMAPSIZE 4*1024*1024
/* #define fs_print(format,args...) g_print(format, ## args) */ /* #define fs_print(format,args...) g_print(format, ## args) */
#define fs_print(format,args...) #define fs_print(format,args...)
@ -93,7 +96,7 @@ enum {
ARG_LOCATION, ARG_LOCATION,
ARG_FD, ARG_FD,
ARG_BLOCKSIZE, ARG_BLOCKSIZE,
ARG_MAPSIZE, ARG_MMAPSIZE,
ARG_TOUCH, ARG_TOUCH,
}; };
@ -167,14 +170,23 @@ gst_filesrc_class_init (GstFileSrcClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_element_class_install_std_props ( g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
GST_ELEMENT_CLASS (klass), g_param_spec_int ("fd", "File-descriptor", "File-descriptor for the file being mmap()d",
"fd", ARG_FD, G_PARAM_READABLE, 0, G_MAXINT, 0, G_PARAM_READABLE));
"location", ARG_LOCATION, G_PARAM_READWRITE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
"blocksize", ARG_BLOCKSIZE, G_PARAM_READWRITE, g_param_spec_string ("location", "File Location", "Location of the file to read",
"mmapsize", ARG_MAPSIZE, G_PARAM_READWRITE, NULL, G_PARAM_READWRITE));
"touch", ARG_TOUCH, G_PARAM_READWRITE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
NULL); g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer",
1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MMAPSIZE,
g_param_spec_ulong ("mmapsize", "mmap() Block Size",
"Size in bytes of mmap()d regions",
0, G_MAXULONG, DEFAULT_MMAPSIZE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOUCH,
g_param_spec_boolean ("touch", "Touch read data",
"Touch data to force disk read",
FALSE, G_PARAM_READWRITE));
gobject_class->dispose = gst_filesrc_dispose; gobject_class->dispose = gst_filesrc_dispose;
gobject_class->set_property = gst_filesrc_set_property; gobject_class->set_property = gst_filesrc_set_property;
@ -215,11 +227,11 @@ gst_filesrc_init (GstFileSrc *src)
src->filelen = 0; src->filelen = 0;
src->curoffset = 0; src->curoffset = 0;
src->block_size = 4096; src->block_size = DEFAULT_BLOCKSIZE;
src->touch = TRUE; src->touch = FALSE;
src->mapbuf = NULL; src->mapbuf = NULL;
src->mapsize = 4 * 1024 * 1024; /* default is 4MB */ src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */
src->map_regions = g_tree_new (gst_filesrc_bufcmp); src->map_regions = g_tree_new (gst_filesrc_bufcmp);
src->map_regions_lock = g_mutex_new(); src->map_regions_lock = g_mutex_new();
@ -273,12 +285,13 @@ gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
src->block_size = g_value_get_ulong (value); src->block_size = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "blocksize"); g_object_notify (G_OBJECT (src), "blocksize");
break; break;
case ARG_MAPSIZE: case ARG_MMAPSIZE:
if ((src->mapsize % src->pagesize) == 0) { if ((src->mapsize % src->pagesize) == 0) {
src->mapsize = g_value_get_ulong (value); src->mapsize = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "mmapsize"); g_object_notify (G_OBJECT (src), "mmapsize");
} else { } else {
GST_INFO(0, "invalid mapsize, must a multiple of pagesize, which is %d\n",src->pagesize); GST_INFO (0, "invalid mapsize, must a multiple of pagesize, which is %d\n",
src->pagesize);
} }
break; break;
case ARG_TOUCH: case ARG_TOUCH:
@ -310,7 +323,7 @@ gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
case ARG_BLOCKSIZE: case ARG_BLOCKSIZE:
g_value_set_ulong (value, src->block_size); g_value_set_ulong (value, src->block_size);
break; break;
case ARG_MAPSIZE: case ARG_MMAPSIZE:
g_value_set_ulong (value, src->mapsize); g_value_set_ulong (value, src->mapsize);
break; break;
case ARG_TOUCH: case ARG_TOUCH:
@ -327,7 +340,8 @@ gst_filesrc_free_parent_mmap (GstBuffer *buf)
{ {
GstFileSrc *src = GST_FILESRC (GST_BUFFER_POOL_PRIVATE (buf)); GstFileSrc *src = GST_FILESRC (GST_BUFFER_POOL_PRIVATE (buf));
fs_print ("freeing mmap()d buffer at %d+%d\n",GST_BUFFER_OFFSET(buf),GST_BUFFER_SIZE(buf)); fs_print ("freeing mmap()d buffer at %d+%d\n",
GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf));
/* remove the buffer from the list of available mmap'd regions */ /* remove the buffer from the list of available mmap'd regions */
g_mutex_lock (src->map_regions_lock); g_mutex_lock (src->map_regions_lock);
@ -587,6 +601,7 @@ gst_filesrc_get (GstPad *pad)
/* if we need to touch the buffer (to bring it into memory), do so */ /* if we need to touch the buffer (to bring it into memory), do so */
if (src->touch) { if (src->touch) {
volatile guchar *p = GST_BUFFER_DATA (buf), c; volatile guchar *p = GST_BUFFER_DATA (buf), c;
for (i=0; i < GST_BUFFER_SIZE (buf); i += src->pagesize) for (i=0; i < GST_BUFFER_SIZE (buf); i += src->pagesize)
c = p[i]; c = p[i];
} }

View file

@ -116,13 +116,13 @@ gst_fakesink_class_init (GstFakeSinkClass *klass)
NULL, G_PARAM_READABLE)); NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "Sync on the clock", g_param_spec_boolean ("sync", "Sync", "Sync on the clock",
FALSE, G_PARAM_READWRITE)); /* CHECKME */ FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
gst_element_class_install_std_props ( g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
GST_ELEMENT_CLASS (klass), FALSE, G_PARAM_READWRITE));
"silent", ARG_SILENT, G_PARAM_READWRITE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
"dump", ARG_DUMP, G_PARAM_READWRITE, g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout",
NULL); FALSE, G_PARAM_READWRITE));
gst_fakesink_signals[SIGNAL_HANDOFF] = gst_fakesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -140,6 +140,7 @@ static void
gst_fakesink_init (GstFakeSink *fakesink) gst_fakesink_init (GstFakeSink *fakesink)
{ {
GstPad *pad; GstPad *pad;
pad = gst_pad_new ("sink", GST_PAD_SINK); pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (fakesink), pad); gst_element_add_pad (GST_ELEMENT (fakesink), pad);
gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_chain)); gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_chain));
@ -259,6 +260,15 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
if (GST_IS_EVENT (buf)) { if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf); GstEvent *event = GST_EVENT (buf);
if (!fakesink->silent) {
g_free (fakesink->last_message);
fakesink->last_message = g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p",
GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event);
g_object_notify (G_OBJECT (fakesink), "last_message");
}
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_DISCONTINUOUS:
if (fakesink->sync && fakesink->clock) { if (fakesink->sync && fakesink->clock) {

View file

@ -26,6 +26,9 @@
#include <gstfakesrc.h> #include <gstfakesrc.h>
#define DEFAULT_SIZEMIN 0
#define DEFAULT_SIZEMAX 4096
#define DEFAULT_PARENTSIZE 4096*10
GstElementDetails gst_fakesrc_details = { GstElementDetails gst_fakesrc_details = {
"Fake Source", "Fake Source",
@ -215,13 +218,13 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
GST_TYPE_FAKESRC_SIZETYPE, FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE)); GST_TYPE_FAKESRC_SIZETYPE, FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN,
g_param_spec_int ("sizemin","sizemin","Minimum buffer size", g_param_spec_int ("sizemin","sizemin","Minimum buffer size",
0, G_MAXINT, 0, G_PARAM_READWRITE)); 0, G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX,
g_param_spec_int ("sizemax","sizemax","Maximum buffer size", g_param_spec_int ("sizemax","sizemax","Maximum buffer size",
0, G_MAXINT, 4096, G_PARAM_READWRITE)); 0, G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE,
g_param_spec_int ("parentsize","parentsize","Size of parent buffer for sub-buffered allocation", g_param_spec_int ("parentsize","parentsize","Size of parent buffer for sub-buffered allocation",
0, G_MAXINT, 4096 * 10, G_PARAM_READWRITE)); 0, G_MAXINT, DEFAULT_PARENTSIZE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE,
g_param_spec_enum ("filltype", "filltype", "How to fill the buffer, if at all", g_param_spec_enum ("filltype", "filltype", "How to fill the buffer, if at all",
GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE)); GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
@ -237,12 +240,12 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", "The last status message", g_param_spec_string ("last-message", "last-message", "The last status message",
NULL, G_PARAM_READABLE)); NULL, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
gst_element_class_install_std_props ( g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
GST_ELEMENT_CLASS (klass), FALSE, G_PARAM_READWRITE));
"silent", ARG_SILENT, G_PARAM_READWRITE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
"dump", ARG_DUMP, G_PARAM_READWRITE, g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
NULL); FALSE, G_PARAM_READWRITE));
gst_fakesrc_signals[SIGNAL_HANDOFF] = gst_fakesrc_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
@ -282,10 +285,10 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
fakesrc->data = FAKESRC_DATA_ALLOCATE; fakesrc->data = FAKESRC_DATA_ALLOCATE;
fakesrc->sizetype = FAKESRC_SIZETYPE_NULL; fakesrc->sizetype = FAKESRC_SIZETYPE_NULL;
fakesrc->filltype = FAKESRC_FILLTYPE_NOTHING; fakesrc->filltype = FAKESRC_FILLTYPE_NOTHING;
fakesrc->sizemin = 0; fakesrc->sizemin = DEFAULT_SIZEMIN;
fakesrc->sizemax = 4096; fakesrc->sizemax = DEFAULT_SIZEMAX;
fakesrc->parent = NULL; fakesrc->parent = NULL;
fakesrc->parentsize = 4096 * 10; fakesrc->parentsize = DEFAULT_PARENTSIZE;
fakesrc->last_message = NULL; fakesrc->last_message = NULL;
} }

View file

@ -90,10 +90,9 @@ gst_fdsink_class_init (GstFdSinkClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_element_class_install_std_props ( g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
GST_ELEMENT_CLASS (klass), g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
"fd", ARG_FD, G_PARAM_READWRITE, 0, G_MAXINT, 1, G_PARAM_READWRITE));
NULL);
gobject_class->set_property = gst_fdsink_set_property; gobject_class->set_property = gst_fdsink_set_property;
gobject_class->get_property = gst_fdsink_get_property; gobject_class->get_property = gst_fdsink_get_property;

View file

@ -29,8 +29,10 @@
#include <gstfdsrc.h> #include <gstfdsrc.h>
#define DEFAULT_BLOCKSIZE 4096
GstElementDetails gst_fdsrc_details = { GstElementDetails gst_fdsrc_details =
{
"Disk Source", "Disk Source",
"Source/File", "Source/File",
"LGPL", "LGPL",
@ -49,10 +51,8 @@ enum {
enum { enum {
ARG_0, ARG_0,
ARG_LOCATION,
ARG_BYTESPERREAD,
ARG_OFFSET,
ARG_FD, ARG_FD,
ARG_BLOCKSIZE,
}; };
@ -77,7 +77,8 @@ gst_fdsrc_get_type (void)
if (!fdsrc_type) { if (!fdsrc_type) {
static const GTypeInfo fdsrc_info = { static const GTypeInfo fdsrc_info = {
sizeof(GstFdSrcClass), NULL, sizeof(GstFdSrcClass),
NULL,
NULL, NULL,
(GClassInitFunc)gst_fdsrc_class_init, (GClassInitFunc)gst_fdsrc_class_init,
NULL, NULL,
@ -100,16 +101,12 @@ gst_fdsrc_class_init (GstFdSrcClass *klass)
parent_class = g_type_class_ref(GST_TYPE_ELEMENT); parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
gst_element_class_install_std_props (
GST_ELEMENT_CLASS (klass),
"location", ARG_LOCATION, G_PARAM_WRITABLE,
"bytesperread", ARG_BYTESPERREAD, G_PARAM_READWRITE,
"offset", ARG_OFFSET, G_PARAM_READABLE,
NULL);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
g_param_spec_int ("fd", "fd", "An open file descriptor to read from", g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
0, G_MAXINT, 0, G_PARAM_READWRITE)); 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer",
1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE));
gobject_class->set_property = gst_fdsrc_set_property; gobject_class->set_property = gst_fdsrc_set_property;
gobject_class->get_property = gst_fdsrc_get_property; gobject_class->get_property = gst_fdsrc_get_property;
@ -122,7 +119,7 @@ static void gst_fdsrc_init(GstFdSrc *fdsrc) {
fdsrc->fd = 0; fdsrc->fd = 0;
fdsrc->curoffset = 0; fdsrc->curoffset = 0;
fdsrc->bytes_per_read = 4096; fdsrc->blocksize = DEFAULT_BLOCKSIZE;
fdsrc->seq = 0; fdsrc->seq = 0;
} }
@ -131,7 +128,6 @@ static void
gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{ {
GstFdSrc *src; GstFdSrc *src;
int fd;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSRC (object)); g_return_if_fail (GST_IS_FDSRC (object));
@ -139,25 +135,11 @@ gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GPa
src = GST_FDSRC (object); src = GST_FDSRC (object);
switch (prop_id) { switch (prop_id) {
case ARG_LOCATION:
/* the element must not be playing in order to do this */
g_return_if_fail (GST_STATE (src) < GST_STATE_PLAYING);
/* if we get a NULL, consider it to be a fd of 0 */
if (g_value_get_string (value) == NULL) {
gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
src->fd = 0;
/* otherwise set the new filename */
} else {
if (sscanf (g_value_get_string (value), "%d", &fd))
src->fd = fd;
}
break;
case ARG_FD: case ARG_FD:
src->fd = g_value_get_int (value); src->fd = g_value_get_int (value);
break; break;
case ARG_BYTESPERREAD: case ARG_BLOCKSIZE:
src->bytes_per_read = g_value_get_int (value); src->blocksize = g_value_get_ulong (value);
break; break;
default: default:
break; break;
@ -175,11 +157,8 @@ gst_fdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
src = GST_FDSRC (object); src = GST_FDSRC (object);
switch (prop_id) { switch (prop_id) {
case ARG_BYTESPERREAD: case ARG_BLOCKSIZE:
g_value_set_int (value, src->bytes_per_read); g_value_set_ulong (value, src->blocksize);
break;
case ARG_OFFSET:
g_value_set_int64 (value, src->curoffset);
break; break;
case ARG_FD: case ARG_FD:
g_value_set_int (value, src->fd); g_value_set_int (value, src->fd);
@ -206,11 +185,11 @@ gst_fdsrc_get(GstPad *pad)
g_return_val_if_fail (buf, NULL); g_return_val_if_fail (buf, NULL);
/* allocate the space for the buffer data */ /* allocate the space for the buffer data */
GST_BUFFER_DATA(buf) = g_malloc(src->bytes_per_read); GST_BUFFER_DATA(buf) = g_malloc(src->blocksize);
g_return_val_if_fail(GST_BUFFER_DATA(buf) != NULL, NULL); g_return_val_if_fail(GST_BUFFER_DATA(buf) != NULL, NULL);
/* read it in from the file */ /* read it in from the file */
readbytes = read(src->fd,GST_BUFFER_DATA(buf),src->bytes_per_read); readbytes = read(src->fd,GST_BUFFER_DATA(buf),src->blocksize);
/* if nothing was read, we're in eos */ /* if nothing was read, we're in eos */
if (readbytes == 0) { if (readbytes == 0) {
gst_element_set_eos (GST_ELEMENT (src)); gst_element_set_eos (GST_ELEMENT (src));

View file

@ -57,7 +57,7 @@ struct _GstFdSrc {
gint fd; gint fd;
gulong curoffset; /* current offset in file */ gulong curoffset; /* current offset in file */
gulong bytes_per_read; /* bytes per read */ gulong blocksize; /* bytes per read */
gulong seq; /* buffer sequence number */ gulong seq; /* buffer sequence number */
}; };

View file

@ -112,14 +112,12 @@ gst_filesink_class_init (GstFileSinkClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_element_class_install_std_props ( g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
GST_ELEMENT_CLASS (klass), g_param_spec_string ("location", "File Location", "Location of the file to write",
"location", ARG_LOCATION, G_PARAM_READWRITE, NULL, G_PARAM_READWRITE));
NULL);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAXFILESIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAXFILESIZE,
g_param_spec_int("maxfilesize","MaxFileSize","Maximum Size Per File", g_param_spec_int ("maxfilesize", "MaxFileSize", "Maximum Size Per File in MB (-1 == no limit)",
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); -1, G_MAXINT, -1, G_PARAM_READWRITE));
gst_filesink_signals[SIGNAL_HANDOFF] = gst_filesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,

View file

@ -79,6 +79,9 @@ GstElementDetails gst_filesrc_details = {
"(C) 1999", "(C) 1999",
}; };
#define DEFAULT_BLOCKSIZE 4*1024
#define DEFAULT_MMAPSIZE 4*1024*1024
/* #define fs_print(format,args...) g_print(format, ## args) */ /* #define fs_print(format,args...) g_print(format, ## args) */
#define fs_print(format,args...) #define fs_print(format,args...)
@ -93,7 +96,7 @@ enum {
ARG_LOCATION, ARG_LOCATION,
ARG_FD, ARG_FD,
ARG_BLOCKSIZE, ARG_BLOCKSIZE,
ARG_MAPSIZE, ARG_MMAPSIZE,
ARG_TOUCH, ARG_TOUCH,
}; };
@ -167,14 +170,23 @@ gst_filesrc_class_init (GstFileSrcClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_element_class_install_std_props ( g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
GST_ELEMENT_CLASS (klass), g_param_spec_int ("fd", "File-descriptor", "File-descriptor for the file being mmap()d",
"fd", ARG_FD, G_PARAM_READABLE, 0, G_MAXINT, 0, G_PARAM_READABLE));
"location", ARG_LOCATION, G_PARAM_READWRITE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
"blocksize", ARG_BLOCKSIZE, G_PARAM_READWRITE, g_param_spec_string ("location", "File Location", "Location of the file to read",
"mmapsize", ARG_MAPSIZE, G_PARAM_READWRITE, NULL, G_PARAM_READWRITE));
"touch", ARG_TOUCH, G_PARAM_READWRITE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
NULL); g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer",
1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MMAPSIZE,
g_param_spec_ulong ("mmapsize", "mmap() Block Size",
"Size in bytes of mmap()d regions",
0, G_MAXULONG, DEFAULT_MMAPSIZE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOUCH,
g_param_spec_boolean ("touch", "Touch read data",
"Touch data to force disk read",
FALSE, G_PARAM_READWRITE));
gobject_class->dispose = gst_filesrc_dispose; gobject_class->dispose = gst_filesrc_dispose;
gobject_class->set_property = gst_filesrc_set_property; gobject_class->set_property = gst_filesrc_set_property;
@ -215,11 +227,11 @@ gst_filesrc_init (GstFileSrc *src)
src->filelen = 0; src->filelen = 0;
src->curoffset = 0; src->curoffset = 0;
src->block_size = 4096; src->block_size = DEFAULT_BLOCKSIZE;
src->touch = TRUE; src->touch = FALSE;
src->mapbuf = NULL; src->mapbuf = NULL;
src->mapsize = 4 * 1024 * 1024; /* default is 4MB */ src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */
src->map_regions = g_tree_new (gst_filesrc_bufcmp); src->map_regions = g_tree_new (gst_filesrc_bufcmp);
src->map_regions_lock = g_mutex_new(); src->map_regions_lock = g_mutex_new();
@ -273,12 +285,13 @@ gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
src->block_size = g_value_get_ulong (value); src->block_size = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "blocksize"); g_object_notify (G_OBJECT (src), "blocksize");
break; break;
case ARG_MAPSIZE: case ARG_MMAPSIZE:
if ((src->mapsize % src->pagesize) == 0) { if ((src->mapsize % src->pagesize) == 0) {
src->mapsize = g_value_get_ulong (value); src->mapsize = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "mmapsize"); g_object_notify (G_OBJECT (src), "mmapsize");
} else { } else {
GST_INFO(0, "invalid mapsize, must a multiple of pagesize, which is %d\n",src->pagesize); GST_INFO (0, "invalid mapsize, must a multiple of pagesize, which is %d\n",
src->pagesize);
} }
break; break;
case ARG_TOUCH: case ARG_TOUCH:
@ -310,7 +323,7 @@ gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
case ARG_BLOCKSIZE: case ARG_BLOCKSIZE:
g_value_set_ulong (value, src->block_size); g_value_set_ulong (value, src->block_size);
break; break;
case ARG_MAPSIZE: case ARG_MMAPSIZE:
g_value_set_ulong (value, src->mapsize); g_value_set_ulong (value, src->mapsize);
break; break;
case ARG_TOUCH: case ARG_TOUCH:
@ -327,7 +340,8 @@ gst_filesrc_free_parent_mmap (GstBuffer *buf)
{ {
GstFileSrc *src = GST_FILESRC (GST_BUFFER_POOL_PRIVATE (buf)); GstFileSrc *src = GST_FILESRC (GST_BUFFER_POOL_PRIVATE (buf));
fs_print ("freeing mmap()d buffer at %d+%d\n",GST_BUFFER_OFFSET(buf),GST_BUFFER_SIZE(buf)); fs_print ("freeing mmap()d buffer at %d+%d\n",
GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf));
/* remove the buffer from the list of available mmap'd regions */ /* remove the buffer from the list of available mmap'd regions */
g_mutex_lock (src->map_regions_lock); g_mutex_lock (src->map_regions_lock);
@ -587,6 +601,7 @@ gst_filesrc_get (GstPad *pad)
/* if we need to touch the buffer (to bring it into memory), do so */ /* if we need to touch the buffer (to bring it into memory), do so */
if (src->touch) { if (src->touch) {
volatile guchar *p = GST_BUFFER_DATA (buf), c; volatile guchar *p = GST_BUFFER_DATA (buf), c;
for (i=0; i < GST_BUFFER_SIZE (buf); i += src->pagesize) for (i=0; i < GST_BUFFER_SIZE (buf); i += src->pagesize)
c = p[i]; c = p[i];
} }