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

zbar_image_t* zbar_video_next_image ( zbar_video_t video  ) 

retrieve next captured image. blocks until an image is available.

Returns:
NULL if video is not enabled or an error occurs

Definition at line 334 of file video.c.

References zbar_image_create(), and zbar_video_next_image().

Referenced by zbar::Video::next_image(), and zbar_video_next_image().

{
    if(video_lock(vdo))
        return(NULL);
    if(!vdo->active) {
        video_unlock(vdo);
        return(NULL);
    }

    unsigned frame = vdo->frame++;
    zbar_image_t *img = vdo->dq(vdo);
    if(img) {
        img->seq = frame;
        if(vdo->num_images < 2) {
            /* return a *copy* of the video image and immediately recycle
             * the driver's buffer to avoid deadlocking the resources
             */
            zbar_image_t *tmp = img;
            video_lock(vdo);
            img = vdo->shadow_image;
            vdo->shadow_image = (img) ? img->next : NULL;
            video_unlock(vdo);
                
            if(!img) {
                img = zbar_image_create();
                assert(img);
                img->refcnt = 0;
                img->src = vdo;
                /* recycle the shadow images */

                img->format = vdo->format;
                img->width = vdo->width;
                img->height = vdo->height;
                img->datalen = vdo->datalen;
                img->data = malloc(vdo->datalen);
            }
            img->cleanup = _zbar_video_recycle_shadow;
            img->seq = frame;
            memcpy((void*)img->data, tmp->data, img->datalen);
            _zbar_video_recycle_image(tmp);
        }
        else
            img->cleanup = _zbar_video_recycle_image;
        _zbar_image_refcnt(img, 1);
    }
    return(img);
}


Generated by  Doxygen 1.6.0   Back to index