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");
}
*
* Returns: a new index object
*/
-GstIndex *
+GstIndex*
gst_index_new()
{
GstIndex *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
*
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;
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;
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;
gst_index_add_object (GstIndex *index, gint id, gchar *key,
GType type, gpointer object)
{
+ if (!GST_INDEX_IS_WRITABLE (index))
+ return NULL;
+
return NULL;
}
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;
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);
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);