int zbar_processor_user_wait (zbar_processor_t *proc, int timeout) { int rc; proc_enter(proc); _zbar_mutex_unlock(&proc->mutex); rc = -1; if(proc->visible || proc->streaming || timeout >= 0) { zbar_timer_t timer; rc = _zbar_processor_wait(proc, EVENT_INPUT, _zbar_timer_init(&timer, timeout)); } if(!proc->visible) rc = err_capture(proc, SEV_WARNING, ZBAR_ERR_CLOSED, __func__, "display window not available for input"); if(rc > 0) rc = proc->input; _zbar_mutex_lock(&proc->mutex); proc_leave(proc); return(rc); }
int zbar_process_one (zbar_processor_t *proc, int timeout) { proc_enter(proc); int streaming = proc->streaming; _zbar_mutex_unlock(&proc->mutex); int rc = 0; if(!proc->video) { rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "video input not initialized"); goto done; } if(!streaming) { rc = zbar_processor_set_active(proc, 1); if(rc) goto done; } zbar_timer_t timer; rc = _zbar_processor_wait(proc, EVENT_OUTPUT, _zbar_timer_init(&timer, timeout)); if(!streaming && zbar_processor_set_active(proc, 0)) rc = -1; done: _zbar_mutex_lock(&proc->mutex); proc_leave(proc); return(rc); }
int zbar_processor_set_visible (zbar_processor_t *proc, int visible) { proc_enter(proc); _zbar_mutex_unlock(&proc->mutex); int rc = 0; if(proc->window) { if(proc->video) rc = _zbar_processor_set_size(proc, zbar_video_get_width(proc->video), zbar_video_get_height(proc->video)); if(!rc) rc = _zbar_processor_set_visible(proc, visible); if(!rc) proc->visible = (visible != 0); } else if(visible) rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "processor display window not initialized"); _zbar_mutex_lock(&proc->mutex); proc_leave(proc); return(rc); }
int zbar_processor_is_visible (zbar_processor_t *proc) { proc_enter(proc); int visible = proc->window && proc->visible; proc_leave(proc); return(visible); }
int zbar_processor_request_iomode (zbar_processor_t *proc, int iomode) { proc_enter(proc); proc->req_iomode = iomode; proc_leave(proc); return(0); }
int zbar_processor_request_interface (zbar_processor_t *proc, int ver) { proc_enter(proc); proc->req_intf = ver; proc_leave(proc); return(0); }
int zbar_processor_force_format (zbar_processor_t *proc, unsigned long input, unsigned long output) { proc_enter(proc); proc->force_input = input; proc->force_output = output; proc_leave(proc); return(0); }
int zbar_processor_request_size (zbar_processor_t *proc, unsigned width, unsigned height) { proc_enter(proc); proc->req_width = width; proc->req_height = height; proc_leave(proc); return(0); }
int zbar_processor_set_config (zbar_processor_t *proc, zbar_symbol_type_t sym, zbar_config_t cfg, int val) { proc_enter(proc); int rc = zbar_image_scanner_set_config(proc->scanner, sym, cfg, val); proc_leave(proc); return(rc); }
const zbar_symbol_set_t* zbar_processor_get_results (const zbar_processor_t *proc) { zbar_processor_t *ncproc = (zbar_processor_t*)proc; proc_enter(ncproc); const zbar_symbol_set_t *syms = proc->syms; if(syms) zbar_symbol_set_ref(syms, 1); proc_leave(ncproc); return(syms); }
int zbar_processor_set_visible (zbar_processor_t *proc, int visible) { int rc = 0; proc_enter(proc); _zbar_mutex_unlock(&proc->mutex); rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "processor display window not initialized"); _zbar_mutex_lock(&proc->mutex); proc_leave(proc); return(rc); }
zbar_image_data_handler_t* zbar_processor_set_data_handler (zbar_processor_t *proc, zbar_image_data_handler_t *handler, const void *userdata) { zbar_image_data_handler_t *result = NULL; proc_enter(proc); result = proc->handler; proc->handler = handler; proc->userdata = userdata; proc_leave(proc); return(result); }
int zbar_process_image (zbar_processor_t *proc, zbar_image_t *img) { int rc; proc_enter(proc); _zbar_mutex_unlock(&proc->mutex); rc = 0; if(!rc) { zbar_image_scanner_enable_cache(proc->scanner, 0); rc = _zbar_process_image(proc, img); if(proc->streaming) zbar_image_scanner_enable_cache(proc->scanner, 1); } _zbar_mutex_lock(&proc->mutex); proc_leave(proc); return(rc); }
int zbar_process_image (zbar_processor_t *proc, zbar_image_t *img) { proc_enter(proc); _zbar_mutex_unlock(&proc->mutex); int rc = 0; if(img && proc->window) rc = _zbar_processor_set_size(proc, zbar_image_get_width(img), zbar_image_get_height(img)); if(!rc) { zbar_image_scanner_enable_cache(proc->scanner, 0); rc = _zbar_process_image(proc, img); if(proc->streaming) zbar_image_scanner_enable_cache(proc->scanner, 1); } _zbar_mutex_lock(&proc->mutex); proc_leave(proc); return(rc); }
int zbar_processor_set_active (zbar_processor_t *proc, int active) { proc_enter(proc); int rc; if(!proc->video) { rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_INVALID, __func__, "video input not initialized"); goto done; } _zbar_mutex_unlock(&proc->mutex); zbar_image_scanner_enable_cache(proc->scanner, active); rc = zbar_video_enable(proc->video, active); if(!rc) { _zbar_mutex_lock(&proc->mutex); proc->streaming = active; _zbar_mutex_unlock(&proc->mutex); rc = _zbar_processor_enable(proc); } else err_copy(proc, proc->video); if(!proc->streaming && proc->window) { if(zbar_window_draw(proc->window, NULL) && !rc) rc = err_copy(proc, proc->window); _zbar_processor_invalidate(proc); } _zbar_mutex_lock(&proc->mutex); if(proc->video_thread.started) _zbar_event_trigger(&proc->video_thread.notify); done: proc_leave(proc); return(rc); }