// we consider the initiating process to be cothread 0
ctx->nthreads = 1;
ctx->current = 0;
+ ctx->data = g_hash_table_new(g_str_hash, g_str_equal);
return ctx;
}
//printf("uh, yeah, we shouldn't be here, but we should deal anyway\n");
}
+void
+cothread_set_data (cothread_state *thread,
+ gchar *key,
+ gpointer data)
+{
+ cothread_context *ctx = pthread_getspecific(_cothread_key);
+
+ g_hash_table_insert(ctx->data, key, data);
+}
+
+gpointer
+cothread_get_data (cothread_state *thread,
+ gchar *key)
+{
+ cothread_context *ctx = pthread_getspecific(_cothread_key);
+
+ return g_hash_table_lookup(ctx->data, key);
+}
+
void
cothread_switch (cothread_state *thread)
{
cothread_state *threads[COTHREAD_MAXTHREADS];
int nthreads;
int current;
+ GHashTable *data;
};
cothread_context* cothread_init();
void cothread_setfunc (cothread_state *thread, cothread_func func,
int argc, char **argv);
void cothread_switch (cothread_state *thread);
+void cothread_set_data (cothread_state *thread, gchar *key, gpointer data);
+gpointer cothread_get_data (cothread_state *thread, gchar *key);
+
cothread_state* cothread_main (cothread_context *ctx);
#endif /* __COTHREAD_H__ */
gsttypefind.h \
gstsinesrc.h
-CFLAGS += -g -O2 -Wall
+CFLAGS += -O2 -Wall
libgstelements_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(GHTTP_LIBS)
libgstelements_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE)
};
-static void gst_asyncdisksrc_class_init(GstAsyncDiskSrcClass *klass);
-static void gst_asyncdisksrc_init(GstAsyncDiskSrc *asyncdisksrc);
-static void gst_asyncdisksrc_set_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_asyncdisksrc_get_arg(GtkObject *object,GtkArg *arg,guint id);
+static void gst_asyncdisksrc_class_init (GstAsyncDiskSrcClass *klass);
+static void gst_asyncdisksrc_init (GstAsyncDiskSrc *asyncdisksrc);
-static void gst_asyncdisksrc_push(GstSrc *src);
-static void gst_asyncdisksrc_push_region(GstSrc *src,gulong offset,
- gulong size);
-static GstElementStateReturn gst_asyncdisksrc_change_state(GstElement *element);
+static void gst_asyncdisksrc_set_arg (GtkObject *object, GtkArg *arg, guint id);
+static void gst_asyncdisksrc_get_arg (GtkObject *object, GtkArg *arg, guint id);
+
+static void gst_asyncdisksrc_push (GstSrc *src);
+static void gst_asyncdisksrc_push_region (GstSrc *src, gulong offset, gulong size);
+
+static GstElementStateReturn gst_asyncdisksrc_change_state (GstElement *element);
static GstSrcClass *parent_class = NULL;
//static guint gst_asyncdisksrc_signals[LAST_SIGNAL] = { 0 };
GtkType
-gst_asyncdisksrc_get_type(void) {
+gst_asyncdisksrc_get_type(void)
+{
static GtkType asyncdisksrc_type = 0;
if (!asyncdisksrc_type) {
(GtkArgGetFunc)gst_asyncdisksrc_get_arg,
(GtkClassInitFunc)NULL,
};
- asyncdisksrc_type = gtk_type_unique(GST_TYPE_SRC,&asyncdisksrc_info);
+ asyncdisksrc_type = gtk_type_unique (GST_TYPE_SRC, &asyncdisksrc_info);
}
return asyncdisksrc_type;
}
static void
-gst_asyncdisksrc_class_init(GstAsyncDiskSrcClass *klass) {
+gst_asyncdisksrc_class_init (GstAsyncDiskSrcClass *klass)
+{
GtkObjectClass *gtkobject_class;
GstElementClass *gstelement_class;
GstSrcClass *gstsrc_class;
gstelement_class = (GstElementClass*)klass;
gstsrc_class = (GstSrcClass*)klass;
- parent_class = gtk_type_class(GST_TYPE_SRC);
+ parent_class = gtk_type_class (GST_TYPE_SRC);
- gtk_object_add_arg_type("GstAsyncDiskSrc::location", GST_TYPE_FILENAME,
- GTK_ARG_READWRITE, ARG_LOCATION);
- gtk_object_add_arg_type("GstAsyncDiskSrc::bytesperread", GTK_TYPE_INT,
- GTK_ARG_READWRITE, ARG_BYTESPERREAD);
- gtk_object_add_arg_type("GstAsyncDiskSrc::offset", GTK_TYPE_LONG,
- GTK_ARG_READWRITE, ARG_OFFSET);
- gtk_object_add_arg_type("GstAsyncDiskSrc::size", GTK_TYPE_LONG,
- GTK_ARG_READABLE, ARG_SIZE);
+ gtk_object_add_arg_type ("GstAsyncDiskSrc::location", GST_TYPE_FILENAME,
+ GTK_ARG_READWRITE, ARG_LOCATION);
+ gtk_object_add_arg_type ("GstAsyncDiskSrc::bytesperread", GTK_TYPE_INT,
+ GTK_ARG_READWRITE, ARG_BYTESPERREAD);
+ gtk_object_add_arg_type ("GstAsyncDiskSrc::offset", GTK_TYPE_LONG,
+ GTK_ARG_READWRITE, ARG_OFFSET);
+ gtk_object_add_arg_type ("GstAsyncDiskSrc::size", GTK_TYPE_LONG,
+ GTK_ARG_READABLE, ARG_SIZE);
gtkobject_class->set_arg = gst_asyncdisksrc_set_arg;
gtkobject_class->get_arg = gst_asyncdisksrc_get_arg;
gstelement_class->change_state = gst_asyncdisksrc_change_state;
- gstsrc_class->push = gst_asyncdisksrc_push;
- gstsrc_class->push_region = gst_asyncdisksrc_push_region;
+ gstsrc_class->push = gst_asyncdisksrc_push;
+ gstsrc_class->push_region = gst_asyncdisksrc_push_region;
}
-static void gst_asyncdisksrc_init(GstAsyncDiskSrc *asyncdisksrc) {
- GST_SRC_SET_FLAGS(asyncdisksrc,GST_SRC_ASYNC);
+static void
+gst_asyncdisksrc_init (GstAsyncDiskSrc *asyncdisksrc)
+{
+ GST_SRC_SET_FLAGS (asyncdisksrc, GST_SRC_ASYNC);
- asyncdisksrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
- gst_element_add_pad(GST_ELEMENT(asyncdisksrc),asyncdisksrc->srcpad);
+ asyncdisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_element_add_pad (GST_ELEMENT (asyncdisksrc), asyncdisksrc->srcpad);
asyncdisksrc->filename = NULL;
asyncdisksrc->fd = 0;
asyncdisksrc->curoffset = 0;
asyncdisksrc->bytes_per_read = 4096;
asyncdisksrc->seq = 0;
+ asyncdisksrc->new_seek = FALSE;
}
-static void gst_asyncdisksrc_set_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_asyncdisksrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
+{
GstAsyncDiskSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_ASYNCDISKSRC(object));
- src = GST_ASYNCDISKSRC(object);
+ g_return_if_fail (GST_IS_ASYNCDISKSRC (object));
+
+ src = GST_ASYNCDISKSRC (object);
switch(id) {
case ARG_LOCATION:
/* the element must be stopped in order to do this */
- g_return_if_fail(GST_STATE(src) < GST_STATE_PLAYING);
+ g_return_if_fail (GST_STATE (src) < GST_STATE_PLAYING);
- if (src->filename) g_free(src->filename);
+ if (src->filename) g_free (src->filename);
/* clear the filename if we get a NULL (is that possible?) */
- if (GTK_VALUE_STRING(*arg) == NULL) {
- gst_element_set_state(GST_ELEMENT(object),GST_STATE_NULL);
+ if (GTK_VALUE_STRING (*arg) == NULL) {
+ gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
src->filename = NULL;
/* otherwise set the new filename */
} else {
- src->filename = g_strdup(GTK_VALUE_STRING(*arg));
+ src->filename = g_strdup (GTK_VALUE_STRING (*arg));
}
break;
case ARG_BYTESPERREAD:
- src->bytes_per_read = GTK_VALUE_INT(*arg);
+ src->bytes_per_read = GTK_VALUE_INT (*arg);
break;
case ARG_OFFSET:
- src->curoffset = GTK_VALUE_LONG(*arg);
+ src->curoffset = GTK_VALUE_LONG (*arg);
+ src->new_seek = TRUE;
break;
default:
break;
}
}
-static void gst_asyncdisksrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_asyncdisksrc_get_arg (GtkObject *object, GtkArg *arg, guint id)
+{
GstAsyncDiskSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_ASYNCDISKSRC(object));
- src = GST_ASYNCDISKSRC(object);
+ g_return_if_fail (GST_IS_ASYNCDISKSRC (object));
+
+ src = GST_ASYNCDISKSRC (object);
switch (id) {
case ARG_LOCATION:
- GTK_VALUE_STRING(*arg) = src->filename;
+ GTK_VALUE_STRING (*arg) = src->filename;
break;
case ARG_BYTESPERREAD:
- GTK_VALUE_INT(*arg) = src->bytes_per_read;
+ GTK_VALUE_INT (*arg) = src->bytes_per_read;
break;
case ARG_OFFSET:
- GTK_VALUE_LONG(*arg) = src->curoffset;
+ GTK_VALUE_LONG (*arg) = src->curoffset;
break;
case ARG_SIZE:
- GTK_VALUE_LONG(*arg) = src->size;
+ GTK_VALUE_LONG (*arg) = src->size;
break;
default:
arg->type = GTK_TYPE_INVALID;
*
* Push a new buffer from the asyncdisksrc at the current offset.
*/
-void gst_asyncdisksrc_push(GstSrc *src) {
+static void
+gst_asyncdisksrc_push (GstSrc *src)
+{
GstAsyncDiskSrc *asyncdisksrc;
GstBuffer *buf;
- g_return_if_fail(src != NULL);
- g_return_if_fail(GST_IS_ASYNCDISKSRC(src));
- g_return_if_fail(GST_FLAG_IS_SET(src,GST_ASYNCDISKSRC_OPEN));
- asyncdisksrc = GST_ASYNCDISKSRC(src);
+ g_return_if_fail (src != NULL);
+ g_return_if_fail (GST_IS_ASYNCDISKSRC (src));
+ g_return_if_fail (GST_FLAG_IS_SET (src, GST_ASYNCDISKSRC_OPEN));
+
+ asyncdisksrc = GST_ASYNCDISKSRC (src);
/* deal with EOF state */
if (asyncdisksrc->curoffset >= asyncdisksrc->size) {
- gst_src_signal_eos(GST_SRC(asyncdisksrc));
+ gst_src_signal_eos (GST_SRC (asyncdisksrc));
return;
}
/* create the buffer */
// FIXME: should eventually use a bufferpool for this
- buf = gst_buffer_new();
- g_return_if_fail(buf != NULL);
+ buf = gst_buffer_new ();
+
+ g_return_if_fail (buf != NULL);
/* simply set the buffer to point to the correct region of the file */
- GST_BUFFER_DATA(buf) = asyncdisksrc->map + asyncdisksrc->curoffset;
- GST_BUFFER_OFFSET(buf) = asyncdisksrc->curoffset;
- GST_BUFFER_FLAG_SET(buf, GST_BUFFER_DONTFREE);
+ GST_BUFFER_DATA (buf) = asyncdisksrc->map + asyncdisksrc->curoffset;
+ GST_BUFFER_OFFSET (buf) = asyncdisksrc->curoffset;
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
if ((asyncdisksrc->curoffset + asyncdisksrc->bytes_per_read) >
asyncdisksrc->size) {
- GST_BUFFER_SIZE(buf) = asyncdisksrc->size - asyncdisksrc->curoffset;
+ GST_BUFFER_SIZE (buf) = asyncdisksrc->size - asyncdisksrc->curoffset;
// FIXME: set the buffer's EOF bit here
} else
- GST_BUFFER_SIZE(buf) = asyncdisksrc->bytes_per_read;
- asyncdisksrc->curoffset += GST_BUFFER_SIZE(buf);
+ GST_BUFFER_SIZE (buf) = asyncdisksrc->bytes_per_read;
- //gst_buffer_ref(buf);
+ asyncdisksrc->curoffset += GST_BUFFER_SIZE (buf);
+
+ if (asyncdisksrc->new_seek) {
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLUSH);
+ asyncdisksrc->new_seek = FALSE;
+ }
/* we're done, push the buffer off now */
- gst_pad_push(asyncdisksrc->srcpad,buf);
+ gst_pad_push (asyncdisksrc->srcpad, buf);
}
/**
*
* Push a new buffer from the asyncdisksrc of given size at given offset.
*/
-void gst_asyncdisksrc_push_region(GstSrc *src,gulong offset,gulong size) {
+static void
+gst_asyncdisksrc_push_region (GstSrc *src, gulong offset, gulong size)
+{
GstAsyncDiskSrc *asyncdisksrc;
GstBuffer *buf;
- g_return_if_fail(src != NULL);
- g_return_if_fail(GST_IS_ASYNCDISKSRC(src));
- g_return_if_fail(GST_FLAG_IS_SET(src,GST_STATE_READY));
- asyncdisksrc = GST_ASYNCDISKSRC(src);
+ g_return_if_fail (src != NULL);
+ g_return_if_fail (GST_IS_ASYNCDISKSRC (src));
+ g_return_if_fail (GST_FLAG_IS_SET (src, GST_ASYNCDISKSRC_OPEN));
+
+ asyncdisksrc = GST_ASYNCDISKSRC (src);
/* deal with EOF state */
if (offset >= asyncdisksrc->size) {
- gst_src_signal_eos(GST_SRC(asyncdisksrc));
+ gst_src_signal_eos (GST_SRC (asyncdisksrc));
return;
}
/* create the buffer */
// FIXME: should eventually use a bufferpool for this
- buf = gst_buffer_new();
- g_return_if_fail(buf);
+ buf = gst_buffer_new ();
+ g_return_if_fail (buf);
/* simply set the buffer to point to the correct region of the file */
- GST_BUFFER_DATA(buf) = asyncdisksrc->map + offset;
- GST_BUFFER_OFFSET(buf) = asyncdisksrc->curoffset;
- GST_BUFFER_FLAG_SET(buf, GST_BUFFER_DONTFREE);
+ GST_BUFFER_DATA (buf) = asyncdisksrc->map + offset;
+ GST_BUFFER_OFFSET (buf) = offset;
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
if ((offset + size) > asyncdisksrc->size) {
- GST_BUFFER_SIZE(buf) = asyncdisksrc->size - offset;
+ GST_BUFFER_SIZE (buf) = asyncdisksrc->size - offset;
// FIXME: set the buffer's EOF bit here
} else
- GST_BUFFER_SIZE(buf) = size;
- asyncdisksrc->curoffset += GST_BUFFER_SIZE(buf);
+ GST_BUFFER_SIZE (buf) = size;
/* we're done, push the buffer off now */
- gst_pad_push(asyncdisksrc->srcpad,buf);
+ gst_pad_push (asyncdisksrc->srcpad,buf);
}
/* open the file and mmap it, necessary to go to READY state */
-static gboolean gst_asyncdisksrc_open_file(GstAsyncDiskSrc *src) {
- g_return_val_if_fail(!GST_FLAG_IS_SET(src,GST_ASYNCDISKSRC_OPEN), FALSE);
+static
+gboolean gst_asyncdisksrc_open_file (GstAsyncDiskSrc *src)
+{
+ g_return_val_if_fail (!GST_FLAG_IS_SET (src ,GST_ASYNCDISKSRC_OPEN), FALSE);
/* open the file */
- src->fd = open(src->filename,O_RDONLY);
+ src->fd = open (src->filename, O_RDONLY);
if (src->fd < 0) {
- gst_element_error(GST_ELEMENT(src),"opening file");
+ gst_element_error (GST_ELEMENT (src), "opening file");
return FALSE;
} else {
/* find the file length */
- src->size = lseek(src->fd,0,SEEK_END);
- lseek(src->fd,0,SEEK_SET);
+ src->size = lseek (src->fd, 0, SEEK_END);
+ lseek (src->fd, 0, SEEK_SET);
/* map the file into memory */
- src->map = mmap(NULL,src->size,PROT_READ,MAP_SHARED,src->fd,0);
- madvise(src->map,src->size,2);
+ src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0);
+ madvise (src->map,src->size, 2);
/* collapse state if that failed */
if (src->map == NULL) {
- close(src->fd);
- gst_element_error(GST_ELEMENT(src),"mmapping file");
+ close (src->fd);
+ gst_element_error (GST_ELEMENT (src),"mmapping file");
return FALSE;
}
- GST_FLAG_SET(src,GST_ASYNCDISKSRC_OPEN);
+ GST_FLAG_SET (src, GST_ASYNCDISKSRC_OPEN);
}
return TRUE;
}
/* unmap and close the file */
-static void gst_asyncdisksrc_close_file(GstAsyncDiskSrc *src) {
- g_return_if_fail(GST_FLAG_IS_SET(src,GST_ASYNCDISKSRC_OPEN));
+static void
+gst_asyncdisksrc_close_file (GstAsyncDiskSrc *src)
+{
+ g_return_if_fail (GST_FLAG_IS_SET (src, GST_ASYNCDISKSRC_OPEN));
/* unmap the file from memory */
- munmap(src->map,src->size);
+ munmap (src->map, src->size);
/* close the file */
- close(src->fd);
+ close (src->fd);
/* zero out a lot of our state */
src->fd = 0;
src->curoffset = 0;
src->seq = 0;
- GST_FLAG_UNSET(src,GST_ASYNCDISKSRC_OPEN);
+ GST_FLAG_UNSET (src, GST_ASYNCDISKSRC_OPEN);
}
-static GstElementStateReturn gst_asyncdisksrc_change_state(GstElement *element) {
- g_return_val_if_fail(GST_IS_ASYNCDISKSRC(element),GST_STATE_FAILURE);
+static
+GstElementStateReturn gst_asyncdisksrc_change_state (GstElement *element)
+{
+ g_return_val_if_fail (GST_IS_ASYNCDISKSRC (element), GST_STATE_FAILURE);
- if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
- if (GST_FLAG_IS_SET(element,GST_ASYNCDISKSRC_OPEN))
- gst_asyncdisksrc_close_file(GST_ASYNCDISKSRC(element));
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
+ if (GST_FLAG_IS_SET (element, GST_ASYNCDISKSRC_OPEN))
+ gst_asyncdisksrc_close_file (GST_ASYNCDISKSRC (element));
} else {
- if (!GST_FLAG_IS_SET(element,GST_ASYNCDISKSRC_OPEN)) {
- if (!gst_asyncdisksrc_open_file(GST_ASYNCDISKSRC(element)))
+ if (!GST_FLAG_IS_SET (element, GST_ASYNCDISKSRC_OPEN)) {
+ if (!gst_asyncdisksrc_open_file (GST_ASYNCDISKSRC (element)))
return GST_STATE_FAILURE;
}
}
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
/* details for fallback synchronous read */
gulong curoffset; /* current offset in file */
gulong bytes_per_read; /* bytes per read */
+ gboolean new_seek;
gulong seq; /* buffer sequence number */
};
};
-static void gst_disksrc_class_init(GstDiskSrcClass *klass);
-static void gst_disksrc_init(GstDiskSrc *disksrc);
-static void gst_disksrc_set_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_disksrc_get_arg(GtkObject *object,GtkArg *arg,guint id);
+static void gst_disksrc_class_init (GstDiskSrcClass *klass);
+static void gst_disksrc_init (GstDiskSrc *disksrc);
-static void gst_disksrc_close_file(GstDiskSrc *src);
+static void gst_disksrc_set_arg (GtkObject *object, GtkArg *arg, guint id);
+static void gst_disksrc_get_arg (GtkObject *object, GtkArg *arg, guint id);
-static void gst_disksrc_push(GstSrc *src);
-//static void gst_disksrc_push_region(GstSrc *src,gulong offset,gulong size);
-static GstElementStateReturn gst_disksrc_change_state(GstElement *element);
+static void gst_disksrc_close_file (GstDiskSrc *src);
+
+static void gst_disksrc_push (GstSrc *src);
+
+static GstElementStateReturn gst_disksrc_change_state (GstElement *element);
static GstSrcClass *parent_class = NULL;
gtk_object_add_arg_type("GstDiskSrc::bytesperread", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
gtk_object_add_arg_type("GstDiskSrc::offset", GTK_TYPE_INT,
- GTK_ARG_READWRITE, ARG_OFFSET);
+ GTK_ARG_READABLE, ARG_OFFSET);
gtk_object_add_arg_type("GstDiskSrc::size", GTK_TYPE_INT,
GTK_ARG_READABLE, ARG_SIZE);
case ARG_BYTESPERREAD:
src->bytes_per_read = GTK_VALUE_INT(*arg);
break;
+ /*
case ARG_OFFSET:
src->curoffset = GTK_VALUE_INT(*arg);
lseek(src->fd,src->curoffset, SEEK_SET);
src->new_seek = TRUE;
break;
+ */
default:
break;
}
(oclass->create_plan) (bin);
}
+typedef struct {
+ gulong offset;
+ gulong size;
+} region_struct;
+
static int
gst_bin_loopfunc_wrapper (int argc,char *argv[])
{
} else {
DEBUG("** gst_bin_loopfunc_wrapper(): element %s is chain-based, calling in infinite loop\n", name);
if (GST_IS_SRC (element)) {
- DEBUG("** gst_bin_loopfunc_wrapper(): calling push function of source %s\n", name);
- gst_src_push (GST_SRC (element));
- DEBUG("** gst_bin_loopfunc_wrapper(): calling push function of source %s done\n", name);
+ region_struct *region = cothread_get_data (element->threadstate, "region");
+ if (region) {
+ gst_src_push_region (GST_SRC (element), region->offset, region->size);
+ }
+ else {
+ DEBUG("** gst_bin_loopfunc_wrapper(): calling push function of source %s\n", name);
+ gst_src_push (GST_SRC (element));
+ DEBUG("** gst_bin_loopfunc_wrapper(): calling push function of source %s done\n", name);
+ }
} else if (GST_IS_CONNECTION (element) && argc == 1) {
while (1) {
DEBUG("** gst_bin_loopfunc_wrapper(): calling push function of connection %s\n", name);
}
static void
+gst_bin_pullregionfunc_wrapper (GstPad *pad,
+ gulong offset,
+ gulong size)
+{
+ region_struct region;
+
+ region.offset = offset;
+ region.size = size;
+
+ DEBUG("** in gst_bin_pullregionfunc_wrapper()============================= %s\n",
+ gst_element_get_name (GST_ELEMENT (pad->parent)));
+ cothread_set_data (GST_ELEMENT (pad->parent)->threadstate, "region", ®ion);
+ cothread_switch (GST_ELEMENT (pad->parent)->threadstate);
+ cothread_set_data (GST_ELEMENT (pad->parent)->threadstate, "region", NULL);
+ DEBUG("** out gst_bin_pullregionfunc_wrapper()============================= %s\n",
+ gst_element_get_name (GST_ELEMENT (pad->parent)));
+}
+
+static void
gst_bin_pushfunc_wrapper (GstPad *pad)
{
DEBUG("** in gst_bin_pushfunc_wrapper()============================= %s\n",
pad->pushfunc = gst_bin_pushfunc_wrapper;
}
pad->pullfunc = gst_bin_pullfunc_wrapper;
+ pad->pullregionfunc = gst_bin_pullregionfunc_wrapper;
/* we only worry about sink pads */
if (gst_pad_get_direction (pad) == GST_PAD_SINK) {
opad->pushfunc = gst_bin_pushfunc_wrapper;
opad->pullfunc = gst_bin_pullfunc_wrapper;
+ opad->pullregionfunc = gst_bin_pullregionfunc_wrapper;
if (outside->threadstate == NULL) {
outside->threadstate = cothread_create (bin->threadcontext);
pad->peer = NULL;
pad->chainfunc = NULL;
pad->pullfunc = NULL;
+ pad->pullregionfunc = NULL;
pad->pushfunc = NULL;
pad->qosfunc = NULL;
pad->parent = NULL;
// first check to see if there's a push handler
if (pad->pushfunc != NULL) {
- //g_print("-- gst_pad_push(): putting buffer in pen and calling push handler\n");
// put the buffer in peer's holding pen
pad->peer->bufpen = buffer;
// now inform the handler that the peer pad has something
gst_pad_pull (GstPad *pad)
{
GstBuffer *buf;
-// GstElement *peerparent;
-// cothread_state *state;
g_return_val_if_fail(pad != NULL, NULL);
g_return_val_if_fail(GST_IS_PAD(pad), NULL);
-// g_print("-- gst_pad_pull(): attempting to pull buffer\n");
-
-// g_return_val_if_fail(pad->pullfunc != NULL, NULL);
-
// if no buffer in pen and there's a pull handler, fire it
if (pad->bufpen == NULL) {
if (pad->pullfunc != NULL) {
-// g_print("-- gst_pad_pull(): calling pull handler\n");
(pad->pullfunc)(pad->peer);
} else {
g_print("-- gst_pad_pull(%s:%s): no buffer in pen, and no handler to get one there!!!\n",
// if there's a buffer in the holding pen, use it
if (pad->bufpen != NULL) {
-// g_print("-- gst_pad_pull(): buffer available, pulling\n");
buf = pad->bufpen;
pad->bufpen = NULL;
return buf;
gulong offset,
gulong size)
{
- // FIXME
- return gst_pad_pull (pad);
+ GstBuffer *buf;
+
+ g_return_val_if_fail(pad != NULL, NULL);
+ g_return_val_if_fail(GST_IS_PAD(pad), NULL);
+
+ DEBUG("-- gst_pad_pull_region(%s:%s): region (%lu,%lu)\n",
+ GST_ELEMENT(pad->parent)->name, pad->peer->name,
+ offset, size);
+
+ // if no buffer in pen and there's a pull handler, fire it
+ if (pad->bufpen == NULL) {
+ if (pad->pullregionfunc != NULL) {
+ (pad->pullregionfunc)(pad->peer, offset, size);
+ } else {
+ g_print("-- gst_pad_pull_region(%s:%s): no buffer in pen, and no handler to get one there!!!\n",
+ GST_ELEMENT(pad->parent)->name, pad->name);
+ }
+ }
+
+ // if there's a buffer in the holding pen, use it
+ if (pad->bufpen != NULL) {
+ buf = pad->bufpen;
+ pad->bufpen = NULL;
+ return buf;
+ // else we have a big problem...
+ } else {
+ g_print("-- gst_pad_pull_region(%s:%s): no buffer in pen, and no handler\n",
+ GST_ELEMENT(pad->parent)->name, pad->peer->name);
+ return NULL;
+ }
+
+ return NULL;
}
/**
* buf is the buffer being passed */
typedef void (*GstPadChainFunction) (GstPad *pad,GstBuffer *buf);
typedef void (*GstPadPullFunction) (GstPad *pad);
+typedef void (*GstPadPullRegionFunction) (GstPad *pad, gulong offset, gulong size);
typedef void (*GstPadPushFunction) (GstPad *pad);
typedef void (*GstPadQoSFunction) (GstPad *pad, glong qos_message);
GstPadChainFunction chainfunc;
GstPadPullFunction pullfunc;
+ GstPadPullRegionFunction pullregionfunc;
GstPadPushFunction pushfunc;
GstPadQoSFunction qosfunc;
i = j =0;
while (i<size) {
- g_print("%02x ", mem[i]);
- if (j == 16) {
- g_print("\n");
- j = 0;
+ if (j == 0) {
+ g_print("\n%08x : ", i);
+ j = 15;
}
else {
- j++;
+ j--;
}
+ g_print("%02x ", mem[i]);
i++;
}
g_print("\n");
priv->uri = NULL;
priv->offset_element = NULL;
priv->bit_rate_element = NULL;
+ priv->media_time_element = NULL;
}
GstPlay *
gst_play_eos (GstElement *element,
GstPlay *play)
{
+ g_print("gstplay: eos reached\n");
gst_play_stop(play);
}
}
else {
// first come first serve here...
- if (!priv->offset_element) gst_play_object_introspect(element, "offset", &priv->offset_element);
- if (!priv->bit_rate_element) gst_play_object_introspect(element, "bit_rate", &priv->bit_rate_element);
+ if (!priv->offset_element)
+ gst_play_object_introspect (element, "offset", &priv->offset_element);
+ if (!priv->bit_rate_element)
+ gst_play_object_introspect (element, "bit_rate", &priv->bit_rate_element);
+ if (!priv->media_time_element)
+ gst_play_object_introspect (element, "media_time", &priv->media_time_element);
+ if (!priv->current_time_element)
+ gst_play_object_introspect (element, "current_time", &priv->current_time_element);
}
}
priv->uri = g_strdup (uri);
- priv->src = gst_elementfactory_make ("disksrc", "disk_src");
+ priv->src = gst_elementfactory_make ("asyncdisksrc", "disk_src");
g_return_val_if_fail (priv->src != NULL, -1);
gtk_object_set (GTK_OBJECT (priv->src),"location",uri,NULL);
gtk_signal_connect (GTK_OBJECT (priv->src), "eos", GTK_SIGNAL_FUNC (gst_play_eos), play);
priv = (GstPlayPrivate *)play->priv;
+ if (priv->media_time_element) {
+ return gst_util_get_long_arg (GTK_OBJECT (priv->media_time_element), "media_time");
+ }
+
if (priv->bit_rate_element == NULL) return 0;
bit_rate = gst_util_get_long_arg (GTK_OBJECT (priv->bit_rate_element), "bit_rate");
priv = (GstPlayPrivate *)play->priv;
+ if (priv->current_time_element) {
+ return gst_util_get_long_arg (GTK_OBJECT (priv->current_time_element), "current_time");
+ }
+
if (priv->bit_rate_element == NULL) return 0;
bit_rate = gst_util_get_long_arg (GTK_OBJECT (priv->bit_rate_element), "bit_rate");
GstElement *offset_element;
GstElement *bit_rate_element;
+ GstElement *media_time_element;
+ GstElement *current_time_element;
};
#endif /* __GSTPLAY_PRIVATE_H__ */
#define __GST_RIFF_H__
-#include <gst/gstbuffer.h>
-#include <gst/gstplugin.h>
-
+#include <gst/gst.h>
typedef enum {
GST_RIFF_OK = 0,
guint32 size;
};
-typedef struct _gst_riff_riff gst_riff_riff;
-typedef struct _gst_riff_list gst_riff_list;
-typedef struct _gst_riff_chunk gst_riff_chunk;
+struct _gst_riff_index_entry {
+ guint32 id;
+ guint32 flags;
+#define GST_RIFF_IF_LIST (0x00000001L)
+#define GST_RIFF_IF_KEYFRAME (0x00000010L)
+#define GST_RIFF_IF_NO_TIME (0x00000100L)
+#define GST_RIFF_IF_COMPUSE (0x0FFF0000L)
+ guint32 offset;
+ guint32 size;
+};
+
+typedef struct _gst_riff_riff gst_riff_riff;
+typedef struct _gst_riff_list gst_riff_list;
+typedef struct _gst_riff_chunk gst_riff_chunk;
+typedef struct _gst_riff_index_entry gst_riff_index_entry;
-typedef struct _gst_riff_avih gst_riff_avih;
-typedef struct _gst_riff_strh gst_riff_strh;
-typedef struct _gst_riff_strf_vids gst_riff_strf_vids;
-typedef struct _gst_riff_strf_auds gst_riff_strf_auds;
-typedef struct _GstRiff GstRiff;
-typedef struct _GstRiffChunk GstRiffChunk;
+typedef struct _gst_riff_avih gst_riff_avih;
+typedef struct _gst_riff_strh gst_riff_strh;
+typedef struct _gst_riff_strf_vids gst_riff_strf_vids;
+typedef struct _gst_riff_strf_auds gst_riff_strf_auds;
+typedef struct _GstRiff GstRiff;
+typedef struct _GstRiffChunk GstRiffChunk;
-typedef void (*GstRiffCallback) (GstRiffChunk *chunk, gpointer data);
+typedef void (*GstRiffCallback) (GstRiffChunk *chunk, gpointer data);
struct _GstRiff {
guint32 form;
/* from gstriffparse.c */
-GstRiff *gst_riff_parser_new(GstRiffCallback function, gpointer data);
-GstRiffReturn gst_riff_parser_next_buffer(GstRiff *riff,GstBuffer *buf,gulong off);
+GstRiff* gst_riff_parser_new (GstRiffCallback function, gpointer data);
+GstRiffReturn gst_riff_parser_next_buffer (GstRiff *riff, GstBuffer *buf, gulong off);
+void gst_riff_parser_resync (GstRiff *riff, gulong offset);
/* from gstriffencode.c */
-GstRiff *gst_riff_encoder_new(guint32 type);
-GstRiffReturn gst_riff_encoder_avih(GstRiff *riff, gst_riff_avih *head, gulong size);
-GstRiffReturn gst_riff_encoder_strh(GstRiff *riff, guint32 fcc_type, gst_riff_strh *head, gulong size);
-GstRiffReturn gst_riff_encoder_strf(GstRiff *riff, void *format, gulong size);
-GstRiffReturn gst_riff_encoder_chunk(GstRiff *riff, guint32 chunk_type, void *chunk, gulong size);
+GstRiff* gst_riff_encoder_new (guint32 type);
+GstRiffReturn gst_riff_encoder_avih (GstRiff *riff, gst_riff_avih *head, gulong size);
+GstRiffReturn gst_riff_encoder_strh (GstRiff *riff, guint32 fcc_type,
+ gst_riff_strh *head, gulong size);
+GstRiffReturn gst_riff_encoder_strf (GstRiff *riff, void *format, gulong size);
+GstRiffReturn gst_riff_encoder_chunk (GstRiff *riff, guint32 chunk_type,
+ void *chunk, gulong size);
-GstBuffer *gst_riff_encoder_get_buffer(GstRiff *riff);
-GstBuffer *gst_riff_encoder_get_and_reset_buffer(GstRiff *riff);
+GstBuffer* gst_riff_encoder_get_buffer (GstRiff *riff);
+GstBuffer* gst_riff_encoder_get_and_reset_buffer (GstRiff *riff);
/* from gstriffutil.c */
-gulong gst_riff_fourcc_to_id(gchar *fourcc);
-gchar *gst_riff_id_to_fourcc(gulong id);
+gulong gst_riff_fourcc_to_id (gchar *fourcc);
+gchar* gst_riff_id_to_fourcc (gulong id);
#endif /* __GST_RIFF_H__ */
#include <gst/gst.h>
#include <gstriff.h>
-GstRiff *gst_riff_parser_new(GstRiffCallback function, gpointer data) {
+GstRiff*
+gst_riff_parser_new (GstRiffCallback function, gpointer data)
+{
GstRiff *riff;
riff = (GstRiff *)g_malloc(sizeof(GstRiff));
return riff;
}
-gint gst_riff_parser_next_buffer(GstRiff *riff,GstBuffer *buf,gulong off) {
+gint
+gst_riff_parser_next_buffer (GstRiff *riff, GstBuffer *buf, gulong off)
+{
gulong last, size;
GstRiffChunk *chunk;
DEBUG("gst_riff_parser: next 0x%08x offset 0x%08lx size 0x%08x\n",riff->nextlikely,
chunk->offset, chunk->size);
- if (riff->nextlikely >= chunk->offset+chunk->size) {
+ if (riff->nextlikely >= chunk->offset+chunk->size) {
DEBUG("gst_riff_parser: found END LIST\n");
- // we have the end of the chunk on the stack, remove it
- riff->chunks = g_list_remove(riff->chunks, chunk);
+ // we have the end of the chunk on the stack, remove it
+ riff->chunks = g_list_remove(riff->chunks, chunk);
}
- else break;
+ else break;
}
DEBUG("gst_riff_parser: next likely chunk is at offset 0x%08x\n",riff->nextlikely);
riff->nextlikely += 8 + chunk->size; /* doesn't include hdr */
// if this buffer is incomplete
if (riff->nextlikely > last) {
- guint left = size - (riff->nextlikely - chunk->size - off);
+ guint left = size - (riff->nextlikely - chunk->size - off);
DEBUG("make incomplete buffer %08x\n", left);
- chunk->data = g_malloc(chunk->size);
+ chunk->data = g_malloc(chunk->size);
memcpy(chunk->data, (gchar *)(words+2), left);
riff->incomplete_chunk = chunk;
riff->incomplete_chunk_size = left;
return 0;
}
+void
+gst_riff_parser_resync (GstRiff *riff, gulong offset)
+{
+ riff->incomplete_chunk = NULL;
+ riff->dataleft = NULL;
+ riff->nextlikely = offset;
+}
gsttypefind.h \
gstsinesrc.h
-CFLAGS += -g -O2 -Wall
+CFLAGS += -O2 -Wall
libgstelements_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(GHTTP_LIBS)
libgstelements_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE)
};
-static void gst_asyncdisksrc_class_init(GstAsyncDiskSrcClass *klass);
-static void gst_asyncdisksrc_init(GstAsyncDiskSrc *asyncdisksrc);
-static void gst_asyncdisksrc_set_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_asyncdisksrc_get_arg(GtkObject *object,GtkArg *arg,guint id);
+static void gst_asyncdisksrc_class_init (GstAsyncDiskSrcClass *klass);
+static void gst_asyncdisksrc_init (GstAsyncDiskSrc *asyncdisksrc);
-static void gst_asyncdisksrc_push(GstSrc *src);
-static void gst_asyncdisksrc_push_region(GstSrc *src,gulong offset,
- gulong size);
-static GstElementStateReturn gst_asyncdisksrc_change_state(GstElement *element);
+static void gst_asyncdisksrc_set_arg (GtkObject *object, GtkArg *arg, guint id);
+static void gst_asyncdisksrc_get_arg (GtkObject *object, GtkArg *arg, guint id);
+
+static void gst_asyncdisksrc_push (GstSrc *src);
+static void gst_asyncdisksrc_push_region (GstSrc *src, gulong offset, gulong size);
+
+static GstElementStateReturn gst_asyncdisksrc_change_state (GstElement *element);
static GstSrcClass *parent_class = NULL;
//static guint gst_asyncdisksrc_signals[LAST_SIGNAL] = { 0 };
GtkType
-gst_asyncdisksrc_get_type(void) {
+gst_asyncdisksrc_get_type(void)
+{
static GtkType asyncdisksrc_type = 0;
if (!asyncdisksrc_type) {
(GtkArgGetFunc)gst_asyncdisksrc_get_arg,
(GtkClassInitFunc)NULL,
};
- asyncdisksrc_type = gtk_type_unique(GST_TYPE_SRC,&asyncdisksrc_info);
+ asyncdisksrc_type = gtk_type_unique (GST_TYPE_SRC, &asyncdisksrc_info);
}
return asyncdisksrc_type;
}
static void
-gst_asyncdisksrc_class_init(GstAsyncDiskSrcClass *klass) {
+gst_asyncdisksrc_class_init (GstAsyncDiskSrcClass *klass)
+{
GtkObjectClass *gtkobject_class;
GstElementClass *gstelement_class;
GstSrcClass *gstsrc_class;
gstelement_class = (GstElementClass*)klass;
gstsrc_class = (GstSrcClass*)klass;
- parent_class = gtk_type_class(GST_TYPE_SRC);
+ parent_class = gtk_type_class (GST_TYPE_SRC);
- gtk_object_add_arg_type("GstAsyncDiskSrc::location", GST_TYPE_FILENAME,
- GTK_ARG_READWRITE, ARG_LOCATION);
- gtk_object_add_arg_type("GstAsyncDiskSrc::bytesperread", GTK_TYPE_INT,
- GTK_ARG_READWRITE, ARG_BYTESPERREAD);
- gtk_object_add_arg_type("GstAsyncDiskSrc::offset", GTK_TYPE_LONG,
- GTK_ARG_READWRITE, ARG_OFFSET);
- gtk_object_add_arg_type("GstAsyncDiskSrc::size", GTK_TYPE_LONG,
- GTK_ARG_READABLE, ARG_SIZE);
+ gtk_object_add_arg_type ("GstAsyncDiskSrc::location", GST_TYPE_FILENAME,
+ GTK_ARG_READWRITE, ARG_LOCATION);
+ gtk_object_add_arg_type ("GstAsyncDiskSrc::bytesperread", GTK_TYPE_INT,
+ GTK_ARG_READWRITE, ARG_BYTESPERREAD);
+ gtk_object_add_arg_type ("GstAsyncDiskSrc::offset", GTK_TYPE_LONG,
+ GTK_ARG_READWRITE, ARG_OFFSET);
+ gtk_object_add_arg_type ("GstAsyncDiskSrc::size", GTK_TYPE_LONG,
+ GTK_ARG_READABLE, ARG_SIZE);
gtkobject_class->set_arg = gst_asyncdisksrc_set_arg;
gtkobject_class->get_arg = gst_asyncdisksrc_get_arg;
gstelement_class->change_state = gst_asyncdisksrc_change_state;
- gstsrc_class->push = gst_asyncdisksrc_push;
- gstsrc_class->push_region = gst_asyncdisksrc_push_region;
+ gstsrc_class->push = gst_asyncdisksrc_push;
+ gstsrc_class->push_region = gst_asyncdisksrc_push_region;
}
-static void gst_asyncdisksrc_init(GstAsyncDiskSrc *asyncdisksrc) {
- GST_SRC_SET_FLAGS(asyncdisksrc,GST_SRC_ASYNC);
+static void
+gst_asyncdisksrc_init (GstAsyncDiskSrc *asyncdisksrc)
+{
+ GST_SRC_SET_FLAGS (asyncdisksrc, GST_SRC_ASYNC);
- asyncdisksrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
- gst_element_add_pad(GST_ELEMENT(asyncdisksrc),asyncdisksrc->srcpad);
+ asyncdisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_element_add_pad (GST_ELEMENT (asyncdisksrc), asyncdisksrc->srcpad);
asyncdisksrc->filename = NULL;
asyncdisksrc->fd = 0;
asyncdisksrc->curoffset = 0;
asyncdisksrc->bytes_per_read = 4096;
asyncdisksrc->seq = 0;
+ asyncdisksrc->new_seek = FALSE;
}
-static void gst_asyncdisksrc_set_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_asyncdisksrc_set_arg (GtkObject *object, GtkArg *arg, guint id)
+{
GstAsyncDiskSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_ASYNCDISKSRC(object));
- src = GST_ASYNCDISKSRC(object);
+ g_return_if_fail (GST_IS_ASYNCDISKSRC (object));
+
+ src = GST_ASYNCDISKSRC (object);
switch(id) {
case ARG_LOCATION:
/* the element must be stopped in order to do this */
- g_return_if_fail(GST_STATE(src) < GST_STATE_PLAYING);
+ g_return_if_fail (GST_STATE (src) < GST_STATE_PLAYING);
- if (src->filename) g_free(src->filename);
+ if (src->filename) g_free (src->filename);
/* clear the filename if we get a NULL (is that possible?) */
- if (GTK_VALUE_STRING(*arg) == NULL) {
- gst_element_set_state(GST_ELEMENT(object),GST_STATE_NULL);
+ if (GTK_VALUE_STRING (*arg) == NULL) {
+ gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL);
src->filename = NULL;
/* otherwise set the new filename */
} else {
- src->filename = g_strdup(GTK_VALUE_STRING(*arg));
+ src->filename = g_strdup (GTK_VALUE_STRING (*arg));
}
break;
case ARG_BYTESPERREAD:
- src->bytes_per_read = GTK_VALUE_INT(*arg);
+ src->bytes_per_read = GTK_VALUE_INT (*arg);
break;
case ARG_OFFSET:
- src->curoffset = GTK_VALUE_LONG(*arg);
+ src->curoffset = GTK_VALUE_LONG (*arg);
+ src->new_seek = TRUE;
break;
default:
break;
}
}
-static void gst_asyncdisksrc_get_arg(GtkObject *object,GtkArg *arg,guint id) {
+static void
+gst_asyncdisksrc_get_arg (GtkObject *object, GtkArg *arg, guint id)
+{
GstAsyncDiskSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_ASYNCDISKSRC(object));
- src = GST_ASYNCDISKSRC(object);
+ g_return_if_fail (GST_IS_ASYNCDISKSRC (object));
+
+ src = GST_ASYNCDISKSRC (object);
switch (id) {
case ARG_LOCATION:
- GTK_VALUE_STRING(*arg) = src->filename;
+ GTK_VALUE_STRING (*arg) = src->filename;
break;
case ARG_BYTESPERREAD:
- GTK_VALUE_INT(*arg) = src->bytes_per_read;
+ GTK_VALUE_INT (*arg) = src->bytes_per_read;
break;
case ARG_OFFSET:
- GTK_VALUE_LONG(*arg) = src->curoffset;
+ GTK_VALUE_LONG (*arg) = src->curoffset;
break;
case ARG_SIZE:
- GTK_VALUE_LONG(*arg) = src->size;
+ GTK_VALUE_LONG (*arg) = src->size;
break;
default:
arg->type = GTK_TYPE_INVALID;
*
* Push a new buffer from the asyncdisksrc at the current offset.
*/
-void gst_asyncdisksrc_push(GstSrc *src) {
+static void
+gst_asyncdisksrc_push (GstSrc *src)
+{
GstAsyncDiskSrc *asyncdisksrc;
GstBuffer *buf;
- g_return_if_fail(src != NULL);
- g_return_if_fail(GST_IS_ASYNCDISKSRC(src));
- g_return_if_fail(GST_FLAG_IS_SET(src,GST_ASYNCDISKSRC_OPEN));
- asyncdisksrc = GST_ASYNCDISKSRC(src);
+ g_return_if_fail (src != NULL);
+ g_return_if_fail (GST_IS_ASYNCDISKSRC (src));
+ g_return_if_fail (GST_FLAG_IS_SET (src, GST_ASYNCDISKSRC_OPEN));
+
+ asyncdisksrc = GST_ASYNCDISKSRC (src);
/* deal with EOF state */
if (asyncdisksrc->curoffset >= asyncdisksrc->size) {
- gst_src_signal_eos(GST_SRC(asyncdisksrc));
+ gst_src_signal_eos (GST_SRC (asyncdisksrc));
return;
}
/* create the buffer */
// FIXME: should eventually use a bufferpool for this
- buf = gst_buffer_new();
- g_return_if_fail(buf != NULL);
+ buf = gst_buffer_new ();
+
+ g_return_if_fail (buf != NULL);
/* simply set the buffer to point to the correct region of the file */
- GST_BUFFER_DATA(buf) = asyncdisksrc->map + asyncdisksrc->curoffset;
- GST_BUFFER_OFFSET(buf) = asyncdisksrc->curoffset;
- GST_BUFFER_FLAG_SET(buf, GST_BUFFER_DONTFREE);
+ GST_BUFFER_DATA (buf) = asyncdisksrc->map + asyncdisksrc->curoffset;
+ GST_BUFFER_OFFSET (buf) = asyncdisksrc->curoffset;
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
if ((asyncdisksrc->curoffset + asyncdisksrc->bytes_per_read) >
asyncdisksrc->size) {
- GST_BUFFER_SIZE(buf) = asyncdisksrc->size - asyncdisksrc->curoffset;
+ GST_BUFFER_SIZE (buf) = asyncdisksrc->size - asyncdisksrc->curoffset;
// FIXME: set the buffer's EOF bit here
} else
- GST_BUFFER_SIZE(buf) = asyncdisksrc->bytes_per_read;
- asyncdisksrc->curoffset += GST_BUFFER_SIZE(buf);
+ GST_BUFFER_SIZE (buf) = asyncdisksrc->bytes_per_read;
- //gst_buffer_ref(buf);
+ asyncdisksrc->curoffset += GST_BUFFER_SIZE (buf);
+
+ if (asyncdisksrc->new_seek) {
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLUSH);
+ asyncdisksrc->new_seek = FALSE;
+ }
/* we're done, push the buffer off now */
- gst_pad_push(asyncdisksrc->srcpad,buf);
+ gst_pad_push (asyncdisksrc->srcpad, buf);
}
/**
*
* Push a new buffer from the asyncdisksrc of given size at given offset.
*/
-void gst_asyncdisksrc_push_region(GstSrc *src,gulong offset,gulong size) {
+static void
+gst_asyncdisksrc_push_region (GstSrc *src, gulong offset, gulong size)
+{
GstAsyncDiskSrc *asyncdisksrc;
GstBuffer *buf;
- g_return_if_fail(src != NULL);
- g_return_if_fail(GST_IS_ASYNCDISKSRC(src));
- g_return_if_fail(GST_FLAG_IS_SET(src,GST_STATE_READY));
- asyncdisksrc = GST_ASYNCDISKSRC(src);
+ g_return_if_fail (src != NULL);
+ g_return_if_fail (GST_IS_ASYNCDISKSRC (src));
+ g_return_if_fail (GST_FLAG_IS_SET (src, GST_ASYNCDISKSRC_OPEN));
+
+ asyncdisksrc = GST_ASYNCDISKSRC (src);
/* deal with EOF state */
if (offset >= asyncdisksrc->size) {
- gst_src_signal_eos(GST_SRC(asyncdisksrc));
+ gst_src_signal_eos (GST_SRC (asyncdisksrc));
return;
}
/* create the buffer */
// FIXME: should eventually use a bufferpool for this
- buf = gst_buffer_new();
- g_return_if_fail(buf);
+ buf = gst_buffer_new ();
+ g_return_if_fail (buf);
/* simply set the buffer to point to the correct region of the file */
- GST_BUFFER_DATA(buf) = asyncdisksrc->map + offset;
- GST_BUFFER_OFFSET(buf) = asyncdisksrc->curoffset;
- GST_BUFFER_FLAG_SET(buf, GST_BUFFER_DONTFREE);
+ GST_BUFFER_DATA (buf) = asyncdisksrc->map + offset;
+ GST_BUFFER_OFFSET (buf) = offset;
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
if ((offset + size) > asyncdisksrc->size) {
- GST_BUFFER_SIZE(buf) = asyncdisksrc->size - offset;
+ GST_BUFFER_SIZE (buf) = asyncdisksrc->size - offset;
// FIXME: set the buffer's EOF bit here
} else
- GST_BUFFER_SIZE(buf) = size;
- asyncdisksrc->curoffset += GST_BUFFER_SIZE(buf);
+ GST_BUFFER_SIZE (buf) = size;
/* we're done, push the buffer off now */
- gst_pad_push(asyncdisksrc->srcpad,buf);
+ gst_pad_push (asyncdisksrc->srcpad,buf);
}
/* open the file and mmap it, necessary to go to READY state */
-static gboolean gst_asyncdisksrc_open_file(GstAsyncDiskSrc *src) {
- g_return_val_if_fail(!GST_FLAG_IS_SET(src,GST_ASYNCDISKSRC_OPEN), FALSE);
+static
+gboolean gst_asyncdisksrc_open_file (GstAsyncDiskSrc *src)
+{
+ g_return_val_if_fail (!GST_FLAG_IS_SET (src ,GST_ASYNCDISKSRC_OPEN), FALSE);
/* open the file */
- src->fd = open(src->filename,O_RDONLY);
+ src->fd = open (src->filename, O_RDONLY);
if (src->fd < 0) {
- gst_element_error(GST_ELEMENT(src),"opening file");
+ gst_element_error (GST_ELEMENT (src), "opening file");
return FALSE;
} else {
/* find the file length */
- src->size = lseek(src->fd,0,SEEK_END);
- lseek(src->fd,0,SEEK_SET);
+ src->size = lseek (src->fd, 0, SEEK_END);
+ lseek (src->fd, 0, SEEK_SET);
/* map the file into memory */
- src->map = mmap(NULL,src->size,PROT_READ,MAP_SHARED,src->fd,0);
- madvise(src->map,src->size,2);
+ src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0);
+ madvise (src->map,src->size, 2);
/* collapse state if that failed */
if (src->map == NULL) {
- close(src->fd);
- gst_element_error(GST_ELEMENT(src),"mmapping file");
+ close (src->fd);
+ gst_element_error (GST_ELEMENT (src),"mmapping file");
return FALSE;
}
- GST_FLAG_SET(src,GST_ASYNCDISKSRC_OPEN);
+ GST_FLAG_SET (src, GST_ASYNCDISKSRC_OPEN);
}
return TRUE;
}
/* unmap and close the file */
-static void gst_asyncdisksrc_close_file(GstAsyncDiskSrc *src) {
- g_return_if_fail(GST_FLAG_IS_SET(src,GST_ASYNCDISKSRC_OPEN));
+static void
+gst_asyncdisksrc_close_file (GstAsyncDiskSrc *src)
+{
+ g_return_if_fail (GST_FLAG_IS_SET (src, GST_ASYNCDISKSRC_OPEN));
/* unmap the file from memory */
- munmap(src->map,src->size);
+ munmap (src->map, src->size);
/* close the file */
- close(src->fd);
+ close (src->fd);
/* zero out a lot of our state */
src->fd = 0;
src->curoffset = 0;
src->seq = 0;
- GST_FLAG_UNSET(src,GST_ASYNCDISKSRC_OPEN);
+ GST_FLAG_UNSET (src, GST_ASYNCDISKSRC_OPEN);
}
-static GstElementStateReturn gst_asyncdisksrc_change_state(GstElement *element) {
- g_return_val_if_fail(GST_IS_ASYNCDISKSRC(element),GST_STATE_FAILURE);
+static
+GstElementStateReturn gst_asyncdisksrc_change_state (GstElement *element)
+{
+ g_return_val_if_fail (GST_IS_ASYNCDISKSRC (element), GST_STATE_FAILURE);
- if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
- if (GST_FLAG_IS_SET(element,GST_ASYNCDISKSRC_OPEN))
- gst_asyncdisksrc_close_file(GST_ASYNCDISKSRC(element));
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
+ if (GST_FLAG_IS_SET (element, GST_ASYNCDISKSRC_OPEN))
+ gst_asyncdisksrc_close_file (GST_ASYNCDISKSRC (element));
} else {
- if (!GST_FLAG_IS_SET(element,GST_ASYNCDISKSRC_OPEN)) {
- if (!gst_asyncdisksrc_open_file(GST_ASYNCDISKSRC(element)))
+ if (!GST_FLAG_IS_SET (element, GST_ASYNCDISKSRC_OPEN)) {
+ if (!gst_asyncdisksrc_open_file (GST_ASYNCDISKSRC (element)))
return GST_STATE_FAILURE;
}
}
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
/* details for fallback synchronous read */
gulong curoffset; /* current offset in file */
gulong bytes_per_read; /* bytes per read */
+ gboolean new_seek;
gulong seq; /* buffer sequence number */
};
};
-static void gst_disksrc_class_init(GstDiskSrcClass *klass);
-static void gst_disksrc_init(GstDiskSrc *disksrc);
-static void gst_disksrc_set_arg(GtkObject *object,GtkArg *arg,guint id);
-static void gst_disksrc_get_arg(GtkObject *object,GtkArg *arg,guint id);
+static void gst_disksrc_class_init (GstDiskSrcClass *klass);
+static void gst_disksrc_init (GstDiskSrc *disksrc);
-static void gst_disksrc_close_file(GstDiskSrc *src);
+static void gst_disksrc_set_arg (GtkObject *object, GtkArg *arg, guint id);
+static void gst_disksrc_get_arg (GtkObject *object, GtkArg *arg, guint id);
-static void gst_disksrc_push(GstSrc *src);
-//static void gst_disksrc_push_region(GstSrc *src,gulong offset,gulong size);
-static GstElementStateReturn gst_disksrc_change_state(GstElement *element);
+static void gst_disksrc_close_file (GstDiskSrc *src);
+
+static void gst_disksrc_push (GstSrc *src);
+
+static GstElementStateReturn gst_disksrc_change_state (GstElement *element);
static GstSrcClass *parent_class = NULL;
gtk_object_add_arg_type("GstDiskSrc::bytesperread", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_BYTESPERREAD);
gtk_object_add_arg_type("GstDiskSrc::offset", GTK_TYPE_INT,
- GTK_ARG_READWRITE, ARG_OFFSET);
+ GTK_ARG_READABLE, ARG_OFFSET);
gtk_object_add_arg_type("GstDiskSrc::size", GTK_TYPE_INT,
GTK_ARG_READABLE, ARG_SIZE);
case ARG_BYTESPERREAD:
src->bytes_per_read = GTK_VALUE_INT(*arg);
break;
+ /*
case ARG_OFFSET:
src->curoffset = GTK_VALUE_INT(*arg);
lseek(src->fd,src->curoffset, SEEK_SET);
src->new_seek = TRUE;
break;
+ */
default:
break;
}