Пример #1
0
void video_close(void *handle) {
    if(isdesktop(handle)) {
        XShmDetach(deskdisplay, &shminfo);
        return;
    }

    v4l_close();
}
Пример #2
0
bool native_video_init(void *handle) {
    if (isdesktop(handle)) {
        utox_v4l_fd = -1;

        GRAB_POS grab = grab_pos();
        video_x      = MIN(grab.dn_x, grab.up_x);
        video_y      = MIN(grab.dn_y, grab.up_y);
        video_width  = MAX(grab.dn_x, grab.up_x) - MIN(grab.dn_x, grab.up_x);
        video_height = MAX(grab.dn_y, grab.up_y) - MIN(grab.dn_y, grab.up_y);

        if (video_width & 1) {
            if (video_x & 1) {
                video_x--;
            }
            video_width++;
        }

        if (video_height & 1) {
            if (video_y & 1) {
                video_y--;
            }
            video_height++;
        }

        if (!(screen_image = XShmCreateImage(deskdisplay, DefaultVisual(deskdisplay, deskscreen),
                                             DefaultDepth(deskdisplay, deskscreen), ZPixmap, NULL, &shminfo,
                                             video_width, video_height))) {
            return false;
        }

        if ((shminfo.shmid = shmget(IPC_PRIVATE, screen_image->bytes_per_line * screen_image->height, IPC_CREAT | 0777))
            < 0) {
            return false;
        }

        if ((shminfo.shmaddr = screen_image->data = (char *)shmat(shminfo.shmid, 0, 0)) == (char *)-1) {
            return false;
        }

        shminfo.readOnly = False;
        if (!XShmAttach(deskdisplay, &shminfo)) {
            return false;
        }

        return true;
    }

    return v4l_init(handle);
}