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

zebra_image_t* zebra_video_next_image ( zebra_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 232 of file video.c.

References ZEBRA_ERR_INVALID, zebra_image_create(), and zebra_video_next_image().

Referenced by zebra::Video::next_image(), and zebra_video_next_image().

{
    if(video_lock(vdo))
        return(NULL);
    if(!vdo->active) {
        err_capture(vdo, SEV_ERROR, ZEBRA_ERR_INVALID, __func__,
                    "video not enabled");
        (void)video_unlock(vdo);
        return(NULL);
    }
    zebra_image_t *img = vdo->dq(vdo);
    if(img) {
        if(vdo->num_images < 2) {
            /* return a *copy* of the video image and immediately recycle
             * the driver's buffer to avoid deadlocking the resources
             */
            zebra_image_t *tmp = img;
            (void)video_lock(vdo);
            img = vdo->shadow_image;
            vdo->shadow_image = (img) ? img->next : NULL;
            (void)video_unlock(vdo);
                
            if(!img) {
                img = zebra_image_create();
                assert(img);
                img->refcnt = 0;
                img->src = vdo;
                /* recycle the shadow images */
                img->cleanup = _zebra_video_recycle_shadow;

                img->format = vdo->format;
                img->width = vdo->width;
                img->height = vdo->height;
                img->datalen = vdo->datalen;
                img->data = malloc(vdo->datalen);
            }
            memcpy((void*)img->data, tmp->data, img->datalen);
            _zebra_video_recycle_image(tmp);
        }
        img->refcnt++;
    }
    return(img);
}


Generated by  Doxygen 1.6.0   Back to index