Logo Search packages:      
Sourcecode: zbar version File versions  Download package

int zbar_video_enable ( zbar_video_t video,
int  enable 
)

start/stop video capture. all buffered images are retired when capture is disabled.

Returns:
0 if successful or -1 if an error occurs

Definition at line 293 of file video.c.

References ZBAR_ERR_INVALID, zbar_negotiate_format(), and zbar_video_enable().

Referenced by zbar::Video::enable(), zbar_processor_set_active(), zbar_video_enable(), and zbar_video_open().

{
    if(vdo->active == enable)
        return(0);

    if(enable) {
        if(vdo->intf == VIDEO_INVALID)
            return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_INVALID, __func__,
                               "video device not opened"));

        if(!vdo->initialized &&
           zbar_negotiate_format(vdo, NULL))
            return(-1);
    }

    if(video_lock(vdo))
        return(-1);
    vdo->active = enable;
    if(enable) {
        /* enqueue all buffers */
        int i;
        for(i = 0; i < vdo->num_images; i++)
            if(vdo->nq(vdo, vdo->images[i]) ||
               ((i + 1 < vdo->num_images) && video_lock(vdo)))
                return(-1);
        
        return(vdo->start(vdo));
    }
    else {
        int i;
        for(i = 0; i < vdo->num_images; i++)
            vdo->images[i]->next = NULL;
        vdo->nq_image = vdo->dq_image = NULL;
        if(video_unlock(vdo))
            return(-1);

        return(vdo->stop(vdo));
    }
}


Generated by  Doxygen 1.6.0   Back to index