mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-14 11:33:43 +00:00
configurable input channel
This commit is contained in:
@@ -185,6 +185,7 @@ void device_close(struct device_t *dev) {
|
|||||||
|
|
||||||
static int _device_open_check_cap(struct device_t *dev) {
|
static int _device_open_check_cap(struct device_t *dev) {
|
||||||
struct v4l2_capability cap;
|
struct v4l2_capability cap;
|
||||||
|
int input = dev->input; // Needs pointer to int for ioctl()
|
||||||
|
|
||||||
MEMSET_ZERO(cap);
|
MEMSET_ZERO(cap);
|
||||||
|
|
||||||
@@ -204,10 +205,16 @@ static int _device_open_check_cap(struct device_t *dev) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_INFO("Using input channel: %d", input);
|
||||||
|
if (xioctl(dev->run->fd, VIDIOC_S_INPUT, &input) < 0) {
|
||||||
|
LOG_ERROR("Can't set input channel");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (dev->standard != V4L2_STD_UNKNOWN) {
|
if (dev->standard != V4L2_STD_UNKNOWN) {
|
||||||
LOG_INFO("Using TV standard: %s", _standard_to_string(dev->standard));
|
LOG_INFO("Using TV standard: %s", _standard_to_string(dev->standard));
|
||||||
if (xioctl(dev->run->fd, VIDIOC_S_STD, &dev->standard) < 0) {
|
if (xioctl(dev->run->fd, VIDIOC_S_STD, &dev->standard) < 0) {
|
||||||
LOG_PERROR("Can't set video standard");
|
LOG_ERROR("Can't set video standard");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ struct device_runtime_t {
|
|||||||
|
|
||||||
struct device_t {
|
struct device_t {
|
||||||
char *path;
|
char *path;
|
||||||
|
unsigned input;
|
||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
unsigned format;
|
unsigned format;
|
||||||
|
|||||||
11
src/main.c
11
src/main.c
@@ -40,9 +40,10 @@
|
|||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
|
|
||||||
static const char _short_opts[] = "d:x:y:f:a:e:z:tn:w:q:c:s:p:r:h";
|
static const char _short_opts[] = "d:i:x:y:f:a:e:z:tn:w:q:c:s:p:r:h";
|
||||||
static const struct option _long_opts[] = {
|
static const struct option _long_opts[] = {
|
||||||
{"device", required_argument, NULL, 'd'},
|
{"device", required_argument, NULL, 'd'},
|
||||||
|
{"input", required_argument, NULL, 'i'},
|
||||||
{"width", required_argument, NULL, 'x'},
|
{"width", required_argument, NULL, 'x'},
|
||||||
{"height", required_argument, NULL, 'y'},
|
{"height", required_argument, NULL, 'y'},
|
||||||
{"format", required_argument, NULL, 'f'},
|
{"format", required_argument, NULL, 'f'},
|
||||||
@@ -83,9 +84,10 @@ static void _help(struct device_t *dev, struct encoder_t *encoder, struct http_s
|
|||||||
printf("Copyright (C) 2018 Maxim Devaev <mdevaev@gmail.com>\n\n");
|
printf("Copyright (C) 2018 Maxim Devaev <mdevaev@gmail.com>\n\n");
|
||||||
printf("Capturing options:\n");
|
printf("Capturing options:\n");
|
||||||
printf("------------------\n");
|
printf("------------------\n");
|
||||||
printf(" -d|--device </dev/path> -- Path to V4L2 device. Default: %s\n\n", dev->path);
|
printf(" -d|--device </dev/path> -- Path to V4L2 device. Default: %s.\n\n", dev->path);
|
||||||
printf(" -x|--width <N> -- Initial image width. Default: %d\n\n", dev->width);
|
printf(" -i|--input <N> -- Input channel. Default: %u.\n\n", dev->input);
|
||||||
printf(" -y|--height <N> -- Initial image height. Default: %d\n\n", dev->height);
|
printf(" -x|--width <N> -- Initial image width. Default: %d.\n\n", dev->width);
|
||||||
|
printf(" -y|--height <N> -- Initial image height. Default: %d.\n\n", dev->height);
|
||||||
printf(" -f|--format <fmt> -- Image format.\n");
|
printf(" -f|--format <fmt> -- Image format.\n");
|
||||||
printf(" Available: %s; default: YUYV.\n\n", FORMATS_STR);
|
printf(" Available: %s; default: YUYV.\n\n", FORMATS_STR);
|
||||||
printf(" -a|--tv-standard <std> -- Force TV standard.\n");
|
printf(" -a|--tv-standard <std> -- Force TV standard.\n");
|
||||||
@@ -156,6 +158,7 @@ static int _parse_options(int argc, char *argv[], struct device_t *dev, struct e
|
|||||||
while ((ch = getopt_long(argc, argv, _short_opts, _long_opts, &index)) >= 0) {
|
while ((ch = getopt_long(argc, argv, _short_opts, _long_opts, &index)) >= 0) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'd': OPT_SET(dev->path, optarg);
|
case 'd': OPT_SET(dev->path, optarg);
|
||||||
|
case 'i': OPT_UNSIGNED(dev->input, "--input", 0, 128);
|
||||||
case 'x': OPT_UNSIGNED(dev->width, "--width", 320, 1920);
|
case 'x': OPT_UNSIGNED(dev->width, "--width", 320, 1920);
|
||||||
case 'y': OPT_UNSIGNED(dev->height, "--height", 180, 1200);
|
case 'y': OPT_UNSIGNED(dev->height, "--height", 180, 1200);
|
||||||
# pragma GCC diagnostic ignored "-Wsign-compare"
|
# pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
|||||||
Reference in New Issue
Block a user