mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
more of the popular // fixes
Original commit message from CVS: more of the popular // fixes
This commit is contained in:
parent
1776717a40
commit
7886394507
24 changed files with 194 additions and 194 deletions
|
@ -88,7 +88,7 @@ static void gst_aggregator_chain (GstPad *pad, GstBuffer *buf);
|
||||||
static void gst_aggregator_loop (GstElement *element);
|
static void gst_aggregator_loop (GstElement *element);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_aggregator_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_aggregator_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_aggregator_get_type (void)
|
gst_aggregator_get_type (void)
|
||||||
|
@ -331,7 +331,7 @@ gst_aggregator_chain (GstPad *pad, GstBuffer *buf)
|
||||||
g_return_if_fail (buf != NULL);
|
g_return_if_fail (buf != NULL);
|
||||||
|
|
||||||
aggregator = GST_AGGREGATOR (gst_pad_get_parent (pad));
|
aggregator = GST_AGGREGATOR (gst_pad_get_parent (pad));
|
||||||
// gst_trace_add_entry (NULL, 0, buf, "aggregator buffer");
|
/* gst_trace_add_entry (NULL, 0, buf, "aggregator buffer");*/
|
||||||
|
|
||||||
gst_aggregator_push (aggregator, pad, buf, "chain");
|
gst_aggregator_push (aggregator, pad, buf, "chain");
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,12 +96,12 @@ plugin_init (GModule *module, GstPlugin *plugin)
|
||||||
if (_elements[i].factoryinit) {
|
if (_elements[i].factoryinit) {
|
||||||
_elements[i].factoryinit (factory);
|
_elements[i].factoryinit (factory);
|
||||||
}
|
}
|
||||||
// g_print("added factory '%s'\n",_elements[i].name);
|
/* g_print("added factory '%s'\n",_elements[i].name); */
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INFO (GST_INFO_PLUGIN_LOAD,"gstelements: loaded %d standard elements", i);
|
/* INFO (GST_INFO_PLUGIN_LOAD,"gstelements: loaded %d standard elements", i);*/
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,10 +200,10 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
|
||||||
1, G_MAXINT, 1, G_PARAM_READABLE));
|
1, G_MAXINT, 1, G_PARAM_READABLE));
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOOP_BASED,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOOP_BASED,
|
||||||
g_param_spec_boolean("loop_based","loop_based","loop_based",
|
g_param_spec_boolean("loop_based","loop_based","loop_based",
|
||||||
FALSE, G_PARAM_READWRITE)); // CHECKME
|
FALSE, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OUTPUT,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OUTPUT,
|
||||||
g_param_spec_enum("output","output","output",
|
g_param_spec_enum("output","output","output",
|
||||||
GST_TYPE_FAKESRC_OUTPUT,FAKESRC_FIRST_LAST_LOOP,G_PARAM_READWRITE)); // CHECKME!
|
GST_TYPE_FAKESRC_OUTPUT,FAKESRC_FIRST_LAST_LOOP,G_PARAM_READWRITE)); /* CHECKME! */
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA,
|
||||||
g_param_spec_enum ("data", "data", "data",
|
g_param_spec_enum ("data", "data", "data",
|
||||||
GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE));
|
GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE));
|
||||||
|
@ -224,13 +224,13 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
|
||||||
GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
|
GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PATTERN,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PATTERN,
|
||||||
g_param_spec_string("pattern","pattern","pattern",
|
g_param_spec_string("pattern","pattern","pattern",
|
||||||
NULL, G_PARAM_READWRITE)); // CHECKME
|
NULL, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUM_BUFFERS,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUM_BUFFERS,
|
||||||
g_param_spec_int("num_buffers","num_buffers","num_buffers",
|
g_param_spec_int("num_buffers","num_buffers","num_buffers",
|
||||||
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME
|
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_EOS,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_EOS,
|
||||||
g_param_spec_boolean("eos","eos","eos",
|
g_param_spec_boolean("eos","eos","eos",
|
||||||
TRUE,G_PARAM_READWRITE)); // CHECKME
|
TRUE,G_PARAM_READWRITE)); /* CHECKME */
|
||||||
|
|
||||||
gst_element_install_std_props (
|
gst_element_install_std_props (
|
||||||
GST_ELEMENT_CLASS (klass),
|
GST_ELEMENT_CLASS (klass),
|
||||||
|
@ -256,7 +256,7 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
|
||||||
{
|
{
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
|
|
||||||
// create our first output pad
|
/* create our first output pad */
|
||||||
pad = gst_pad_new ("src", GST_PAD_SRC);
|
pad = gst_pad_new ("src", GST_PAD_SRC);
|
||||||
gst_element_add_pad (GST_ELEMENT (fakesrc), pad);
|
gst_element_add_pad (GST_ELEMENT (fakesrc), pad);
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ gst_fakesrc_event_handler (GstPad *pad, GstEvent *event)
|
||||||
gst_event_free (event);
|
gst_event_free (event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// else we do a flush too
|
/* else we do a flush too */
|
||||||
case GST_EVENT_FLUSH:
|
case GST_EVENT_FLUSH:
|
||||||
g_print("fakesrc: have flush event\n");
|
g_print("fakesrc: have flush event\n");
|
||||||
src->need_flush = TRUE;
|
src->need_flush = TRUE;
|
||||||
|
@ -601,21 +601,21 @@ gst_fakesrc_create_buffer (GstFakeSrc *src)
|
||||||
buf = gst_fakesrc_alloc_buffer (src, size);
|
buf = gst_fakesrc_alloc_buffer (src, size);
|
||||||
break;
|
break;
|
||||||
case FAKESRC_DATA_SUBBUFFER:
|
case FAKESRC_DATA_SUBBUFFER:
|
||||||
// see if we have a parent to subbuffer
|
/* see if we have a parent to subbuffer */
|
||||||
if (!src->parent) {
|
if (!src->parent) {
|
||||||
gst_fakesrc_alloc_parent (src);
|
gst_fakesrc_alloc_parent (src);
|
||||||
g_assert (src->parent);
|
g_assert (src->parent);
|
||||||
}
|
}
|
||||||
// see if it's large enough
|
/* see if it's large enough */
|
||||||
if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) {
|
if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) {
|
||||||
buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
|
buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
|
||||||
src->parentoffset += size;
|
src->parentoffset += size;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// the parent is useless now
|
/* the parent is useless now */
|
||||||
gst_buffer_unref (src->parent);
|
gst_buffer_unref (src->parent);
|
||||||
src->parent = NULL;
|
src->parent = NULL;
|
||||||
// try again (this will allocate a new parent)
|
/* try again (this will allocate a new parent) */
|
||||||
return gst_fakesrc_create_buffer (src);
|
return gst_fakesrc_create_buffer (src);
|
||||||
}
|
}
|
||||||
gst_fakesrc_prepare_buffer (src, buf);
|
gst_fakesrc_prepare_buffer (src, buf);
|
||||||
|
|
|
@ -57,7 +57,7 @@ static void gst_fdsink_get_property (GObject *object, guint prop_id,
|
||||||
static void gst_fdsink_chain (GstPad *pad,GstBuffer *buf);
|
static void gst_fdsink_chain (GstPad *pad,GstBuffer *buf);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_fdsink_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_fdsink_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_fdsink_get_type (void)
|
gst_fdsink_get_type (void)
|
||||||
|
|
|
@ -66,7 +66,7 @@ static GstBuffer * gst_fdsrc_get (GstPad *pad);
|
||||||
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_fdsrc_get_type (void)
|
gst_fdsrc_get_type (void)
|
||||||
|
@ -189,7 +189,7 @@ gst_fdsrc_get(GstPad *pad)
|
||||||
src = GST_FDSRC(gst_pad_get_parent (pad));
|
src = GST_FDSRC(gst_pad_get_parent (pad));
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
// FIXME: should eventually use a bufferpool for this
|
/* FIXME: should eventually use a bufferpool for this*/
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
g_return_val_if_fail (buf, NULL);
|
g_return_val_if_fail (buf, NULL);
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ gst_fdsrc_get(GstPad *pad)
|
||||||
|
|
||||||
/* if we didn't get as many bytes as we asked for, we're at EOF */
|
/* if we didn't get as many bytes as we asked for, we're at EOF */
|
||||||
if (readbytes < src->bytes_per_read) {
|
if (readbytes < src->bytes_per_read) {
|
||||||
// set the buffer's EOF bit here
|
/* set the buffer's EOF bit here */
|
||||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
|
||||||
}
|
}
|
||||||
GST_BUFFER_OFFSET(buf) = src->curoffset;
|
GST_BUFFER_OFFSET(buf) = src->curoffset;
|
||||||
|
|
|
@ -77,7 +77,7 @@ GstElementDetails gst_filesrc_details = {
|
||||||
"(C) 1999",
|
"(C) 1999",
|
||||||
};
|
};
|
||||||
|
|
||||||
//#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...)
|
||||||
|
|
||||||
/* FileSrc signals and args */
|
/* FileSrc signals and args */
|
||||||
|
@ -113,7 +113,7 @@ static GstElementStateReturn gst_filesrc_change_state (GstElement *element);
|
||||||
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_filesrc_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_filesrc_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_filesrc_get_type(void)
|
gst_filesrc_get_type(void)
|
||||||
|
@ -167,9 +167,9 @@ gst_filesrc_class_init (GstFileSrcClass *klass)
|
||||||
static gint
|
static gint
|
||||||
gst_filesrc_bufcmp (gconstpointer a, gconstpointer b)
|
gst_filesrc_bufcmp (gconstpointer a, gconstpointer b)
|
||||||
{
|
{
|
||||||
// GstBuffer *bufa = (GstBuffer *)a, *bufb = (GstBuffer *)b;
|
/* GstBuffer *bufa = (GstBuffer *)a, *bufb = (GstBuffer *)b;*/
|
||||||
|
|
||||||
// sort first by offset, then in reverse by size
|
/* sort first by offset, then in reverse by size */
|
||||||
if (GST_BUFFER_OFFSET(a) < GST_BUFFER_OFFSET(b)) return -1;
|
if (GST_BUFFER_OFFSET(a) < GST_BUFFER_OFFSET(b)) return -1;
|
||||||
else if (GST_BUFFER_OFFSET(a) > GST_BUFFER_OFFSET(b)) return 1;
|
else if (GST_BUFFER_OFFSET(a) > GST_BUFFER_OFFSET(b)) return 1;
|
||||||
else if (GST_BUFFER_SIZE(a) > GST_BUFFER_SIZE(b)) return -1;
|
else if (GST_BUFFER_SIZE(a) > GST_BUFFER_SIZE(b)) return -1;
|
||||||
|
@ -196,7 +196,7 @@ gst_filesrc_init (GstFileSrc *src)
|
||||||
src->touch = TRUE;
|
src->touch = TRUE;
|
||||||
|
|
||||||
src->mapbuf = NULL;
|
src->mapbuf = NULL;
|
||||||
src->mapsize = 4 * 1024 * 1024; // default is 4MB
|
src->mapsize = 4 * 1024 * 1024; /* 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();
|
||||||
|
@ -295,20 +295,20 @@ gst_filesrc_free_parent_mmap (GstBuffer *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);
|
||||||
g_tree_remove(src->map_regions,buf);
|
g_tree_remove(src->map_regions,buf);
|
||||||
// check to see if the tree is empty
|
/* 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
|
/* 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
|
#ifdef MADV_DONTNEED
|
||||||
// madvise to tell the kernel what to do with it
|
/* 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
|
#endif
|
||||||
// now unmap the memory
|
/* now unmap the memory */
|
||||||
munmap(GST_BUFFER_DATA(buf),GST_BUFFER_MAXSIZE(buf));
|
munmap(GST_BUFFER_DATA(buf),GST_BUFFER_MAXSIZE(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,9 +322,9 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
|
||||||
|
|
||||||
fs_print ("mapping region %08lx+%08lx from file into memory\n",offset,size);
|
fs_print ("mapping region %08lx+%08lx from file into memory\n",offset,size);
|
||||||
|
|
||||||
// time to allocate a new mapbuf
|
/* time to allocate a new mapbuf */
|
||||||
buf = gst_buffer_new();
|
buf = gst_buffer_new();
|
||||||
// mmap() the data into this new buffer
|
/* mmap() the data into this new buffer */
|
||||||
GST_BUFFER_DATA(buf) = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);
|
GST_BUFFER_DATA(buf) = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);
|
||||||
if (GST_BUFFER_DATA(buf) == NULL) {
|
if (GST_BUFFER_DATA(buf) == NULL) {
|
||||||
fprintf (stderr, "ERROR: gstfilesrc couldn't map file!\n");
|
fprintf (stderr, "ERROR: gstfilesrc couldn't map file!\n");
|
||||||
|
@ -333,10 +333,10 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
|
||||||
size, src->fd, offset, sys_errlist[errno]);
|
size, src->fd, offset, sys_errlist[errno]);
|
||||||
}
|
}
|
||||||
#ifdef MADV_SEQUENTIAL
|
#ifdef MADV_SEQUENTIAL
|
||||||
// madvise to tell the kernel what to do with it
|
/* 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
|
#endif
|
||||||
// fill in the rest of the fields
|
/* fill in the rest of the fields */
|
||||||
GST_BUFFER_FLAGS(buf) = GST_BUFFER_READONLY | GST_BUFFER_ORIGINAL;
|
GST_BUFFER_FLAGS(buf) = GST_BUFFER_READONLY | GST_BUFFER_ORIGINAL;
|
||||||
GST_BUFFER_SIZE(buf) = size;
|
GST_BUFFER_SIZE(buf) = size;
|
||||||
GST_BUFFER_MAXSIZE(buf) = size;
|
GST_BUFFER_MAXSIZE(buf) = size;
|
||||||
|
@ -359,15 +359,15 @@ gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size)
|
||||||
off_t mod, mapbase;
|
off_t mod, mapbase;
|
||||||
GstBuffer *map;
|
GstBuffer *map;
|
||||||
|
|
||||||
// printf("attempting to map a small buffer at %d+%d\n",offset,size);
|
/* printf("attempting to map a small buffer at %d+%d\n",offset,size); */
|
||||||
|
|
||||||
// if the offset starts at a non-page boundary, we have to special case
|
/* if the offset starts at a non-page boundary, we have to special case */
|
||||||
if ((mod = offset % src->pagesize)) {
|
if ((mod = offset % src->pagesize)) {
|
||||||
GstBuffer *ret;
|
GstBuffer *ret;
|
||||||
|
|
||||||
mapbase = offset - mod;
|
mapbase = offset - mod;
|
||||||
mapsize = ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize;
|
mapsize = ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize;
|
||||||
// printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);
|
/* printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);*/
|
||||||
map = gst_filesrc_map_region(src, mapbase, mapsize);
|
map = gst_filesrc_map_region(src, mapbase, mapsize);
|
||||||
ret = gst_buffer_create_sub (map, offset - mapbase, size);
|
ret = gst_buffer_create_sub (map, offset - mapbase, size);
|
||||||
|
|
||||||
|
@ -384,13 +384,13 @@ typedef struct {
|
||||||
off_t size;
|
off_t size;
|
||||||
} GstFileSrcRegion;
|
} GstFileSrcRegion;
|
||||||
|
|
||||||
// This allows us to search for a potential mmap region.
|
/* This allows us to search for a potential mmap region. */
|
||||||
static gint
|
static gint
|
||||||
gst_filesrc_search_region_match (gpointer a, gpointer b)
|
gst_filesrc_search_region_match (gpointer a, gpointer b)
|
||||||
{
|
{
|
||||||
GstFileSrcRegion *r = (GstFileSrcRegion *)b;
|
GstFileSrcRegion *r = (GstFileSrcRegion *)b;
|
||||||
|
|
||||||
// trying to walk b down the tree, current node is a
|
/* trying to walk b down the tree, current node is a */
|
||||||
if (r->offset < GST_BUFFER_OFFSET(a)) return -1;
|
if (r->offset < GST_BUFFER_OFFSET(a)) return -1;
|
||||||
else if (r->offset >= (GST_BUFFER_OFFSET(a) + GST_BUFFER_SIZE(a))) return 1;
|
else if (r->offset >= (GST_BUFFER_OFFSET(a) + GST_BUFFER_SIZE(a))) return 1;
|
||||||
else if ((r->offset + r->size) <= (GST_BUFFER_OFFSET(a) + GST_BUFFER_SIZE(a))) return 0;
|
else if ((r->offset + r->size) <= (GST_BUFFER_OFFSET(a) + GST_BUFFER_SIZE(a))) return 0;
|
||||||
|
@ -418,63 +418,63 @@ gst_filesrc_get (GstPad *pad)
|
||||||
src = GST_FILESRC (gst_pad_get_parent (pad));
|
src = GST_FILESRC (gst_pad_get_parent (pad));
|
||||||
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), NULL);
|
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), NULL);
|
||||||
|
|
||||||
// check for seek
|
/* check for seek */
|
||||||
if (src->seek_happened) {
|
if (src->seek_happened) {
|
||||||
src->seek_happened = FALSE;
|
src->seek_happened = FALSE;
|
||||||
return GST_BUFFER (gst_event_new(GST_EVENT_DISCONTINUOUS));
|
return GST_BUFFER (gst_event_new(GST_EVENT_DISCONTINUOUS));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for EOF
|
/* check for EOF */
|
||||||
if (src->curoffset == src->filelen) {
|
if (src->curoffset == src->filelen) {
|
||||||
gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED);
|
gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED);
|
||||||
return GST_BUFFER (gst_event_new(GST_EVENT_EOS));
|
return GST_BUFFER (gst_event_new(GST_EVENT_EOS));
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate end pointers so we don't have to do so repeatedly later
|
/* calculate end pointers so we don't have to do so repeatedly later */
|
||||||
readsize = src->block_size;
|
readsize = src->block_size;
|
||||||
readend = src->curoffset + src->block_size; // note this is the byte *after* the read
|
readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */
|
||||||
mapstart = GST_BUFFER_OFFSET(src->mapbuf);
|
mapstart = GST_BUFFER_OFFSET(src->mapbuf);
|
||||||
mapend = mapstart + GST_BUFFER_SIZE(src->mapbuf); // note this is the byte *after* the map
|
mapend = mapstart + GST_BUFFER_SIZE(src->mapbuf); /* note this is the byte *after* the map */
|
||||||
|
|
||||||
// check to see if we're going to overflow the end of the file
|
/* check to see if we're going to overflow the end of the file */
|
||||||
if (readend > src->filelen) {
|
if (readend > src->filelen) {
|
||||||
readsize = src->filelen - src->curoffset;
|
readsize = src->filelen - src->curoffset;
|
||||||
readend = src->curoffset;
|
readend = src->curoffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the start is past the mapstart
|
/* if the start is past the mapstart */
|
||||||
if (src->curoffset >= mapstart) {
|
if (src->curoffset >= mapstart) {
|
||||||
// if the end is before the mapend, the buffer is in current mmap region...
|
/* if the end is before the mapend, the buffer is in current mmap region... */
|
||||||
// ('cause by definition if readend is in the buffer, so's readstart)
|
/* ('cause by definition if readend is in the buffer, so's readstart) */
|
||||||
if (readend <= mapend) {
|
if (readend <= mapend) {
|
||||||
fs_print ("read buf %d+%d lives in current mapbuf %d+%d, creating subbuffer of mapbuf\n",
|
fs_print ("read buf %d+%d lives in current mapbuf %d+%d, creating subbuffer of mapbuf\n",
|
||||||
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
||||||
buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - GST_BUFFER_OFFSET(src->mapbuf),
|
buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - GST_BUFFER_OFFSET(src->mapbuf),
|
||||||
readsize);
|
readsize);
|
||||||
|
|
||||||
// if the start actually is within the current mmap region, map an overlap buffer
|
/* if the start actually is within the current mmap region, map an overlap buffer */
|
||||||
} else if (src->curoffset < mapend) {
|
} else if (src->curoffset < mapend) {
|
||||||
fs_print ("read buf %d+%d starts in mapbuf %d+%d but ends outside, creating new mmap\n",
|
fs_print ("read buf %d+%d starts in mapbuf %d+%d but ends outside, creating new mmap\n",
|
||||||
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
||||||
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the only other option is that buffer is totally outside, which means we search for it
|
/* the only other option is that buffer is totally outside, which means we search for it */
|
||||||
|
|
||||||
// now we can assume that the start is *before* the current mmap region
|
/* now we can assume that the start is *before* the current mmap region */
|
||||||
// if the readend is past mapstart, we have two options
|
/* if the readend is past mapstart, we have two options */
|
||||||
} else if (readend >= mapstart) {
|
} else if (readend >= mapstart) {
|
||||||
// either the read buffer overlaps the start of the mmap region
|
/* either the read buffer overlaps the start of the mmap region */
|
||||||
// or the read buffer fully contains the current mmap region
|
/* or the read buffer fully contains the current mmap region */
|
||||||
// either way, it's really not relevant, we just create a new region anyway
|
/* either way, it's really not relevant, we just create a new region anyway*/
|
||||||
fs_print ("read buf %d+%d starts before mapbuf %d+%d, but overlaps it\n",
|
fs_print ("read buf %d+%d starts before mapbuf %d+%d, but overlaps it\n",
|
||||||
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
||||||
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// then deal with the case where the read buffer is totally outside
|
/* then deal with the case where the read buffer is totally outside */
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
// first check to see if there's a map that covers the right region already
|
/* first check to see if there's a map that covers the right region already */
|
||||||
fs_print ("searching for mapbuf to cover %d+%d\n",src->curoffset,readsize);
|
fs_print ("searching for mapbuf to cover %d+%d\n",src->curoffset,readsize);
|
||||||
region.offset = src->curoffset;
|
region.offset = src->curoffset;
|
||||||
region.size = readsize;
|
region.size = readsize;
|
||||||
|
@ -482,29 +482,29 @@ gst_filesrc_get (GstPad *pad)
|
||||||
(GCompareFunc) gst_filesrc_search_region_match,
|
(GCompareFunc) gst_filesrc_search_region_match,
|
||||||
®ion);
|
®ion);
|
||||||
|
|
||||||
// if we found an exact match, subbuffer it
|
/* if we found an exact match, subbuffer it */
|
||||||
if (map != NULL) {
|
if (map != NULL) {
|
||||||
fs_print ("found mapbuf at %d+%d, creating subbuffer\n",GST_BUFFER_OFFSET(map),GST_BUFFER_SIZE(map));
|
fs_print ("found mapbuf at %d+%d, creating subbuffer\n",GST_BUFFER_OFFSET(map),GST_BUFFER_SIZE(map));
|
||||||
buf = gst_buffer_create_sub (map, src->curoffset - GST_BUFFER_OFFSET(map), readsize);
|
buf = gst_buffer_create_sub (map, src->curoffset - GST_BUFFER_OFFSET(map), readsize);
|
||||||
|
|
||||||
// otherwise we need to create something out of thin air
|
/* otherwise we need to create something out of thin air */
|
||||||
} else {
|
} else {
|
||||||
// if the read buffer crosses a mmap region boundary, create a one-off region
|
/* if the read buffer crosses a mmap region boundary, create a one-off region */
|
||||||
if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) {
|
if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) {
|
||||||
fs_print ("read buf %d+%d crosses a %d-byte boundary, creating a one-off\n",
|
fs_print ("read buf %d+%d crosses a %d-byte boundary, creating a one-off\n",
|
||||||
src->curoffset,readsize,src->mapsize);
|
src->curoffset,readsize,src->mapsize);
|
||||||
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
||||||
|
|
||||||
// otherwise we will create a new mmap region and set it to the default
|
/* otherwise we will create a new mmap region and set it to the default */
|
||||||
} else {
|
} else {
|
||||||
off_t nextmap = src->curoffset - (src->curoffset % src->mapsize);
|
off_t nextmap = src->curoffset - (src->curoffset % src->mapsize);
|
||||||
fs_print ("read buf %d+%d in new mapbuf at %d+%d, mapping and subbuffering\n",
|
fs_print ("read buf %d+%d in new mapbuf at %d+%d, mapping and subbuffering\n",
|
||||||
src->curoffset,readsize,nextmap,src->mapsize);
|
src->curoffset,readsize,nextmap,src->mapsize);
|
||||||
// first, we're done with the old mapbuf
|
/* first, we're done with the old mapbuf */
|
||||||
gst_buffer_unref(src->mapbuf);
|
gst_buffer_unref(src->mapbuf);
|
||||||
// create a new one
|
/* create a new one */
|
||||||
src->mapbuf = gst_filesrc_map_region (src, nextmap, src->mapsize);
|
src->mapbuf = gst_filesrc_map_region (src, nextmap, src->mapsize);
|
||||||
// subbuffer it
|
/* subbuffer it */
|
||||||
buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - GST_BUFFER_OFFSET(src->mapbuf), readsize);
|
buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - GST_BUFFER_OFFSET(src->mapbuf), readsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -541,7 +541,7 @@ gst_filesrc_open_file (GstFileSrc *src)
|
||||||
src->filelen = lseek (src->fd, 0, SEEK_END);
|
src->filelen = lseek (src->fd, 0, SEEK_END);
|
||||||
lseek (src->fd, 0, SEEK_SET);
|
lseek (src->fd, 0, SEEK_SET);
|
||||||
|
|
||||||
// allocate the first mmap'd region
|
/* allocate the first mmap'd region */
|
||||||
src->mapbuf = gst_filesrc_map_region (src, 0, src->mapsize);
|
src->mapbuf = gst_filesrc_map_region (src, 0, src->mapsize);
|
||||||
|
|
||||||
src->curoffset = 0;
|
src->curoffset = 0;
|
||||||
|
@ -601,7 +601,7 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
|
||||||
src->curoffset = (guint64) GST_EVENT_SEEK_OFFSET (event);
|
src->curoffset = (guint64) GST_EVENT_SEEK_OFFSET (event);
|
||||||
src->seek_happened = TRUE;
|
src->seek_happened = TRUE;
|
||||||
gst_event_free (event);
|
gst_event_free (event);
|
||||||
// push a discontinuous event?
|
/* push a discontinuous event? */
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,15 +57,15 @@ struct _GstFileSrc {
|
||||||
GstElement element;
|
GstElement element;
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
|
|
||||||
guint pagesize; // system page size
|
guint pagesize; /* system page size*/
|
||||||
|
|
||||||
gchar *filename; // filename
|
gchar *filename; /* filename */
|
||||||
gint fd; // open file descriptor
|
gint fd; /* open file descriptor*/
|
||||||
off_t filelen; // what's the file length?
|
off_t filelen; /* what's the file length?*/
|
||||||
|
|
||||||
off_t curoffset; // current offset in file
|
off_t curoffset; /* current offset in file*/
|
||||||
off_t block_size; // bytes per read
|
off_t block_size; /* bytes per read */
|
||||||
gboolean touch; // whether to touch every page
|
gboolean touch; /* whether to touch every page */
|
||||||
|
|
||||||
GstBuffer *mapbuf;
|
GstBuffer *mapbuf;
|
||||||
size_t mapsize;
|
size_t mapsize;
|
||||||
|
|
|
@ -67,7 +67,7 @@ static void gst_httpsrc_close_url (GstHttpSrc *src);
|
||||||
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_httpsrc_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_httpsrc_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_httpsrc_get_type (void)
|
gst_httpsrc_get_type (void)
|
||||||
|
@ -145,9 +145,9 @@ gst_httpsrc_get(GstPad *pad)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//g_print ("%ld\n", readbytes);
|
/*g_print ("%ld\n", readbytes);*/
|
||||||
if (readbytes < src->bytes_per_read) {
|
if (readbytes < src->bytes_per_read) {
|
||||||
// FIXME: set the buffer's EOF bit here
|
/* FIXME: set the buffer's EOF bit here */
|
||||||
}
|
}
|
||||||
GST_BUFFER_OFFSET(buf) = src->curoffset;
|
GST_BUFFER_OFFSET(buf) = src->curoffset;
|
||||||
GST_BUFFER_SIZE(buf) = readbytes;
|
GST_BUFFER_SIZE(buf) = readbytes;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
//#define GST_DEBUG_ENABLED
|
/*#define GST_DEBUG_ENABLED*/
|
||||||
|
|
||||||
#include "gstmultidisksrc.h"
|
#include "gstmultidisksrc.h"
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ static void gst_multidisksrc_set_property (GObject *object, guint prop_id, cons
|
||||||
static void gst_multidisksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
static void gst_multidisksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||||
|
|
||||||
static GstBuffer * gst_multidisksrc_get (GstPad *pad);
|
static GstBuffer * gst_multidisksrc_get (GstPad *pad);
|
||||||
//static GstBuffer * gst_multidisksrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);
|
/*static GstBuffer * gst_multidisksrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);*/
|
||||||
|
|
||||||
static GstElementStateReturn gst_multidisksrc_change_state (GstElement *element);
|
static GstElementStateReturn gst_multidisksrc_change_state (GstElement *element);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ gst_multidisksrc_class_init (GstMultiDiskSrcClass *klass)
|
||||||
|
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS,
|
||||||
g_param_spec_string("locations","locations","locations",
|
g_param_spec_string("locations","locations","locations",
|
||||||
NULL, G_PARAM_READWRITE)); // CHECKME
|
NULL, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
|
|
||||||
gobject_class->set_property = gst_multidisksrc_set_property;
|
gobject_class->set_property = gst_multidisksrc_set_property;
|
||||||
gobject_class->get_property = gst_multidisksrc_get_property;
|
gobject_class->get_property = gst_multidisksrc_get_property;
|
||||||
|
@ -119,11 +119,11 @@ gst_multidisksrc_class_init (GstMultiDiskSrcClass *klass)
|
||||||
static void
|
static void
|
||||||
gst_multidisksrc_init (GstMultiDiskSrc *multidisksrc)
|
gst_multidisksrc_init (GstMultiDiskSrc *multidisksrc)
|
||||||
{
|
{
|
||||||
// GST_FLAG_SET (disksrc, GST_SRC_);
|
/* GST_FLAG_SET (disksrc, GST_SRC_); */
|
||||||
|
|
||||||
multidisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
multidisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||||
gst_pad_set_get_function (multidisksrc->srcpad,gst_multidisksrc_get);
|
gst_pad_set_get_function (multidisksrc->srcpad,gst_multidisksrc_get);
|
||||||
// gst_pad_set_getregion_function (multidisksrc->srcpad,gst_multidisksrc_get_region);
|
/* gst_pad_set_getregion_function (multidisksrc->srcpad,gst_multidisksrc_get_region); */
|
||||||
gst_element_add_pad (GST_ELEMENT (multidisksrc), multidisksrc->srcpad);
|
gst_element_add_pad (GST_ELEMENT (multidisksrc), multidisksrc->srcpad);
|
||||||
|
|
||||||
multidisksrc->listptr = NULL;
|
multidisksrc->listptr = NULL;
|
||||||
|
@ -213,11 +213,11 @@ gst_multidisksrc_get (GstPad *pad)
|
||||||
if (!gst_multidisksrc_open_file(src, pad))
|
if (!gst_multidisksrc_open_file(src, pad))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// emitted after the open, as the user may free the list and string from here
|
/* emitted after the open, as the user may free the list and string from here*/
|
||||||
g_signal_emit(G_OBJECT(src), gst_multidisksrc_signals[NEW_FILE], 0, list);
|
g_signal_emit(G_OBJECT(src), gst_multidisksrc_signals[NEW_FILE], 0, list);
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
// FIXME: should eventually use a bufferpool for this
|
/* FIXME: should eventually use a bufferpool for this */
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
|
|
||||||
g_return_val_if_fail (buf != NULL, NULL);
|
g_return_val_if_fail (buf != NULL, NULL);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
//#define GST_DEBUG_ENABLED
|
/*#define GST_DEBUG_ENABLED*/
|
||||||
|
|
||||||
#include "gstmultidisksrc.h"
|
#include "gstmultidisksrc.h"
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ static void gst_multidisksrc_set_property (GObject *object, guint prop_id, cons
|
||||||
static void gst_multidisksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
static void gst_multidisksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||||
|
|
||||||
static GstBuffer * gst_multidisksrc_get (GstPad *pad);
|
static GstBuffer * gst_multidisksrc_get (GstPad *pad);
|
||||||
//static GstBuffer * gst_multidisksrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);
|
/*static GstBuffer * gst_multidisksrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);*/
|
||||||
|
|
||||||
static GstElementStateReturn gst_multidisksrc_change_state (GstElement *element);
|
static GstElementStateReturn gst_multidisksrc_change_state (GstElement *element);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ gst_multidisksrc_class_init (GstMultiDiskSrcClass *klass)
|
||||||
|
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS,
|
||||||
g_param_spec_string("locations","locations","locations",
|
g_param_spec_string("locations","locations","locations",
|
||||||
NULL, G_PARAM_READWRITE)); // CHECKME
|
NULL, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
|
|
||||||
gobject_class->set_property = gst_multidisksrc_set_property;
|
gobject_class->set_property = gst_multidisksrc_set_property;
|
||||||
gobject_class->get_property = gst_multidisksrc_get_property;
|
gobject_class->get_property = gst_multidisksrc_get_property;
|
||||||
|
@ -119,11 +119,11 @@ gst_multidisksrc_class_init (GstMultiDiskSrcClass *klass)
|
||||||
static void
|
static void
|
||||||
gst_multidisksrc_init (GstMultiDiskSrc *multidisksrc)
|
gst_multidisksrc_init (GstMultiDiskSrc *multidisksrc)
|
||||||
{
|
{
|
||||||
// GST_FLAG_SET (disksrc, GST_SRC_);
|
/* GST_FLAG_SET (disksrc, GST_SRC_); */
|
||||||
|
|
||||||
multidisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
multidisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||||
gst_pad_set_get_function (multidisksrc->srcpad,gst_multidisksrc_get);
|
gst_pad_set_get_function (multidisksrc->srcpad,gst_multidisksrc_get);
|
||||||
// gst_pad_set_getregion_function (multidisksrc->srcpad,gst_multidisksrc_get_region);
|
/* gst_pad_set_getregion_function (multidisksrc->srcpad,gst_multidisksrc_get_region); */
|
||||||
gst_element_add_pad (GST_ELEMENT (multidisksrc), multidisksrc->srcpad);
|
gst_element_add_pad (GST_ELEMENT (multidisksrc), multidisksrc->srcpad);
|
||||||
|
|
||||||
multidisksrc->listptr = NULL;
|
multidisksrc->listptr = NULL;
|
||||||
|
@ -213,11 +213,11 @@ gst_multidisksrc_get (GstPad *pad)
|
||||||
if (!gst_multidisksrc_open_file(src, pad))
|
if (!gst_multidisksrc_open_file(src, pad))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// emitted after the open, as the user may free the list and string from here
|
/* emitted after the open, as the user may free the list and string from here*/
|
||||||
g_signal_emit(G_OBJECT(src), gst_multidisksrc_signals[NEW_FILE], 0, list);
|
g_signal_emit(G_OBJECT(src), gst_multidisksrc_signals[NEW_FILE], 0, list);
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
// FIXME: should eventually use a bufferpool for this
|
/* FIXME: should eventually use a bufferpool for this */
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
|
|
||||||
g_return_val_if_fail (buf != NULL, NULL);
|
g_return_val_if_fail (buf != NULL, NULL);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
//#define DEBUG_ENABLED
|
/*#define DEBUG_ENABLED*/
|
||||||
#include "gstpipefilter.h"
|
#include "gstpipefilter.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ static gboolean gst_pipefilter_handle_event (GstPad *pad, GstEvent *event);
|
||||||
static GstElementStateReturn gst_pipefilter_change_state (GstElement *element);
|
static GstElementStateReturn gst_pipefilter_change_state (GstElement *element);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_pipefilter_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_pipefilter_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_pipefilter_get_type (void)
|
gst_pipefilter_get_type (void)
|
||||||
|
@ -107,7 +107,7 @@ gst_pipefilter_class_init (GstPipefilterClass *klass)
|
||||||
|
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_COMMAND,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_COMMAND,
|
||||||
g_param_spec_string("command","command","command",
|
g_param_spec_string("command","command","command",
|
||||||
NULL, G_PARAM_READWRITE)); // CHECKME
|
NULL, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
|
|
||||||
gobject_class->set_property = gst_pipefilter_set_property;
|
gobject_class->set_property = gst_pipefilter_set_property;
|
||||||
gobject_class->get_property = gst_pipefilter_get_property;
|
gobject_class->get_property = gst_pipefilter_get_property;
|
||||||
|
@ -161,7 +161,7 @@ gst_pipefilter_get (GstPad *pad)
|
||||||
pipefilter = GST_PIPEFILTER (gst_pad_get_parent (pad));
|
pipefilter = GST_PIPEFILTER (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
// FIXME: should eventually use a bufferpool for this
|
/* FIXME: should eventually use a bufferpool for this */
|
||||||
newbuf = gst_buffer_new();
|
newbuf = gst_buffer_new();
|
||||||
g_return_val_if_fail(newbuf, NULL);
|
g_return_val_if_fail(newbuf, NULL);
|
||||||
|
|
||||||
|
@ -277,11 +277,11 @@ gst_pipefilter_open_file (GstPipefilter *src)
|
||||||
{
|
{
|
||||||
close(src->fdin[1]);
|
close(src->fdin[1]);
|
||||||
close(src->fdout[0]);
|
close(src->fdout[0]);
|
||||||
// child
|
/* child */
|
||||||
dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */
|
dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */
|
||||||
dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
|
dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
|
||||||
execvp(src->command[0], &src->command[0]);
|
execvp(src->command[0], &src->command[0]);
|
||||||
// will only reach if error
|
/* will only reach if error */
|
||||||
perror("exec");
|
perror("exec");
|
||||||
gst_element_error(GST_ELEMENT(src),"starting child process");
|
gst_element_error(GST_ELEMENT(src),"starting child process");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -66,7 +66,7 @@ static void gst_tee_get_property (GObject *object, guint prop_id,
|
||||||
static void gst_tee_chain (GstPad *pad, GstBuffer *buf);
|
static void gst_tee_chain (GstPad *pad, GstBuffer *buf);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_tee_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_tee_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_tee_get_type(void) {
|
gst_tee_get_type(void) {
|
||||||
|
@ -213,7 +213,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf)
|
||||||
g_return_if_fail (buf != NULL);
|
g_return_if_fail (buf != NULL);
|
||||||
|
|
||||||
tee = GST_TEE (gst_pad_get_parent (pad));
|
tee = GST_TEE (gst_pad_get_parent (pad));
|
||||||
// gst_trace_add_entry (NULL, 0, buf, "tee buffer");
|
/* gst_trace_add_entry (NULL, 0, buf, "tee buffer");*/
|
||||||
|
|
||||||
for (i=0; i<tee->numsrcpads-1; i++)
|
for (i=0; i<tee->numsrcpads-1; i++)
|
||||||
gst_buffer_ref (buf);
|
gst_buffer_ref (buf);
|
||||||
|
|
|
@ -88,7 +88,7 @@ static void gst_aggregator_chain (GstPad *pad, GstBuffer *buf);
|
||||||
static void gst_aggregator_loop (GstElement *element);
|
static void gst_aggregator_loop (GstElement *element);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_aggregator_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_aggregator_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_aggregator_get_type (void)
|
gst_aggregator_get_type (void)
|
||||||
|
@ -331,7 +331,7 @@ gst_aggregator_chain (GstPad *pad, GstBuffer *buf)
|
||||||
g_return_if_fail (buf != NULL);
|
g_return_if_fail (buf != NULL);
|
||||||
|
|
||||||
aggregator = GST_AGGREGATOR (gst_pad_get_parent (pad));
|
aggregator = GST_AGGREGATOR (gst_pad_get_parent (pad));
|
||||||
// gst_trace_add_entry (NULL, 0, buf, "aggregator buffer");
|
/* gst_trace_add_entry (NULL, 0, buf, "aggregator buffer");*/
|
||||||
|
|
||||||
gst_aggregator_push (aggregator, pad, buf, "chain");
|
gst_aggregator_push (aggregator, pad, buf, "chain");
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,12 +96,12 @@ plugin_init (GModule *module, GstPlugin *plugin)
|
||||||
if (_elements[i].factoryinit) {
|
if (_elements[i].factoryinit) {
|
||||||
_elements[i].factoryinit (factory);
|
_elements[i].factoryinit (factory);
|
||||||
}
|
}
|
||||||
// g_print("added factory '%s'\n",_elements[i].name);
|
/* g_print("added factory '%s'\n",_elements[i].name); */
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INFO (GST_INFO_PLUGIN_LOAD,"gstelements: loaded %d standard elements", i);
|
/* INFO (GST_INFO_PLUGIN_LOAD,"gstelements: loaded %d standard elements", i);*/
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,10 +200,10 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
|
||||||
1, G_MAXINT, 1, G_PARAM_READABLE));
|
1, G_MAXINT, 1, G_PARAM_READABLE));
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOOP_BASED,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOOP_BASED,
|
||||||
g_param_spec_boolean("loop_based","loop_based","loop_based",
|
g_param_spec_boolean("loop_based","loop_based","loop_based",
|
||||||
FALSE, G_PARAM_READWRITE)); // CHECKME
|
FALSE, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OUTPUT,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OUTPUT,
|
||||||
g_param_spec_enum("output","output","output",
|
g_param_spec_enum("output","output","output",
|
||||||
GST_TYPE_FAKESRC_OUTPUT,FAKESRC_FIRST_LAST_LOOP,G_PARAM_READWRITE)); // CHECKME!
|
GST_TYPE_FAKESRC_OUTPUT,FAKESRC_FIRST_LAST_LOOP,G_PARAM_READWRITE)); /* CHECKME! */
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA,
|
||||||
g_param_spec_enum ("data", "data", "data",
|
g_param_spec_enum ("data", "data", "data",
|
||||||
GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE));
|
GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE));
|
||||||
|
@ -224,13 +224,13 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
|
||||||
GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
|
GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PATTERN,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PATTERN,
|
||||||
g_param_spec_string("pattern","pattern","pattern",
|
g_param_spec_string("pattern","pattern","pattern",
|
||||||
NULL, G_PARAM_READWRITE)); // CHECKME
|
NULL, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUM_BUFFERS,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUM_BUFFERS,
|
||||||
g_param_spec_int("num_buffers","num_buffers","num_buffers",
|
g_param_spec_int("num_buffers","num_buffers","num_buffers",
|
||||||
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME
|
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_EOS,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_EOS,
|
||||||
g_param_spec_boolean("eos","eos","eos",
|
g_param_spec_boolean("eos","eos","eos",
|
||||||
TRUE,G_PARAM_READWRITE)); // CHECKME
|
TRUE,G_PARAM_READWRITE)); /* CHECKME */
|
||||||
|
|
||||||
gst_element_install_std_props (
|
gst_element_install_std_props (
|
||||||
GST_ELEMENT_CLASS (klass),
|
GST_ELEMENT_CLASS (klass),
|
||||||
|
@ -256,7 +256,7 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
|
||||||
{
|
{
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
|
|
||||||
// create our first output pad
|
/* create our first output pad */
|
||||||
pad = gst_pad_new ("src", GST_PAD_SRC);
|
pad = gst_pad_new ("src", GST_PAD_SRC);
|
||||||
gst_element_add_pad (GST_ELEMENT (fakesrc), pad);
|
gst_element_add_pad (GST_ELEMENT (fakesrc), pad);
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ gst_fakesrc_event_handler (GstPad *pad, GstEvent *event)
|
||||||
gst_event_free (event);
|
gst_event_free (event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// else we do a flush too
|
/* else we do a flush too */
|
||||||
case GST_EVENT_FLUSH:
|
case GST_EVENT_FLUSH:
|
||||||
g_print("fakesrc: have flush event\n");
|
g_print("fakesrc: have flush event\n");
|
||||||
src->need_flush = TRUE;
|
src->need_flush = TRUE;
|
||||||
|
@ -601,21 +601,21 @@ gst_fakesrc_create_buffer (GstFakeSrc *src)
|
||||||
buf = gst_fakesrc_alloc_buffer (src, size);
|
buf = gst_fakesrc_alloc_buffer (src, size);
|
||||||
break;
|
break;
|
||||||
case FAKESRC_DATA_SUBBUFFER:
|
case FAKESRC_DATA_SUBBUFFER:
|
||||||
// see if we have a parent to subbuffer
|
/* see if we have a parent to subbuffer */
|
||||||
if (!src->parent) {
|
if (!src->parent) {
|
||||||
gst_fakesrc_alloc_parent (src);
|
gst_fakesrc_alloc_parent (src);
|
||||||
g_assert (src->parent);
|
g_assert (src->parent);
|
||||||
}
|
}
|
||||||
// see if it's large enough
|
/* see if it's large enough */
|
||||||
if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) {
|
if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) {
|
||||||
buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
|
buf = gst_buffer_create_sub (src->parent, src->parentoffset, size);
|
||||||
src->parentoffset += size;
|
src->parentoffset += size;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// the parent is useless now
|
/* the parent is useless now */
|
||||||
gst_buffer_unref (src->parent);
|
gst_buffer_unref (src->parent);
|
||||||
src->parent = NULL;
|
src->parent = NULL;
|
||||||
// try again (this will allocate a new parent)
|
/* try again (this will allocate a new parent) */
|
||||||
return gst_fakesrc_create_buffer (src);
|
return gst_fakesrc_create_buffer (src);
|
||||||
}
|
}
|
||||||
gst_fakesrc_prepare_buffer (src, buf);
|
gst_fakesrc_prepare_buffer (src, buf);
|
||||||
|
|
|
@ -57,7 +57,7 @@ static void gst_fdsink_get_property (GObject *object, guint prop_id,
|
||||||
static void gst_fdsink_chain (GstPad *pad,GstBuffer *buf);
|
static void gst_fdsink_chain (GstPad *pad,GstBuffer *buf);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_fdsink_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_fdsink_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_fdsink_get_type (void)
|
gst_fdsink_get_type (void)
|
||||||
|
|
|
@ -66,7 +66,7 @@ static GstBuffer * gst_fdsrc_get (GstPad *pad);
|
||||||
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_fdsrc_get_type (void)
|
gst_fdsrc_get_type (void)
|
||||||
|
@ -189,7 +189,7 @@ gst_fdsrc_get(GstPad *pad)
|
||||||
src = GST_FDSRC(gst_pad_get_parent (pad));
|
src = GST_FDSRC(gst_pad_get_parent (pad));
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
// FIXME: should eventually use a bufferpool for this
|
/* FIXME: should eventually use a bufferpool for this*/
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
g_return_val_if_fail (buf, NULL);
|
g_return_val_if_fail (buf, NULL);
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ gst_fdsrc_get(GstPad *pad)
|
||||||
|
|
||||||
/* if we didn't get as many bytes as we asked for, we're at EOF */
|
/* if we didn't get as many bytes as we asked for, we're at EOF */
|
||||||
if (readbytes < src->bytes_per_read) {
|
if (readbytes < src->bytes_per_read) {
|
||||||
// set the buffer's EOF bit here
|
/* set the buffer's EOF bit here */
|
||||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
|
||||||
}
|
}
|
||||||
GST_BUFFER_OFFSET(buf) = src->curoffset;
|
GST_BUFFER_OFFSET(buf) = src->curoffset;
|
||||||
|
|
|
@ -77,7 +77,7 @@ GstElementDetails gst_filesrc_details = {
|
||||||
"(C) 1999",
|
"(C) 1999",
|
||||||
};
|
};
|
||||||
|
|
||||||
//#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...)
|
||||||
|
|
||||||
/* FileSrc signals and args */
|
/* FileSrc signals and args */
|
||||||
|
@ -113,7 +113,7 @@ static GstElementStateReturn gst_filesrc_change_state (GstElement *element);
|
||||||
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_filesrc_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_filesrc_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_filesrc_get_type(void)
|
gst_filesrc_get_type(void)
|
||||||
|
@ -167,9 +167,9 @@ gst_filesrc_class_init (GstFileSrcClass *klass)
|
||||||
static gint
|
static gint
|
||||||
gst_filesrc_bufcmp (gconstpointer a, gconstpointer b)
|
gst_filesrc_bufcmp (gconstpointer a, gconstpointer b)
|
||||||
{
|
{
|
||||||
// GstBuffer *bufa = (GstBuffer *)a, *bufb = (GstBuffer *)b;
|
/* GstBuffer *bufa = (GstBuffer *)a, *bufb = (GstBuffer *)b;*/
|
||||||
|
|
||||||
// sort first by offset, then in reverse by size
|
/* sort first by offset, then in reverse by size */
|
||||||
if (GST_BUFFER_OFFSET(a) < GST_BUFFER_OFFSET(b)) return -1;
|
if (GST_BUFFER_OFFSET(a) < GST_BUFFER_OFFSET(b)) return -1;
|
||||||
else if (GST_BUFFER_OFFSET(a) > GST_BUFFER_OFFSET(b)) return 1;
|
else if (GST_BUFFER_OFFSET(a) > GST_BUFFER_OFFSET(b)) return 1;
|
||||||
else if (GST_BUFFER_SIZE(a) > GST_BUFFER_SIZE(b)) return -1;
|
else if (GST_BUFFER_SIZE(a) > GST_BUFFER_SIZE(b)) return -1;
|
||||||
|
@ -196,7 +196,7 @@ gst_filesrc_init (GstFileSrc *src)
|
||||||
src->touch = TRUE;
|
src->touch = TRUE;
|
||||||
|
|
||||||
src->mapbuf = NULL;
|
src->mapbuf = NULL;
|
||||||
src->mapsize = 4 * 1024 * 1024; // default is 4MB
|
src->mapsize = 4 * 1024 * 1024; /* 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();
|
||||||
|
@ -295,20 +295,20 @@ gst_filesrc_free_parent_mmap (GstBuffer *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);
|
||||||
g_tree_remove(src->map_regions,buf);
|
g_tree_remove(src->map_regions,buf);
|
||||||
// check to see if the tree is empty
|
/* 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
|
/* 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
|
#ifdef MADV_DONTNEED
|
||||||
// madvise to tell the kernel what to do with it
|
/* 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
|
#endif
|
||||||
// now unmap the memory
|
/* now unmap the memory */
|
||||||
munmap(GST_BUFFER_DATA(buf),GST_BUFFER_MAXSIZE(buf));
|
munmap(GST_BUFFER_DATA(buf),GST_BUFFER_MAXSIZE(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,9 +322,9 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
|
||||||
|
|
||||||
fs_print ("mapping region %08lx+%08lx from file into memory\n",offset,size);
|
fs_print ("mapping region %08lx+%08lx from file into memory\n",offset,size);
|
||||||
|
|
||||||
// time to allocate a new mapbuf
|
/* time to allocate a new mapbuf */
|
||||||
buf = gst_buffer_new();
|
buf = gst_buffer_new();
|
||||||
// mmap() the data into this new buffer
|
/* mmap() the data into this new buffer */
|
||||||
GST_BUFFER_DATA(buf) = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);
|
GST_BUFFER_DATA(buf) = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);
|
||||||
if (GST_BUFFER_DATA(buf) == NULL) {
|
if (GST_BUFFER_DATA(buf) == NULL) {
|
||||||
fprintf (stderr, "ERROR: gstfilesrc couldn't map file!\n");
|
fprintf (stderr, "ERROR: gstfilesrc couldn't map file!\n");
|
||||||
|
@ -333,10 +333,10 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
|
||||||
size, src->fd, offset, sys_errlist[errno]);
|
size, src->fd, offset, sys_errlist[errno]);
|
||||||
}
|
}
|
||||||
#ifdef MADV_SEQUENTIAL
|
#ifdef MADV_SEQUENTIAL
|
||||||
// madvise to tell the kernel what to do with it
|
/* 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
|
#endif
|
||||||
// fill in the rest of the fields
|
/* fill in the rest of the fields */
|
||||||
GST_BUFFER_FLAGS(buf) = GST_BUFFER_READONLY | GST_BUFFER_ORIGINAL;
|
GST_BUFFER_FLAGS(buf) = GST_BUFFER_READONLY | GST_BUFFER_ORIGINAL;
|
||||||
GST_BUFFER_SIZE(buf) = size;
|
GST_BUFFER_SIZE(buf) = size;
|
||||||
GST_BUFFER_MAXSIZE(buf) = size;
|
GST_BUFFER_MAXSIZE(buf) = size;
|
||||||
|
@ -359,15 +359,15 @@ gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size)
|
||||||
off_t mod, mapbase;
|
off_t mod, mapbase;
|
||||||
GstBuffer *map;
|
GstBuffer *map;
|
||||||
|
|
||||||
// printf("attempting to map a small buffer at %d+%d\n",offset,size);
|
/* printf("attempting to map a small buffer at %d+%d\n",offset,size); */
|
||||||
|
|
||||||
// if the offset starts at a non-page boundary, we have to special case
|
/* if the offset starts at a non-page boundary, we have to special case */
|
||||||
if ((mod = offset % src->pagesize)) {
|
if ((mod = offset % src->pagesize)) {
|
||||||
GstBuffer *ret;
|
GstBuffer *ret;
|
||||||
|
|
||||||
mapbase = offset - mod;
|
mapbase = offset - mod;
|
||||||
mapsize = ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize;
|
mapsize = ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize;
|
||||||
// printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);
|
/* printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);*/
|
||||||
map = gst_filesrc_map_region(src, mapbase, mapsize);
|
map = gst_filesrc_map_region(src, mapbase, mapsize);
|
||||||
ret = gst_buffer_create_sub (map, offset - mapbase, size);
|
ret = gst_buffer_create_sub (map, offset - mapbase, size);
|
||||||
|
|
||||||
|
@ -384,13 +384,13 @@ typedef struct {
|
||||||
off_t size;
|
off_t size;
|
||||||
} GstFileSrcRegion;
|
} GstFileSrcRegion;
|
||||||
|
|
||||||
// This allows us to search for a potential mmap region.
|
/* This allows us to search for a potential mmap region. */
|
||||||
static gint
|
static gint
|
||||||
gst_filesrc_search_region_match (gpointer a, gpointer b)
|
gst_filesrc_search_region_match (gpointer a, gpointer b)
|
||||||
{
|
{
|
||||||
GstFileSrcRegion *r = (GstFileSrcRegion *)b;
|
GstFileSrcRegion *r = (GstFileSrcRegion *)b;
|
||||||
|
|
||||||
// trying to walk b down the tree, current node is a
|
/* trying to walk b down the tree, current node is a */
|
||||||
if (r->offset < GST_BUFFER_OFFSET(a)) return -1;
|
if (r->offset < GST_BUFFER_OFFSET(a)) return -1;
|
||||||
else if (r->offset >= (GST_BUFFER_OFFSET(a) + GST_BUFFER_SIZE(a))) return 1;
|
else if (r->offset >= (GST_BUFFER_OFFSET(a) + GST_BUFFER_SIZE(a))) return 1;
|
||||||
else if ((r->offset + r->size) <= (GST_BUFFER_OFFSET(a) + GST_BUFFER_SIZE(a))) return 0;
|
else if ((r->offset + r->size) <= (GST_BUFFER_OFFSET(a) + GST_BUFFER_SIZE(a))) return 0;
|
||||||
|
@ -418,63 +418,63 @@ gst_filesrc_get (GstPad *pad)
|
||||||
src = GST_FILESRC (gst_pad_get_parent (pad));
|
src = GST_FILESRC (gst_pad_get_parent (pad));
|
||||||
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), NULL);
|
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), NULL);
|
||||||
|
|
||||||
// check for seek
|
/* check for seek */
|
||||||
if (src->seek_happened) {
|
if (src->seek_happened) {
|
||||||
src->seek_happened = FALSE;
|
src->seek_happened = FALSE;
|
||||||
return GST_BUFFER (gst_event_new(GST_EVENT_DISCONTINUOUS));
|
return GST_BUFFER (gst_event_new(GST_EVENT_DISCONTINUOUS));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for EOF
|
/* check for EOF */
|
||||||
if (src->curoffset == src->filelen) {
|
if (src->curoffset == src->filelen) {
|
||||||
gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED);
|
gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED);
|
||||||
return GST_BUFFER (gst_event_new(GST_EVENT_EOS));
|
return GST_BUFFER (gst_event_new(GST_EVENT_EOS));
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate end pointers so we don't have to do so repeatedly later
|
/* calculate end pointers so we don't have to do so repeatedly later */
|
||||||
readsize = src->block_size;
|
readsize = src->block_size;
|
||||||
readend = src->curoffset + src->block_size; // note this is the byte *after* the read
|
readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */
|
||||||
mapstart = GST_BUFFER_OFFSET(src->mapbuf);
|
mapstart = GST_BUFFER_OFFSET(src->mapbuf);
|
||||||
mapend = mapstart + GST_BUFFER_SIZE(src->mapbuf); // note this is the byte *after* the map
|
mapend = mapstart + GST_BUFFER_SIZE(src->mapbuf); /* note this is the byte *after* the map */
|
||||||
|
|
||||||
// check to see if we're going to overflow the end of the file
|
/* check to see if we're going to overflow the end of the file */
|
||||||
if (readend > src->filelen) {
|
if (readend > src->filelen) {
|
||||||
readsize = src->filelen - src->curoffset;
|
readsize = src->filelen - src->curoffset;
|
||||||
readend = src->curoffset;
|
readend = src->curoffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the start is past the mapstart
|
/* if the start is past the mapstart */
|
||||||
if (src->curoffset >= mapstart) {
|
if (src->curoffset >= mapstart) {
|
||||||
// if the end is before the mapend, the buffer is in current mmap region...
|
/* if the end is before the mapend, the buffer is in current mmap region... */
|
||||||
// ('cause by definition if readend is in the buffer, so's readstart)
|
/* ('cause by definition if readend is in the buffer, so's readstart) */
|
||||||
if (readend <= mapend) {
|
if (readend <= mapend) {
|
||||||
fs_print ("read buf %d+%d lives in current mapbuf %d+%d, creating subbuffer of mapbuf\n",
|
fs_print ("read buf %d+%d lives in current mapbuf %d+%d, creating subbuffer of mapbuf\n",
|
||||||
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
||||||
buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - GST_BUFFER_OFFSET(src->mapbuf),
|
buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - GST_BUFFER_OFFSET(src->mapbuf),
|
||||||
readsize);
|
readsize);
|
||||||
|
|
||||||
// if the start actually is within the current mmap region, map an overlap buffer
|
/* if the start actually is within the current mmap region, map an overlap buffer */
|
||||||
} else if (src->curoffset < mapend) {
|
} else if (src->curoffset < mapend) {
|
||||||
fs_print ("read buf %d+%d starts in mapbuf %d+%d but ends outside, creating new mmap\n",
|
fs_print ("read buf %d+%d starts in mapbuf %d+%d but ends outside, creating new mmap\n",
|
||||||
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
||||||
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the only other option is that buffer is totally outside, which means we search for it
|
/* the only other option is that buffer is totally outside, which means we search for it */
|
||||||
|
|
||||||
// now we can assume that the start is *before* the current mmap region
|
/* now we can assume that the start is *before* the current mmap region */
|
||||||
// if the readend is past mapstart, we have two options
|
/* if the readend is past mapstart, we have two options */
|
||||||
} else if (readend >= mapstart) {
|
} else if (readend >= mapstart) {
|
||||||
// either the read buffer overlaps the start of the mmap region
|
/* either the read buffer overlaps the start of the mmap region */
|
||||||
// or the read buffer fully contains the current mmap region
|
/* or the read buffer fully contains the current mmap region */
|
||||||
// either way, it's really not relevant, we just create a new region anyway
|
/* either way, it's really not relevant, we just create a new region anyway*/
|
||||||
fs_print ("read buf %d+%d starts before mapbuf %d+%d, but overlaps it\n",
|
fs_print ("read buf %d+%d starts before mapbuf %d+%d, but overlaps it\n",
|
||||||
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
src->curoffset,readsize,GST_BUFFER_OFFSET(src->mapbuf),GST_BUFFER_SIZE(src->mapbuf));
|
||||||
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// then deal with the case where the read buffer is totally outside
|
/* then deal with the case where the read buffer is totally outside */
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
// first check to see if there's a map that covers the right region already
|
/* first check to see if there's a map that covers the right region already */
|
||||||
fs_print ("searching for mapbuf to cover %d+%d\n",src->curoffset,readsize);
|
fs_print ("searching for mapbuf to cover %d+%d\n",src->curoffset,readsize);
|
||||||
region.offset = src->curoffset;
|
region.offset = src->curoffset;
|
||||||
region.size = readsize;
|
region.size = readsize;
|
||||||
|
@ -482,29 +482,29 @@ gst_filesrc_get (GstPad *pad)
|
||||||
(GCompareFunc) gst_filesrc_search_region_match,
|
(GCompareFunc) gst_filesrc_search_region_match,
|
||||||
®ion);
|
®ion);
|
||||||
|
|
||||||
// if we found an exact match, subbuffer it
|
/* if we found an exact match, subbuffer it */
|
||||||
if (map != NULL) {
|
if (map != NULL) {
|
||||||
fs_print ("found mapbuf at %d+%d, creating subbuffer\n",GST_BUFFER_OFFSET(map),GST_BUFFER_SIZE(map));
|
fs_print ("found mapbuf at %d+%d, creating subbuffer\n",GST_BUFFER_OFFSET(map),GST_BUFFER_SIZE(map));
|
||||||
buf = gst_buffer_create_sub (map, src->curoffset - GST_BUFFER_OFFSET(map), readsize);
|
buf = gst_buffer_create_sub (map, src->curoffset - GST_BUFFER_OFFSET(map), readsize);
|
||||||
|
|
||||||
// otherwise we need to create something out of thin air
|
/* otherwise we need to create something out of thin air */
|
||||||
} else {
|
} else {
|
||||||
// if the read buffer crosses a mmap region boundary, create a one-off region
|
/* if the read buffer crosses a mmap region boundary, create a one-off region */
|
||||||
if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) {
|
if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) {
|
||||||
fs_print ("read buf %d+%d crosses a %d-byte boundary, creating a one-off\n",
|
fs_print ("read buf %d+%d crosses a %d-byte boundary, creating a one-off\n",
|
||||||
src->curoffset,readsize,src->mapsize);
|
src->curoffset,readsize,src->mapsize);
|
||||||
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
buf = gst_filesrc_map_small_region (src, src->curoffset, readsize);
|
||||||
|
|
||||||
// otherwise we will create a new mmap region and set it to the default
|
/* otherwise we will create a new mmap region and set it to the default */
|
||||||
} else {
|
} else {
|
||||||
off_t nextmap = src->curoffset - (src->curoffset % src->mapsize);
|
off_t nextmap = src->curoffset - (src->curoffset % src->mapsize);
|
||||||
fs_print ("read buf %d+%d in new mapbuf at %d+%d, mapping and subbuffering\n",
|
fs_print ("read buf %d+%d in new mapbuf at %d+%d, mapping and subbuffering\n",
|
||||||
src->curoffset,readsize,nextmap,src->mapsize);
|
src->curoffset,readsize,nextmap,src->mapsize);
|
||||||
// first, we're done with the old mapbuf
|
/* first, we're done with the old mapbuf */
|
||||||
gst_buffer_unref(src->mapbuf);
|
gst_buffer_unref(src->mapbuf);
|
||||||
// create a new one
|
/* create a new one */
|
||||||
src->mapbuf = gst_filesrc_map_region (src, nextmap, src->mapsize);
|
src->mapbuf = gst_filesrc_map_region (src, nextmap, src->mapsize);
|
||||||
// subbuffer it
|
/* subbuffer it */
|
||||||
buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - GST_BUFFER_OFFSET(src->mapbuf), readsize);
|
buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - GST_BUFFER_OFFSET(src->mapbuf), readsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -541,7 +541,7 @@ gst_filesrc_open_file (GstFileSrc *src)
|
||||||
src->filelen = lseek (src->fd, 0, SEEK_END);
|
src->filelen = lseek (src->fd, 0, SEEK_END);
|
||||||
lseek (src->fd, 0, SEEK_SET);
|
lseek (src->fd, 0, SEEK_SET);
|
||||||
|
|
||||||
// allocate the first mmap'd region
|
/* allocate the first mmap'd region */
|
||||||
src->mapbuf = gst_filesrc_map_region (src, 0, src->mapsize);
|
src->mapbuf = gst_filesrc_map_region (src, 0, src->mapsize);
|
||||||
|
|
||||||
src->curoffset = 0;
|
src->curoffset = 0;
|
||||||
|
@ -601,7 +601,7 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event)
|
||||||
src->curoffset = (guint64) GST_EVENT_SEEK_OFFSET (event);
|
src->curoffset = (guint64) GST_EVENT_SEEK_OFFSET (event);
|
||||||
src->seek_happened = TRUE;
|
src->seek_happened = TRUE;
|
||||||
gst_event_free (event);
|
gst_event_free (event);
|
||||||
// push a discontinuous event?
|
/* push a discontinuous event? */
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,15 +57,15 @@ struct _GstFileSrc {
|
||||||
GstElement element;
|
GstElement element;
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
|
|
||||||
guint pagesize; // system page size
|
guint pagesize; /* system page size*/
|
||||||
|
|
||||||
gchar *filename; // filename
|
gchar *filename; /* filename */
|
||||||
gint fd; // open file descriptor
|
gint fd; /* open file descriptor*/
|
||||||
off_t filelen; // what's the file length?
|
off_t filelen; /* what's the file length?*/
|
||||||
|
|
||||||
off_t curoffset; // current offset in file
|
off_t curoffset; /* current offset in file*/
|
||||||
off_t block_size; // bytes per read
|
off_t block_size; /* bytes per read */
|
||||||
gboolean touch; // whether to touch every page
|
gboolean touch; /* whether to touch every page */
|
||||||
|
|
||||||
GstBuffer *mapbuf;
|
GstBuffer *mapbuf;
|
||||||
size_t mapsize;
|
size_t mapsize;
|
||||||
|
|
|
@ -67,7 +67,7 @@ static void gst_httpsrc_close_url (GstHttpSrc *src);
|
||||||
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_httpsrc_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_httpsrc_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_httpsrc_get_type (void)
|
gst_httpsrc_get_type (void)
|
||||||
|
@ -145,9 +145,9 @@ gst_httpsrc_get(GstPad *pad)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//g_print ("%ld\n", readbytes);
|
/*g_print ("%ld\n", readbytes);*/
|
||||||
if (readbytes < src->bytes_per_read) {
|
if (readbytes < src->bytes_per_read) {
|
||||||
// FIXME: set the buffer's EOF bit here
|
/* FIXME: set the buffer's EOF bit here */
|
||||||
}
|
}
|
||||||
GST_BUFFER_OFFSET(buf) = src->curoffset;
|
GST_BUFFER_OFFSET(buf) = src->curoffset;
|
||||||
GST_BUFFER_SIZE(buf) = readbytes;
|
GST_BUFFER_SIZE(buf) = readbytes;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
//#define GST_DEBUG_ENABLED
|
/*#define GST_DEBUG_ENABLED*/
|
||||||
|
|
||||||
#include "gstmultidisksrc.h"
|
#include "gstmultidisksrc.h"
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ static void gst_multidisksrc_set_property (GObject *object, guint prop_id, cons
|
||||||
static void gst_multidisksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
static void gst_multidisksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||||
|
|
||||||
static GstBuffer * gst_multidisksrc_get (GstPad *pad);
|
static GstBuffer * gst_multidisksrc_get (GstPad *pad);
|
||||||
//static GstBuffer * gst_multidisksrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);
|
/*static GstBuffer * gst_multidisksrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);*/
|
||||||
|
|
||||||
static GstElementStateReturn gst_multidisksrc_change_state (GstElement *element);
|
static GstElementStateReturn gst_multidisksrc_change_state (GstElement *element);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ gst_multidisksrc_class_init (GstMultiDiskSrcClass *klass)
|
||||||
|
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS,
|
||||||
g_param_spec_string("locations","locations","locations",
|
g_param_spec_string("locations","locations","locations",
|
||||||
NULL, G_PARAM_READWRITE)); // CHECKME
|
NULL, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
|
|
||||||
gobject_class->set_property = gst_multidisksrc_set_property;
|
gobject_class->set_property = gst_multidisksrc_set_property;
|
||||||
gobject_class->get_property = gst_multidisksrc_get_property;
|
gobject_class->get_property = gst_multidisksrc_get_property;
|
||||||
|
@ -119,11 +119,11 @@ gst_multidisksrc_class_init (GstMultiDiskSrcClass *klass)
|
||||||
static void
|
static void
|
||||||
gst_multidisksrc_init (GstMultiDiskSrc *multidisksrc)
|
gst_multidisksrc_init (GstMultiDiskSrc *multidisksrc)
|
||||||
{
|
{
|
||||||
// GST_FLAG_SET (disksrc, GST_SRC_);
|
/* GST_FLAG_SET (disksrc, GST_SRC_); */
|
||||||
|
|
||||||
multidisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
multidisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||||
gst_pad_set_get_function (multidisksrc->srcpad,gst_multidisksrc_get);
|
gst_pad_set_get_function (multidisksrc->srcpad,gst_multidisksrc_get);
|
||||||
// gst_pad_set_getregion_function (multidisksrc->srcpad,gst_multidisksrc_get_region);
|
/* gst_pad_set_getregion_function (multidisksrc->srcpad,gst_multidisksrc_get_region); */
|
||||||
gst_element_add_pad (GST_ELEMENT (multidisksrc), multidisksrc->srcpad);
|
gst_element_add_pad (GST_ELEMENT (multidisksrc), multidisksrc->srcpad);
|
||||||
|
|
||||||
multidisksrc->listptr = NULL;
|
multidisksrc->listptr = NULL;
|
||||||
|
@ -213,11 +213,11 @@ gst_multidisksrc_get (GstPad *pad)
|
||||||
if (!gst_multidisksrc_open_file(src, pad))
|
if (!gst_multidisksrc_open_file(src, pad))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// emitted after the open, as the user may free the list and string from here
|
/* emitted after the open, as the user may free the list and string from here*/
|
||||||
g_signal_emit(G_OBJECT(src), gst_multidisksrc_signals[NEW_FILE], 0, list);
|
g_signal_emit(G_OBJECT(src), gst_multidisksrc_signals[NEW_FILE], 0, list);
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
// FIXME: should eventually use a bufferpool for this
|
/* FIXME: should eventually use a bufferpool for this */
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
|
|
||||||
g_return_val_if_fail (buf != NULL, NULL);
|
g_return_val_if_fail (buf != NULL, NULL);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
//#define GST_DEBUG_ENABLED
|
/*#define GST_DEBUG_ENABLED*/
|
||||||
|
|
||||||
#include "gstmultidisksrc.h"
|
#include "gstmultidisksrc.h"
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ static void gst_multidisksrc_set_property (GObject *object, guint prop_id, cons
|
||||||
static void gst_multidisksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
static void gst_multidisksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||||
|
|
||||||
static GstBuffer * gst_multidisksrc_get (GstPad *pad);
|
static GstBuffer * gst_multidisksrc_get (GstPad *pad);
|
||||||
//static GstBuffer * gst_multidisksrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);
|
/*static GstBuffer * gst_multidisksrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);*/
|
||||||
|
|
||||||
static GstElementStateReturn gst_multidisksrc_change_state (GstElement *element);
|
static GstElementStateReturn gst_multidisksrc_change_state (GstElement *element);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ gst_multidisksrc_class_init (GstMultiDiskSrcClass *klass)
|
||||||
|
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS,
|
||||||
g_param_spec_string("locations","locations","locations",
|
g_param_spec_string("locations","locations","locations",
|
||||||
NULL, G_PARAM_READWRITE)); // CHECKME
|
NULL, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
|
|
||||||
gobject_class->set_property = gst_multidisksrc_set_property;
|
gobject_class->set_property = gst_multidisksrc_set_property;
|
||||||
gobject_class->get_property = gst_multidisksrc_get_property;
|
gobject_class->get_property = gst_multidisksrc_get_property;
|
||||||
|
@ -119,11 +119,11 @@ gst_multidisksrc_class_init (GstMultiDiskSrcClass *klass)
|
||||||
static void
|
static void
|
||||||
gst_multidisksrc_init (GstMultiDiskSrc *multidisksrc)
|
gst_multidisksrc_init (GstMultiDiskSrc *multidisksrc)
|
||||||
{
|
{
|
||||||
// GST_FLAG_SET (disksrc, GST_SRC_);
|
/* GST_FLAG_SET (disksrc, GST_SRC_); */
|
||||||
|
|
||||||
multidisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
multidisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||||
gst_pad_set_get_function (multidisksrc->srcpad,gst_multidisksrc_get);
|
gst_pad_set_get_function (multidisksrc->srcpad,gst_multidisksrc_get);
|
||||||
// gst_pad_set_getregion_function (multidisksrc->srcpad,gst_multidisksrc_get_region);
|
/* gst_pad_set_getregion_function (multidisksrc->srcpad,gst_multidisksrc_get_region); */
|
||||||
gst_element_add_pad (GST_ELEMENT (multidisksrc), multidisksrc->srcpad);
|
gst_element_add_pad (GST_ELEMENT (multidisksrc), multidisksrc->srcpad);
|
||||||
|
|
||||||
multidisksrc->listptr = NULL;
|
multidisksrc->listptr = NULL;
|
||||||
|
@ -213,11 +213,11 @@ gst_multidisksrc_get (GstPad *pad)
|
||||||
if (!gst_multidisksrc_open_file(src, pad))
|
if (!gst_multidisksrc_open_file(src, pad))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// emitted after the open, as the user may free the list and string from here
|
/* emitted after the open, as the user may free the list and string from here*/
|
||||||
g_signal_emit(G_OBJECT(src), gst_multidisksrc_signals[NEW_FILE], 0, list);
|
g_signal_emit(G_OBJECT(src), gst_multidisksrc_signals[NEW_FILE], 0, list);
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
// FIXME: should eventually use a bufferpool for this
|
/* FIXME: should eventually use a bufferpool for this */
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
|
|
||||||
g_return_val_if_fail (buf != NULL, NULL);
|
g_return_val_if_fail (buf != NULL, NULL);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
//#define DEBUG_ENABLED
|
/*#define DEBUG_ENABLED*/
|
||||||
#include "gstpipefilter.h"
|
#include "gstpipefilter.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ static gboolean gst_pipefilter_handle_event (GstPad *pad, GstEvent *event);
|
||||||
static GstElementStateReturn gst_pipefilter_change_state (GstElement *element);
|
static GstElementStateReturn gst_pipefilter_change_state (GstElement *element);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_pipefilter_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_pipefilter_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_pipefilter_get_type (void)
|
gst_pipefilter_get_type (void)
|
||||||
|
@ -107,7 +107,7 @@ gst_pipefilter_class_init (GstPipefilterClass *klass)
|
||||||
|
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_COMMAND,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_COMMAND,
|
||||||
g_param_spec_string("command","command","command",
|
g_param_spec_string("command","command","command",
|
||||||
NULL, G_PARAM_READWRITE)); // CHECKME
|
NULL, G_PARAM_READWRITE)); /* CHECKME */
|
||||||
|
|
||||||
gobject_class->set_property = gst_pipefilter_set_property;
|
gobject_class->set_property = gst_pipefilter_set_property;
|
||||||
gobject_class->get_property = gst_pipefilter_get_property;
|
gobject_class->get_property = gst_pipefilter_get_property;
|
||||||
|
@ -161,7 +161,7 @@ gst_pipefilter_get (GstPad *pad)
|
||||||
pipefilter = GST_PIPEFILTER (gst_pad_get_parent (pad));
|
pipefilter = GST_PIPEFILTER (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
/* create the buffer */
|
/* create the buffer */
|
||||||
// FIXME: should eventually use a bufferpool for this
|
/* FIXME: should eventually use a bufferpool for this */
|
||||||
newbuf = gst_buffer_new();
|
newbuf = gst_buffer_new();
|
||||||
g_return_val_if_fail(newbuf, NULL);
|
g_return_val_if_fail(newbuf, NULL);
|
||||||
|
|
||||||
|
@ -277,11 +277,11 @@ gst_pipefilter_open_file (GstPipefilter *src)
|
||||||
{
|
{
|
||||||
close(src->fdin[1]);
|
close(src->fdin[1]);
|
||||||
close(src->fdout[0]);
|
close(src->fdout[0]);
|
||||||
// child
|
/* child */
|
||||||
dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */
|
dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */
|
||||||
dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
|
dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
|
||||||
execvp(src->command[0], &src->command[0]);
|
execvp(src->command[0], &src->command[0]);
|
||||||
// will only reach if error
|
/* will only reach if error */
|
||||||
perror("exec");
|
perror("exec");
|
||||||
gst_element_error(GST_ELEMENT(src),"starting child process");
|
gst_element_error(GST_ELEMENT(src),"starting child process");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -66,7 +66,7 @@ static void gst_tee_get_property (GObject *object, guint prop_id,
|
||||||
static void gst_tee_chain (GstPad *pad, GstBuffer *buf);
|
static void gst_tee_chain (GstPad *pad, GstBuffer *buf);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
//static guint gst_tee_signals[LAST_SIGNAL] = { 0 };
|
/*static guint gst_tee_signals[LAST_SIGNAL] = { 0 };*/
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_tee_get_type(void) {
|
gst_tee_get_type(void) {
|
||||||
|
@ -213,7 +213,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf)
|
||||||
g_return_if_fail (buf != NULL);
|
g_return_if_fail (buf != NULL);
|
||||||
|
|
||||||
tee = GST_TEE (gst_pad_get_parent (pad));
|
tee = GST_TEE (gst_pad_get_parent (pad));
|
||||||
// gst_trace_add_entry (NULL, 0, buf, "tee buffer");
|
/* gst_trace_add_entry (NULL, 0, buf, "tee buffer");*/
|
||||||
|
|
||||||
for (i=0; i<tee->numsrcpads-1; i++)
|
for (i=0; i<tee->numsrcpads-1; i++)
|
||||||
gst_buffer_ref (buf);
|
gst_buffer_ref (buf);
|
||||||
|
|
Loading…
Reference in a new issue