|
@@ -18,6 +18,7 @@
|
18
|
18
|
#include "cmd.h"
|
19
|
19
|
#include "net.h"
|
20
|
20
|
#include "util.h"
|
|
21
|
+#include "display.h"
|
21
|
22
|
#include "version.h"
|
22
|
23
|
|
23
|
24
|
#include "libfuncs/libfuncs.h"
|
|
@@ -28,6 +29,13 @@ int quiet;
|
28
|
29
|
static struct videohub_data maindata;
|
29
|
30
|
static int show_info = 1;
|
30
|
31
|
static int show_monitor = 0;
|
|
32
|
+static int show_list = 0;
|
|
33
|
+
|
|
34
|
+enum list_actions {
|
|
35
|
+ action_list_device = (1 << 0),
|
|
36
|
+ action_list_vinputs = (1 << 1),
|
|
37
|
+ action_list_voutputs = (1 << 2),
|
|
38
|
+};
|
31
|
39
|
|
32
|
40
|
static const char *program_id = PROGRAM_NAME " Version: " VERSION " Git: " GIT_VER;
|
33
|
41
|
|
|
@@ -42,6 +50,9 @@ static const struct option long_options[] = {
|
42
|
50
|
{ "version", no_argument, NULL, 'V' },
|
43
|
51
|
{ "info", no_argument, NULL, 'i' },
|
44
|
52
|
{ "monitor", no_argument, NULL, 'm' },
|
|
53
|
+ { "list-device", no_argument, NULL, 901 },
|
|
54
|
+ { "list-vinputs", no_argument, NULL, 902 },
|
|
55
|
+ { "list-voutputs", no_argument, NULL, 903 },
|
45
|
56
|
{ "vi-name", required_argument, NULL, 1001 },
|
46
|
57
|
{ "vo-name", required_argument, NULL, 1002 },
|
47
|
58
|
{ "vo-route", required_argument, NULL, 1011 },
|
|
@@ -66,8 +77,14 @@ static void show_help(struct videohub_data *data) {
|
66
|
77
|
printf(" -V --version | Show program version.\n");
|
67
|
78
|
printf("\n");
|
68
|
79
|
printf("Commands:\n");
|
69
|
|
- printf(" -i --info | Show device info (default command).\n");
|
70
|
|
- printf(" -m --monitor | Show real time monitor for config changes.\n");
|
|
80
|
+ printf(" -i --info | Show full device info (default command).\n");
|
|
81
|
+ printf(" . This command is shows the equivallent of\n");
|
|
82
|
+ printf(" . running all --list-XXX commands.\n");
|
|
83
|
+ printf(" -m --monitor | Display real-time config changes monitor.\n");
|
|
84
|
+ printf("\n");
|
|
85
|
+ printf(" --list-device | Display device info.\n");
|
|
86
|
+ printf(" --list-vinputs | List device video inputs.\n");
|
|
87
|
+ printf(" --list-voutputs | List device video outputs.\n");
|
71
|
88
|
printf("\n");
|
72
|
89
|
printf("Configuration:\n");
|
73
|
90
|
printf(" --vi-name <in_X> <name> | Set input <name> to input port X.\n");
|
|
@@ -116,6 +133,9 @@ static void parse_options(struct videohub_data *data, int argc, char **argv) {
|
116
|
133
|
case 'm': // --monitor
|
117
|
134
|
show_monitor = 1;
|
118
|
135
|
break;
|
|
136
|
+ case 901: show_list |= action_list_device; break; // --list-device
|
|
137
|
+ case 902: show_list |= action_list_vinputs; break; // --list-vinputs
|
|
138
|
+ case 903: show_list |= action_list_voutputs; break; // --list-voutputs
|
119
|
139
|
case 1001: // --vi-name
|
120
|
140
|
case 1002: // --vo-name
|
121
|
141
|
case 1011: // --vi-route
|
|
@@ -168,43 +188,6 @@ static void parse_options(struct videohub_data *data, int argc, char **argv) {
|
168
|
188
|
d("Device address: %s:%s\n", data->dev_host, data->dev_port);
|
169
|
189
|
}
|
170
|
190
|
|
171
|
|
-static void print_device_desc(struct device_desc *d) {
|
172
|
|
- printf("\n");
|
173
|
|
- printf("Protocol version: %s\n", d->protocol_ver);
|
174
|
|
- printf("Model name: %s\n", d->model_name);
|
175
|
|
- printf("Unique ID: %s\n", d->unique_id);
|
176
|
|
- printf("Video inputs: %u\n", d->num_video_inputs);
|
177
|
|
- printf("Video processing units: %u\n", d->num_video_processing_units);
|
178
|
|
- printf("Video outputs: %u\n", d->num_video_outputs);
|
179
|
|
- printf("Video monitoring outputs: %u\n", d->num_video_monitoring_outputs);
|
180
|
|
- printf("Serial ports: %u\n", d->num_serial_ports);
|
181
|
|
-}
|
182
|
|
-
|
183
|
|
-static void printf_line(int len) {
|
184
|
|
- int i;
|
185
|
|
- for (i = 0; i < len; i++)
|
186
|
|
- printf("-");
|
187
|
|
- printf("\n");
|
188
|
|
-}
|
189
|
|
-
|
190
|
|
-static void print_device_settings(struct videohub_data *d) {
|
191
|
|
- unsigned int i;
|
192
|
|
- printf("\n");
|
193
|
|
- printf_line(71);
|
194
|
|
- printf("| i# | %-25s | o# | x | %-25s |\n", "Input name", "Output name");
|
195
|
|
- printf_line(71);
|
196
|
|
- for(i = 0; i < MIN(d->device.num_video_outputs, ARRAY_SIZE(d->outputs)); i++) {
|
197
|
|
- printf("| %2d | %-25s | %2d | %c | %-25s |\n",
|
198
|
|
- i + 1,
|
199
|
|
- d->inputs[d->outputs[i].routed_to].name,
|
200
|
|
- i + 1,
|
201
|
|
- d->outputs[i].locked ? (d->outputs[i].locked_other ? 'L' : 'O') : ' ',
|
202
|
|
- d->outputs[i].name
|
203
|
|
- );
|
204
|
|
- }
|
205
|
|
- printf_line(71);
|
206
|
|
-}
|
207
|
|
-
|
208
|
191
|
static int read_device_command_stream(struct videohub_data *d) {
|
209
|
192
|
int ret, ncommands = 0;
|
210
|
193
|
char buf[8192 + 1];
|
|
@@ -277,17 +260,23 @@ int main(int argc, char **argv) {
|
277
|
260
|
} else if (show_monitor) {
|
278
|
261
|
while (1) {
|
279
|
262
|
printf("\e[2J\e[H"); // Clear screen
|
280
|
|
- printf("%s\n", program_id);
|
281
|
|
- print_device_desc(&data->device);
|
282
|
|
- print_device_settings(data);
|
|
263
|
+ print_device_info(data);
|
|
264
|
+ print_device_video_inputs(data);
|
|
265
|
+ print_device_video_outputs(data);
|
283
|
266
|
fflush(stdout);
|
284
|
267
|
do {
|
285
|
268
|
sleep(1);
|
286
|
269
|
} while (read_device_command_stream(data) == 0);
|
287
|
270
|
}
|
|
271
|
+ } else if (show_list) {
|
|
272
|
+ if (show_list & action_list_device) print_device_info(data);
|
|
273
|
+ if (show_list & action_list_vinputs) print_device_video_inputs(data);
|
|
274
|
+ if (show_list & action_list_voutputs) print_device_video_outputs(data);
|
|
275
|
+ fflush(stdout);
|
288
|
276
|
} else if (show_info) {
|
289
|
|
- print_device_desc(&data->device);
|
290
|
|
- print_device_settings(data);
|
|
277
|
+ print_device_info(data);
|
|
278
|
+ print_device_video_inputs(data);
|
|
279
|
+ print_device_video_outputs(data);
|
291
|
280
|
fflush(stdout);
|
292
|
281
|
}
|
293
|
282
|
|