buncha fixes to bufferstore and the typefind element - we now seek to the point where we need data, not somewhere before

Original commit message from CVS:
buncha fixes to bufferstore and the typefind element - we now seek to the point where we need data, not somewhere before
This commit is contained in:
Benjamin Otte 2003-10-27 21:46:26 +00:00
parent 67caa79531
commit d8d210a406
6 changed files with 68 additions and 20 deletions

View file

@ -173,6 +173,7 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *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 */
@ -215,7 +216,7 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer)
}
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, walk, buffer);
store->buffers = g_list_insert_before (store->buffers, current_list, buffer);
buffer = NULL;
break;
}
@ -232,6 +233,14 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer)
store->buffers = g_list_prepend (NULL, buffer);
}
}
{
GList *walk = store->buffers;
while (walk) {
g_print (" %llu - %u\n", GST_BUFFER_OFFSET (walk->data), GST_BUFFER_SIZE (walk->data));
walk = g_list_next (walk);
}
g_print ("\n");
}
return TRUE;
}
}
@ -363,12 +372,12 @@ gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size)
while (size) {
if (walk == NULL ||
(have_offset &&
cur_offset + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (walk->data))) {
GST_DEBUG_OBJECT (store, "not all data for offset %"G_GUINT64_FORMAT" and size %u available, aborting",
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);
gst_data_unref (GST_DATA (ret));
ret = NULL;
break;
goto out;
}
current = GST_BUFFER (walk->data);
walk = g_list_next (walk);
@ -381,6 +390,7 @@ gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size)
cur_offset += GST_BUFFER_SIZE (current);
}
}
out:
return ret;
}

View file

@ -576,15 +576,22 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
walk = g_list_next (walk);
if (entry->requested_size > 0) {
/* FIXME: need heuristic to find out if we should seek */
GstEvent *event = gst_event_new_seek (GST_FORMAT_BYTES | (entry->requested_offset > 0 ?
GST_SEEK_METHOD_SET : GST_SEEK_METHOD_END), entry->requested_offset);
gint64 seek_offset;
GstEvent *event;
seek_offset = entry->requested_offset > 0 ? entry->requested_offset :
find_element_get_length (entry) + entry->requested_offset;
seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset);
event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset);
if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
/* done seeking */
GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
break;
} else if (entry->requested_offset < 0) {
/* impossible to seek */
GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->requested_offset);
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
entry->requested_size = 0;
entry->requested_offset = 0;
}

View file

@ -576,15 +576,22 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
walk = g_list_next (walk);
if (entry->requested_size > 0) {
/* FIXME: need heuristic to find out if we should seek */
GstEvent *event = gst_event_new_seek (GST_FORMAT_BYTES | (entry->requested_offset > 0 ?
GST_SEEK_METHOD_SET : GST_SEEK_METHOD_END), entry->requested_offset);
gint64 seek_offset;
GstEvent *event;
seek_offset = entry->requested_offset > 0 ? entry->requested_offset :
find_element_get_length (entry) + entry->requested_offset;
seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset);
event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset);
if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
/* done seeking */
GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
break;
} else if (entry->requested_offset < 0) {
/* impossible to seek */
GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->requested_offset);
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
entry->requested_size = 0;
entry->requested_offset = 0;
}

View file

@ -173,6 +173,7 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *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 */
@ -215,7 +216,7 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer)
}
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, walk, buffer);
store->buffers = g_list_insert_before (store->buffers, current_list, buffer);
buffer = NULL;
break;
}
@ -232,6 +233,14 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer)
store->buffers = g_list_prepend (NULL, buffer);
}
}
{
GList *walk = store->buffers;
while (walk) {
g_print (" %llu - %u\n", GST_BUFFER_OFFSET (walk->data), GST_BUFFER_SIZE (walk->data));
walk = g_list_next (walk);
}
g_print ("\n");
}
return TRUE;
}
}
@ -363,12 +372,12 @@ gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size)
while (size) {
if (walk == NULL ||
(have_offset &&
cur_offset + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (walk->data))) {
GST_DEBUG_OBJECT (store, "not all data for offset %"G_GUINT64_FORMAT" and size %u available, aborting",
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);
gst_data_unref (GST_DATA (ret));
ret = NULL;
break;
goto out;
}
current = GST_BUFFER (walk->data);
walk = g_list_next (walk);
@ -381,6 +390,7 @@ gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size)
cur_offset += GST_BUFFER_SIZE (current);
}
}
out:
return ret;
}

View file

@ -576,15 +576,22 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
walk = g_list_next (walk);
if (entry->requested_size > 0) {
/* FIXME: need heuristic to find out if we should seek */
GstEvent *event = gst_event_new_seek (GST_FORMAT_BYTES | (entry->requested_offset > 0 ?
GST_SEEK_METHOD_SET : GST_SEEK_METHOD_END), entry->requested_offset);
gint64 seek_offset;
GstEvent *event;
seek_offset = entry->requested_offset > 0 ? entry->requested_offset :
find_element_get_length (entry) + entry->requested_offset;
seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset);
event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset);
if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
/* done seeking */
GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
break;
} else if (entry->requested_offset < 0) {
/* impossible to seek */
GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->requested_offset);
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
entry->requested_size = 0;
entry->requested_offset = 0;
}

View file

@ -576,15 +576,22 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
walk = g_list_next (walk);
if (entry->requested_size > 0) {
/* FIXME: need heuristic to find out if we should seek */
GstEvent *event = gst_event_new_seek (GST_FORMAT_BYTES | (entry->requested_offset > 0 ?
GST_SEEK_METHOD_SET : GST_SEEK_METHOD_END), entry->requested_offset);
gint64 seek_offset;
GstEvent *event;
seek_offset = entry->requested_offset > 0 ? entry->requested_offset :
find_element_get_length (entry) + entry->requested_offset;
seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset);
event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset);
if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
/* done seeking */
GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
break;
} else if (entry->requested_offset < 0) {
/* impossible to seek */
GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->requested_offset);
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
entry->requested_size = 0;
entry->requested_offset = 0;
}