mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
Applied patch 13357
Original commit message from CVS: Applied patch 13357
This commit is contained in:
parent
841f9b14f4
commit
d4881f29fd
3 changed files with 91 additions and 57 deletions
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 2a7d1c564cbf64d94cb04fb8615afb761e89f80c
|
||||
Subproject commit 86c508421de359776c4c2cb411a78c729330a250
|
|
@ -20,73 +20,90 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
static void
|
||||
lookup (GstCache *cache, GstCacheLookupMethod method,
|
||||
lookup (GstIndex *index, GstIndexLookupMethod method,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat dest_format)
|
||||
GstFormat dest_format, gint64 expecting)
|
||||
{
|
||||
GstCacheEntry *entry;
|
||||
GstIndexEntry *entry;
|
||||
gint64 result;
|
||||
|
||||
entry = gst_cache_get_assoc_entry (cache, 0, method,
|
||||
entry = gst_index_get_assoc_entry (index, 0, method, 0,
|
||||
src_format, src_value);
|
||||
if (entry) {
|
||||
gst_cache_entry_assoc_map (entry, dest_format, &result);
|
||||
gst_index_entry_assoc_map (entry, dest_format, &result);
|
||||
|
||||
g_print ("%lld\n", result);
|
||||
if (result == expecting) {
|
||||
g_print ("OK (%lld)\n", result);
|
||||
} else {
|
||||
g_print ("FAIL - expecting %lld, got %lld\n", expecting, result);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const GstFormatDefinition *def = gst_format_get_details (src_format);
|
||||
|
||||
g_print ("no cache entry found for %lld %s\n", src_value, def->nick);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct _GstCacheTestCase
|
||||
typedef struct _GstIndexTestCase
|
||||
{
|
||||
GstCacheLookupMethod method;
|
||||
GstIndexLookupMethod method;
|
||||
GstFormat src_format;
|
||||
gint64 src_value;
|
||||
GstFormat dest_format;
|
||||
} GstCacheTestCase;
|
||||
gint64 expecting;
|
||||
} GstIndexTestCase;
|
||||
|
||||
const static GstCacheTestCase cases[] =
|
||||
const static GstIndexTestCase cases[] =
|
||||
{
|
||||
{ GST_CACHE_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME },
|
||||
{ GST_CACHE_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES },
|
||||
{ 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[])
|
||||
{
|
||||
GstCache *cache;
|
||||
GstIndex *index;
|
||||
GstElement *element;
|
||||
gint i, id;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
cache = gst_cache_factory_make ("memcache");
|
||||
g_assert (cache != NULL);
|
||||
if (argc != 2)
|
||||
{ g_print ("usage: cache1 (memindex | fileindex)\n"); exit (0); }
|
||||
|
||||
index = gst_index_factory_make (argv[1]);
|
||||
g_assert (index != NULL);
|
||||
|
||||
element = gst_element_factory_make ("identity", "element");
|
||||
g_assert (element != NULL);
|
||||
|
||||
gst_cache_get_writer_id (cache, GST_OBJECT (element), &id);
|
||||
gst_index_get_writer_id (index, GST_OBJECT (element), &id);
|
||||
|
||||
g_print ("Building index...\n");
|
||||
|
||||
for (i = 0; i < 100000; i++) {
|
||||
gst_cache_add_association (cache, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME,
|
||||
gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME,
|
||||
(gint64) (i * 1000), 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < (sizeof (cases) / sizeof (GstCacheTestCase)); i++) {
|
||||
lookup (cache, cases[i].method, cases[i].src_format, cases[i].src_value, cases[i].dest_format);
|
||||
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);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -20,73 +20,90 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
static void
|
||||
lookup (GstCache *cache, GstCacheLookupMethod method,
|
||||
lookup (GstIndex *index, GstIndexLookupMethod method,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat dest_format)
|
||||
GstFormat dest_format, gint64 expecting)
|
||||
{
|
||||
GstCacheEntry *entry;
|
||||
GstIndexEntry *entry;
|
||||
gint64 result;
|
||||
|
||||
entry = gst_cache_get_assoc_entry (cache, 0, method,
|
||||
entry = gst_index_get_assoc_entry (index, 0, method, 0,
|
||||
src_format, src_value);
|
||||
if (entry) {
|
||||
gst_cache_entry_assoc_map (entry, dest_format, &result);
|
||||
gst_index_entry_assoc_map (entry, dest_format, &result);
|
||||
|
||||
g_print ("%lld\n", result);
|
||||
if (result == expecting) {
|
||||
g_print ("OK (%lld)\n", result);
|
||||
} else {
|
||||
g_print ("FAIL - expecting %lld, got %lld\n", expecting, result);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const GstFormatDefinition *def = gst_format_get_details (src_format);
|
||||
|
||||
g_print ("no cache entry found for %lld %s\n", src_value, def->nick);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct _GstCacheTestCase
|
||||
typedef struct _GstIndexTestCase
|
||||
{
|
||||
GstCacheLookupMethod method;
|
||||
GstIndexLookupMethod method;
|
||||
GstFormat src_format;
|
||||
gint64 src_value;
|
||||
GstFormat dest_format;
|
||||
} GstCacheTestCase;
|
||||
gint64 expecting;
|
||||
} GstIndexTestCase;
|
||||
|
||||
const static GstCacheTestCase cases[] =
|
||||
const static GstIndexTestCase cases[] =
|
||||
{
|
||||
{ GST_CACHE_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME },
|
||||
{ GST_CACHE_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES },
|
||||
{ GST_CACHE_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES },
|
||||
{ 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[])
|
||||
{
|
||||
GstCache *cache;
|
||||
GstIndex *index;
|
||||
GstElement *element;
|
||||
gint i, id;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
cache = gst_cache_factory_make ("memcache");
|
||||
g_assert (cache != NULL);
|
||||
if (argc != 2)
|
||||
{ g_print ("usage: cache1 (memindex | fileindex)\n"); exit (0); }
|
||||
|
||||
index = gst_index_factory_make (argv[1]);
|
||||
g_assert (index != NULL);
|
||||
|
||||
element = gst_element_factory_make ("identity", "element");
|
||||
g_assert (element != NULL);
|
||||
|
||||
gst_cache_get_writer_id (cache, GST_OBJECT (element), &id);
|
||||
gst_index_get_writer_id (index, GST_OBJECT (element), &id);
|
||||
|
||||
g_print ("Building index...\n");
|
||||
|
||||
for (i = 0; i < 100000; i++) {
|
||||
gst_cache_add_association (cache, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME,
|
||||
gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME,
|
||||
(gint64) (i * 1000), 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < (sizeof (cases) / sizeof (GstCacheTestCase)); i++) {
|
||||
lookup (cache, cases[i].method, cases[i].src_format, cases[i].src_value, cases[i].dest_format);
|
||||
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);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue