various fixes like in/valid buffer handling in bufferstore and handling small streams in typefind

Original commit message from CVS:
various fixes like in/valid buffer handling in bufferstore and handling small streams in typefind
This commit is contained in:
Benjamin Otte 2003-10-28 00:32:46 +00:00
parent 76855da107
commit d967c20451
6 changed files with 172 additions and 102 deletions

View file

@ -140,7 +140,7 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer)
GST_DEBUG_OBJECT (store, "attempting to add buffer %p with invalid offset to store with valid offset, abort",
buffer);
return FALSE;
} else if (store->buffers && !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
} else if (!store->buffers || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
/* 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",
buffer, GST_BUFFER_SIZE (buffer));
@ -287,6 +287,11 @@ gst_buffer_store_add_buffer (GstBufferStore *store, GstBuffer *buffer)
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;
g_signal_emit (store, gst_buffer_store_signals [BUFFER_ADDED], 0, buffer, &ret);
return ret;

View file

@ -301,28 +301,6 @@ gst_type_find_element_src_event (GstPad *pad, GstEvent *event)
}
return gst_pad_event_default (pad, event);
}
static void
start_typefinding (GstTypeFindElement *typefind)
{
g_assert (typefind->caps == NULL);
GST_DEBUG_OBJECT (typefind, "starting typefinding");
typefind->mode = MODE_TYPEFIND;
typefind->stream_length_available = TRUE;
typefind->stream_length = 0;
}
static void
gst_type_find_element_handle_event (GstPad *pad, GstEvent *event)
{
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->mode == MODE_TYPEFIND) {
/* need to do more? */
gst_data_unref (GST_DATA (event));
} else {
gst_pad_event_default (pad, event);
}
}
typedef struct {
GstTypeFindFactory * factory;
gint probability;
@ -350,6 +328,16 @@ free_entry (TypeFindEntry *entry)
g_free (entry);
}
static void
start_typefinding (GstTypeFindElement *typefind)
{
g_assert (typefind->caps == NULL);
GST_DEBUG_OBJECT (typefind, "starting typefinding");
typefind->mode = MODE_TYPEFIND;
typefind->stream_length_available = TRUE;
typefind->stream_length = 0;
}
static void
stop_typefinding (GstTypeFindElement *typefind)
{
/* stop all typefinding and set mode back to normal */
@ -357,9 +345,8 @@ stop_typefinding (GstTypeFindElement *typefind)
GST_DEBUG_OBJECT (typefind, "stopping typefinding%s", push_cached_buffers ? " and pushing cached buffers" : "");
if (typefind->possibilities != NULL) {
/* this can only happen on PAUSED => READY */
/* this should only happen on PAUSED => READY or EOS */
GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", g_list_length (typefind->possibilities));
g_assert (push_cached_buffers == FALSE);
g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL);
g_list_free (typefind->possibilities);
typefind->possibilities = NULL;
@ -412,6 +399,34 @@ find_element_get_length (gpointer data)
return entry->self->stream_length;
}
static void
gst_type_find_element_handle_event (GstPad *pad, GstEvent *event)
{
TypeFindEntry *entry;
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->mode == MODE_TYPEFIND) {
/* need to do more? */
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
/* this should only happen when we got all available data */
entry = (TypeFindEntry *) typefind->possibilities ? typefind->possibilities->data : NULL;
if (entry && entry->probability >= typefind->min_probability) {
GST_INFO_OBJECT (typefind, "'%s' is the best typefind left after we got all data, using it now (probability %u)",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);
}
stop_typefinding (typefind);
gst_pad_event_default (pad, event);
break;
default:
gst_data_unref (GST_DATA (event));
break;
}
} else {
gst_pad_event_default (pad, event);
}
}
static guint8 *
find_peek (gpointer data, gint64 offset, guint size)
{
@ -612,7 +627,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
}
if (g_list_next (typefind->possibilities) == NULL) {
entry = (TypeFindEntry *) typefind->possibilities->data;
if (entry->probability > 0) {
if (entry->probability > typefind->min_probability) {
GST_INFO_OBJECT (typefind, "'%s' is the only typefind left, using it now (probability %u)",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);

View file

@ -301,28 +301,6 @@ gst_type_find_element_src_event (GstPad *pad, GstEvent *event)
}
return gst_pad_event_default (pad, event);
}
static void
start_typefinding (GstTypeFindElement *typefind)
{
g_assert (typefind->caps == NULL);
GST_DEBUG_OBJECT (typefind, "starting typefinding");
typefind->mode = MODE_TYPEFIND;
typefind->stream_length_available = TRUE;
typefind->stream_length = 0;
}
static void
gst_type_find_element_handle_event (GstPad *pad, GstEvent *event)
{
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->mode == MODE_TYPEFIND) {
/* need to do more? */
gst_data_unref (GST_DATA (event));
} else {
gst_pad_event_default (pad, event);
}
}
typedef struct {
GstTypeFindFactory * factory;
gint probability;
@ -350,6 +328,16 @@ free_entry (TypeFindEntry *entry)
g_free (entry);
}
static void
start_typefinding (GstTypeFindElement *typefind)
{
g_assert (typefind->caps == NULL);
GST_DEBUG_OBJECT (typefind, "starting typefinding");
typefind->mode = MODE_TYPEFIND;
typefind->stream_length_available = TRUE;
typefind->stream_length = 0;
}
static void
stop_typefinding (GstTypeFindElement *typefind)
{
/* stop all typefinding and set mode back to normal */
@ -357,9 +345,8 @@ stop_typefinding (GstTypeFindElement *typefind)
GST_DEBUG_OBJECT (typefind, "stopping typefinding%s", push_cached_buffers ? " and pushing cached buffers" : "");
if (typefind->possibilities != NULL) {
/* this can only happen on PAUSED => READY */
/* this should only happen on PAUSED => READY or EOS */
GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", g_list_length (typefind->possibilities));
g_assert (push_cached_buffers == FALSE);
g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL);
g_list_free (typefind->possibilities);
typefind->possibilities = NULL;
@ -412,6 +399,34 @@ find_element_get_length (gpointer data)
return entry->self->stream_length;
}
static void
gst_type_find_element_handle_event (GstPad *pad, GstEvent *event)
{
TypeFindEntry *entry;
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->mode == MODE_TYPEFIND) {
/* need to do more? */
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
/* this should only happen when we got all available data */
entry = (TypeFindEntry *) typefind->possibilities ? typefind->possibilities->data : NULL;
if (entry && entry->probability >= typefind->min_probability) {
GST_INFO_OBJECT (typefind, "'%s' is the best typefind left after we got all data, using it now (probability %u)",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);
}
stop_typefinding (typefind);
gst_pad_event_default (pad, event);
break;
default:
gst_data_unref (GST_DATA (event));
break;
}
} else {
gst_pad_event_default (pad, event);
}
}
static guint8 *
find_peek (gpointer data, gint64 offset, guint size)
{
@ -612,7 +627,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
}
if (g_list_next (typefind->possibilities) == NULL) {
entry = (TypeFindEntry *) typefind->possibilities->data;
if (entry->probability > 0) {
if (entry->probability > typefind->min_probability) {
GST_INFO_OBJECT (typefind, "'%s' is the only typefind left, using it now (probability %u)",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);

View file

@ -140,7 +140,7 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer)
GST_DEBUG_OBJECT (store, "attempting to add buffer %p with invalid offset to store with valid offset, abort",
buffer);
return FALSE;
} else if (store->buffers && !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
} else if (!store->buffers || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) {
/* 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",
buffer, GST_BUFFER_SIZE (buffer));
@ -287,6 +287,11 @@ gst_buffer_store_add_buffer (GstBufferStore *store, GstBuffer *buffer)
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;
g_signal_emit (store, gst_buffer_store_signals [BUFFER_ADDED], 0, buffer, &ret);
return ret;

View file

@ -301,28 +301,6 @@ gst_type_find_element_src_event (GstPad *pad, GstEvent *event)
}
return gst_pad_event_default (pad, event);
}
static void
start_typefinding (GstTypeFindElement *typefind)
{
g_assert (typefind->caps == NULL);
GST_DEBUG_OBJECT (typefind, "starting typefinding");
typefind->mode = MODE_TYPEFIND;
typefind->stream_length_available = TRUE;
typefind->stream_length = 0;
}
static void
gst_type_find_element_handle_event (GstPad *pad, GstEvent *event)
{
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->mode == MODE_TYPEFIND) {
/* need to do more? */
gst_data_unref (GST_DATA (event));
} else {
gst_pad_event_default (pad, event);
}
}
typedef struct {
GstTypeFindFactory * factory;
gint probability;
@ -350,6 +328,16 @@ free_entry (TypeFindEntry *entry)
g_free (entry);
}
static void
start_typefinding (GstTypeFindElement *typefind)
{
g_assert (typefind->caps == NULL);
GST_DEBUG_OBJECT (typefind, "starting typefinding");
typefind->mode = MODE_TYPEFIND;
typefind->stream_length_available = TRUE;
typefind->stream_length = 0;
}
static void
stop_typefinding (GstTypeFindElement *typefind)
{
/* stop all typefinding and set mode back to normal */
@ -357,9 +345,8 @@ stop_typefinding (GstTypeFindElement *typefind)
GST_DEBUG_OBJECT (typefind, "stopping typefinding%s", push_cached_buffers ? " and pushing cached buffers" : "");
if (typefind->possibilities != NULL) {
/* this can only happen on PAUSED => READY */
/* this should only happen on PAUSED => READY or EOS */
GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", g_list_length (typefind->possibilities));
g_assert (push_cached_buffers == FALSE);
g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL);
g_list_free (typefind->possibilities);
typefind->possibilities = NULL;
@ -412,6 +399,34 @@ find_element_get_length (gpointer data)
return entry->self->stream_length;
}
static void
gst_type_find_element_handle_event (GstPad *pad, GstEvent *event)
{
TypeFindEntry *entry;
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->mode == MODE_TYPEFIND) {
/* need to do more? */
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
/* this should only happen when we got all available data */
entry = (TypeFindEntry *) typefind->possibilities ? typefind->possibilities->data : NULL;
if (entry && entry->probability >= typefind->min_probability) {
GST_INFO_OBJECT (typefind, "'%s' is the best typefind left after we got all data, using it now (probability %u)",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);
}
stop_typefinding (typefind);
gst_pad_event_default (pad, event);
break;
default:
gst_data_unref (GST_DATA (event));
break;
}
} else {
gst_pad_event_default (pad, event);
}
}
static guint8 *
find_peek (gpointer data, gint64 offset, guint size)
{
@ -612,7 +627,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
}
if (g_list_next (typefind->possibilities) == NULL) {
entry = (TypeFindEntry *) typefind->possibilities->data;
if (entry->probability > 0) {
if (entry->probability > typefind->min_probability) {
GST_INFO_OBJECT (typefind, "'%s' is the only typefind left, using it now (probability %u)",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);

View file

@ -301,28 +301,6 @@ gst_type_find_element_src_event (GstPad *pad, GstEvent *event)
}
return gst_pad_event_default (pad, event);
}
static void
start_typefinding (GstTypeFindElement *typefind)
{
g_assert (typefind->caps == NULL);
GST_DEBUG_OBJECT (typefind, "starting typefinding");
typefind->mode = MODE_TYPEFIND;
typefind->stream_length_available = TRUE;
typefind->stream_length = 0;
}
static void
gst_type_find_element_handle_event (GstPad *pad, GstEvent *event)
{
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->mode == MODE_TYPEFIND) {
/* need to do more? */
gst_data_unref (GST_DATA (event));
} else {
gst_pad_event_default (pad, event);
}
}
typedef struct {
GstTypeFindFactory * factory;
gint probability;
@ -350,6 +328,16 @@ free_entry (TypeFindEntry *entry)
g_free (entry);
}
static void
start_typefinding (GstTypeFindElement *typefind)
{
g_assert (typefind->caps == NULL);
GST_DEBUG_OBJECT (typefind, "starting typefinding");
typefind->mode = MODE_TYPEFIND;
typefind->stream_length_available = TRUE;
typefind->stream_length = 0;
}
static void
stop_typefinding (GstTypeFindElement *typefind)
{
/* stop all typefinding and set mode back to normal */
@ -357,9 +345,8 @@ stop_typefinding (GstTypeFindElement *typefind)
GST_DEBUG_OBJECT (typefind, "stopping typefinding%s", push_cached_buffers ? " and pushing cached buffers" : "");
if (typefind->possibilities != NULL) {
/* this can only happen on PAUSED => READY */
/* this should only happen on PAUSED => READY or EOS */
GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", g_list_length (typefind->possibilities));
g_assert (push_cached_buffers == FALSE);
g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL);
g_list_free (typefind->possibilities);
typefind->possibilities = NULL;
@ -412,6 +399,34 @@ find_element_get_length (gpointer data)
return entry->self->stream_length;
}
static void
gst_type_find_element_handle_event (GstPad *pad, GstEvent *event)
{
TypeFindEntry *entry;
GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad));
if (typefind->mode == MODE_TYPEFIND) {
/* need to do more? */
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
/* this should only happen when we got all available data */
entry = (TypeFindEntry *) typefind->possibilities ? typefind->possibilities->data : NULL;
if (entry && entry->probability >= typefind->min_probability) {
GST_INFO_OBJECT (typefind, "'%s' is the best typefind left after we got all data, using it now (probability %u)",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);
}
stop_typefinding (typefind);
gst_pad_event_default (pad, event);
break;
default:
gst_data_unref (GST_DATA (event));
break;
}
} else {
gst_pad_event_default (pad, event);
}
}
static guint8 *
find_peek (gpointer data, gint64 offset, guint size)
{
@ -612,7 +627,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
}
if (g_list_next (typefind->possibilities) == NULL) {
entry = (TypeFindEntry *) typefind->possibilities->data;
if (entry->probability > 0) {
if (entry->probability > typefind->min_probability) {
GST_INFO_OBJECT (typefind, "'%s' is the only typefind left, using it now (probability %u)",
GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps);