- Added commit

Original commit message from CVS:
- Added commit
- Added flags to make index readonly
This commit is contained in:
Wim Taymans 2002-12-23 00:31:14 +00:00
parent 4bbde846e3
commit cfeeeee2cf
2 changed files with 50 additions and 1 deletions

View file

@ -107,6 +107,9 @@ gst_index_init (GstIndex *index)
index->writers = g_hash_table_new (NULL, NULL);
index->last_id = 0;
GST_FLAG_SET (index, GST_INDEX_WRITABLE);
GST_FLAG_SET (index, GST_INDEX_READABLE);
GST_DEBUG(0, "created new index");
}
@ -118,7 +121,7 @@ gst_index_init (GstIndex *index)
*
* Returns: a new index object
*/
GstIndex *
GstIndex*
gst_index_new()
{
GstIndex *index;
@ -128,6 +131,27 @@ gst_index_new()
return index;
}
/**
* gst_index_commit:
* @index: the index to commit
* @id: the writer that commited the index
*
* Tell the index that the writer with the given id is done
* with this index and is not going to write any more entries
* to it.
*/
void
gst_index_commit (GstIndex *index, gint id)
{
GstIndexClass *iclass;
iclass = GST_INDEX_GET_CLASS (index);
if (iclass->commit)
iclass->commit (index, id);
}
/**
* gst_index_get_group:
* @index: the index to get the current group from
@ -295,6 +319,9 @@ gst_index_add_format (GstIndex *index, gint id, GstFormat format)
g_return_val_if_fail (GST_IS_INDEX (index), NULL);
g_return_val_if_fail (format != 0, NULL);
if (!GST_INDEX_IS_WRITABLE (index))
return NULL;
entry = g_new0 (GstIndexEntry, 1);
entry->type = GST_INDEX_ENTRY_FORMAT;
@ -333,6 +360,9 @@ gst_index_add_id (GstIndex *index, gint id, gchar *description)
g_return_val_if_fail (GST_IS_INDEX (index), NULL);
g_return_val_if_fail (description != NULL, NULL);
if (!GST_INDEX_IS_WRITABLE (index))
return NULL;
entry = g_new0 (GstIndexEntry, 1);
entry->type = GST_INDEX_ENTRY_ID;
entry->id = id;
@ -432,6 +462,9 @@ gst_index_add_association (GstIndex *index, gint id, GstAssocFlags flags,
g_return_val_if_fail (GST_IS_INDEX (index), NULL);
g_return_val_if_fail (format != 0, NULL);
if (!GST_INDEX_IS_WRITABLE (index))
return NULL;
va_start (args, value);
cur_format = format;
@ -495,6 +528,9 @@ GstIndexEntry*
gst_index_add_object (GstIndex *index, gint id, gchar *key,
GType type, gpointer object)
{
if (!GST_INDEX_IS_WRITABLE (index))
return NULL;
return NULL;
}

View file

@ -131,6 +131,16 @@ typedef gboolean (*GstIndexResolver) (GstIndex *index,
gint *writer_id,
gchar **writer_string,
gpointer user_data);
typedef enum {
GST_INDEX_WRITABLE = GST_OBJECT_FLAG_LAST,
GST_INDEX_READABLE,
GST_INDEX_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8
} GstIndexFlags;
#define GST_INDEX_IS_READABLE(obj) (GST_FLAG_IS_SET (obj, GST_INDEX_READABLE))
#define GST_INDEX_IS_WRITABLE(obj) (GST_FLAG_IS_SET (obj, GST_INDEX_WRITABLE))
struct _GstIndex {
GstObject object;
@ -156,6 +166,8 @@ struct _GstIndexClass {
gboolean (*resolve_writer) (GstIndex *index, GstObject *writer,
gint *writer_id, gchar **writer_string);
void (*commit) (GstIndex *index, gint id);
/* abstract methods */
void (*add_entry) (GstIndex *index, GstIndexEntry *entry);
@ -172,6 +184,7 @@ struct _GstIndexClass {
GType gst_index_get_type (void);
GstIndex* gst_index_new (void);
void gst_index_commit (GstIndex *index, gint id);
gint gst_index_get_group (GstIndex *index);
gint gst_index_new_group (GstIndex *index);