trying to work with v4l2 loopback but not implemented
This commit is contained in:
@@ -92,6 +92,7 @@ typedef struct VideoDevice {
|
|||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int pixelformat;
|
unsigned int pixelformat;
|
||||||
unsigned int bytesperline;
|
unsigned int bytesperline;
|
||||||
|
bool output;
|
||||||
struct v4l2_buffer buf;
|
struct v4l2_buffer buf;
|
||||||
EGLImageKHR dma_image;
|
EGLImageKHR dma_image;
|
||||||
} VideoDevice;
|
} VideoDevice;
|
||||||
|
|||||||
+20
-8
@@ -94,6 +94,8 @@ static bool set_device_format(VideoDevice *device, unsigned int preferred_width,
|
|||||||
unsigned int preferred_height) {
|
unsigned int preferred_height) {
|
||||||
struct v4l2_format fmt;
|
struct v4l2_format fmt;
|
||||||
|
|
||||||
|
device->output = false;
|
||||||
|
|
||||||
memset(&fmt, 0, sizeof(fmt));
|
memset(&fmt, 0, sizeof(fmt));
|
||||||
|
|
||||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
@@ -103,9 +105,16 @@ static bool set_device_format(VideoDevice *device, unsigned int preferred_width,
|
|||||||
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
||||||
|
|
||||||
if (ioctl(device->fd, VIDIOC_S_FMT, &fmt) == -1) {
|
if (ioctl(device->fd, VIDIOC_S_FMT, &fmt) == -1) {
|
||||||
ioctl_error(device, "VIDIOC_S_FMT", "Requested buffer type not supported");
|
fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
|
||||||
|
|
||||||
|
device->output = true;
|
||||||
|
|
||||||
|
if (ioctl(device->fd, VIDIOC_S_FMT, &fmt) == -1) {
|
||||||
|
ioctl_error(device, "VIDIOC_S_FMT",
|
||||||
|
"Requested buffer type not supported");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
device->width = fmt.fmt.pix.width;
|
device->width = fmt.fmt.pix.width;
|
||||||
device->height = fmt.fmt.pix.height;
|
device->height = fmt.fmt.pix.height;
|
||||||
@@ -126,7 +135,8 @@ static bool request_buffers(VideoDevice *device) {
|
|||||||
|
|
||||||
memset(&reqbuf, 0, sizeof(reqbuf));
|
memset(&reqbuf, 0, sizeof(reqbuf));
|
||||||
|
|
||||||
reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
reqbuf.type =
|
||||||
|
device->output ? V4L2_BUF_TYPE_VIDEO_OUTPUT : V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
reqbuf.memory = V4L2_MEMORY_MMAP;
|
reqbuf.memory = V4L2_MEMORY_MMAP;
|
||||||
reqbuf.count = 1;
|
reqbuf.count = 1;
|
||||||
|
|
||||||
@@ -148,8 +158,9 @@ static bool export_buffer(VideoDevice *device) {
|
|||||||
|
|
||||||
memset(&expbuf, 0, sizeof(expbuf));
|
memset(&expbuf, 0, sizeof(expbuf));
|
||||||
|
|
||||||
expbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
expbuf.type =
|
||||||
expbuf.index = 0; /// '0' for one buffer
|
device->output ? V4L2_BUF_TYPE_VIDEO_OUTPUT : V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
expbuf.index = 0;
|
||||||
expbuf.flags = O_RDONLY;
|
expbuf.flags = O_RDONLY;
|
||||||
|
|
||||||
if (ioctl(device->fd, VIDIOC_EXPBUF, &expbuf) == -1) {
|
if (ioctl(device->fd, VIDIOC_EXPBUF, &expbuf) == -1) {
|
||||||
@@ -180,7 +191,8 @@ static bool open_stream(VideoDevice *device) {
|
|||||||
static void create_image_buffer(VideoDevice *device) {
|
static void create_image_buffer(VideoDevice *device) {
|
||||||
memset(&device->buf, 0, sizeof(device->buf));
|
memset(&device->buf, 0, sizeof(device->buf));
|
||||||
|
|
||||||
device->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
device->buf.type =
|
||||||
|
device->output ? V4L2_BUF_TYPE_VIDEO_OUTPUT : V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
device->buf.memory = V4L2_MEMORY_MMAP;
|
device->buf.memory = V4L2_MEMORY_MMAP;
|
||||||
device->buf.index = 0;
|
device->buf.index = 0;
|
||||||
|
|
||||||
@@ -209,9 +221,9 @@ VideoDevice video_init(char *name, unsigned int preferred_width,
|
|||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!request_buffers(&device)) {
|
if (!request_buffers(&device)) {
|
||||||
// return device;
|
return device;
|
||||||
// }
|
}
|
||||||
|
|
||||||
if (!export_buffer(&device)) {
|
if (!export_buffer(&device)) {
|
||||||
return device;
|
return device;
|
||||||
|
|||||||
Reference in New Issue
Block a user