summaryrefslogtreecommitdiff
path: root/testsuite/indexers
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/indexers')
-rw-r--r--testsuite/indexers/cache1.c76
-rw-r--r--testsuite/indexers/indexdump.c33
2 files changed, 57 insertions, 52 deletions
diff --git a/testsuite/indexers/cache1.c b/testsuite/indexers/cache1.c
index 0392a196c..ed2bb4d1d 100644
--- a/testsuite/indexers/cache1.c
+++ b/testsuite/indexers/cache1.c
@@ -20,70 +20,71 @@
#include <gst/gst.h>
static void
-lookup (GstIndex *index, GstIndexLookupMethod method,
- GstFormat src_format, gint64 src_value,
- GstFormat dest_format, gint64 expecting)
+lookup (GstIndex * index, GstIndexLookupMethod method,
+ GstFormat src_format, gint64 src_value,
+ GstFormat dest_format, gint64 expecting)
{
GstIndexEntry *entry;
gint64 result;
entry = gst_index_get_assoc_entry (index, 0, method, 0,
- src_format, src_value);
+ src_format, src_value);
if (entry) {
- gst_index_entry_assoc_map (entry, dest_format, &result);
+ gst_index_entry_assoc_map (entry, dest_format, &result);
if (result == expecting) {
g_print ("OK (%lld)\n", result);
} else {
g_print ("FAIL - expecting %lld, got %lld\n", expecting, result);
}
- }
- else {
+ } else {
const GstFormatDefinition *def = gst_format_get_details (src_format);
-
- if (expecting == -1)
+
+ if (expecting == -1)
g_print ("OK (not found)\n");
else
g_print ("FAIL - no index entry found for %lld %s, expecting %lld\n",
- src_value, def->nick, expecting);
+ src_value, def->nick, expecting);
}
}
typedef struct _GstIndexTestCase
{
- GstIndexLookupMethod method;
- GstFormat src_format;
- gint64 src_value;
- GstFormat dest_format;
- gint64 expecting;
+ GstIndexLookupMethod method;
+ GstFormat src_format;
+ gint64 src_value;
+ GstFormat dest_format;
+ gint64 expecting;
} GstIndexTestCase;
-const static GstIndexTestCase cases[] =
-{
- { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000 },
- { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5 },
- { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1 },
- { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, 99999 },
- { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 },
+const static GstIndexTestCase cases[] = {
+ {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000},
+ {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5},
+ {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1},
+ {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES,
+ 99999},
+ {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1},
};
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstIndex *index;
GstElement *element;
gint i, id;
-
+
gst_init (&argc, &argv);
- if (argc != 2)
- { g_print ("usage: cache1 (memindex | fileindex)\n"); exit (0); }
+ if (argc != 2) {
+ g_print ("usage: cache1 (memindex | fileindex)\n");
+ exit (0);
+ }
index = gst_index_factory_make (argv[1]);
g_assert (index != NULL);
@@ -96,15 +97,16 @@ main (gint argc, gchar *argv[])
g_print ("Building index...\n");
for (i = 0; i < 100000; i++) {
- gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME,
- (gint64) (i * 1000), 0);
+ gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64) i,
+ GST_FORMAT_TIME, (gint64) (i * 1000), 0);
}
g_print ("Testing index...\n");
for (i = 0; i < (sizeof (cases) / sizeof (GstIndexTestCase)); i++) {
- lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value, cases[i].dest_format, cases[i].expecting);
+ lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value,
+ cases[i].dest_format, cases[i].expecting);
}
-
+
return 0;
}
diff --git a/testsuite/indexers/indexdump.c b/testsuite/indexers/indexdump.c
index e528e4afe..d2f168a8f 100644
--- a/testsuite/indexers/indexdump.c
+++ b/testsuite/indexers/indexdump.c
@@ -20,18 +20,20 @@
#include <gst/gst.h>
static void
-my_resolver (GstIndex *index, GstObject *_ign, gchar **writer_string,
- gpointer user_data)
-{ *writer_string = user_data; }
+my_resolver (GstIndex * index, GstObject * _ign, gchar ** writer_string,
+ gpointer user_data)
+{
+ *writer_string = user_data;
+}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstIndex *index;
GstObject *identity;
gint id;
gint64 cur;
-
+
gst_init (&argc, &argv);
if (argc != 3) {
@@ -45,29 +47,30 @@ main (gint argc, gchar *argv[])
g_object_set (index, "location", argv[1], NULL);
gst_index_set_resolver (index, (GstIndexResolver) my_resolver, argv[2]);
- identity = (GstObject*) gst_element_factory_make ("identity", "element");
+ identity = (GstObject *) gst_element_factory_make ("identity", "element");
g_assert (identity);
gst_index_get_writer_id (index, identity, &id);
-
+
cur = 0;
while (1) {
gint fx;
GstIndexEntry *entry =
- gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0,
- GST_FORMAT_TIME, cur);
+ gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0,
+ GST_FORMAT_TIME, cur);
+
if (!entry)
break;
g_print ("%x", GST_INDEX_ASSOC_FLAGS (entry));
- for (fx=0; fx < GST_INDEX_NASSOCS (entry); fx++) {
+ for (fx = 0; fx < GST_INDEX_NASSOCS (entry); fx++) {
GstFormat fmt = GST_INDEX_ASSOC_FORMAT (entry, fx);
- const GstFormatDefinition* def = gst_format_get_details (fmt);
+ const GstFormatDefinition *def = gst_format_get_details (fmt);
+
if (fmt == GST_FORMAT_TIME) {
cur = GST_INDEX_ASSOC_VALUE (entry, fx) + 1;
g_print (" time %.4f",
- GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND);
- }
- else
+ GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND);
+ } else
g_print (" %s %lld", def->nick, GST_INDEX_ASSOC_VALUE (entry, fx));
}
g_print ("\n");