mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-05 23:18:47 +00:00
Commit my pending changes.
Original commit message from CVS: Commit my pending changes. - revert WHERE stuff - added fast type checking - add preliminary stack trace functionality - minor fixes/cleanups.
This commit is contained in:
parent
1058e3cf90
commit
ccccda7d5d
28 changed files with 402 additions and 480 deletions
|
@ -8,6 +8,8 @@ else
|
|||
GSTARCH_SRCS =
|
||||
endif
|
||||
|
||||
#GST_INSTRUMENT_FLAGS = -finstrument-functions -DGST_ENABLE_FUNC_INSTRUMENTATION
|
||||
|
||||
if USE_GLIB2
|
||||
GST_OBJECT_MODEL_SRC = gstmarshal.c
|
||||
GST_OBJECT_MODEL_HDR = gstmarshal.h
|
||||
|
@ -198,7 +200,7 @@ noinst_HEADERS = \
|
|||
gstarch.h \
|
||||
gstpropsprivate.h
|
||||
|
||||
CFLAGS = $(LIBGST_CFLAGS) -D_GNU_SOURCE -DGST_CONFIG_DIR=\""$(GST_CONFIG_DIR)"\"
|
||||
CFLAGS = $(LIBGST_CFLAGS) -D_GNU_SOURCE -DGST_CONFIG_DIR=\""$(GST_CONFIG_DIR)"\" -Wall
|
||||
LIBS = $(LIBGST_LIBS)
|
||||
LDFLAGS = ""
|
||||
libgst_la_LDFLAGS = -version-info $(GST_LIBVERSION)
|
||||
|
|
|
@ -41,7 +41,7 @@ noinst_HEADERS = \
|
|||
gstaggregator.h \
|
||||
gstsinesrc.h
|
||||
|
||||
CFLAGS += -O2 -Wall
|
||||
CFLAGS += -O2 -Wall -finstrument-functions -DGST_ENABLE_FUNC_INSTRUMENTATION
|
||||
LDFLAGS += -lm
|
||||
|
||||
libgstelements_la_LIBADD = $(GHTTP_LIBS)
|
||||
|
|
|
@ -64,8 +64,8 @@ static void gst_disksrc_set_property (GObject *object, guint prop_id,
|
|||
static void gst_disksrc_get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec);
|
||||
|
||||
static GstBuffer * gst_disksrc_get (GstPad *pad);
|
||||
static GstBuffer * gst_disksrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);
|
||||
static GstBuffer* gst_disksrc_get (GstPad *pad);
|
||||
static GstBufferPool* gst_disksrc_get_bufferpool (GstPad *pad);
|
||||
|
||||
static GstElementStateReturn
|
||||
gst_disksrc_change_state (GstElement *element);
|
||||
|
@ -73,7 +73,7 @@ static GstElementStateReturn
|
|||
static gboolean gst_disksrc_open_file (GstDiskSrc *src);
|
||||
static void gst_disksrc_close_file (GstDiskSrc *src);
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
static GstElementClass* parent_class = NULL;
|
||||
//static guint gst_disksrc_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GType
|
||||
|
@ -133,8 +133,8 @@ gst_disksrc_init (GstDiskSrc *disksrc)
|
|||
// GST_FLAG_SET (disksrc, GST_SRC_);
|
||||
|
||||
disksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_pad_set_get_function (disksrc->srcpad,gst_disksrc_get);
|
||||
gst_pad_set_getregion_function (disksrc->srcpad,gst_disksrc_get_region);
|
||||
gst_pad_set_get_function (disksrc->srcpad, gst_disksrc_get);
|
||||
gst_pad_set_bufferpool_function (disksrc->srcpad, gst_disksrc_get_bufferpool);
|
||||
gst_element_add_pad (GST_ELEMENT (disksrc), disksrc->srcpad);
|
||||
|
||||
disksrc->filename = NULL;
|
||||
|
@ -220,6 +220,56 @@ gst_disksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
|
|||
}
|
||||
}
|
||||
|
||||
static GstBuffer*
|
||||
gst_disksrc_buffer_new (GstBufferPool *pool, gint64 location, gint size, gpointer user_data)
|
||||
{
|
||||
GstDiskSrc *src;
|
||||
GstBuffer *buf;
|
||||
|
||||
src = GST_DISKSRC (user_data);
|
||||
|
||||
buf = gst_buffer_new ();
|
||||
g_return_val_if_fail (buf != NULL, NULL);
|
||||
|
||||
/* simply set the buffer to point to the correct region of the file */
|
||||
GST_BUFFER_DATA (buf) = src->map + location;
|
||||
GST_BUFFER_OFFSET (buf) = location;
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
|
||||
|
||||
if ((location + size) > src->size)
|
||||
GST_BUFFER_SIZE (buf) = src->size - location;
|
||||
else
|
||||
GST_BUFFER_SIZE (buf) = size;
|
||||
|
||||
GST_DEBUG (0,"map %p, offset %ld (%p), size %d\n", src->map, src->curoffset,
|
||||
src->map + src->curoffset, GST_BUFFER_SIZE (buf));
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_disksrc_buffer_free (GstBuffer *buf)
|
||||
{
|
||||
// FIXME do something here
|
||||
}
|
||||
|
||||
static GstBufferPool*
|
||||
gst_disksrc_get_bufferpool (GstPad *pad)
|
||||
{
|
||||
GstDiskSrc *src;
|
||||
|
||||
src = GST_DISKSRC (gst_pad_get_parent (pad));
|
||||
|
||||
if (!src->bufferpool) {
|
||||
src->bufferpool = gst_buffer_pool_new ();
|
||||
gst_buffer_pool_set_buffer_new_function (src->bufferpool, gst_disksrc_buffer_new);
|
||||
gst_buffer_pool_set_buffer_free_function (src->bufferpool, gst_disksrc_buffer_free);
|
||||
gst_buffer_pool_set_user_data (src->bufferpool, src);
|
||||
}
|
||||
|
||||
return src->bufferpool;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_disksrc_get:
|
||||
* @pad: #GstPad to push a buffer from
|
||||
|
@ -246,28 +296,10 @@ gst_disksrc_get (GstPad *pad)
|
|||
return buf;
|
||||
}
|
||||
|
||||
/* create the buffer */
|
||||
// FIXME: should eventually use a bufferpool for this
|
||||
buf = gst_buffer_new ();
|
||||
|
||||
g_return_val_if_fail (buf != NULL, NULL);
|
||||
|
||||
/* simply set the buffer to point to the correct region of the file */
|
||||
GST_BUFFER_DATA (buf) = src->map + src->curoffset;
|
||||
GST_BUFFER_OFFSET (buf) = src->curoffset;
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
|
||||
|
||||
if ((src->curoffset + src->bytes_per_read) > src->size) {
|
||||
GST_BUFFER_SIZE (buf) = src->size - src->curoffset;
|
||||
// FIXME: set the buffer's EOF bit here
|
||||
} else
|
||||
GST_BUFFER_SIZE (buf) = src->bytes_per_read;
|
||||
|
||||
GST_DEBUG (0,"map %p, offset %ld (%p), size %d\n", src->map, src->curoffset,
|
||||
src->map + src->curoffset, GST_BUFFER_SIZE (buf));
|
||||
// FIXME use a bufferpool
|
||||
buf = gst_disksrc_buffer_new (NULL, src->curoffset, src->bytes_per_read, src);
|
||||
|
||||
//gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
|
||||
src->curoffset += GST_BUFFER_SIZE (buf);
|
||||
|
||||
if (src->new_seek) {
|
||||
|
@ -280,61 +312,6 @@ gst_disksrc_get (GstPad *pad)
|
|||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_disksrc_get_region:
|
||||
* @src: #GstSrc to push a buffer from
|
||||
* @offset: offset in file
|
||||
* @size: number of bytes
|
||||
*
|
||||
* Push a new buffer from the disksrc of given size at given offset.
|
||||
*/
|
||||
static GstBuffer *
|
||||
gst_disksrc_get_region (GstPad *pad, GstRegionType type,guint64 offset,guint64 len)
|
||||
{
|
||||
GstDiskSrc *src;
|
||||
GstBuffer *buf;
|
||||
|
||||
g_return_val_if_fail (pad != NULL, NULL);
|
||||
g_return_val_if_fail (type == GST_REGION_OFFSET_LEN, NULL);
|
||||
|
||||
src = GST_DISKSRC (gst_pad_get_parent (pad));
|
||||
|
||||
g_return_val_if_fail (GST_IS_DISKSRC (src), NULL);
|
||||
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN), NULL);
|
||||
|
||||
/* deal with EOF state */
|
||||
if (offset >= src->size) {
|
||||
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
|
||||
GST_DEBUG (0,"map offset %lld >= size %ld --> eos\n", offset, src->size);
|
||||
//FIXME
|
||||
buf = gst_buffer_new();
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* create the buffer */
|
||||
// FIXME: should eventually use a bufferpool for this
|
||||
buf = gst_buffer_new ();
|
||||
g_return_val_if_fail (buf != NULL, NULL);
|
||||
|
||||
/* simply set the buffer to point to the correct region of the file */
|
||||
GST_BUFFER_DATA (buf) = src->map + offset;
|
||||
GST_BUFFER_OFFSET (buf) = offset;
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
|
||||
|
||||
if ((offset + len) > src->size) {
|
||||
GST_BUFFER_SIZE (buf) = src->size - offset;
|
||||
// FIXME: set the buffer's EOF bit here
|
||||
} else
|
||||
GST_BUFFER_SIZE (buf) = len;
|
||||
|
||||
GST_DEBUG (0,"map %p, offset %lld, size %d\n", src->map, offset, GST_BUFFER_SIZE (buf));
|
||||
|
||||
/* we're done, return the buffer off now */
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/* open the file and mmap it, necessary to go to READY state */
|
||||
static gboolean
|
||||
gst_disksrc_open_file (GstDiskSrc *src)
|
||||
|
|
|
@ -64,6 +64,7 @@ struct _GstDiskSrc {
|
|||
gchar *filename;
|
||||
/* fd */
|
||||
gint fd;
|
||||
GstBufferPool *bufferpool;
|
||||
|
||||
/* mapping parameters */
|
||||
gulong size; /* how long is the file? */
|
||||
|
|
|
@ -225,6 +225,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
|
|||
|
||||
if (GST_IS_EVENT(buf)) {
|
||||
g_print("fakesink: have event!\n");
|
||||
gst_element_set_state (GST_ELEMENT (fakesink), GST_STATE_PAUSED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -335,7 +335,8 @@ gst_fakesrc_get(GstPad *pad)
|
|||
|
||||
if (src->num_buffers == 0) {
|
||||
g_print("fakesrc: sending EOS\n");
|
||||
return GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS));
|
||||
gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED);
|
||||
return GST_BUFFER(gst_event_new (GST_EVENT_EOS));
|
||||
}
|
||||
else {
|
||||
if (src->num_buffers > 0)
|
||||
|
@ -345,7 +346,7 @@ gst_fakesrc_get(GstPad *pad)
|
|||
if (src->eos) {
|
||||
GST_INFO (0, "fakesrc is setting eos on pad");
|
||||
g_print("fakesrc: sending EOS\n");
|
||||
return GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS));
|
||||
return GST_BUFFER(gst_event_new (GST_EVENT_EOS));
|
||||
}
|
||||
|
||||
buf = gst_buffer_new();
|
||||
|
@ -397,7 +398,7 @@ gst_fakesrc_loop(GstElement *element)
|
|||
|
||||
if (src->eos) {
|
||||
GST_INFO (0, "fakesrc is setting eos on pad");
|
||||
gst_pad_push(pad, GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS)));
|
||||
gst_pad_push(pad, GST_BUFFER(gst_event_new (GST_EVENT_EOS)));
|
||||
}
|
||||
|
||||
buf = gst_buffer_new();
|
||||
|
|
|
@ -596,6 +596,7 @@ gst_filesrc_close_file (GstFileSrc *src)
|
|||
{
|
||||
g_return_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN));
|
||||
|
||||
g_print ("close\n");
|
||||
/* close the file */
|
||||
close (src->fd);
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ gtk_signal_handler_pending ((GtkObject *)object,name,may_block)
|
|||
gint* g_signal_list_ids (GType type, guint *n_ids);
|
||||
|
||||
// lists
|
||||
GSList* g_slist_delete_link (GSList *list, GSList *link);
|
||||
GSList* g_slist_delete_link (GSList *list, GSList *link) __attribute__ ((no_instrument_function));
|
||||
|
||||
|
||||
// arguments/parameters
|
||||
|
|
|
@ -90,7 +90,12 @@ gst_init (int *argc, char **argv[])
|
|||
|
||||
GST_INFO (GST_CAT_GST_INIT, "Initializing GStreamer Core Library");
|
||||
|
||||
gst_object_get_type ();
|
||||
gst_pad_get_type ();
|
||||
gst_real_pad_get_type ();
|
||||
gst_ghost_pad_get_type ();
|
||||
gst_elementfactory_get_type ();
|
||||
gst_element_get_type ();
|
||||
gst_typefactory_get_type ();
|
||||
#ifndef GST_DISABLE_AUTOPLUG
|
||||
gst_autoplugfactory_get_type ();
|
||||
|
|
112
gst/gstbuffer.c
112
gst/gstbuffer.c
|
@ -32,13 +32,6 @@ GType _gst_buffer_type;
|
|||
static GMemChunk *_gst_buffer_chunk;
|
||||
static GMutex *_gst_buffer_chunk_lock;
|
||||
|
||||
#ifdef GST_BUFFER_WHERE
|
||||
static GSList *_debug_live = 0;
|
||||
# define GST_BUFFERS_COUNT (g_slist_length(_debug_live))
|
||||
#else
|
||||
# define GST_BUFFERS_COUNT 1
|
||||
#endif
|
||||
|
||||
void
|
||||
_gst_buffer_initialize (void)
|
||||
{
|
||||
|
@ -74,15 +67,12 @@ _gst_buffer_initialize (void)
|
|||
* Returns: new buffer
|
||||
*/
|
||||
GstBuffer*
|
||||
gst_buffer_new_loc (GST_WHERE_ARGS)
|
||||
gst_buffer_new (void)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
|
||||
g_mutex_lock (_gst_buffer_chunk_lock);
|
||||
buffer = g_mem_chunk_alloc (_gst_buffer_chunk);
|
||||
#ifdef GST_BUFFER_WHERE
|
||||
_debug_live = g_slist_prepend (_debug_live, buffer);
|
||||
#endif
|
||||
g_mutex_unlock (_gst_buffer_chunk_lock);
|
||||
GST_INFO (GST_CAT_BUFFER,"creating new buffer %p",buffer);
|
||||
|
||||
|
@ -105,11 +95,6 @@ gst_buffer_new_loc (GST_WHERE_ARGS)
|
|||
buffer->pool_private = NULL;
|
||||
buffer->free = NULL;
|
||||
buffer->copy = NULL;
|
||||
|
||||
#ifdef GST_BUFFER_WHERE
|
||||
buffer->file = where_file;
|
||||
buffer->line = where_line;
|
||||
#endif
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
@ -152,10 +137,9 @@ gst_buffer_new_from_pool (GstBufferPool *pool, guint32 offset, guint32 size)
|
|||
* Returns: new buffer
|
||||
*/
|
||||
GstBuffer*
|
||||
gst_buffer_create_sub_loc (GST_WHERE_ARGS_
|
||||
GstBuffer *parent,
|
||||
guint32 offset,
|
||||
guint32 size)
|
||||
gst_buffer_create_sub (GstBuffer *parent,
|
||||
guint32 offset,
|
||||
guint32 size)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
|
||||
|
@ -166,9 +150,6 @@ gst_buffer_create_sub_loc (GST_WHERE_ARGS_
|
|||
|
||||
g_mutex_lock (_gst_buffer_chunk_lock);
|
||||
buffer = g_mem_chunk_alloc (_gst_buffer_chunk);
|
||||
#ifdef GST_BUFFER_WHERE
|
||||
_debug_live = g_slist_prepend (_debug_live, buffer);
|
||||
#endif
|
||||
g_mutex_unlock (_gst_buffer_chunk_lock);
|
||||
GST_INFO (GST_CAT_BUFFER,"creating new subbuffer %p from parent %p (size %u, offset %u)",
|
||||
buffer, parent, size, offset);
|
||||
|
@ -208,11 +189,6 @@ gst_buffer_create_sub_loc (GST_WHERE_ARGS_
|
|||
|
||||
buffer->pool = NULL;
|
||||
|
||||
#ifdef GST_BUFFER_WHERE
|
||||
buffer->file = where_file;
|
||||
buffer->line = where_line;
|
||||
#endif
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -229,9 +205,8 @@ gst_buffer_create_sub_loc (GST_WHERE_ARGS_
|
|||
* Returns: new buffer
|
||||
*/
|
||||
GstBuffer*
|
||||
gst_buffer_append_loc (GST_WHERE_ARGS_
|
||||
GstBuffer *buffer,
|
||||
GstBuffer *append)
|
||||
gst_buffer_append (GstBuffer *buffer,
|
||||
GstBuffer *append)
|
||||
{
|
||||
guint size;
|
||||
GstBuffer *newbuf;
|
||||
|
@ -257,7 +232,7 @@ gst_buffer_append_loc (GST_WHERE_ARGS_
|
|||
}
|
||||
// the buffer is used, create a new one
|
||||
else {
|
||||
newbuf = gst_buffer_new_loc (GST_WHERE_VARS);
|
||||
newbuf = gst_buffer_new ();
|
||||
newbuf->size = buffer->size+append->size;
|
||||
newbuf->data = g_malloc (newbuf->size);
|
||||
memcpy (newbuf->data, buffer->data, buffer->size);
|
||||
|
@ -281,10 +256,9 @@ gst_buffer_destroy (GstBuffer *buffer)
|
|||
|
||||
g_return_if_fail (buffer != NULL);
|
||||
|
||||
GST_INFO (GST_CAT_BUFFER, "freeing %sbuffer %p (%d buffers remain)",
|
||||
GST_INFO (GST_CAT_BUFFER, "freeing %sbuffer %p",
|
||||
(buffer->parent?"sub":""),
|
||||
buffer,
|
||||
GST_BUFFERS_COUNT - 1);
|
||||
buffer);
|
||||
|
||||
// free the data only if there is some, DONTFREE isn't set, and not sub
|
||||
if (GST_BUFFER_DATA (buffer) &&
|
||||
|
@ -313,61 +287,9 @@ gst_buffer_destroy (GstBuffer *buffer)
|
|||
// remove it entirely from memory
|
||||
g_mutex_lock (_gst_buffer_chunk_lock);
|
||||
g_mem_chunk_free (_gst_buffer_chunk,buffer);
|
||||
#ifdef GST_BUFFER_WHERE
|
||||
_debug_live = g_slist_delete_link (_debug_live,
|
||||
g_slist_find (_debug_live, buffer));
|
||||
#endif
|
||||
g_mutex_unlock (_gst_buffer_chunk_lock);
|
||||
}
|
||||
|
||||
#ifdef GST_BUFFER_WHERE
|
||||
static gint
|
||||
_compare_buffer (GstBuffer *b1, GstBuffer *b2)
|
||||
{
|
||||
if (b1->timestamp == b2->timestamp)
|
||||
return 0;
|
||||
else if (b1->timestamp > b2->timestamp)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
// GST_BUFFER_WHERE will be replaced with something better as
|
||||
// soon as something better is actually implemented. The
|
||||
// problems with this technique are:
|
||||
//
|
||||
// 1. Toggling debugging changes the function prototypes, causing
|
||||
// a full recompile. Yuk.
|
||||
//
|
||||
// 2. The prototypes don't match the documentation. This may cause
|
||||
// gtk-doc to choak.
|
||||
//
|
||||
// 3. Lots of ugly macros make the source code hard to maintain.
|
||||
//
|
||||
|
||||
void gst_buffer_print_live ()
|
||||
{
|
||||
GSList *elem;
|
||||
|
||||
g_mutex_lock (_gst_buffer_chunk_lock);
|
||||
|
||||
_debug_live = g_slist_sort (_debug_live, (GCompareFunc) _compare_buffer);
|
||||
|
||||
for (elem = _debug_live; elem; elem = elem->next) {
|
||||
GstBuffer *buf = elem->data;
|
||||
g_print ("%sbuffer %p created %s:%d data=%p size=0x%x\n",
|
||||
buf->parent? "sub":" ",
|
||||
buf, (!buf->file || buf->file == NULL)? "?" : buf->file,
|
||||
buf->line, buf->data, buf->size);
|
||||
}
|
||||
|
||||
g_print ("(%d buffers)\n", g_slist_length (_debug_live));
|
||||
|
||||
g_mutex_unlock (_gst_buffer_chunk_lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* gst_buffer_ref:
|
||||
* @buffer: the GstBuffer to reference
|
||||
|
@ -432,7 +354,7 @@ gst_buffer_unref (GstBuffer *buffer)
|
|||
* Returns: new buffer
|
||||
*/
|
||||
GstBuffer *
|
||||
gst_buffer_copy_loc (GST_WHERE_ARGS_ GstBuffer *buffer)
|
||||
gst_buffer_copy (GstBuffer *buffer)
|
||||
{
|
||||
GstBuffer *newbuf;
|
||||
|
||||
|
@ -506,8 +428,7 @@ gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2)
|
|||
*/
|
||||
// FIXME need to think about CoW and such...
|
||||
GstBuffer *
|
||||
gst_buffer_span_loc (GST_WHERE_ARGS_
|
||||
GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len)
|
||||
gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len)
|
||||
{
|
||||
GstBuffer *newbuf;
|
||||
|
||||
|
@ -527,13 +448,12 @@ gst_buffer_span_loc (GST_WHERE_ARGS_
|
|||
// ((buf1->data + buf1->size) == buf2->data)) {
|
||||
if (gst_buffer_is_span_fast(buf1,buf2)) {
|
||||
// we simply create a subbuffer of the common parent
|
||||
newbuf = gst_buffer_create_sub_loc(GST_WHERE_VARS_
|
||||
buf1->parent, buf1->data - (buf1->parent->data) + offset, len);
|
||||
newbuf = gst_buffer_create_sub (buf1->parent, buf1->data - (buf1->parent->data) + offset, len);
|
||||
}
|
||||
else {
|
||||
g_print ("slow path taken in buffer_span\n");
|
||||
// otherwise we simply have to brute-force copy the buffers
|
||||
newbuf = gst_buffer_new_loc (GST_WHERE_VARS);
|
||||
newbuf = gst_buffer_new ();
|
||||
|
||||
// put in new size
|
||||
newbuf->size = len;
|
||||
|
@ -571,10 +491,8 @@ gst_buffer_span_loc (GST_WHERE_ARGS_
|
|||
* Returns: new buffer that's the concatenation of the source buffers
|
||||
*/
|
||||
GstBuffer *
|
||||
gst_buffer_merge_loc (GST_WHERE_ARGS_
|
||||
GstBuffer *buf1, GstBuffer *buf2)
|
||||
gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2)
|
||||
{
|
||||
// we're just a specific case of the more general gst_buffer_span()
|
||||
return gst_buffer_span_loc (GST_WHERE_VARS_
|
||||
buf1, 0, buf2, buf1->size + buf2->size);
|
||||
return gst_buffer_span (buf1, 0, buf2, buf1->size + buf2->size);
|
||||
}
|
||||
|
|
109
gst/gstbuffer.h
109
gst/gstbuffer.h
|
@ -57,14 +57,10 @@ extern GType _gst_buffer_type;
|
|||
#define GST_BUFFER(buf) ((GstBuffer *)(buf))
|
||||
#define GST_IS_BUFFER(buf) (GST_DATA_TYPE(buf) == GST_TYPE_BUFFER)
|
||||
|
||||
#define GST_BUFFER_FLAGS(buf) \
|
||||
(GST_BUFFER(buf)->flags)
|
||||
#define GST_BUFFER_FLAG_IS_SET(buf,flag) \
|
||||
(GST_BUFFER_FLAGS(buf) & (1<<(flag)))
|
||||
#define GST_BUFFER_FLAG_SET(buf,flag) \
|
||||
G_STMT_START{ (GST_BUFFER_FLAGS(buf) |= (1<<(flag))); }G_STMT_END
|
||||
#define GST_BUFFER_FLAG_UNSET(buf,flag) \
|
||||
G_STMT_START{ (GST_BUFFER_FLAGS(buf) &= ~(1<<(flag))); }G_STMT_END
|
||||
#define GST_BUFFER_FLAGS(buf) (GST_BUFFER(buf)->flags)
|
||||
#define GST_BUFFER_FLAG_IS_SET(buf,flag) (GST_BUFFER_FLAGS(buf) & (1<<(flag)))
|
||||
#define GST_BUFFER_FLAG_SET(buf,flag) G_STMT_START{ (GST_BUFFER_FLAGS(buf) |= (1<<(flag))); }G_STMT_END
|
||||
#define GST_BUFFER_FLAG_UNSET(buf,flag) G_STMT_START{ (GST_BUFFER_FLAGS(buf) &= ~(1<<(flag))); }G_STMT_END
|
||||
|
||||
|
||||
#define GST_BUFFER_DATA(buf) (GST_BUFFER(buf)->data)
|
||||
|
@ -96,7 +92,6 @@ typedef enum {
|
|||
} GstBufferFlags;
|
||||
|
||||
|
||||
|
||||
typedef struct _GstBuffer GstBuffer;
|
||||
|
||||
|
||||
|
@ -107,101 +102,53 @@ typedef GstBuffer *(*GstBufferCopyFunc) (GstBuffer *srcbuf);
|
|||
#include <gst/gstbufferpool.h>
|
||||
|
||||
struct _GstBuffer {
|
||||
GstData data_type;
|
||||
GstData data_type;
|
||||
|
||||
/* locking */
|
||||
GMutex *lock;
|
||||
GMutex *lock;
|
||||
|
||||
/* refcounting */
|
||||
#ifdef HAVE_ATOMIC_H
|
||||
atomic_t refcount;
|
||||
atomic_t refcount;
|
||||
#define GST_BUFFER_REFCOUNT(buf) (atomic_read(&(GST_BUFFER((buf))->refcount)))
|
||||
#else
|
||||
int refcount;
|
||||
int refcount;
|
||||
#define GST_BUFFER_REFCOUNT(buf) (GST_BUFFER(buf)->refcount)
|
||||
#endif
|
||||
|
||||
/* flags */
|
||||
guint16 flags;
|
||||
guint16 flags;
|
||||
|
||||
/* pointer to data, its size, and offset in original source if known */
|
||||
guchar *data;
|
||||
guint32 size;
|
||||
guint32 maxsize;
|
||||
guint32 offset;
|
||||
|
||||
#ifdef GST_BUFFER_WHERE
|
||||
const gchar *file;
|
||||
gint line;
|
||||
#endif
|
||||
guchar *data;
|
||||
guint32 size;
|
||||
guint32 maxsize;
|
||||
guint32 offset;
|
||||
|
||||
/* timestamp */
|
||||
gint64 timestamp;
|
||||
gint64 maxage;
|
||||
gint64 timestamp;
|
||||
gint64 maxage;
|
||||
|
||||
/* subbuffer support, who's my parent? */
|
||||
GstBuffer *parent;
|
||||
GstBuffer *parent;
|
||||
|
||||
/* this is a pointer to the buffer pool (if any) */
|
||||
GstBufferPool *pool;
|
||||
gpointer pool_private;
|
||||
GstBufferPool *pool;
|
||||
gpointer pool_private;
|
||||
|
||||
/* utility function pointers */
|
||||
GstBufferFreeFunc free; // free the data associated with the buffer
|
||||
GstBufferCopyFunc copy; // copy the data from one buffer to another
|
||||
GstBufferFreeFunc free; // free the data associated with the buffer
|
||||
GstBufferCopyFunc copy; // copy the data from one buffer to another
|
||||
};
|
||||
|
||||
#ifdef GST_BUFFER_WHERE
|
||||
|
||||
# define GST_WHERE_ARGS const gchar *where_file, gint where_line
|
||||
# define GST_WHERE_ARGS_ GST_WHERE_ARGS,
|
||||
# define GST_WHERE_VARS where_file, where_line
|
||||
# define GST_WHERE_VARS_ where_file, where_line,
|
||||
|
||||
# define gst_buffer_new() \
|
||||
gst_buffer_new_loc(__FILE__, __LINE__)
|
||||
# define gst_buffer_create_sub(parent, offset, size) \
|
||||
gst_buffer_create_sub_loc(__FILE__, __LINE__, parent, offset, size)
|
||||
# define gst_buffer_copy(buffer) \
|
||||
gst_buffer_copy_loc(__FILE__, __LINE__, buffer)
|
||||
# define gst_buffer_merge(buf1, buf2) \
|
||||
gst_buffer_merge_loc(__FILE__, __LINE__, buf1, buf2)
|
||||
# define gst_buffer_span(buf1, offset, buf2, len) \
|
||||
gst_buffer_span_loc(__FILE__, __LINE__, buf1, offset, buf2, len)
|
||||
# define gst_buffer_append(buf, buf2) \
|
||||
gst_buffer_append_loc(__FILE__, __LINE__, buf, buf2)
|
||||
|
||||
#else /* GST_BUFFER_WHERE */
|
||||
|
||||
# define GST_WHERE_ARGS
|
||||
# define GST_WHERE_ARGS_
|
||||
# define GST_WHERE_VARS
|
||||
# define GST_WHERE_VARS_
|
||||
|
||||
# define gst_buffer_new() \
|
||||
gst_buffer_new_loc()
|
||||
# define gst_buffer_create_sub(parent, offset, size) \
|
||||
gst_buffer_create_sub_loc(parent, offset, size)
|
||||
# define gst_buffer_copy(buffer) \
|
||||
gst_buffer_copy_loc(buffer)
|
||||
# define gst_buffer_merge(buf1, buf2) \
|
||||
gst_buffer_merge_loc(buf1, buf2)
|
||||
# define gst_buffer_span(buf1, offset, buf2, len) \
|
||||
gst_buffer_span_loc(buf1, offset, buf2, len)
|
||||
# define gst_buffer_append(buf, buf2) \
|
||||
gst_buffer_append_loc(buf, buf2)
|
||||
|
||||
#endif /* GST_BUFFER_WHERE */
|
||||
|
||||
/* initialisation */
|
||||
void _gst_buffer_initialize (void);
|
||||
/* creating a new buffer from scratch */
|
||||
GstBuffer* gst_buffer_new_loc (GST_WHERE_ARGS);
|
||||
GstBuffer* gst_buffer_new (void);
|
||||
GstBuffer* gst_buffer_new_from_pool (GstBufferPool *pool, guint32 offset, guint32 size);
|
||||
|
||||
/* creating a subbuffer */
|
||||
GstBuffer* gst_buffer_create_sub_loc (GST_WHERE_ARGS_
|
||||
GstBuffer *parent, guint32 offset, guint32 size);
|
||||
GstBuffer* gst_buffer_create_sub (GstBuffer *parent, guint32 offset, guint32 size);
|
||||
|
||||
/* refcounting */
|
||||
void gst_buffer_ref (GstBuffer *buffer);
|
||||
|
@ -211,16 +158,12 @@ void gst_buffer_unref (GstBuffer *buffer);
|
|||
void gst_buffer_destroy (GstBuffer *buffer);
|
||||
|
||||
/* copy buffer */
|
||||
GstBuffer* gst_buffer_copy_loc (GST_WHERE_ARGS_
|
||||
GstBuffer *buffer);
|
||||
GstBuffer* gst_buffer_copy (GstBuffer *buffer);
|
||||
|
||||
/* merge, span, or append two buffers, intelligently */
|
||||
GstBuffer* gst_buffer_merge_loc (GST_WHERE_ARGS_
|
||||
GstBuffer *buf1, GstBuffer *buf2);
|
||||
GstBuffer* gst_buffer_span_loc (GST_WHERE_ARGS_
|
||||
GstBuffer *buf1,guint32 offset,GstBuffer *buf2,guint32 len);
|
||||
GstBuffer* gst_buffer_append_loc (GST_WHERE_ARGS_
|
||||
GstBuffer *buf, GstBuffer *buf2);
|
||||
GstBuffer* gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2);
|
||||
GstBuffer* gst_buffer_span (GstBuffer *buf1,guint32 offset,GstBuffer *buf2,guint32 len);
|
||||
GstBuffer* gst_buffer_append (GstBuffer *buf, GstBuffer *buf2);
|
||||
|
||||
gboolean gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2);
|
||||
|
||||
|
|
|
@ -66,13 +66,14 @@ static xmlNodePtr gst_element_save_thyself (GstObject *object, xmlNodePtr paren
|
|||
GstElement* gst_element_restore_thyself (xmlNodePtr self, GstObject *parent);
|
||||
#endif
|
||||
|
||||
GType _gst_element_type = 0;
|
||||
|
||||
static GstObjectClass *parent_class = NULL;
|
||||
static guint gst_element_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GType gst_element_get_type(void) {
|
||||
static GType element_type = 0;
|
||||
|
||||
if (!element_type) {
|
||||
GType gst_element_get_type (void)
|
||||
{
|
||||
if (!_gst_element_type) {
|
||||
static const GTypeInfo element_info = {
|
||||
sizeof(GstElementClass),
|
||||
(GBaseInitFunc)gst_element_base_class_init,
|
||||
|
@ -84,9 +85,9 @@ GType gst_element_get_type(void) {
|
|||
0,
|
||||
(GInstanceInitFunc)gst_element_init,
|
||||
};
|
||||
element_type = g_type_register_static(GST_TYPE_OBJECT, "GstElement", &element_info, G_TYPE_FLAG_ABSTRACT);
|
||||
_gst_element_type = g_type_register_static(GST_TYPE_OBJECT, "GstElement", &element_info, G_TYPE_FLAG_ABSTRACT);
|
||||
}
|
||||
return element_type;
|
||||
return _gst_element_type;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -73,16 +73,22 @@ typedef enum {
|
|||
#define GST_STATE_PAUSED_TO_READY ((GST_STATE_PAUSED<<8) | GST_STATE_READY)
|
||||
#define GST_STATE_READY_TO_NULL ((GST_STATE_READY<<8) | GST_STATE_NULL)
|
||||
|
||||
#define GST_TYPE_ELEMENT \
|
||||
(gst_element_get_type())
|
||||
#define GST_ELEMENT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ELEMENT,GstElement))
|
||||
#define GST_ELEMENT_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ELEMENT,GstElementClass))
|
||||
#define GST_IS_ELEMENT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ELEMENT))
|
||||
#define GST_IS_ELEMENT_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ELEMENT))
|
||||
extern GType _gst_element_type;
|
||||
|
||||
#define GST_TYPE_ELEMENT (_gst_element_type)
|
||||
|
||||
#define GST_ELEMENT_FAST(obj) ((GstElement*)(obj))
|
||||
#define GST_ELEMENT_CLASS_FAST(klass) ((GstElementClass*)(klass))
|
||||
#define GST_IS_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_ELEMENT))
|
||||
#define GST_IS_ELEMENT_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_ELEMENT))
|
||||
|
||||
#ifdef GST_TYPE_PARANOID
|
||||
# define GST_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_ELEMENT, GstElement))
|
||||
# define GST_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_ELEMENT, GstElementClass))
|
||||
#else
|
||||
# define GST_ELEMENT GST_ELEMENT_FAST
|
||||
# define GST_ELEMENT_CLASS GST_ELEMENT_CLASS_FAST
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
/* element is complex (for some def.) and generally require a cothread */
|
||||
|
@ -124,7 +130,7 @@ typedef enum {
|
|||
#define GST_ELEMENT_MANAGER(obj) (((GstElement*)(obj))->manager)
|
||||
#define GST_ELEMENT_SCHED(obj) (((GstElement*)(obj))->sched)
|
||||
#define GST_ELEMENT_PADS(obj) ((obj)->pads)
|
||||
#define GST_ELEMENT_DPARAM_MANAGER(obj) ((obj)->dpman)
|
||||
#define GST_ELEMENT_DPARAM_MANAGER(obj) ((obj)->dpman)
|
||||
|
||||
//typedef struct _GstElement GstElement;
|
||||
//typedef struct _GstElementClass GstElementClass;
|
||||
|
@ -134,33 +140,34 @@ typedef struct _GstElementFactoryClass GstElementFactoryClass;
|
|||
typedef void (*GstElementLoopFunction) (GstElement *element);
|
||||
|
||||
struct _GstElement {
|
||||
GstObject object;
|
||||
|
||||
guint8 current_state;
|
||||
guint8 pending_state;
|
||||
GstObject object;
|
||||
|
||||
/* element state and scheduling */
|
||||
guint8 current_state;
|
||||
guint8 pending_state;
|
||||
GstElement *manager;
|
||||
GstSchedule *sched;
|
||||
GstElementLoopFunction loopfunc;
|
||||
cothread_state *threadstate;
|
||||
GstPad *select_pad;
|
||||
cothread_state *threadstate;
|
||||
|
||||
guint16 numpads;
|
||||
guint16 numsrcpads;
|
||||
guint16 numsinkpads;
|
||||
GList *pads;
|
||||
/* element pads */
|
||||
guint16 numpads;
|
||||
guint16 numsrcpads;
|
||||
guint16 numsinkpads;
|
||||
GList *pads;
|
||||
GstPad *select_pad;
|
||||
|
||||
GstElement *manager;
|
||||
GstSchedule *sched;
|
||||
GstDParamManager *dpman;
|
||||
GstDParamManager *dpman;
|
||||
};
|
||||
|
||||
struct _GstElementClass {
|
||||
GstObjectClass parent_class;
|
||||
GstObjectClass parent_class;
|
||||
|
||||
/* the elementfactory that created us */
|
||||
GstElementFactory *elementfactory;
|
||||
GstElementFactory *elementfactory;
|
||||
/* templates for our pads */
|
||||
GList *padtemplates;
|
||||
gint numpadtemplates;
|
||||
GList *padtemplates;
|
||||
gint numpadtemplates;
|
||||
|
||||
/* signal callbacks */
|
||||
void (*state_change) (GstElement *element,GstElementState state);
|
||||
|
@ -172,8 +179,8 @@ struct _GstElementClass {
|
|||
void (*eos) (GstElement *element);
|
||||
|
||||
/* local pointers for get/set */
|
||||
void (*set_property) (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||
void (*get_property) (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||
void (*set_property) (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||
void (*get_property) (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||
|
||||
/* change the element state */
|
||||
GstElementStateReturn (*change_state) (GstElement *element);
|
||||
|
@ -247,16 +254,13 @@ struct _GstElementDetails {
|
|||
gchar *copyright; /* copyright details (year, etc.) */
|
||||
};
|
||||
|
||||
#define GST_TYPE_ELEMENTFACTORY \
|
||||
(gst_elementfactory_get_type())
|
||||
#define GST_ELEMENTFACTORY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ELEMENTFACTORY,GstElementFactory))
|
||||
#define GST_ELEMENTFACTORY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ELEMENTFACTORY,GstElementFactoryClass))
|
||||
#define GST_IS_ELEMENTFACTORY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ELEMENTFACTORY))
|
||||
#define GST_IS_ELEMENTFACTORY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ELEMENTFACTORY))
|
||||
#define GST_TYPE_ELEMENTFACTORY (gst_elementfactory_get_type())
|
||||
#define GST_ELEMENTFACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ELEMENTFACTORY,\
|
||||
GstElementFactory))
|
||||
#define GST_ELEMENTFACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ELEMENTFACTORY,\
|
||||
GstElementFactoryClass))
|
||||
#define GST_IS_ELEMENTFACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ELEMENTFACTORY))
|
||||
#define GST_IS_ELEMENTFACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ELEMENTFACTORY))
|
||||
|
||||
struct _GstElementFactory {
|
||||
GstPluginFeature feature;
|
||||
|
|
|
@ -459,6 +459,8 @@ gst_default_error_handler (gchar *file, gchar *function,
|
|||
|
||||
/***** DEBUG system *****/
|
||||
GHashTable *__gst_function_pointers = NULL;
|
||||
// FIXME make this thread specific
|
||||
static GSList* stack_trace = NULL;
|
||||
|
||||
gchar *_gst_debug_nameof_funcptr (void *ptr) __attribute__ ((no_instrument_function));
|
||||
|
||||
|
@ -479,15 +481,52 @@ _gst_debug_nameof_funcptr (void *ptr)
|
|||
|
||||
|
||||
#ifdef GST_ENABLE_FUNC_INSTRUMENTATION
|
||||
|
||||
void __cyg_profile_func_enter(void *this_fn,void *call_site) __attribute__ ((no_instrument_function));
|
||||
void __cyg_profile_func_enter(void *this_fn,void *call_site) {
|
||||
GST_DEBUG(GST_CAT_CALL_TRACE, "entering function %s\n", _gst_debug_nameof_funcptr (this_fn));
|
||||
void __cyg_profile_func_enter(void *this_fn,void *call_site)
|
||||
{
|
||||
gchar *name = _gst_debug_nameof_funcptr (this_fn);
|
||||
gchar *site = _gst_debug_nameof_funcptr (call_site);
|
||||
|
||||
GST_DEBUG(GST_CAT_CALL_TRACE, "entering function %s from %s\n", name, site);
|
||||
stack_trace = g_slist_prepend (stack_trace, g_strdup_printf ("%8p in %s from %p (%s)", this_fn, name, call_site, site));
|
||||
|
||||
g_free (name);
|
||||
g_free (site);
|
||||
}
|
||||
|
||||
void __cyg_profile_func_exit(void *this_fn,void *call_site) __attribute__ ((no_instrument_function));
|
||||
void __cyg_profile_func_exit(void *this_fn,void *call_site) {
|
||||
GST_DEBUG(GST_CAT_CALL_TRACE, "leavinging function %s\n", _gst_debug_nameof_funcptr (this_fn));
|
||||
void __cyg_profile_func_exit(void *this_fn,void *call_site)
|
||||
{
|
||||
gchar *name = _gst_debug_nameof_funcptr (this_fn);
|
||||
|
||||
GST_DEBUG(GST_CAT_CALL_TRACE, "leaving function %s\n", name);
|
||||
g_free (stack_trace->data);
|
||||
stack_trace = g_slist_delete_link (stack_trace, stack_trace);
|
||||
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
void
|
||||
gst_debug_print_stack_trace (void)
|
||||
{
|
||||
GSList *walk = stack_trace;
|
||||
gint count = 0;
|
||||
|
||||
if (walk)
|
||||
walk = g_slist_next (walk);
|
||||
|
||||
while (walk) {
|
||||
gchar *name = (gchar *) walk->data;
|
||||
|
||||
g_print ("#%-2d %s\n", count++, name);
|
||||
|
||||
walk = g_slist_next (walk);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
gst_debug_print_stack_trace (void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* GST_ENABLE_FUNC_INTSTRUMENTATION */
|
||||
|
|
|
@ -341,6 +341,8 @@ _gst_debug_register_funcptr (void *ptr, gchar *ptrname)
|
|||
|
||||
gchar *_gst_debug_nameof_funcptr (void *ptr);
|
||||
|
||||
void gst_debug_print_stack_trace (void);
|
||||
|
||||
|
||||
|
||||
#endif /* __GSTINFO_H__ */
|
||||
|
|
|
@ -43,6 +43,8 @@ enum {
|
|||
SO_LAST_SIGNAL
|
||||
};
|
||||
|
||||
GType _gst_object_type = 0;
|
||||
|
||||
typedef struct _GstSignalObject GstSignalObject;
|
||||
typedef struct _GstSignalObjectClass GstSignalObjectClass;
|
||||
|
||||
|
@ -65,9 +67,7 @@ static guint gst_object_signals[LAST_SIGNAL] = { 0 };
|
|||
GType
|
||||
gst_object_get_type (void)
|
||||
{
|
||||
static GType object_type = 0;
|
||||
|
||||
if (!object_type) {
|
||||
if (!_gst_object_type) {
|
||||
static const GTypeInfo object_info = {
|
||||
sizeof (GstObjectClass),
|
||||
NULL,
|
||||
|
@ -79,9 +79,9 @@ gst_object_get_type (void)
|
|||
32,
|
||||
(GInstanceInitFunc) gst_object_init,
|
||||
};
|
||||
object_type = g_type_register_static (G_TYPE_OBJECT, "GstObject", &object_info, G_TYPE_FLAG_ABSTRACT);
|
||||
_gst_object_type = g_type_register_static (G_TYPE_OBJECT, "GstObject", &object_info, G_TYPE_FLAG_ABSTRACT);
|
||||
}
|
||||
return object_type;
|
||||
return _gst_object_type;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -52,17 +52,22 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern GType _gst_object_type;
|
||||
|
||||
#define GST_TYPE_OBJECT \
|
||||
(gst_object_get_type())
|
||||
#define GST_OBJECT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OBJECT,GstObject))
|
||||
#define GST_OBJECT_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OBJECT,GstObjectClass))
|
||||
#define GST_IS_OBJECT(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OBJECT))
|
||||
#define GST_IS_OBJECT_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OBJECT))
|
||||
#define GST_TYPE_OBJECT (_gst_object_type)
|
||||
# define GST_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_OBJECT))
|
||||
# define GST_IS_OBJECT_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_OBJECT))
|
||||
|
||||
#define GST_OBJECT_FAST(obj) ((GstObject*)(obj))
|
||||
#define GST_OBJECT_CLASS_FAST(klass) ((GstObjectClass*)(klass))
|
||||
|
||||
#ifdef GST_TYPE_PARANOID
|
||||
# define GST_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_OBJECT, GstObject))
|
||||
# define GST_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_OBJECT, GstObjectClass))
|
||||
#else
|
||||
# define GST_OBJECT GST_OBJECT_FAST
|
||||
# define GST_OBJECT_CLASS GST_OBJECT_CLASS_FAST
|
||||
#endif
|
||||
|
||||
//typedef struct _GstObject GstObject;
|
||||
//typedef struct _GstObjectClass GstObjectClass;
|
||||
|
@ -76,30 +81,29 @@ typedef enum
|
|||
} GstObjectFlags;
|
||||
|
||||
struct _GstObject {
|
||||
GObject object;
|
||||
GObject object;
|
||||
|
||||
gchar *name;
|
||||
gchar *name;
|
||||
/* have to have a refcount for the object */
|
||||
#ifdef HAVE_ATOMIC_H
|
||||
atomic_t refcount;
|
||||
atomic_t refcount;
|
||||
#else
|
||||
int refcount;
|
||||
gint refcount;
|
||||
#endif
|
||||
|
||||
/* locking for all sorts of things (like the refcount) */
|
||||
GMutex *lock;
|
||||
|
||||
GMutex *lock;
|
||||
/* this objects parent */
|
||||
GstObject *parent;
|
||||
GstObject *parent;
|
||||
|
||||
guint32 flags;
|
||||
guint32 flags;
|
||||
};
|
||||
|
||||
struct _GstObjectClass {
|
||||
GObjectClass parent_class;
|
||||
|
||||
gchar *path_string_separator;
|
||||
GObject *signal_object;
|
||||
gchar *path_string_separator;
|
||||
GObject *signal_object;
|
||||
|
||||
/* signals */
|
||||
void (*parent_set) (GstObject *object, GstObject *parent);
|
||||
|
|
30
gst/gstpad.c
30
gst/gstpad.c
|
@ -29,6 +29,7 @@
|
|||
#include "gstbin.h"
|
||||
#include "gstscheduler.h"
|
||||
|
||||
GType _gst_pad_type = 0;
|
||||
|
||||
/***** Start with the base GstPad class *****/
|
||||
static void gst_pad_class_init (GstPadClass *klass);
|
||||
|
@ -41,10 +42,9 @@ static xmlNodePtr gst_pad_save_thyself (GstObject *object, xmlNodePtr parent);
|
|||
static GstObject *pad_parent_class = NULL;
|
||||
|
||||
GType
|
||||
gst_pad_get_type(void) {
|
||||
static GType pad_type = 0;
|
||||
|
||||
if (!pad_type) {
|
||||
gst_pad_get_type(void)
|
||||
{
|
||||
if (!_gst_pad_type) {
|
||||
static const GTypeInfo pad_info = {
|
||||
sizeof(GstPadClass),
|
||||
NULL,
|
||||
|
@ -56,9 +56,9 @@ gst_pad_get_type(void) {
|
|||
32,
|
||||
(GInstanceInitFunc)gst_pad_init,
|
||||
};
|
||||
pad_type = g_type_register_static(GST_TYPE_OBJECT, "GstPad", &pad_info, 0);
|
||||
_gst_pad_type = g_type_register_static(GST_TYPE_OBJECT, "GstPad", &pad_info, 0);
|
||||
}
|
||||
return pad_type;
|
||||
return _gst_pad_type;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -105,15 +105,14 @@ static void gst_real_pad_destroy (GObject *object);
|
|||
|
||||
static void gst_pad_push_func (GstPad *pad, GstBuffer *buf);
|
||||
|
||||
GType _gst_real_pad_type = 0;
|
||||
|
||||
static GstPad *real_pad_parent_class = NULL;
|
||||
static guint gst_real_pad_signals[REAL_LAST_SIGNAL] = { 0 };
|
||||
|
||||
GType
|
||||
gst_real_pad_get_type(void) {
|
||||
static GType pad_type = 0;
|
||||
|
||||
if (!pad_type) {
|
||||
if (!_gst_real_pad_type) {
|
||||
static const GTypeInfo pad_info = {
|
||||
sizeof(GstRealPadClass),
|
||||
NULL,
|
||||
|
@ -125,9 +124,9 @@ gst_real_pad_get_type(void) {
|
|||
32,
|
||||
(GInstanceInitFunc)gst_real_pad_init,
|
||||
};
|
||||
pad_type = g_type_register_static(GST_TYPE_PAD, "GstRealPad", &pad_info, 0);
|
||||
_gst_real_pad_type = g_type_register_static(GST_TYPE_PAD, "GstRealPad", &pad_info, 0);
|
||||
}
|
||||
return pad_type;
|
||||
return _gst_real_pad_type;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1838,6 +1837,7 @@ gst_pad_get_element_private (GstPad *pad)
|
|||
|
||||
|
||||
/***** ghost pads *****/
|
||||
GType _gst_ghost_pad_type = 0;
|
||||
|
||||
static void gst_ghost_pad_class_init (GstGhostPadClass *klass);
|
||||
static void gst_ghost_pad_init (GstGhostPad *pad);
|
||||
|
@ -1847,9 +1847,7 @@ static GstPad *ghost_pad_parent_class = NULL;
|
|||
|
||||
GType
|
||||
gst_ghost_pad_get_type(void) {
|
||||
static GType pad_type = 0;
|
||||
|
||||
if (!pad_type) {
|
||||
if (!_gst_ghost_pad_type) {
|
||||
static const GTypeInfo pad_info = {
|
||||
sizeof(GstGhostPadClass),
|
||||
NULL,
|
||||
|
@ -1861,9 +1859,9 @@ gst_ghost_pad_get_type(void) {
|
|||
8,
|
||||
(GInstanceInitFunc)gst_ghost_pad_init,
|
||||
};
|
||||
pad_type = g_type_register_static(GST_TYPE_PAD, "GstGhostPad", &pad_info, 0);
|
||||
_gst_ghost_pad_type = g_type_register_static(GST_TYPE_PAD, "GstGhostPad", &pad_info, 0);
|
||||
}
|
||||
return pad_type;
|
||||
return _gst_ghost_pad_type;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
63
gst/gstpad.h
63
gst/gstpad.h
|
@ -44,25 +44,70 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern GType _gst_pad_type;
|
||||
extern GType _gst_real_pad_type;
|
||||
extern GType _gst_ghost_pad_type;
|
||||
|
||||
#define GST_TYPE_PAD (gst_pad_get_type ())
|
||||
#define GST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad))
|
||||
#define GST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass))
|
||||
//#define GST_TYPE_PARANOID
|
||||
|
||||
/*
|
||||
* Pad base class
|
||||
*/
|
||||
#define GST_TYPE_PAD (_gst_pad_type)
|
||||
|
||||
#define GST_PAD_FAST(obj) ((GstPad*)(obj))
|
||||
#define GST_PAD_CLASS_FAST(klass) ((GstPadClass*)(klass))
|
||||
#define GST_IS_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD))
|
||||
#define GST_IS_PAD_FAST(obj) (G_OBJECT_TYPE(obj) == GST_TYPE_REAL_PAD || \
|
||||
G_OBJECT_TYPE(obj) == GST_TYPE_GHOST_PAD)
|
||||
#define GST_IS_PAD_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD))
|
||||
|
||||
#define GST_TYPE_REAL_PAD (gst_real_pad_get_type ())
|
||||
#define GST_REAL_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_REAL_PAD, GstRealPad))
|
||||
#define GST_REAL_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_REAL_PAD, GstRealPadClass))
|
||||
#ifdef GST_TYPE_PARANOID
|
||||
# define GST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad))
|
||||
# define GST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass))
|
||||
#else
|
||||
# define GST_PAD GST_PAD_FAST
|
||||
# define GST_PAD_CLASS GST_PAD_CLASS_FAST
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Real Pads
|
||||
*/
|
||||
#define GST_TYPE_REAL_PAD (_gst_real_pad_type)
|
||||
|
||||
#define GST_REAL_PAD_FAST(obj) ((GstRealPad*)(obj))
|
||||
#define GST_REAL_PAD_CLASS_FAST(klass) ((GstRealPadClass*)(klass))
|
||||
#define GST_IS_REAL_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_REAL_PAD))
|
||||
#define GST_IS_REAL_PAD_FAST(obj) (G_OBJECT_TYPE(obj) == GST_TYPE_REAL_PAD)
|
||||
#define GST_IS_REAL_PAD_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_REAL_PAD))
|
||||
|
||||
#define GST_TYPE_GHOST_PAD (gst_ghost_pad_get_type ())
|
||||
#define GST_GHOST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GHOST_PAD, GstGhostPad))
|
||||
#define GST_GHOST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GHOST_PAD, GstGhostPadClass))
|
||||
#ifdef GST_TYPE_PARANOID
|
||||
# define GST_REAL_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_REAL_PAD, GstRealPad))
|
||||
# define GST_REAL_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_REAL_PAD, GstRealPadClass))
|
||||
#else
|
||||
# define GST_REAL_PAD GST_REAL_PAD_FAST
|
||||
# define GST_REAL_PAD_CLASS GST_REAL_PAD_CLASS_FAST
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ghost Pads
|
||||
*/
|
||||
#define GST_TYPE_GHOST_PAD (_gst_ghost_pad_type)
|
||||
|
||||
#define GST_GHOST_PAD_FAST(obj) ((GstGhostPad*)(obj))
|
||||
#define GST_GHOST_PAD_CLASS_FAST(klass) ((GstGhostPadClass*)(klass))
|
||||
#define GST_IS_GHOST_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GHOST_PAD))
|
||||
#define GST_IS_GHOST_PAD_FAST(obj) (G_OBJECT_TYPE(obj) == GST_TYPE_GHOST_PAD)
|
||||
#define GST_IS_GHOST_PAD_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GHOST_PAD))
|
||||
|
||||
#ifdef GST_TYPE_PARANOID
|
||||
# define GST_GHOST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GHOST_PAD, GstGhostPad))
|
||||
# define GST_GHOST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GHOST_PAD, GstGhostPadClass))
|
||||
#else
|
||||
# define GST_GHOST_PAD GST_GHOST_PAD_FAST
|
||||
# define GST_GHOST_PAD_CLASS GST_GHOST_PAD_CLASS_FAST
|
||||
#endif
|
||||
|
||||
|
||||
//typedef struct _GstPad GstPad;
|
||||
//typedef struct _GstPadClass GstPadClass;
|
||||
|
|
|
@ -1419,11 +1419,11 @@ GST_DEBUG(GST_CAT_SCHEDULING,"there are %d elements in this chain\n",chain->num_
|
|||
|
||||
} else {
|
||||
GST_INFO (GST_CAT_DATAFLOW,"NO ENTRY INTO CHAIN!");
|
||||
//eos = TRUE;
|
||||
eos = TRUE;
|
||||
}
|
||||
} else {
|
||||
GST_INFO (GST_CAT_DATAFLOW,"NO ENABLED ELEMENTS IN CHAIN!!");
|
||||
//eos = TRUE;
|
||||
eos = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -33,10 +33,10 @@
|
|||
*
|
||||
* Returns: a new #GstByteStream object
|
||||
*/
|
||||
GstByteStream*
|
||||
gst_bytestream_new (GstPad *pad)
|
||||
GstByteStream *
|
||||
gst_bytestream_new (GstPad * pad)
|
||||
{
|
||||
GstByteStream *bs = g_new(GstByteStream, 1);
|
||||
GstByteStream *bs = g_new (GstByteStream, 1);
|
||||
|
||||
bs->pad = pad;
|
||||
bs->data = NULL;
|
||||
|
@ -47,37 +47,37 @@ gst_bytestream_new (GstPad *pad)
|
|||
}
|
||||
|
||||
void
|
||||
gst_bytestream_destroy (GstByteStream *bs)
|
||||
gst_bytestream_destroy (GstByteStream * bs)
|
||||
{
|
||||
if (bs->data) {
|
||||
g_free(bs->data);
|
||||
g_free (bs->data);
|
||||
}
|
||||
g_free(bs);
|
||||
g_free (bs);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_bytestream_bytes_fill (GstByteStream *bs, guint64 len)
|
||||
static void
|
||||
gst_bytestream_bytes_fill (GstByteStream * bs, guint64 len)
|
||||
{
|
||||
size_t oldlen;
|
||||
GstBuffer *buf;
|
||||
|
||||
while ((bs->index + len) > bs->size) {
|
||||
buf = gst_pad_pull(bs->pad);
|
||||
buf = gst_pad_pull (bs->pad);
|
||||
oldlen = bs->size - bs->index;
|
||||
memmove(bs->data, bs->data + bs->index, oldlen);
|
||||
bs->size = oldlen + GST_BUFFER_SIZE(buf);
|
||||
memmove (bs->data, bs->data + bs->index, oldlen);
|
||||
bs->size = oldlen + GST_BUFFER_SIZE (buf);
|
||||
bs->index = 0;
|
||||
bs->data = realloc(bs->data, bs->size);
|
||||
bs->data = realloc (bs->data, bs->size);
|
||||
if (!bs->data) {
|
||||
fprintf(stderr, "realloc failed: d:%p s:%d\n", bs->data, bs->size);
|
||||
fprintf (stderr, "realloc failed: d:%p s:%d\n", bs->data, bs->size);
|
||||
}
|
||||
memcpy(bs->data + oldlen, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
|
||||
memcpy (bs->data + oldlen, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
}
|
||||
g_assert ((bs->index + len) <= bs->size);
|
||||
}
|
||||
|
||||
guint8*
|
||||
gst_bytestream_bytes_peek (GstByteStream *bs, guint64 len)
|
||||
guint8 *
|
||||
gst_bytestream_bytes_peek (GstByteStream * bs, guint64 len)
|
||||
{
|
||||
g_return_val_if_fail (len > 0, NULL);
|
||||
|
||||
|
@ -86,29 +86,28 @@ gst_bytestream_bytes_peek (GstByteStream *bs, guint64 len)
|
|||
return gst_bytestream_pos (bs);
|
||||
}
|
||||
|
||||
guint8*
|
||||
gst_bytestream_bytes_read (GstByteStream *bs, guint64 len)
|
||||
guint8 *
|
||||
gst_bytestream_bytes_read (GstByteStream * bs, guint64 len)
|
||||
{
|
||||
guint8 *ptr;
|
||||
|
||||
g_return_val_if_fail (len > 0, NULL);
|
||||
|
||||
gst_bytestream_bytes_fill(bs, len);
|
||||
ptr = gst_bytestream_pos(bs);
|
||||
gst_bytestream_bytes_fill (bs, len);
|
||||
ptr = gst_bytestream_pos (bs);
|
||||
bs->index += len;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_bytestream_bytes_seek (GstByteStream *bs, guint64 offset)
|
||||
gst_bytestream_bytes_seek (GstByteStream * bs, guint64 offset)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gst_bytestream_bytes_flush (GstByteStream *bs, guint64 len)
|
||||
gst_bytestream_bytes_flush (GstByteStream * bs, guint64 len)
|
||||
{
|
||||
gst_bytestream_bytes_read(bs, len);
|
||||
gst_bytestream_bytes_read (bs, len);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,10 +43,10 @@ struct _GstByteStream
|
|||
GstByteStream* gst_bytestream_new (GstPad *pad);
|
||||
void gst_bytestream_destroy (GstByteStream *bs);
|
||||
|
||||
guint8* gst_bytestream_bytes_peek (GstByteStream *bs, guint64 len);
|
||||
guint8* gst_bytestream_bytes_read (GstByteStream *bs, guint64 len);
|
||||
gint gst_bytestream_bytes_peek (GstByteStream *bs, guint8 **buf, guint64 len);
|
||||
gint gst_bytestream_bytes_read (GstByteStream *bs, guint8 **buf, guint64 len);
|
||||
gboolean gst_bytestream_bytes_seek (GstByteStream *bs, guint64 offset);
|
||||
void gst_bytestream_bytes_flush (GstByteStream *bs, guint64 len);
|
||||
gint gst_bytestream_bytes_flush (GstByteStream *bs, guint64 len);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -41,7 +41,7 @@ noinst_HEADERS = \
|
|||
gstaggregator.h \
|
||||
gstsinesrc.h
|
||||
|
||||
CFLAGS += -O2 -Wall
|
||||
CFLAGS += -O2 -Wall -finstrument-functions -DGST_ENABLE_FUNC_INSTRUMENTATION
|
||||
LDFLAGS += -lm
|
||||
|
||||
libgstelements_la_LIBADD = $(GHTTP_LIBS)
|
||||
|
|
|
@ -64,8 +64,8 @@ static void gst_disksrc_set_property (GObject *object, guint prop_id,
|
|||
static void gst_disksrc_get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec);
|
||||
|
||||
static GstBuffer * gst_disksrc_get (GstPad *pad);
|
||||
static GstBuffer * gst_disksrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);
|
||||
static GstBuffer* gst_disksrc_get (GstPad *pad);
|
||||
static GstBufferPool* gst_disksrc_get_bufferpool (GstPad *pad);
|
||||
|
||||
static GstElementStateReturn
|
||||
gst_disksrc_change_state (GstElement *element);
|
||||
|
@ -73,7 +73,7 @@ static GstElementStateReturn
|
|||
static gboolean gst_disksrc_open_file (GstDiskSrc *src);
|
||||
static void gst_disksrc_close_file (GstDiskSrc *src);
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
static GstElementClass* parent_class = NULL;
|
||||
//static guint gst_disksrc_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GType
|
||||
|
@ -133,8 +133,8 @@ gst_disksrc_init (GstDiskSrc *disksrc)
|
|||
// GST_FLAG_SET (disksrc, GST_SRC_);
|
||||
|
||||
disksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||
gst_pad_set_get_function (disksrc->srcpad,gst_disksrc_get);
|
||||
gst_pad_set_getregion_function (disksrc->srcpad,gst_disksrc_get_region);
|
||||
gst_pad_set_get_function (disksrc->srcpad, gst_disksrc_get);
|
||||
gst_pad_set_bufferpool_function (disksrc->srcpad, gst_disksrc_get_bufferpool);
|
||||
gst_element_add_pad (GST_ELEMENT (disksrc), disksrc->srcpad);
|
||||
|
||||
disksrc->filename = NULL;
|
||||
|
@ -220,6 +220,56 @@ gst_disksrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
|
|||
}
|
||||
}
|
||||
|
||||
static GstBuffer*
|
||||
gst_disksrc_buffer_new (GstBufferPool *pool, gint64 location, gint size, gpointer user_data)
|
||||
{
|
||||
GstDiskSrc *src;
|
||||
GstBuffer *buf;
|
||||
|
||||
src = GST_DISKSRC (user_data);
|
||||
|
||||
buf = gst_buffer_new ();
|
||||
g_return_val_if_fail (buf != NULL, NULL);
|
||||
|
||||
/* simply set the buffer to point to the correct region of the file */
|
||||
GST_BUFFER_DATA (buf) = src->map + location;
|
||||
GST_BUFFER_OFFSET (buf) = location;
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
|
||||
|
||||
if ((location + size) > src->size)
|
||||
GST_BUFFER_SIZE (buf) = src->size - location;
|
||||
else
|
||||
GST_BUFFER_SIZE (buf) = size;
|
||||
|
||||
GST_DEBUG (0,"map %p, offset %ld (%p), size %d\n", src->map, src->curoffset,
|
||||
src->map + src->curoffset, GST_BUFFER_SIZE (buf));
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_disksrc_buffer_free (GstBuffer *buf)
|
||||
{
|
||||
// FIXME do something here
|
||||
}
|
||||
|
||||
static GstBufferPool*
|
||||
gst_disksrc_get_bufferpool (GstPad *pad)
|
||||
{
|
||||
GstDiskSrc *src;
|
||||
|
||||
src = GST_DISKSRC (gst_pad_get_parent (pad));
|
||||
|
||||
if (!src->bufferpool) {
|
||||
src->bufferpool = gst_buffer_pool_new ();
|
||||
gst_buffer_pool_set_buffer_new_function (src->bufferpool, gst_disksrc_buffer_new);
|
||||
gst_buffer_pool_set_buffer_free_function (src->bufferpool, gst_disksrc_buffer_free);
|
||||
gst_buffer_pool_set_user_data (src->bufferpool, src);
|
||||
}
|
||||
|
||||
return src->bufferpool;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_disksrc_get:
|
||||
* @pad: #GstPad to push a buffer from
|
||||
|
@ -246,28 +296,10 @@ gst_disksrc_get (GstPad *pad)
|
|||
return buf;
|
||||
}
|
||||
|
||||
/* create the buffer */
|
||||
// FIXME: should eventually use a bufferpool for this
|
||||
buf = gst_buffer_new ();
|
||||
|
||||
g_return_val_if_fail (buf != NULL, NULL);
|
||||
|
||||
/* simply set the buffer to point to the correct region of the file */
|
||||
GST_BUFFER_DATA (buf) = src->map + src->curoffset;
|
||||
GST_BUFFER_OFFSET (buf) = src->curoffset;
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
|
||||
|
||||
if ((src->curoffset + src->bytes_per_read) > src->size) {
|
||||
GST_BUFFER_SIZE (buf) = src->size - src->curoffset;
|
||||
// FIXME: set the buffer's EOF bit here
|
||||
} else
|
||||
GST_BUFFER_SIZE (buf) = src->bytes_per_read;
|
||||
|
||||
GST_DEBUG (0,"map %p, offset %ld (%p), size %d\n", src->map, src->curoffset,
|
||||
src->map + src->curoffset, GST_BUFFER_SIZE (buf));
|
||||
// FIXME use a bufferpool
|
||||
buf = gst_disksrc_buffer_new (NULL, src->curoffset, src->bytes_per_read, src);
|
||||
|
||||
//gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
|
||||
src->curoffset += GST_BUFFER_SIZE (buf);
|
||||
|
||||
if (src->new_seek) {
|
||||
|
@ -280,61 +312,6 @@ gst_disksrc_get (GstPad *pad)
|
|||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_disksrc_get_region:
|
||||
* @src: #GstSrc to push a buffer from
|
||||
* @offset: offset in file
|
||||
* @size: number of bytes
|
||||
*
|
||||
* Push a new buffer from the disksrc of given size at given offset.
|
||||
*/
|
||||
static GstBuffer *
|
||||
gst_disksrc_get_region (GstPad *pad, GstRegionType type,guint64 offset,guint64 len)
|
||||
{
|
||||
GstDiskSrc *src;
|
||||
GstBuffer *buf;
|
||||
|
||||
g_return_val_if_fail (pad != NULL, NULL);
|
||||
g_return_val_if_fail (type == GST_REGION_OFFSET_LEN, NULL);
|
||||
|
||||
src = GST_DISKSRC (gst_pad_get_parent (pad));
|
||||
|
||||
g_return_val_if_fail (GST_IS_DISKSRC (src), NULL);
|
||||
g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_DISKSRC_OPEN), NULL);
|
||||
|
||||
/* deal with EOF state */
|
||||
if (offset >= src->size) {
|
||||
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
|
||||
GST_DEBUG (0,"map offset %lld >= size %ld --> eos\n", offset, src->size);
|
||||
//FIXME
|
||||
buf = gst_buffer_new();
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* create the buffer */
|
||||
// FIXME: should eventually use a bufferpool for this
|
||||
buf = gst_buffer_new ();
|
||||
g_return_val_if_fail (buf != NULL, NULL);
|
||||
|
||||
/* simply set the buffer to point to the correct region of the file */
|
||||
GST_BUFFER_DATA (buf) = src->map + offset;
|
||||
GST_BUFFER_OFFSET (buf) = offset;
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_DONTFREE);
|
||||
|
||||
if ((offset + len) > src->size) {
|
||||
GST_BUFFER_SIZE (buf) = src->size - offset;
|
||||
// FIXME: set the buffer's EOF bit here
|
||||
} else
|
||||
GST_BUFFER_SIZE (buf) = len;
|
||||
|
||||
GST_DEBUG (0,"map %p, offset %lld, size %d\n", src->map, offset, GST_BUFFER_SIZE (buf));
|
||||
|
||||
/* we're done, return the buffer off now */
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/* open the file and mmap it, necessary to go to READY state */
|
||||
static gboolean
|
||||
gst_disksrc_open_file (GstDiskSrc *src)
|
||||
|
|
|
@ -64,6 +64,7 @@ struct _GstDiskSrc {
|
|||
gchar *filename;
|
||||
/* fd */
|
||||
gint fd;
|
||||
GstBufferPool *bufferpool;
|
||||
|
||||
/* mapping parameters */
|
||||
gulong size; /* how long is the file? */
|
||||
|
|
|
@ -225,6 +225,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
|
|||
|
||||
if (GST_IS_EVENT(buf)) {
|
||||
g_print("fakesink: have event!\n");
|
||||
gst_element_set_state (GST_ELEMENT (fakesink), GST_STATE_PAUSED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -335,7 +335,8 @@ gst_fakesrc_get(GstPad *pad)
|
|||
|
||||
if (src->num_buffers == 0) {
|
||||
g_print("fakesrc: sending EOS\n");
|
||||
return GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS));
|
||||
gst_element_set_state (GST_ELEMENT (src), GST_STATE_PAUSED);
|
||||
return GST_BUFFER(gst_event_new (GST_EVENT_EOS));
|
||||
}
|
||||
else {
|
||||
if (src->num_buffers > 0)
|
||||
|
@ -345,7 +346,7 @@ gst_fakesrc_get(GstPad *pad)
|
|||
if (src->eos) {
|
||||
GST_INFO (0, "fakesrc is setting eos on pad");
|
||||
g_print("fakesrc: sending EOS\n");
|
||||
return GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS));
|
||||
return GST_BUFFER(gst_event_new (GST_EVENT_EOS));
|
||||
}
|
||||
|
||||
buf = gst_buffer_new();
|
||||
|
@ -397,7 +398,7 @@ gst_fakesrc_loop(GstElement *element)
|
|||
|
||||
if (src->eos) {
|
||||
GST_INFO (0, "fakesrc is setting eos on pad");
|
||||
gst_pad_push(pad, GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS)));
|
||||
gst_pad_push(pad, GST_BUFFER(gst_event_new (GST_EVENT_EOS)));
|
||||
}
|
||||
|
||||
buf = gst_buffer_new();
|
||||
|
|
|
@ -596,6 +596,7 @@ gst_filesrc_close_file (GstFileSrc *src)
|
|||
{
|
||||
g_return_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN));
|
||||
|
||||
g_print ("close\n");
|
||||
/* close the file */
|
||||
close (src->fd);
|
||||
|
||||
|
|
Loading…
Reference in a new issue