Browse Source

Add --list-{device,vinputs,voutputs} parameters and change output formating.

Georgi Chorbadzhiyski 9 years ago
parent
commit
97e21b220e
6 changed files with 193 additions and 79 deletions
  1. 1
    0
      ChangeLog
  2. 1
    0
      Makefile
  3. 59
    35
      README
  4. 79
    0
      display.c
  5. 20
    0
      display.h
  6. 33
    44
      videohubctrl.c

+ 1
- 0
ChangeLog View File

@@ -6,6 +6,7 @@ xxxx-xx-xx : Version next
6 6
  * Change output formatting to better show port locks and numbers.
7 7
  * Add support for setting video input/output names, video output locking
8 8
    and video output routing.
9
+ * Add --list-device, --list-vinputs and --list-voutputs parameters.
9 10
 
10 11
 2014-11-27 : Version 0.2
11 12
  * Fix port routing. Previously it was reversed and incorrect.

+ 1
- 0
Makefile View File

@@ -31,6 +31,7 @@ videohubctrl_SRC = \
31 31
 	cmd.c \
32 32
 	net.c \
33 33
 	util.c \
34
+	display.c \
34 35
 	videohubctrl.c
35 36
 videohubctrl_LIBS = -lpthread
36 37
 videohubctrl_OBJS = $(FUNCS_LIB) $(videohubctrl_SRC:.c=.o)

+ 59
- 35
README View File

@@ -115,49 +115,73 @@ Here is how videohubctrl output looks like:
115 115
 
116 116
 |----------------------------------------------------------------------|
117 117
 gf@gf:~/git/videohubctrl$ ./videohubctrl --host sdi-matrix
118
-Protocol version: 2.4
119
-Model name: Blackmagic Micro Videohub
120
-Unique ID: 7c2e0d021714
121
-Video inputs: 16
122
-Video processing units: 0
123
-Video outputs: 16
124
-Video monitoring outputs: 0
125
-Serial ports: 0
118
+Device info
119
+  -----------------------------------------------------------
120
+  | Device address             | sdi-matrix                 |
121
+  | Device port                | 9990                       |
122
+  | Model name                 | Blackmagic Micro Videohub  |
123
+  | Unique ID                  | 7c2e0d021714               |
124
+  | Protocol                   | 2.4                        |
125
+  | Video inputs               | 16                         |
126
+  | Video outputs              | 16                         |
127
+  -----------------------------------------------------------
126 128
 
127
------------------------------------------------------------------------
128
-| i# | Input name                | o# | x | Output name               |
129
------------------------------------------------------------------------
130
-|  1 | Windows 3                 |  1 | L | Enc1 1                    |
131
-|  2 | Windows 2                 |  2 | L | Enc1 2                    |
132
-|  3 | Windows 1                 |  3 | L | Enc1 3                    |
133
-|  4 | Windows 1                 |  4 | L | Enc1 4                    |
134
-|  5 | Input 5                   |  5 |   | Output 5                  |
135
-|  6 | Input 6                   |  6 |   | Output 6                  |
136
-|  7 | Input 7                   |  7 |   | Output 7                  |
137
-|  8 | Input 8                   |  8 |   | Output 8                  |
138
-|  9 | Windows 4 HD              |  9 | L | Enc2 1                    |
139
-| 10 | Input 10                  | 10 |   | Output 10                 |
140
-| 11 | Input 11                  | 11 |   | Output 11                 |
141
-| 12 | DPlay2                    | 12 | L | Denc                      |
142
-| 13 | DPlay1                    | 13 | O | Output 13                 |
143
-| 14 | Input 14                  | 14 |   | Output 14                 |
144
-| 15 | Input 15                  | 15 |   | Output 15                 |
145
-| 16 | Loopback                  | 16 |   | Loopback                  |
146
------------------------------------------------------------------------
129
+Video inputs
130
+  ---------------------------------
131
+  | ## | Video input name         |
132
+  ---------------------------------
133
+  |  1 | Windows 1                |
134
+  |  2 | Windows 2                |
135
+  |  3 | Windows 3                |
136
+  |  4 | Windows 4 HD             |
137
+  |  5 | Input 5                  |
138
+  |  6 | Input 6                  |
139
+  |  7 | Input 7                  |
140
+  |  8 | Input 8                  |
141
+  |  9 | Input 9                  |
142
+  | 10 | Input 10                 |
143
+  | 11 | Input 11                 |
144
+  | 12 | DPlay1                   |
145
+  | 13 | DPlay2                   |
146
+  | 14 | Input 14                 |
147
+  | 15 | Input 15                 |
148
+  | 16 | Loopback                 |
149
+  ---------------------------------
150
+
151
+Video outputs
152
+  ----------------------------------------------------------------
153
+  | ## | x | Video output name        | Connected video input    |
154
+  ----------------------------------------------------------------
155
+  |  1 | L | Enc1 1                   | Windows 3                |
156
+  |  2 | L | Enc1 2                   | Windows 2                |
157
+  |  3 | L | Enc1 3                   | Windows 1                |
158
+  |  4 | L | Enc1 4                   | Windows 1                |
159
+  |  5 |   | Output 5                 | Input 5                  |
160
+  |  6 |   | Output 6                 | Input 6                  |
161
+  |  7 |   | Output 7                 | Input 7                  |
162
+  |  8 |   | Output 8                 | Input 8                  |
163
+  |  9 | L | Enc2 1                   | Windows 4 HD             |
164
+  | 10 |   | Output 10                | Input 10                 |
165
+  | 11 |   | Output 11                | Input 11                 |
166
+  | 12 | L | Denc                     | DPlay2                   |
167
+  | 13 | O | Output 13                | DPlay1                   |
168
+  | 14 |   | Output 14                | Input 14                 |
169
+  | 15 |   | Output 15                | Input 15                 |
170
+  | 16 | O | Loopback                 | Loopback                 |
171
+  ----------------------------------------------------------------
147 172
 
148 173
 gf@gf:~/git/videohubctrl$
149 174
 |----------------------------------------------------------------------|
150 175
 
151
-Output Legend
152
-=============
176
+Video outputs Legend
177
+====================
153 178
 
154
- Column 1 (i#) - Input port number
155
- Column 2 (..) - Input port names
156
- Column 3 (o#) - Output port number
157
- Column 4 (x)  - Output port lock status
179
+ Column 1 (##) - Input port number
180
+ Column 2 (x)  - Output port lock status
158 181
                   L - The port is locked by another IP address (user)
159 182
                   O - The port is locked by me (from my IP address)
160
- Column 5      - Output port names
183
+ Column 3      - Output port names
184
+ Column 4      - Which input port is routed to this output
161 185
 
162 186
 
163 187
 Reporting bugs

+ 79
- 0
display.c View File

@@ -0,0 +1,79 @@
1
+/*
2
+ * === Display functions ===
3
+ *
4
+ * Blackmagic Design Videohub control application
5
+ * Copyright (C) 2014 Unix Solutions Ltd.
6
+ * Written by Georgi Chorbadzhiyski
7
+ *
8
+ * Released under MIT license.
9
+ * See LICENSE-MIT.txt for license terms.
10
+ *
11
+ */
12
+
13
+#include <stdio.h>
14
+
15
+#include "data.h"
16
+#include "display.h"
17
+
18
+static void printf_line(int len) {
19
+	int i;
20
+	printf("  ");
21
+	for (i = 0; i < len; i++)
22
+		printf("-");
23
+	printf("\n");
24
+}
25
+
26
+void print_device_info(struct videohub_data *d) {
27
+	int len = 59;
28
+	printf("Device info\n");
29
+	printf_line(len);
30
+	printf("  | %-26s | %-26s |\n", "Device address", d->dev_host);
31
+	printf("  | %-26s | %-26s |\n", "Device port", d->dev_port);
32
+	printf("  | %-26s | %-26s |\n", "Model name", d->device.model_name);
33
+	printf("  | %-26s | %-26s |\n", "Unique ID", d->device.unique_id);
34
+	printf("  | %-26s | %-26s |\n", "Protocol", d->device.protocol_ver);
35
+	printf("  | %-26s | %-26u |\n", "Video inputs", d->device.num_video_inputs);
36
+	printf("  | %-26s | %-26u |\n", "Video outputs", d->device.num_video_outputs);
37
+	if (d->device.num_serial_ports)
38
+		printf("  | %-26s | %-26u |\n", "Serial ports", d->device.num_serial_ports);
39
+	if (d->device.num_video_processing_units)
40
+		printf("  | %-26s | %-26u |\n", "Video processing units", d->device.num_video_processing_units);
41
+	if (d->device.num_video_monitoring_outputs)
42
+		printf("  | %-26s | %-26u |\n", "Video monitoring outputs", d->device.num_video_monitoring_outputs);
43
+	printf_line(len);
44
+	printf("\n");
45
+}
46
+
47
+void print_device_video_inputs(struct videohub_data *d) {
48
+	unsigned int i, len = 33;
49
+	printf("Video inputs\n");
50
+	printf_line(len);
51
+	printf("  | ## | %-24s |\n", "Video input name");
52
+	printf_line(len);
53
+	for(i = 0; i < d->device.num_video_inputs; i++) {
54
+		printf("  | %2d | %-24s |\n",
55
+			i + 1,
56
+			d->inputs[i].name
57
+		);
58
+	}
59
+	printf_line(len);
60
+	printf("\n");
61
+}
62
+
63
+void print_device_video_outputs(struct videohub_data *d) {
64
+	unsigned int i, len = 64;
65
+	printf("Video outputs\n");
66
+	printf_line(len);
67
+	printf("  | ## | x | %-24s | %-24s |\n", "Video output name", "Connected video input");
68
+	printf_line(len);
69
+	for(i = 0; i < MIN(d->device.num_video_outputs, ARRAY_SIZE(d->outputs)); i++) {
70
+		printf("  | %2d | %c | %-24s | %-24s |\n",
71
+			i + 1,
72
+			d->outputs[i].locked ? (d->outputs[i].locked_other ? 'L' : 'O') : ' ',
73
+			d->outputs[i].name,
74
+			d->inputs[d->outputs[i].routed_to].name
75
+		);
76
+	}
77
+	printf_line(len);
78
+	printf("\n");
79
+}

+ 20
- 0
display.h View File

@@ -0,0 +1,20 @@
1
+/*
2
+ * === Display functions ===
3
+ *
4
+ * Blackmagic Design Videohub control application
5
+ * Copyright (C) 2014 Unix Solutions Ltd.
6
+ * Written by Georgi Chorbadzhiyski
7
+ *
8
+ * Released under MIT license.
9
+ * See LICENSE-MIT.txt for license terms.
10
+ *
11
+ */
12
+
13
+#ifndef DISPLAY_H
14
+#define DISPLAY_H
15
+
16
+void print_device_info(struct videohub_data *d);
17
+void print_device_video_inputs(struct videohub_data *d);
18
+void print_device_video_outputs(struct videohub_data *d);
19
+
20
+#endif

+ 33
- 44
videohubctrl.c View File

@@ -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
 

Loading…
Cancel
Save