From: Wim Taymans Date: Mon, 23 Dec 2002 00:31:14 +0000 (+0000) Subject: - Added commit X-Git-Tag: BRANCH-RELEASE-0_5_1-ROOT~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfeeeee2cf04edea88c9e8f5be378f331c93daa6;p=platform%2Fupstream%2Fgstreamer.git - Added commit Original commit message from CVS: - Added commit - Added flags to make index readonly --- diff --git a/gst/gstindex.c b/gst/gstindex.c index beeb3ea..f718e7c 100644 --- a/gst/gstindex.c +++ b/gst/gstindex.c @@ -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; @@ -129,6 +132,27 @@ gst_index_new() } /** + * 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; } diff --git a/gst/gstindex.h b/gst/gstindex.h index 091d529..8e3331f 100644 --- a/gst/gstindex.h +++ b/gst/gstindex.h @@ -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);