mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
Small cleanups, more descriptive properties
Original commit message from CVS: Small cleanups, more descriptive properties
This commit is contained in:
parent
774edda66b
commit
12490346d0
14 changed files with 258 additions and 250 deletions
|
@ -114,18 +114,18 @@ gst_fakesink_class_init (GstFakeSinkClass *klass)
|
|||
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);
|
||||
|
@ -140,6 +140,7 @@ static void
|
|||
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));
|
||||
|
@ -259,6 +260,15 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
|
|||
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:
|
||||
if (fakesink->sync && fakesink->clock) {
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
|
||||
#include <gstfakesrc.h>
|
||||
|
||||
#define DEFAULT_SIZEMIN 0
|
||||
#define DEFAULT_SIZEMAX 4096
|
||||
#define DEFAULT_PARENTSIZE 4096*10
|
||||
|
||||
GstElementDetails gst_fakesrc_details = {
|
||||
"Fake Source",
|
||||
|
@ -201,12 +204,12 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
|
|||
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));
|
||||
|
@ -215,37 +218,37 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
|
|||
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",
|
||||
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_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);
|
||||
|
@ -282,10 +285,10 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,10 +90,9 @@ gst_fdsink_class_init (GstFdSinkClass *klass)
|
|||
|
||||
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;
|
||||
|
|
|
@ -29,8 +29,10 @@
|
|||
|
||||
#include <gstfdsrc.h>
|
||||
|
||||
#define DEFAULT_BLOCKSIZE 4096
|
||||
|
||||
GstElementDetails gst_fdsrc_details = {
|
||||
GstElementDetails gst_fdsrc_details =
|
||||
{
|
||||
"Disk Source",
|
||||
"Source/File",
|
||||
"LGPL",
|
||||
|
@ -49,10 +51,8 @@ enum {
|
|||
|
||||
enum {
|
||||
ARG_0,
|
||||
ARG_LOCATION,
|
||||
ARG_BYTESPERREAD,
|
||||
ARG_OFFSET,
|
||||
ARG_FD,
|
||||
ARG_BLOCKSIZE,
|
||||
};
|
||||
|
||||
|
||||
|
@ -77,7 +77,8 @@ gst_fdsrc_get_type (void)
|
|||
|
||||
if (!fdsrc_type) {
|
||||
static const GTypeInfo fdsrc_info = {
|
||||
sizeof(GstFdSrcClass), NULL,
|
||||
sizeof(GstFdSrcClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gst_fdsrc_class_init,
|
||||
NULL,
|
||||
|
@ -100,16 +101,12 @@ gst_fdsrc_class_init (GstFdSrcClass *klass)
|
|||
|
||||
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;
|
||||
|
@ -122,7 +119,7 @@ static void gst_fdsrc_init(GstFdSrc *fdsrc) {
|
|||
|
||||
fdsrc->fd = 0;
|
||||
fdsrc->curoffset = 0;
|
||||
fdsrc->bytes_per_read = 4096;
|
||||
fdsrc->blocksize = DEFAULT_BLOCKSIZE;
|
||||
fdsrc->seq = 0;
|
||||
}
|
||||
|
||||
|
@ -131,7 +128,6 @@ static void
|
|||
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));
|
||||
|
@ -139,25 +135,11 @@ gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GPa
|
|||
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;
|
||||
|
@ -175,11 +157,8 @@ gst_fdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
|
|||
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);
|
||||
|
@ -206,11 +185,11 @@ gst_fdsrc_get(GstPad *pad)
|
|||
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));
|
||||
|
|
|
@ -57,7 +57,7 @@ struct _GstFdSrc {
|
|||
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 */
|
||||
};
|
||||
|
|
|
@ -112,14 +112,12 @@ gst_filesink_class_init (GstFileSinkClass *klass)
|
|||
|
||||
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,
|
||||
|
|
|
@ -79,6 +79,9 @@ GstElementDetails gst_filesrc_details = {
|
|||
"(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...)
|
||||
|
||||
|
@ -93,7 +96,7 @@ enum {
|
|||
ARG_LOCATION,
|
||||
ARG_FD,
|
||||
ARG_BLOCKSIZE,
|
||||
ARG_MAPSIZE,
|
||||
ARG_MMAPSIZE,
|
||||
ARG_TOUCH,
|
||||
};
|
||||
|
||||
|
@ -167,14 +170,23 @@ gst_filesrc_class_init (GstFileSrcClass *klass)
|
|||
|
||||
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;
|
||||
|
@ -215,11 +227,11 @@ gst_filesrc_init (GstFileSrc *src)
|
|||
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();
|
||||
|
@ -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);
|
||||
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:
|
||||
|
@ -310,7 +323,7 @@ gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
|
|||
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:
|
||||
|
@ -325,25 +338,26 @@ gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
|
|||
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;
|
||||
|
||||
|
@ -373,27 +387,27 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
|
|||
}
|
||||
|
||||
/* 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;
|
||||
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);
|
||||
g_mutex_lock (src->map_regions_lock);
|
||||
g_tree_insert (src->map_regions,buf,buf);
|
||||
g_mutex_unlock (src->map_regions_lock);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
@ -587,7 +601,8 @@ gst_filesrc_get (GstPad *pad)
|
|||
/* 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];
|
||||
}
|
||||
|
||||
|
|
|
@ -114,18 +114,18 @@ gst_fakesink_class_init (GstFakeSinkClass *klass)
|
|||
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);
|
||||
|
@ -140,6 +140,7 @@ static void
|
|||
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));
|
||||
|
@ -259,6 +260,15 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
|
|||
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:
|
||||
if (fakesink->sync && fakesink->clock) {
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
|
||||
#include <gstfakesrc.h>
|
||||
|
||||
#define DEFAULT_SIZEMIN 0
|
||||
#define DEFAULT_SIZEMAX 4096
|
||||
#define DEFAULT_PARENTSIZE 4096*10
|
||||
|
||||
GstElementDetails gst_fakesrc_details = {
|
||||
"Fake Source",
|
||||
|
@ -201,12 +204,12 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
|
|||
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));
|
||||
|
@ -215,37 +218,37 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
|
|||
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",
|
||||
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_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);
|
||||
|
@ -282,10 +285,10 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,10 +90,9 @@ gst_fdsink_class_init (GstFdSinkClass *klass)
|
|||
|
||||
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;
|
||||
|
|
|
@ -29,8 +29,10 @@
|
|||
|
||||
#include <gstfdsrc.h>
|
||||
|
||||
#define DEFAULT_BLOCKSIZE 4096
|
||||
|
||||
GstElementDetails gst_fdsrc_details = {
|
||||
GstElementDetails gst_fdsrc_details =
|
||||
{
|
||||
"Disk Source",
|
||||
"Source/File",
|
||||
"LGPL",
|
||||
|
@ -49,10 +51,8 @@ enum {
|
|||
|
||||
enum {
|
||||
ARG_0,
|
||||
ARG_LOCATION,
|
||||
ARG_BYTESPERREAD,
|
||||
ARG_OFFSET,
|
||||
ARG_FD,
|
||||
ARG_BLOCKSIZE,
|
||||
};
|
||||
|
||||
|
||||
|
@ -77,7 +77,8 @@ gst_fdsrc_get_type (void)
|
|||
|
||||
if (!fdsrc_type) {
|
||||
static const GTypeInfo fdsrc_info = {
|
||||
sizeof(GstFdSrcClass), NULL,
|
||||
sizeof(GstFdSrcClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gst_fdsrc_class_init,
|
||||
NULL,
|
||||
|
@ -100,16 +101,12 @@ gst_fdsrc_class_init (GstFdSrcClass *klass)
|
|||
|
||||
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;
|
||||
|
@ -122,7 +119,7 @@ static void gst_fdsrc_init(GstFdSrc *fdsrc) {
|
|||
|
||||
fdsrc->fd = 0;
|
||||
fdsrc->curoffset = 0;
|
||||
fdsrc->bytes_per_read = 4096;
|
||||
fdsrc->blocksize = DEFAULT_BLOCKSIZE;
|
||||
fdsrc->seq = 0;
|
||||
}
|
||||
|
||||
|
@ -131,7 +128,6 @@ static void
|
|||
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));
|
||||
|
@ -139,25 +135,11 @@ gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GPa
|
|||
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;
|
||||
|
@ -175,11 +157,8 @@ gst_fdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
|
|||
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);
|
||||
|
@ -206,11 +185,11 @@ gst_fdsrc_get(GstPad *pad)
|
|||
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));
|
||||
|
|
|
@ -57,7 +57,7 @@ struct _GstFdSrc {
|
|||
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 */
|
||||
};
|
||||
|
|
|
@ -112,14 +112,12 @@ gst_filesink_class_init (GstFileSinkClass *klass)
|
|||
|
||||
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,
|
||||
|
|
|
@ -79,6 +79,9 @@ GstElementDetails gst_filesrc_details = {
|
|||
"(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...)
|
||||
|
||||
|
@ -93,7 +96,7 @@ enum {
|
|||
ARG_LOCATION,
|
||||
ARG_FD,
|
||||
ARG_BLOCKSIZE,
|
||||
ARG_MAPSIZE,
|
||||
ARG_MMAPSIZE,
|
||||
ARG_TOUCH,
|
||||
};
|
||||
|
||||
|
@ -167,14 +170,23 @@ gst_filesrc_class_init (GstFileSrcClass *klass)
|
|||
|
||||
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;
|
||||
|
@ -215,11 +227,11 @@ gst_filesrc_init (GstFileSrc *src)
|
|||
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();
|
||||
|
@ -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);
|
||||
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:
|
||||
|
@ -310,7 +323,7 @@ gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
|
|||
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:
|
||||
|
@ -325,25 +338,26 @@ gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
|
|||
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;
|
||||
|
||||
|
@ -373,27 +387,27 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
|
|||
}
|
||||
|
||||
/* 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;
|
||||
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);
|
||||
g_mutex_lock (src->map_regions_lock);
|
||||
g_tree_insert (src->map_regions,buf,buf);
|
||||
g_mutex_unlock (src->map_regions_lock);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
@ -587,7 +601,8 @@ gst_filesrc_get (GstPad *pad)
|
|||
/* 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];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue