2003-10-28 20:25:30 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
|
|
|
*
|
|
|
|
* gstbufferstore.c: keep an easily accessible list of all buffers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
#include "gstbufferstore.h"
|
2004-01-08 04:10:18 +00:00
|
|
|
#include <gst/gstutils.h>
|
2003-10-28 20:25:30 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_buffer_store_debug);
|
2003-10-28 20:25:30 +00:00
|
|
|
#define GST_CAT_DEFAULT gst_buffer_store_debug
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-10-28 20:25:30 +00:00
|
|
|
CLEARED,
|
|
|
|
BUFFER_ADDED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-10-28 20:25:30 +00:00
|
|
|
ARG_0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_buffer_store_dispose (GObject * object);
|
|
|
|
|
|
|
|
static gboolean gst_buffer_store_add_buffer_func (GstBufferStore * store,
|
|
|
|
GstBuffer * buffer);
|
|
|
|
static void gst_buffer_store_cleared_func (GstBufferStore * store);
|
2003-10-28 20:25:30 +00:00
|
|
|
|
|
|
|
static guint gst_buffer_store_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2004-01-11 18:23:48 +00:00
|
|
|
#define _do_init(bla) \
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_buffer_store_debug, "GstBufferStore", 0, "buffer store helper");
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_BOILERPLATE_FULL (GstBufferStore, gst_buffer_store, GObject, G_TYPE_OBJECT,
|
|
|
|
_do_init);
|
2004-01-08 04:10:18 +00:00
|
|
|
|
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
G_GNUC_UNUSED static void
|
2004-03-13 15:27:01 +00:00
|
|
|
debug_buffers (GstBufferStore * store)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
GList *walk = store->buffers;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
g_printerr ("BUFFERS in store:\n");
|
|
|
|
while (walk) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_print ("%15" G_GUINT64_FORMAT " - %7u\n", GST_BUFFER_OFFSET (walk->data),
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_BUFFER_SIZE (walk->data));
|
2003-10-28 20:25:30 +00:00
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
g_printerr ("\n");
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
continue_accu (GSignalInvocationHint * ihint, GValue * return_accu,
|
|
|
|
const GValue * handler_return, gpointer data)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
gboolean do_continue = g_value_get_boolean (handler_return);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
g_value_set_boolean (return_accu, do_continue);
|
|
|
|
|
|
|
|
return do_continue;
|
|
|
|
}
|
|
|
|
static void
|
2004-01-08 04:10:18 +00:00
|
|
|
gst_buffer_store_base_init (gpointer g_class)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
2004-01-08 04:10:18 +00:00
|
|
|
}
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_buffer_store_class_init (GstBufferStoreClass * store_class)
|
2004-01-08 04:10:18 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (store_class);
|
2003-10-28 20:25:30 +00:00
|
|
|
|
|
|
|
gobject_class->dispose = gst_buffer_store_dispose;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
gst_buffer_store_signals[CLEARED] = g_signal_new ("cleared",
|
|
|
|
G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstBufferStoreClass, cleared), NULL, NULL,
|
|
|
|
gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
|
|
|
gst_buffer_store_signals[BUFFER_ADDED] = g_signal_new ("buffer-added",
|
|
|
|
G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GstBufferStoreClass, buffer_added), continue_accu, NULL,
|
|
|
|
gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_BUFFER);
|
2003-10-28 20:25:30 +00:00
|
|
|
|
|
|
|
store_class->cleared = gst_buffer_store_cleared_func;
|
|
|
|
store_class->buffer_added = gst_buffer_store_add_buffer_func;
|
|
|
|
}
|
|
|
|
static void
|
2005-08-28 17:45:58 +00:00
|
|
|
gst_buffer_store_init (GstBufferStore * store, GstBufferStoreClass * g_class)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
store->buffers = NULL;
|
|
|
|
}
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_buffer_store_dispose (GObject * object)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
GstBufferStore *store = GST_BUFFER_STORE (object);
|
|
|
|
|
|
|
|
gst_buffer_store_clear (store);
|
|
|
|
|
|
|
|
parent_class->dispose (object);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
g_assert (buffer != NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
if (!GST_BUFFER_OFFSET_IS_VALID (buffer) &&
|
2004-03-13 15:27:01 +00:00
|
|
|
store->buffers && GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
|
2003-10-28 20:25:30 +00:00
|
|
|
/* we assumed valid offsets, but suddenly they are not anymore */
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG_OBJECT (store,
|
2004-03-15 19:27:17 +00:00
|
|
|
"attempting to add buffer %p with invalid offset to store with valid offset, abort",
|
|
|
|
buffer);
|
2003-10-28 20:25:30 +00:00
|
|
|
return FALSE;
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!store->buffers
|
|
|
|
|| !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
|
2003-10-28 20:25:30 +00:00
|
|
|
/* the starting buffer had an invalid offset, in that case we assume continuous buffers */
|
|
|
|
GST_LOG_OBJECT (store, "adding buffer %p with invalid offset and size %u",
|
2004-03-15 19:27:17 +00:00
|
|
|
buffer, GST_BUFFER_SIZE (buffer));
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
gst_mini_object_ref (GST_MINI_OBJECT (buffer));
|
2003-10-28 20:25:30 +00:00
|
|
|
store->buffers = g_list_append (store->buffers, buffer);
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
/* both list and buffer have valid offsets, we can really go wild */
|
|
|
|
GList *walk, *current_list = NULL;
|
|
|
|
GstBuffer *current;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
g_assert (GST_BUFFER_OFFSET_IS_VALID (buffer));
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_LOG_OBJECT (store,
|
2004-03-15 19:27:17 +00:00
|
|
|
"attempting to add buffer %p with offset %" G_GUINT64_FORMAT
|
|
|
|
" and size %u", buffer, GST_BUFFER_OFFSET (buffer),
|
|
|
|
GST_BUFFER_SIZE (buffer));
|
2003-10-28 20:25:30 +00:00
|
|
|
/* we keep a sorted list of non-overlapping buffers */
|
|
|
|
walk = store->buffers;
|
|
|
|
while (walk) {
|
|
|
|
current = GST_BUFFER (walk->data);
|
|
|
|
current_list = walk;
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
if (GST_BUFFER_OFFSET (current) < GST_BUFFER_OFFSET (buffer)) {
|
2004-03-15 19:27:17 +00:00
|
|
|
continue;
|
2003-10-28 20:25:30 +00:00
|
|
|
} else if (GST_BUFFER_OFFSET (current) == GST_BUFFER_OFFSET (buffer)) {
|
2004-03-15 19:27:17 +00:00
|
|
|
guint needed_size;
|
|
|
|
|
|
|
|
if (walk) {
|
|
|
|
needed_size = MIN (GST_BUFFER_SIZE (buffer),
|
|
|
|
GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current));
|
|
|
|
} else {
|
|
|
|
needed_size = GST_BUFFER_SIZE (buffer);
|
|
|
|
}
|
|
|
|
if (needed_size <= GST_BUFFER_SIZE (current)) {
|
|
|
|
buffer = NULL;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
if (needed_size < GST_BUFFER_SIZE (buffer)) {
|
|
|
|
/* need to create subbuffer to not have overlapping data */
|
|
|
|
GstBuffer *sub = gst_buffer_create_sub (buffer, 0, needed_size);
|
|
|
|
|
|
|
|
g_assert (sub);
|
|
|
|
buffer = sub;
|
|
|
|
} else {
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
gst_mini_object_ref (GST_MINI_OBJECT (buffer));
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
/* replace current buffer with new one */
|
|
|
|
GST_INFO_OBJECT (store,
|
|
|
|
"replacing buffer %p with buffer %p with offset %" G_GINT64_FORMAT
|
|
|
|
" and size %u", current_list->data, buffer,
|
|
|
|
GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
gst_mini_object_unref (GST_MINI_OBJECT (current_list->data));
|
2004-03-15 19:27:17 +00:00
|
|
|
current_list->data = buffer;
|
|
|
|
buffer = NULL;
|
|
|
|
break;
|
|
|
|
}
|
2003-10-28 20:25:30 +00:00
|
|
|
} else if (GST_BUFFER_OFFSET (current) > GST_BUFFER_OFFSET (buffer)) {
|
2004-03-15 19:27:17 +00:00
|
|
|
GList *previous = g_list_previous (current_list);
|
|
|
|
guint64 start_offset = previous ?
|
|
|
|
GST_BUFFER_OFFSET (previous->data) +
|
|
|
|
GST_BUFFER_SIZE (previous->data) : 0;
|
|
|
|
|
|
|
|
if (start_offset == GST_BUFFER_OFFSET (current)) {
|
|
|
|
buffer = NULL;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
/* we have data to insert */
|
|
|
|
if (start_offset > GST_BUFFER_OFFSET (buffer) ||
|
|
|
|
GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) >
|
|
|
|
GST_BUFFER_OFFSET (current)) {
|
|
|
|
GstBuffer *sub;
|
|
|
|
|
|
|
|
/* need a subbuffer */
|
|
|
|
start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 :
|
|
|
|
start_offset - GST_BUFFER_OFFSET (buffer);
|
|
|
|
sub = gst_buffer_create_sub (buffer, start_offset,
|
2004-11-30 23:45:36 +00:00
|
|
|
MIN (GST_BUFFER_SIZE (buffer) - start_offset,
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_BUFFER_OFFSET (current) - start_offset -
|
|
|
|
GST_BUFFER_OFFSET (buffer)));
|
|
|
|
g_assert (sub);
|
|
|
|
GST_BUFFER_OFFSET (sub) = start_offset + GST_BUFFER_OFFSET (buffer);
|
|
|
|
buffer = sub;
|
|
|
|
} else {
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
gst_mini_object_ref (GST_MINI_OBJECT (buffer));
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
GST_INFO_OBJECT (store,
|
|
|
|
"adding buffer %p with offset %" G_GINT64_FORMAT " and size %u",
|
|
|
|
buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
|
|
|
|
store->buffers =
|
|
|
|
g_list_insert_before (store->buffers, current_list, buffer);
|
|
|
|
buffer = NULL;
|
|
|
|
break;
|
|
|
|
}
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (buffer) {
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
gst_mini_object_ref (GST_MINI_OBJECT (buffer));
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_INFO_OBJECT (store,
|
2004-03-15 19:27:17 +00:00
|
|
|
"adding buffer %p with offset %" G_GINT64_FORMAT " and size %u",
|
|
|
|
buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer));
|
2003-10-28 20:25:30 +00:00
|
|
|
if (current_list) {
|
2004-03-15 19:27:17 +00:00
|
|
|
g_list_append (current_list, buffer);
|
2003-10-28 20:25:30 +00:00
|
|
|
} else {
|
2004-03-15 19:27:17 +00:00
|
|
|
g_assert (store->buffers == NULL);
|
|
|
|
store->buffers = g_list_prepend (NULL, buffer);
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_buffer_store_cleared_func (GstBufferStore * store)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
g_list_foreach (store->buffers, (GFunc) gst_mini_object_unref, NULL);
|
2003-10-28 20:25:30 +00:00
|
|
|
g_list_free (store->buffers);
|
|
|
|
store->buffers = NULL;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_store_new:
|
|
|
|
*
|
|
|
|
* Creates a new bufferstore.
|
|
|
|
*
|
|
|
|
* Returns: the new bufferstore.
|
|
|
|
*/
|
|
|
|
GstBufferStore *
|
|
|
|
gst_buffer_store_new (void)
|
|
|
|
{
|
|
|
|
return GST_BUFFER_STORE (g_object_new (GST_TYPE_BUFFER_STORE, NULL));
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_store_clear:
|
|
|
|
* @store: a bufferstore
|
|
|
|
*
|
|
|
|
* Clears the buffer store. All buffers are removed and the buffer store
|
|
|
|
* behaves like it was just created.
|
|
|
|
*/
|
|
|
|
/* FIXME: call this function _reset ? */
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_buffer_store_clear (GstBufferStore * store)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_BUFFER_STORE (store));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
g_signal_emit (store, gst_buffer_store_signals[CLEARED], 0, NULL);
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_store_add_buffer:
|
|
|
|
* @store: a bufferstore
|
|
|
|
* @buffer: the buffer to add
|
|
|
|
*
|
2005-10-15 15:30:24 +00:00
|
|
|
* Adds a buffer to the buffer store.
|
2003-10-28 20:25:30 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE, if the buffer was added, FALSE if an error occured.
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_buffer_store_add_buffer (GstBufferStore * store, GstBuffer * buffer)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
gboolean ret;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
g_return_val_if_fail (GST_IS_BUFFER_STORE (store), FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
|
|
|
|
|
|
|
|
if (store->buffers &&
|
|
|
|
GST_BUFFER_OFFSET_IS_VALID (store->buffers->data) &&
|
|
|
|
!GST_BUFFER_OFFSET_IS_VALID (buffer))
|
|
|
|
return FALSE;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
g_signal_emit (store, gst_buffer_store_signals[BUFFER_ADDED], 0, buffer,
|
|
|
|
&ret);
|
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_store_get_buffer:
|
|
|
|
* @store: a bufferstore
|
|
|
|
* @offset: starting offset of returned buffer
|
|
|
|
* @size: size of returned buffer
|
|
|
|
*
|
|
|
|
* Returns a buffer that corresponds to the given area of data. If part of the
|
|
|
|
* data is not available inside the store, NULL is returned. You have to unref
|
|
|
|
* the buffer after use.
|
|
|
|
*
|
2005-10-15 15:30:24 +00:00
|
|
|
* Returns: a buffer with the requested data or NULL if the data was not
|
2003-10-28 20:25:30 +00:00
|
|
|
* available.
|
|
|
|
*/
|
|
|
|
GstBuffer *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_buffer_store_get_buffer (GstBufferStore * store, guint64 offset, guint size)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
GstBuffer *current;
|
|
|
|
GList *walk;
|
|
|
|
guint8 *data;
|
|
|
|
guint tmp;
|
|
|
|
gboolean have_offset;
|
2003-10-30 19:54:29 +00:00
|
|
|
guint64 cur_offset = 0;
|
2003-10-28 20:25:30 +00:00
|
|
|
GstBuffer *ret = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_BUFFER_STORE (store), NULL);
|
|
|
|
|
|
|
|
walk = store->buffers;
|
|
|
|
if (!walk)
|
|
|
|
return NULL;
|
|
|
|
if (GST_BUFFER_OFFSET_IS_VALID (walk->data)) {
|
|
|
|
have_offset = TRUE;
|
|
|
|
} else {
|
|
|
|
have_offset = FALSE;
|
|
|
|
}
|
|
|
|
while (walk) {
|
|
|
|
current = GST_BUFFER (walk->data);
|
|
|
|
if (have_offset) {
|
|
|
|
cur_offset = GST_BUFFER_OFFSET (current);
|
|
|
|
}
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
if (cur_offset > offset) {
|
|
|
|
/* #include <windows.h>
|
|
|
|
do_nothing_loop (); */
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (cur_offset == offset && GST_BUFFER_SIZE (current) == size) {
|
|
|
|
GST_LOG_OBJECT (store,
|
2004-03-15 19:27:17 +00:00
|
|
|
"found matching buffer %p for offset %" G_GUINT64_FORMAT
|
|
|
|
" and size %u", current, offset, size);
|
2003-10-28 20:25:30 +00:00
|
|
|
ret = current;
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
gst_mini_object_ref (GST_MINI_OBJECT (ret));
|
|
|
|
GST_LOG_OBJECT (store, "refcount %d", GST_MINI_OBJECT (ret)->refcount);
|
2003-10-28 20:25:30 +00:00
|
|
|
break;
|
|
|
|
} else if (cur_offset + GST_BUFFER_SIZE (current) > offset) {
|
|
|
|
if (cur_offset + GST_BUFFER_SIZE (current) >= offset + size) {
|
2004-03-15 19:27:17 +00:00
|
|
|
ret = gst_buffer_create_sub (current, offset - cur_offset, size);
|
|
|
|
GST_LOG_OBJECT (store,
|
|
|
|
"created subbuffer %p from buffer %p for offset %llu and size %u",
|
|
|
|
ret, current, offset, size);
|
|
|
|
break;
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|
|
|
|
/* uh, the requested data spans some buffers */
|
|
|
|
ret = gst_buffer_new_and_alloc (size);
|
2004-03-30 16:31:06 +00:00
|
|
|
GST_BUFFER_OFFSET (ret) = offset;
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_LOG_OBJECT (store, "created buffer %p for offset %" G_GUINT64_FORMAT
|
2004-03-15 19:27:17 +00:00
|
|
|
" and size %u, will fill with data now", ret, offset, size);
|
2003-10-28 20:25:30 +00:00
|
|
|
data = GST_BUFFER_DATA (ret);
|
|
|
|
tmp = GST_BUFFER_SIZE (current) - offset + cur_offset;
|
|
|
|
memcpy (data, GST_BUFFER_DATA (current) + offset - cur_offset, tmp);
|
|
|
|
data += tmp;
|
|
|
|
size -= tmp;
|
|
|
|
while (size) {
|
2004-03-15 19:27:17 +00:00
|
|
|
if (walk == NULL ||
|
|
|
|
(have_offset &&
|
|
|
|
GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) !=
|
|
|
|
GST_BUFFER_OFFSET (walk->data))) {
|
|
|
|
GST_DEBUG_OBJECT (store,
|
|
|
|
"not all data for offset %" G_GUINT64_FORMAT
|
|
|
|
" and remaining size %u available, aborting", offset, size);
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
gst_mini_object_unref (GST_MINI_OBJECT (ret));
|
2004-03-15 19:27:17 +00:00
|
|
|
ret = NULL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
current = GST_BUFFER (walk->data);
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
tmp = MIN (GST_BUFFER_SIZE (current), size);
|
|
|
|
memcpy (data, GST_BUFFER_DATA (current), tmp);
|
|
|
|
data += tmp;
|
|
|
|
size -= tmp;
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|
2004-04-06 23:46:37 +00:00
|
|
|
goto out;
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|
|
|
|
if (!have_offset) {
|
|
|
|
cur_offset += GST_BUFFER_SIZE (current);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out:
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_buffer_store_get_size:
|
|
|
|
* @store: a bufferstore
|
|
|
|
* @offset: desired offset
|
|
|
|
*
|
|
|
|
* Calculates the number of bytes available starting from offset. This allows
|
|
|
|
* to query a buffer with the returned size.
|
|
|
|
*
|
|
|
|
* Returns: the number of continuous bytes in the bufferstore starting at
|
|
|
|
* offset.
|
|
|
|
*/
|
|
|
|
guint
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_buffer_store_get_size (GstBufferStore * store, guint64 offset)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
GList *walk;
|
|
|
|
gboolean have_offset;
|
|
|
|
gboolean counting = FALSE;
|
2003-10-30 19:54:29 +00:00
|
|
|
guint64 cur_offset = 0;
|
2003-10-29 04:11:11 +00:00
|
|
|
GstBuffer *current = NULL;
|
2003-10-28 20:25:30 +00:00
|
|
|
guint ret = 0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_BUFFER_STORE (store), 0);
|
|
|
|
|
|
|
|
walk = store->buffers;
|
|
|
|
if (!walk)
|
|
|
|
return 0;
|
|
|
|
if (GST_BUFFER_OFFSET_IS_VALID (walk->data)) {
|
|
|
|
have_offset = TRUE;
|
|
|
|
} else {
|
|
|
|
have_offset = FALSE;
|
|
|
|
}
|
|
|
|
while (walk) {
|
2004-03-13 15:27:01 +00:00
|
|
|
if (have_offset && counting &&
|
2004-03-15 19:27:17 +00:00
|
|
|
cur_offset + GST_BUFFER_SIZE (current) !=
|
|
|
|
GST_BUFFER_OFFSET (walk->data)) {
|
2003-10-28 20:25:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
current = GST_BUFFER (walk->data);
|
|
|
|
if (have_offset) {
|
|
|
|
cur_offset = GST_BUFFER_OFFSET (current);
|
|
|
|
}
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
if (counting) {
|
|
|
|
ret += GST_BUFFER_SIZE (current);
|
|
|
|
} else {
|
|
|
|
if (cur_offset > offset)
|
2004-03-15 19:27:17 +00:00
|
|
|
return 0;
|
2003-10-28 20:25:30 +00:00
|
|
|
if (cur_offset + GST_BUFFER_SIZE (current) > offset) {
|
2004-03-15 19:27:17 +00:00
|
|
|
/* we have at least some bytes */
|
|
|
|
ret = cur_offset + GST_BUFFER_SIZE (current) - offset;
|
|
|
|
counting = TRUE;
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!have_offset) {
|
|
|
|
cur_offset += GST_BUFFER_SIZE (current);
|
|
|
|
}
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
return ret;
|
|
|
|
}
|