sysprog21 / vcam

Virtual camera device driver for Linux
MIT License
105 stars 45 forks source link

Can't change video manually #33

Open hankTaro opened 1 year ago

hankTaro commented 1 year ago

I wrote the test.c as below

#include <fcntl.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <unistd.h>

static char fb_path[128] = "/dev/fb1";
static int fd;

void signal_exit_handler(int sig)
{
    close(fd);
    exit(0);
}

int main()
{
    signal(SIGINT, signal_exit_handler);
    fd = open(fb_path, O_RDWR);
    unsigned char rgb[3] = {10, 60, 128};
    while (1) {
        for (int i = 0; i < 480; i++) {
            for (int j = 0; j < 640; j++) {
                write(fd, rgb, sizeof(rgb));
            }
        }
        for (int i = 0; i < 3; i++) {
            rgb[i]++;
        }
    }
    return 0;
}

after compile I enter this command

./test # terminal 1
vlc v4l2:///dev/video2 # terminal 2

but video is still the original black and white gradient picture

AGenchev commented 1 year ago

It works for me, thanks !

But it eats all CPU time because you write byte-by-byte onto the framebuffer. I modified it to have own framebuffer and dump it onto the fd at once. Also limited it to 30FPS to limit the cpu usage. I suggest you to close this issue.