- Added flags to lookup method so that one can search for keyframes too

Original commit message from CVS:
- Added flags to lookup method so that one can search for keyframes too
- Updated memindex
This commit is contained in:
Wim Taymans 2002-12-26 22:35:58 +00:00
parent 2694db659d
commit fb9970d85a
4 changed files with 60 additions and 11 deletions

View file

@ -557,12 +557,12 @@ gst_index_compare_func (gconstpointer a,
*/ */
GstIndexEntry* GstIndexEntry*
gst_index_get_assoc_entry (GstIndex *index, gint id, gst_index_get_assoc_entry (GstIndex *index, gint id,
GstIndexLookupMethod method, GstIndexLookupMethod method, GstAssocFlags flags,
GstFormat format, gint64 value) GstFormat format, gint64 value)
{ {
g_return_val_if_fail (GST_IS_INDEX (index), NULL); g_return_val_if_fail (GST_IS_INDEX (index), NULL);
return gst_index_get_assoc_entry_full (index, id, method, format, value, return gst_index_get_assoc_entry_full (index, id, method, flags, format, value,
gst_index_compare_func, NULL); gst_index_compare_func, NULL);
} }
@ -584,7 +584,7 @@ gst_index_get_assoc_entry (GstIndex *index, gint id,
*/ */
GstIndexEntry* GstIndexEntry*
gst_index_get_assoc_entry_full (GstIndex *index, gint id, gst_index_get_assoc_entry_full (GstIndex *index, gint id,
GstIndexLookupMethod method, GstIndexLookupMethod method, GstAssocFlags flags,
GstFormat format, gint64 value, GstFormat format, gint64 value,
GCompareDataFunc func, GCompareDataFunc func,
gpointer user_data) gpointer user_data)
@ -596,7 +596,7 @@ gst_index_get_assoc_entry_full (GstIndex *index, gint id,
iclass = GST_INDEX_GET_CLASS (index); iclass = GST_INDEX_GET_CLASS (index);
if (iclass->get_assoc_entry) if (iclass->get_assoc_entry)
return iclass->get_assoc_entry (index, id, method, format, value, func, user_data); return iclass->get_assoc_entry (index, id, method, flags, format, value, func, user_data);
return NULL; return NULL;
} }

View file

@ -76,6 +76,9 @@ struct _GstIndexAssociation {
typedef enum { typedef enum {
GST_ACCOCIATION_FLAG_NONE = 0, GST_ACCOCIATION_FLAG_NONE = 0,
GST_ACCOCIATION_FLAG_KEY_UNIT = (1 << 0), GST_ACCOCIATION_FLAG_KEY_UNIT = (1 << 0),
/* new flags should start here */
GST_ACCOCIATION_FLAG_LAST = (1 << 8),
} GstAssocFlags; } GstAssocFlags;
#define GST_INDEX_FORMAT_FORMAT(entry) ((entry)->data.format.format) #define GST_INDEX_FORMAT_FORMAT(entry) ((entry)->data.format.format)
@ -172,7 +175,7 @@ struct _GstIndexClass {
void (*add_entry) (GstIndex *index, GstIndexEntry *entry); void (*add_entry) (GstIndex *index, GstIndexEntry *entry);
GstIndexEntry* (*get_assoc_entry) (GstIndex *index, gint id, GstIndexEntry* (*get_assoc_entry) (GstIndex *index, gint id,
GstIndexLookupMethod method, GstIndexLookupMethod method, GstAssocFlags flags,
GstFormat format, gint64 value, GstFormat format, gint64 value,
GCompareDataFunc func, GCompareDataFunc func,
gpointer user_data); gpointer user_data);
@ -210,10 +213,10 @@ GstIndexEntry* gst_index_add_id (GstIndex *index, gint id,
gchar *description); gchar *description);
GstIndexEntry* gst_index_get_assoc_entry (GstIndex *index, gint id, GstIndexEntry* gst_index_get_assoc_entry (GstIndex *index, gint id,
GstIndexLookupMethod method, GstIndexLookupMethod method, GstAssocFlags flags,
GstFormat format, gint64 value); GstFormat format, gint64 value);
GstIndexEntry* gst_index_get_assoc_entry_full (GstIndex *index, gint id, GstIndexEntry* gst_index_get_assoc_entry_full (GstIndex *index, gint id,
GstIndexLookupMethod method, GstIndexLookupMethod method, GstAssocFlags flags,
GstFormat format, gint64 value, GstFormat format, gint64 value,
GCompareDataFunc func, GCompareDataFunc func,
gpointer user_data); gpointer user_data);

View file

@ -106,7 +106,7 @@ static void gst_mem_index_dispose (GObject *object);
static void gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry); static void gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry);
static GstIndexEntry* gst_mem_index_get_assoc_entry (GstIndex *index, gint id, static GstIndexEntry* gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
GstIndexLookupMethod method, GstIndexLookupMethod method, GstAssocFlags flags,
GstFormat format, gint64 value, GstFormat format, gint64 value,
GCompareDataFunc func, GCompareDataFunc func,
gpointer user_data); gpointer user_data);
@ -332,7 +332,8 @@ mem_index_search (gconstpointer a,
static GstIndexEntry* static GstIndexEntry*
gst_mem_index_get_assoc_entry (GstIndex *index, gint id, gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
GstIndexLookupMethod method, GstIndexLookupMethod method,
GstAssocFlags flags,
GstFormat format, gint64 value, GstFormat format, gint64 value,
GCompareDataFunc func, GCompareDataFunc func,
gpointer user_data) gpointer user_data)
@ -375,6 +376,28 @@ gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
} }
} }
if (entry) {
if ((GST_INDEX_ASSOC_FLAGS (entry) & flags) != flags) {
GList *l_entry = g_list_find (memindex->associations, entry);
entry = NULL;
while (l_entry) {
entry = (GstIndexEntry *) l_entry->data;
if (entry->id == id &&
(GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags)
break;
if (method == GST_INDEX_LOOKUP_BEFORE)
l_entry = g_list_next (l_entry);
else if (method == GST_INDEX_LOOKUP_AFTER) {
l_entry = g_list_previous (l_entry);
}
}
}
}
return entry; return entry;
} }

View file

@ -106,7 +106,7 @@ static void gst_mem_index_dispose (GObject *object);
static void gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry); static void gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry);
static GstIndexEntry* gst_mem_index_get_assoc_entry (GstIndex *index, gint id, static GstIndexEntry* gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
GstIndexLookupMethod method, GstIndexLookupMethod method, GstAssocFlags flags,
GstFormat format, gint64 value, GstFormat format, gint64 value,
GCompareDataFunc func, GCompareDataFunc func,
gpointer user_data); gpointer user_data);
@ -332,7 +332,8 @@ mem_index_search (gconstpointer a,
static GstIndexEntry* static GstIndexEntry*
gst_mem_index_get_assoc_entry (GstIndex *index, gint id, gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
GstIndexLookupMethod method, GstIndexLookupMethod method,
GstAssocFlags flags,
GstFormat format, gint64 value, GstFormat format, gint64 value,
GCompareDataFunc func, GCompareDataFunc func,
gpointer user_data) gpointer user_data)
@ -375,6 +376,28 @@ gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
} }
} }
if (entry) {
if ((GST_INDEX_ASSOC_FLAGS (entry) & flags) != flags) {
GList *l_entry = g_list_find (memindex->associations, entry);
entry = NULL;
while (l_entry) {
entry = (GstIndexEntry *) l_entry->data;
if (entry->id == id &&
(GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags)
break;
if (method == GST_INDEX_LOOKUP_BEFORE)
l_entry = g_list_next (l_entry);
else if (method == GST_INDEX_LOOKUP_AFTER) {
l_entry = g_list_previous (l_entry);
}
}
}
}
return entry; return entry;
} }