g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last_message", "Last Message", "The message describing current status",
NULL, G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SYNC,
- g_param_spec_boolean("sync","Sync","Sync on the clock",
- FALSE, G_PARAM_READWRITE)); /* CHECKME */
-
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "silent", ARG_SILENT, G_PARAM_READWRITE,
- "dump", ARG_DUMP, G_PARAM_READWRITE,
- NULL);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
+ g_param_spec_boolean ("sync", "Sync", "Sync on the clock",
+ FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
+ g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
+ FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
+ g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout",
+ FALSE, G_PARAM_READWRITE));
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,
G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL,
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER);
gst_fakesink_init (GstFakeSink *fakesink)
{
GstPad *pad;
+
pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (fakesink), pad);
gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_chain));
if (GST_IS_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)) {
case GST_EVENT_DISCONTINUOUS:
#include <gstfakesrc.h>
+#define DEFAULT_SIZEMIN 0
+#define DEFAULT_SIZEMAX 4096
+#define DEFAULT_PARENTSIZE 4096*10
GstElementDetails gst_fakesrc_details = {
"Fake Source",
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES,
g_param_spec_int ("num-sources", "num-sources", "Number of sources",
1, G_MAXINT, 1, G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOOP_BASED,
- g_param_spec_boolean("loop-based","loop-based","Enable loop-based operation",
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED,
+ g_param_spec_boolean ("loop-based", "loop-based", "Enable loop-based operation",
FALSE, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OUTPUT,
- g_param_spec_enum("output","output","Output method (currently unused)",
- GST_TYPE_FAKESRC_OUTPUT,FAKESRC_FIRST_LAST_LOOP,G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT,
+ g_param_spec_enum ("output", "output", "Output method (currently unused)",
+ GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA,
g_param_spec_enum ("data", "data", "Data allocation method",
GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, 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_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_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_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_param_spec_enum ("filltype", "filltype", "How to fill the buffer, if at all",
GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PATTERN,
- g_param_spec_string("pattern","pattern","pattern",
- NULL, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUM_BUFFERS,
- g_param_spec_int("num-buffers","num-buffers","Number of buffers to output before sending EOS",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_EOS,
- g_param_spec_boolean("eos","eos","Send out the EOS event?",
- TRUE,G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PATTERN,
+ g_param_spec_string ("pattern", "pattern", "pattern",
+ NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS,
+ g_param_spec_int ("num-buffers", "num-buffers", "Number of buffers to output before sending EOS",
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EOS,
+ g_param_spec_boolean ("eos", "eos", "Send out the EOS event?",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", "The last status message",
NULL, G_PARAM_READABLE));
-
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "silent", ARG_SILENT, G_PARAM_READWRITE,
- "dump", ARG_DUMP, G_PARAM_READWRITE,
- NULL);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
+ g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
+ FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
+ g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
+ FALSE, G_PARAM_READWRITE));
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,
G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL,
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER);
fakesrc->data = FAKESRC_DATA_ALLOCATE;
fakesrc->sizetype = FAKESRC_SIZETYPE_NULL;
fakesrc->filltype = FAKESRC_FILLTYPE_NOTHING;
- fakesrc->sizemin = 0;
- fakesrc->sizemax = 4096;
+ fakesrc->sizemin = DEFAULT_SIZEMIN;
+ fakesrc->sizemax = DEFAULT_SIZEMAX;
fakesrc->parent = NULL;
- fakesrc->parentsize = 4096 * 10;
+ fakesrc->parentsize = DEFAULT_PARENTSIZE;
fakesrc->last_message = NULL;
}
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "fd", ARG_FD, G_PARAM_READWRITE,
- NULL);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
+ g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
+ 0, G_MAXINT, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_fdsink_set_property;
gobject_class->get_property = gst_fdsink_get_property;
#include <gstfdsrc.h>
+#define DEFAULT_BLOCKSIZE 4096
-GstElementDetails gst_fdsrc_details = {
+GstElementDetails gst_fdsrc_details =
+{
"Disk Source",
"Source/File",
"LGPL",
enum {
ARG_0,
- ARG_LOCATION,
- ARG_BYTESPERREAD,
- ARG_OFFSET,
ARG_FD,
+ ARG_BLOCKSIZE,
};
if (!fdsrc_type) {
static const GTypeInfo fdsrc_info = {
- sizeof(GstFdSrcClass), NULL,
+ sizeof(GstFdSrcClass),
+ NULL,
NULL,
(GClassInitFunc)gst_fdsrc_class_init,
NULL,
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_param_spec_int ("fd", "fd", "An open file descriptor to read from",
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->get_property = gst_fdsrc_get_property;
fdsrc->fd = 0;
fdsrc->curoffset = 0;
- fdsrc->bytes_per_read = 4096;
+ fdsrc->blocksize = DEFAULT_BLOCKSIZE;
fdsrc->seq = 0;
}
gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GstFdSrc *src;
- int fd;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSRC (object));
src = GST_FDSRC (object);
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:
src->fd = g_value_get_int (value);
break;
- case ARG_BYTESPERREAD:
- src->bytes_per_read = g_value_get_int (value);
+ case ARG_BLOCKSIZE:
+ src->blocksize = g_value_get_ulong (value);
break;
default:
break;
src = GST_FDSRC (object);
switch (prop_id) {
- case ARG_BYTESPERREAD:
- g_value_set_int (value, src->bytes_per_read);
- break;
- case ARG_OFFSET:
- g_value_set_int64 (value, src->curoffset);
+ case ARG_BLOCKSIZE:
+ g_value_set_ulong (value, src->blocksize);
break;
case ARG_FD:
g_value_set_int (value, src->fd);
g_return_val_if_fail (buf, NULL);
/* 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);
/* 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 (readbytes == 0) {
gst_element_set_eos (GST_ELEMENT (src));
gint fd;
gulong curoffset; /* current offset in file */
- gulong bytes_per_read; /* bytes per read */
+ gulong blocksize; /* bytes per read */
gulong seq; /* buffer sequence number */
};
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "location", ARG_LOCATION, G_PARAM_READWRITE,
- NULL);
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MAXFILESIZE,
- g_param_spec_int("maxfilesize","MaxFileSize","Maximum Size Per File",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
+ g_param_spec_string ("location", "File Location", "Location of the file to write",
+ NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAXFILESIZE,
+ g_param_spec_int ("maxfilesize", "MaxFileSize", "Maximum Size Per File in MB (-1 == no limit)",
+ -1, G_MAXINT, -1, G_PARAM_READWRITE));
gst_filesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
"(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...)
ARG_LOCATION,
ARG_FD,
ARG_BLOCKSIZE,
- ARG_MAPSIZE,
+ ARG_MMAPSIZE,
ARG_TOUCH,
};
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "fd", ARG_FD, G_PARAM_READABLE,
- "location", ARG_LOCATION, G_PARAM_READWRITE,
- "blocksize", ARG_BLOCKSIZE, G_PARAM_READWRITE,
- "mmapsize", ARG_MAPSIZE, G_PARAM_READWRITE,
- "touch", ARG_TOUCH, G_PARAM_READWRITE,
- NULL);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
+ g_param_spec_int ("fd", "File-descriptor", "File-descriptor for the file being mmap()d",
+ 0, G_MAXINT, 0, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
+ g_param_spec_string ("location", "File Location", "Location of the file to read",
+ NULL, 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));
+ 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->set_property = gst_filesrc_set_property;
src->filelen = 0;
src->curoffset = 0;
- src->block_size = 4096;
- src->touch = TRUE;
+ src->block_size = DEFAULT_BLOCKSIZE;
+ src->touch = FALSE;
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_lock = g_mutex_new();
src->block_size = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "blocksize");
break;
- case ARG_MAPSIZE:
+ case ARG_MMAPSIZE:
if ((src->mapsize % src->pagesize) == 0) {
src->mapsize = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "mmapsize");
} 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;
case ARG_TOUCH:
case ARG_BLOCKSIZE:
g_value_set_ulong (value, src->block_size);
break;
- case ARG_MAPSIZE:
+ case ARG_MMAPSIZE:
g_value_set_ulong (value, src->mapsize);
break;
case ARG_TOUCH:
static void
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 */
- g_mutex_lock(src->map_regions_lock);
- g_tree_remove(src->map_regions,buf);
+ g_mutex_lock (src->map_regions_lock);
+ g_tree_remove (src->map_regions, buf);
/* check to see if the tree is empty */
- if (g_tree_nnodes(src->map_regions) == 0) {
+ if (g_tree_nnodes (src->map_regions) == 0) {
/* we have to free the bufferpool we don't have yet */
}
- g_mutex_unlock(src->map_regions_lock);
+ g_mutex_unlock (src->map_regions_lock);
#ifdef MADV_DONTNEED
/* madvise to tell the kernel what to do with it */
- madvise(GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf),MADV_DONTNEED);
+ madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_DONTNEED);
#endif
/* now unmap the memory */
- munmap(GST_BUFFER_DATA(buf),GST_BUFFER_MAXSIZE(buf));
+ munmap (GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf));
GST_BUFFER_DATA (buf) = NULL;
}
/* time to allocate a new mapbuf */
- buf = gst_buffer_new();
+ buf = gst_buffer_new ();
/* mmap() the data into this new buffer */
- GST_BUFFER_DATA(buf) = mmapregion;
+ GST_BUFFER_DATA (buf) = mmapregion;
#ifdef MADV_SEQUENTIAL
/* madvise to tell the kernel what to do with it */
- retval = madvise(GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf),MADV_SEQUENTIAL);
+ retval = madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_SEQUENTIAL);
#endif
/* fill in the rest of the fields */
- GST_BUFFER_FLAG_SET(buf, GST_BUFFER_READONLY);
- GST_BUFFER_FLAG_SET(buf, GST_BUFFER_ORIGINAL);
- GST_BUFFER_SIZE(buf) = size;
- GST_BUFFER_MAXSIZE(buf) = size;
- GST_BUFFER_OFFSET(buf) = offset;
- GST_BUFFER_TIMESTAMP(buf) = -1LL;
- GST_BUFFER_POOL_PRIVATE(buf) = src;
- GST_BUFFER_FREE_FUNC(buf) = (GstDataFreeFunction) gst_filesrc_free_parent_mmap;
-
- g_mutex_lock(src->map_regions_lock);
- g_tree_insert(src->map_regions,buf,buf);
- g_mutex_unlock(src->map_regions_lock);
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_READONLY);
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_ORIGINAL);
+ GST_BUFFER_SIZE (buf) = size;
+ GST_BUFFER_MAXSIZE (buf) = size;
+ GST_BUFFER_OFFSET (buf) = offset;
+ GST_BUFFER_TIMESTAMP (buf) = -1LL;
+ GST_BUFFER_POOL_PRIVATE (buf) = src;
+ GST_BUFFER_FREE_FUNC (buf) = (GstDataFreeFunction) gst_filesrc_free_parent_mmap;
+
+ g_mutex_lock (src->map_regions_lock);
+ g_tree_insert (src->map_regions,buf,buf);
+ g_mutex_unlock (src->map_regions_lock);
return buf;
}
/* if we need to touch the buffer (to bring it into memory), do so */
if (src->touch) {
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];
}
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last_message", "Last Message", "The message describing current status",
NULL, G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SYNC,
- g_param_spec_boolean("sync","Sync","Sync on the clock",
- FALSE, G_PARAM_READWRITE)); /* CHECKME */
-
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "silent", ARG_SILENT, G_PARAM_READWRITE,
- "dump", ARG_DUMP, G_PARAM_READWRITE,
- NULL);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
+ g_param_spec_boolean ("sync", "Sync", "Sync on the clock",
+ FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
+ g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
+ FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
+ g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout",
+ FALSE, G_PARAM_READWRITE));
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,
G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL,
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER);
gst_fakesink_init (GstFakeSink *fakesink)
{
GstPad *pad;
+
pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (fakesink), pad);
gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_chain));
if (GST_IS_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)) {
case GST_EVENT_DISCONTINUOUS:
#include <gstfakesrc.h>
+#define DEFAULT_SIZEMIN 0
+#define DEFAULT_SIZEMAX 4096
+#define DEFAULT_PARENTSIZE 4096*10
GstElementDetails gst_fakesrc_details = {
"Fake Source",
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES,
g_param_spec_int ("num-sources", "num-sources", "Number of sources",
1, G_MAXINT, 1, G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOOP_BASED,
- g_param_spec_boolean("loop-based","loop-based","Enable loop-based operation",
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED,
+ g_param_spec_boolean ("loop-based", "loop-based", "Enable loop-based operation",
FALSE, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OUTPUT,
- g_param_spec_enum("output","output","Output method (currently unused)",
- GST_TYPE_FAKESRC_OUTPUT,FAKESRC_FIRST_LAST_LOOP,G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT,
+ g_param_spec_enum ("output", "output", "Output method (currently unused)",
+ GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA,
g_param_spec_enum ("data", "data", "Data allocation method",
GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, 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_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_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_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_param_spec_enum ("filltype", "filltype", "How to fill the buffer, if at all",
GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PATTERN,
- g_param_spec_string("pattern","pattern","pattern",
- NULL, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUM_BUFFERS,
- g_param_spec_int("num-buffers","num-buffers","Number of buffers to output before sending EOS",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_EOS,
- g_param_spec_boolean("eos","eos","Send out the EOS event?",
- TRUE,G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PATTERN,
+ g_param_spec_string ("pattern", "pattern", "pattern",
+ NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS,
+ g_param_spec_int ("num-buffers", "num-buffers", "Number of buffers to output before sending EOS",
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EOS,
+ g_param_spec_boolean ("eos", "eos", "Send out the EOS event?",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
g_param_spec_string ("last-message", "last-message", "The last status message",
NULL, G_PARAM_READABLE));
-
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "silent", ARG_SILENT, G_PARAM_READWRITE,
- "dump", ARG_DUMP, G_PARAM_READWRITE,
- NULL);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
+ g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
+ FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
+ g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
+ FALSE, G_PARAM_READWRITE));
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,
G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL,
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER);
fakesrc->data = FAKESRC_DATA_ALLOCATE;
fakesrc->sizetype = FAKESRC_SIZETYPE_NULL;
fakesrc->filltype = FAKESRC_FILLTYPE_NOTHING;
- fakesrc->sizemin = 0;
- fakesrc->sizemax = 4096;
+ fakesrc->sizemin = DEFAULT_SIZEMIN;
+ fakesrc->sizemax = DEFAULT_SIZEMAX;
fakesrc->parent = NULL;
- fakesrc->parentsize = 4096 * 10;
+ fakesrc->parentsize = DEFAULT_PARENTSIZE;
fakesrc->last_message = NULL;
}
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "fd", ARG_FD, G_PARAM_READWRITE,
- NULL);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
+ g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
+ 0, G_MAXINT, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_fdsink_set_property;
gobject_class->get_property = gst_fdsink_get_property;
#include <gstfdsrc.h>
+#define DEFAULT_BLOCKSIZE 4096
-GstElementDetails gst_fdsrc_details = {
+GstElementDetails gst_fdsrc_details =
+{
"Disk Source",
"Source/File",
"LGPL",
enum {
ARG_0,
- ARG_LOCATION,
- ARG_BYTESPERREAD,
- ARG_OFFSET,
ARG_FD,
+ ARG_BLOCKSIZE,
};
if (!fdsrc_type) {
static const GTypeInfo fdsrc_info = {
- sizeof(GstFdSrcClass), NULL,
+ sizeof(GstFdSrcClass),
+ NULL,
NULL,
(GClassInitFunc)gst_fdsrc_class_init,
NULL,
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_param_spec_int ("fd", "fd", "An open file descriptor to read from",
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->get_property = gst_fdsrc_get_property;
fdsrc->fd = 0;
fdsrc->curoffset = 0;
- fdsrc->bytes_per_read = 4096;
+ fdsrc->blocksize = DEFAULT_BLOCKSIZE;
fdsrc->seq = 0;
}
gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GstFdSrc *src;
- int fd;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_FDSRC (object));
src = GST_FDSRC (object);
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:
src->fd = g_value_get_int (value);
break;
- case ARG_BYTESPERREAD:
- src->bytes_per_read = g_value_get_int (value);
+ case ARG_BLOCKSIZE:
+ src->blocksize = g_value_get_ulong (value);
break;
default:
break;
src = GST_FDSRC (object);
switch (prop_id) {
- case ARG_BYTESPERREAD:
- g_value_set_int (value, src->bytes_per_read);
- break;
- case ARG_OFFSET:
- g_value_set_int64 (value, src->curoffset);
+ case ARG_BLOCKSIZE:
+ g_value_set_ulong (value, src->blocksize);
break;
case ARG_FD:
g_value_set_int (value, src->fd);
g_return_val_if_fail (buf, NULL);
/* 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);
/* 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 (readbytes == 0) {
gst_element_set_eos (GST_ELEMENT (src));
gint fd;
gulong curoffset; /* current offset in file */
- gulong bytes_per_read; /* bytes per read */
+ gulong blocksize; /* bytes per read */
gulong seq; /* buffer sequence number */
};
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "location", ARG_LOCATION, G_PARAM_READWRITE,
- NULL);
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MAXFILESIZE,
- g_param_spec_int("maxfilesize","MaxFileSize","Maximum Size Per File",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
+ g_param_spec_string ("location", "File Location", "Location of the file to write",
+ NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAXFILESIZE,
+ g_param_spec_int ("maxfilesize", "MaxFileSize", "Maximum Size Per File in MB (-1 == no limit)",
+ -1, G_MAXINT, -1, G_PARAM_READWRITE));
gst_filesink_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
"(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...)
ARG_LOCATION,
ARG_FD,
ARG_BLOCKSIZE,
- ARG_MAPSIZE,
+ ARG_MMAPSIZE,
ARG_TOUCH,
};
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "fd", ARG_FD, G_PARAM_READABLE,
- "location", ARG_LOCATION, G_PARAM_READWRITE,
- "blocksize", ARG_BLOCKSIZE, G_PARAM_READWRITE,
- "mmapsize", ARG_MAPSIZE, G_PARAM_READWRITE,
- "touch", ARG_TOUCH, G_PARAM_READWRITE,
- NULL);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD,
+ g_param_spec_int ("fd", "File-descriptor", "File-descriptor for the file being mmap()d",
+ 0, G_MAXINT, 0, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
+ g_param_spec_string ("location", "File Location", "Location of the file to read",
+ NULL, 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));
+ 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->set_property = gst_filesrc_set_property;
src->filelen = 0;
src->curoffset = 0;
- src->block_size = 4096;
- src->touch = TRUE;
+ src->block_size = DEFAULT_BLOCKSIZE;
+ src->touch = FALSE;
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_lock = g_mutex_new();
src->block_size = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "blocksize");
break;
- case ARG_MAPSIZE:
+ case ARG_MMAPSIZE:
if ((src->mapsize % src->pagesize) == 0) {
src->mapsize = g_value_get_ulong (value);
g_object_notify (G_OBJECT (src), "mmapsize");
} 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;
case ARG_TOUCH:
case ARG_BLOCKSIZE:
g_value_set_ulong (value, src->block_size);
break;
- case ARG_MAPSIZE:
+ case ARG_MMAPSIZE:
g_value_set_ulong (value, src->mapsize);
break;
case ARG_TOUCH:
static void
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 */
- g_mutex_lock(src->map_regions_lock);
- g_tree_remove(src->map_regions,buf);
+ g_mutex_lock (src->map_regions_lock);
+ g_tree_remove (src->map_regions, buf);
/* check to see if the tree is empty */
- if (g_tree_nnodes(src->map_regions) == 0) {
+ if (g_tree_nnodes (src->map_regions) == 0) {
/* we have to free the bufferpool we don't have yet */
}
- g_mutex_unlock(src->map_regions_lock);
+ g_mutex_unlock (src->map_regions_lock);
#ifdef MADV_DONTNEED
/* madvise to tell the kernel what to do with it */
- madvise(GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf),MADV_DONTNEED);
+ madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_DONTNEED);
#endif
/* now unmap the memory */
- munmap(GST_BUFFER_DATA(buf),GST_BUFFER_MAXSIZE(buf));
+ munmap (GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf));
GST_BUFFER_DATA (buf) = NULL;
}
/* time to allocate a new mapbuf */
- buf = gst_buffer_new();
+ buf = gst_buffer_new ();
/* mmap() the data into this new buffer */
- GST_BUFFER_DATA(buf) = mmapregion;
+ GST_BUFFER_DATA (buf) = mmapregion;
#ifdef MADV_SEQUENTIAL
/* madvise to tell the kernel what to do with it */
- retval = madvise(GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf),MADV_SEQUENTIAL);
+ retval = madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_SEQUENTIAL);
#endif
/* fill in the rest of the fields */
- GST_BUFFER_FLAG_SET(buf, GST_BUFFER_READONLY);
- GST_BUFFER_FLAG_SET(buf, GST_BUFFER_ORIGINAL);
- GST_BUFFER_SIZE(buf) = size;
- GST_BUFFER_MAXSIZE(buf) = size;
- GST_BUFFER_OFFSET(buf) = offset;
- GST_BUFFER_TIMESTAMP(buf) = -1LL;
- GST_BUFFER_POOL_PRIVATE(buf) = src;
- GST_BUFFER_FREE_FUNC(buf) = (GstDataFreeFunction) gst_filesrc_free_parent_mmap;
-
- g_mutex_lock(src->map_regions_lock);
- g_tree_insert(src->map_regions,buf,buf);
- g_mutex_unlock(src->map_regions_lock);
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_READONLY);
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_ORIGINAL);
+ GST_BUFFER_SIZE (buf) = size;
+ GST_BUFFER_MAXSIZE (buf) = size;
+ GST_BUFFER_OFFSET (buf) = offset;
+ GST_BUFFER_TIMESTAMP (buf) = -1LL;
+ GST_BUFFER_POOL_PRIVATE (buf) = src;
+ GST_BUFFER_FREE_FUNC (buf) = (GstDataFreeFunction) gst_filesrc_free_parent_mmap;
+
+ g_mutex_lock (src->map_regions_lock);
+ g_tree_insert (src->map_regions,buf,buf);
+ g_mutex_unlock (src->map_regions_lock);
return buf;
}
/* if we need to touch the buffer (to bring it into memory), do so */
if (src->touch) {
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];
}