{
PROP_0,
PROP_MESSAGE,
+ PROP_CACHE,
};
#define DEFAULT_PROP_ZBAR 1
"Post a barcode message for each detected code",
TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_CACHE,
+ g_param_spec_boolean ("cache", "cache",
+ "Enable or disable the inter-image result cache",
+ TRUE, G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY));
+
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_zbar_set_caps);
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_zbar_transform_ip);
trans_class->start = GST_DEBUG_FUNCPTR (gst_zbar_start);
static void
gst_zbar_init (GstZBar * zbar, GstZBarClass * g_class)
{
+ zbar->cache = TRUE;
zbar->message = TRUE;
zbar->scanner = zbar_image_scanner_create ();
zbar = GST_ZBAR (object);
switch (prop_id) {
+ case PROP_CACHE:
+ zbar->cache = g_value_get_boolean (value);
+ break;
case PROP_MESSAGE:
zbar->message = g_value_get_boolean (value);
break;
zbar = GST_ZBAR (object);
switch (prop_id) {
+ case PROP_CACHE:
+ g_value_set_boolean (value, zbar->cache);
+ break;
case PROP_MESSAGE:
g_value_set_boolean (value, zbar->message);
break;
/* scan the image for barcodes */
n = zbar_scan_image (zbar->scanner, image);
+ if (n == 0)
+ goto out;
/* extract results */
symbol = zbar_image_first_symbol (image);
GST_DEBUG_OBJECT (zbar, "decoded %s symbol \"%s\" at quality %d",
zbar_get_symbol_name (typ), data, quality);
- if (zbar_symbol_get_count (symbol) != 0)
+ if (zbar->cache && zbar_symbol_get_count (symbol) != 0)
continue;
if (zbar->message) {
}
}
+out:
/* clean up */
+ zbar_image_scanner_recycle_image (zbar->scanner, image);
zbar_image_destroy (image);
done:
{
GstZBar *zbar = GST_ZBAR (base);
- /* start the cache (e.g. for filtering dupes) */
- zbar_image_scanner_enable_cache (zbar->scanner, TRUE);
+ /* start the cache if enabled (e.g. for filtering dupes) */
+ zbar_image_scanner_enable_cache (zbar->scanner, zbar->cache);
return TRUE;
}
{
GstZBar *zbar = GST_ZBAR (base);
- /* stop the cache (e.g. for filtering dupes) */
- zbar_image_scanner_enable_cache (zbar->scanner, FALSE);
+ /* stop the cache if enabled (e.g. for filtering dupes) */
+ zbar_image_scanner_enable_cache (zbar->scanner, zbar->cache);
return TRUE;
}