Browse Source

Add support for port statuses (types) reported by Univeral Videohub.

Georgi Chorbadzhiyski 9 years ago
parent
commit
f300e5c449
8 changed files with 162 additions and 61 deletions
  1. 2
    0
      ChangeLog
  2. 63
    47
      README
  3. 20
    0
      cmd.c
  4. 2
    0
      cmd.h
  5. 5
    0
      data.h
  6. 23
    10
      display.c
  7. 25
    0
      vh_test_commands.txt
  8. 22
    4
      videohubctrl.1

+ 2
- 0
ChangeLog View File

@@ -5,6 +5,8 @@
5 5
  * Display where each input is being routed.
6 6
  * Add support for testing the program using pre-recorded commands
7 7
    in text file by using -T / --test-input option.
8
+ * Add support for port statuses (types) which are reported by
9
+   Universal Videohub.
8 10
 
9 11
 2014-11-28 : Version 0.3
10 12
  * Rename -v / --verbose parameter to -d / --debug.

+ 63
- 47
README View File

@@ -12,6 +12,7 @@ videohubctrl currently displays and can configure:
12 12
   - Video output port names
13 13
   - Video output routing
14 14
   - Video output locking
15
+  - Input/Output port statuses
15 16
 
16 17
 The following features found in bigger Videohub models are currently
17 18
 not supported (I don't have the hardware):
@@ -37,10 +38,6 @@ Command line parameters
37 38
 videohubctrl is controlled using command line parameters. Here is a list
38 39
 of supported command line parameters:
39 40
 
40
-videohubctrl Version: 0.3 Git: 0.3-dirty
41
-
42
- Usage: videohubctrl --host <host> [..commands..]
43
-
44 41
 Main options:
45 42
  -h --host <host>           | Set device host name.
46 43
  -p --port <port_number>    | Set device port (default: 9990).
@@ -154,62 +151,81 @@ Device info
154 151
   -----------------------------------------------------------
155 152
 
156 153
 Video inputs
157
-  ----------------------------------------------------------------
158
-  | ## | Video input name         | n | Routed to output         |
159
-  ----------------------------------------------------------------
160
-  |  1 | Windows 1                | 2 | Enc1 3                   |
161
-  |    |                          | . | Enc1 4                   |
162
-  |  2 | Windows 2                | 1 | Enc1 2                   |
163
-  |  3 | Windows 3                | 1 | Enc1 1                   |
164
-  |  4 | Windows 4 HD             | 2 | Output 8                 |
165
-  |    |                          | . | Enc2 1                   |
166
-  |  5 | Input 5                  | 1 | Output 5                 |
167
-  |  6 | Input 6                  | 1 | Output 6                 |
168
-  |  7 | Input 7                  | 1 | Output 7                 |
169
-  |  8 | Input 8                  | 0 | -                        |
170
-  |  9 | Input 9                  | 0 | -                        |
171
-  | 10 | Input 10                 | 1 | Output 10                |
172
-  | 11 | Input 11                 | 1 | Output 11                |
173
-  | 12 | DPlay1                   | 1 | Output 13                |
174
-  | 13 | DPlay2                   | 1 | Denc                     |
175
-  | 14 | Input 14                 | 1 | Output 14                |
176
-  | 15 | Input 15                 | 1 | Output 15                |
177
-  | 16 | Loopback                 | 1 | Loopback                 |
178
-  ----------------------------------------------------------------
154
+  --------------------------------------------------------------------
155
+  | ## | Video input name         | n | Routed to output         | s |
156
+  --------------------------------------------------------------------
157
+  |  1 | Windows 1                | 2 | Enc1 3                   | B |
158
+  |    |                          |   | Enc1 4                   |   |
159
+  |  2 | Windows 2                | 1 | Enc1 2                   | B |
160
+  |  3 | Windows 3                | 1 | Enc1 1                   | B |
161
+  |  4 | Windows 4 HD             | 2 | Output 8                 | B |
162
+  |    |                          |   | Enc2 1                   |   |
163
+  |  5 | Input 5                  | 1 | Output 5                 | o |
164
+  |  6 | Input 6                  | 1 | Output 6                 | o |
165
+  |  7 | Input 7                  | 1 | Output 7                 | o |
166
+  |  8 | Input 8                  | 0 | -                        | o |
167
+  |  9 | Input 9                  | 0 | -                        |   |
168
+  | 10 | Input 10                 | 1 | Output 10                |   |
169
+  | 11 | Input 11                 | 1 | Output 11                |   |
170
+  | 12 | DPlay1                   | 1 | Output 13                |   |
171
+  | 13 | DPlay2                   | 1 | Denc                     |   |
172
+  | 14 | Input 14                 | 1 | Output 14                | x |
173
+  | 15 | Input 15                 | 1 | Output 15                | x |
174
+  | 16 | Loopback                 | 1 | Loopback                 |   |
175
+  --------------------------------------------------------------------
179 176
 
180 177
 Video outputs
181
-  ----------------------------------------------------------------
182
-  | ## | x | Video output name        | Connected video input    |
183
-  ----------------------------------------------------------------
184
-  |  1 | L | Enc1 1                   | Windows 3                |
185
-  |  2 | L | Enc1 2                   | Windows 2                |
186
-  |  3 | L | Enc1 3                   | Windows 1                |
187
-  |  4 | L | Enc1 4                   | Windows 1                |
188
-  |  5 |   | Output 5                 | Input 5                  |
189
-  |  6 |   | Output 6                 | Input 6                  |
190
-  |  7 |   | Output 7                 | Input 7                  |
191
-  |  8 |   | Output 8                 | Windows 4 HD             |
192
-  |  9 | L | Enc2 1                   | Windows 4 HD             |
193
-  | 10 |   | Output 10                | Input 10                 |
194
-  | 11 |   | Output 11                | Input 11                 |
195
-  | 12 | L | Denc                     | DPlay2                   |
196
-  | 13 | O | Output 13                | DPlay1                   |
197
-  | 14 |   | Output 14                | Input 14                 |
198
-  | 15 |   | Output 15                | Input 15                 |
199
-  | 16 | O | Loopback                 | Loopback                 |
200
-  ----------------------------------------------------------------
178
+  --------------------------------------------------------------------
179
+  | ## | x | Video output name        | Connected video input    | s |
180
+  --------------------------------------------------------------------
181
+  |  1 | L | Enc1 1                   | Windows 3                |   |
182
+  |  2 | L | Enc1 2                   | Windows 2                |   |
183
+  |  3 | L | Enc1 3                   | Windows 1                |   |
184
+  |  4 | L | Enc1 4                   | Windows 1                |   |
185
+  |  5 |   | Output 5                 | Input 5                  | x |
186
+  |  6 |   | Output 6                 | Input 6                  | x |
187
+  |  7 |   | Output 7                 | Input 7                  | x |
188
+  |  8 |   | Output 8                 | Windows 4 HD             |   |
189
+  |  9 | L | Enc2 1                   | Windows 4 HD             | B |
190
+  | 10 |   | Output 10                | Input 10                 | B |
191
+  | 11 |   | Output 11                | Input 11                 | B |
192
+  | 12 | L | Denc                     | DPlay2                   | B |
193
+  | 13 | O | Output 13                | DPlay1                   | o |
194
+  | 14 |   | Output 14                | Input 14                 | o |
195
+  | 15 |   | Output 15                | Input 15                 | o |
196
+  | 16 | O | Loopback                 | Loopback                 | o |
197
+  --------------------------------------------------------------------
201 198
 
202 199
 |----------------------------------------------------------------------|
203 200
 
201
+
202
+Video inputs Legend
203
+===================
204
+
205
+ Column 1 (##) - Input port number
206
+ Column 2      - Input port names
207
+ Column 3 (n)  - To how much outputs this input is routed.
208
+ Column 4      - List of output ports which are connected to this input.
209
+ Column 5 (s)  - Port status /type/. Universal Videohub's support
210
+                 BNC/Optical ports and this column shows the port type.
211
+                     - Empty means that the device do not support port
212
+                       status.
213
+                  x  - The port type is "None". This means that the
214
+                       port is not installed.
215
+                  B  - The port type is "BNC".
216
+                  o  - The port type is "Optical".
217
+
218
+
204 219
 Video outputs Legend
205 220
 ====================
206 221
 
207
- Column 1 (##) - Input port number
222
+ Column 1 (##) - Output port number
208 223
  Column 2 (x)  - Output port lock status
209 224
                   L - The port is locked by another IP address (user)
210 225
                   O - The port is locked by me (from my IP address)
211 226
  Column 3      - Output port names
212 227
  Column 4      - Which input port is routed to this output
228
+ Column 5 (s)  - Port status /type/. Same format as in input ports.
213 229
 
214 230
 
215 231
 Development

+ 20
- 0
cmd.c View File

@@ -28,6 +28,8 @@ static struct videohub_commands {
28 28
 	{ CMD_OUTPUT_LABELS,           "OUTPUT LABELS" },
29 29
 	{ CMD_VIDEO_OUTPUT_LOCKS,      "VIDEO OUTPUT LOCKS" },
30 30
 	{ CMD_VIDEO_OUTPUT_ROUTING,    "VIDEO OUTPUT ROUTING" },
31
+	{ CMD_VIDEO_INPUT_STATUS,      "VIDEO INPUT STATUS" },
32
+	{ CMD_VIDEO_OUTPUT_STATUS,     "VIDEO OUTPUT STATUS" },
31 33
 	{ CMD_PING,                    "PING" },
32 34
 	{ CMD_ACK,                     "ACK" },
33 35
 	{ CMD_NAK,                     "NAK" },
@@ -92,6 +94,8 @@ bool parse_command(struct videohub_data *data, char *cmd) {
92 94
 		switch (v->cmd) {
93 95
 		case CMD_INPUT_LABELS:
94 96
 		case CMD_OUTPUT_LABELS:
97
+		case CMD_VIDEO_INPUT_STATUS:
98
+		case CMD_VIDEO_OUTPUT_STATUS:
95 99
 		case CMD_VIDEO_OUTPUT_LOCKS:
96 100
 		case CMD_VIDEO_OUTPUT_ROUTING:
97 101
 			slot_data = strchr(line, ' ');
@@ -152,6 +156,16 @@ bool parse_command(struct videohub_data *data, char *cmd) {
152 156
 				snprintf(data->outputs[slot_pos].name, sizeof(data->inputs[slot_pos].name), "%s", slot_data);
153 157
 			break;
154 158
 
159
+		case CMD_VIDEO_INPUT_STATUS:
160
+			if (valid_slot)
161
+				snprintf(data->inputs[slot_pos].status, sizeof(data->inputs[slot_pos].status), "%s", slot_data);
162
+			break;
163
+
164
+		case CMD_VIDEO_OUTPUT_STATUS:
165
+			if (valid_slot)
166
+				snprintf(data->outputs[slot_pos].status, sizeof(data->outputs[slot_pos].status), "%s", slot_data);
167
+			break;
168
+
155 169
 		case CMD_VIDEO_OUTPUT_LOCKS:
156 170
 			if (valid_slot) {
157 171
 				// L is lock owned by somebody else (set from other IP address)
@@ -279,6 +293,8 @@ void prepare_cmd_entry(struct videohub_data *d, struct vcmd_entry *e) {
279 293
 				die("Unknown input port number/name: %s", e->param2);
280 294
 		}
281 295
 		break;
296
+	case CMD_VIDEO_INPUT_STATUS:
297
+	case CMD_VIDEO_OUTPUT_STATUS:
282 298
 	case CMD_PROTOCOL_PREAMBLE:
283 299
 	case CMD_VIDEOHUB_DEVICE:
284 300
 	case CMD_PING:
@@ -306,6 +322,8 @@ void format_cmd_text(struct vcmd_entry *e, char *buf, unsigned int bufsz) {
306 322
 		snprintf(buf, bufsz, "%s:\n%u %u\n\n", get_cmd_text(e->cmd),
307 323
 			e->port_no1 - 1, e->port_no2 - 1);
308 324
 		break;
325
+	case CMD_VIDEO_INPUT_STATUS:
326
+	case CMD_VIDEO_OUTPUT_STATUS:
309 327
 	case CMD_PROTOCOL_PREAMBLE:
310 328
 	case CMD_VIDEOHUB_DEVICE:
311 329
 	case CMD_PING:
@@ -346,6 +364,8 @@ void show_cmd(struct videohub_data *d, struct vcmd_entry *e) {
346 364
 			e->port_no2, d->inputs [e->port_no2 - 1].name
347 365
 		);
348 366
 		break;
367
+	case CMD_VIDEO_INPUT_STATUS:
368
+	case CMD_VIDEO_OUTPUT_STATUS:
349 369
 	case CMD_PROTOCOL_PREAMBLE:
350 370
 	case CMD_VIDEOHUB_DEVICE:
351 371
 	case CMD_PING:

+ 2
- 0
cmd.h View File

@@ -22,6 +22,8 @@ enum vcmd {
22 22
 	CMD_OUTPUT_LABELS,
23 23
 	CMD_VIDEO_OUTPUT_LOCKS,
24 24
 	CMD_VIDEO_OUTPUT_ROUTING,
25
+	CMD_VIDEO_INPUT_STATUS,
26
+	CMD_VIDEO_OUTPUT_STATUS,
25 27
 	CMD_PING,
26 28
 	CMD_ACK,
27 29
 	CMD_NAK,

+ 5
- 0
data.h View File

@@ -36,6 +36,10 @@ struct device_desc {
36 36
 
37 37
 struct input_desc {
38 38
 	char			name[MAX_NAME_LEN];
39
+	// Port statuses are supported only by Universal Videohub
40
+	// The statuses (actually they are connection types) are:
41
+	//    BNC, Optical or None /missing port/
42
+	char			status[8];
39 43
 };
40 44
 
41 45
 struct output_desc {
@@ -43,6 +47,7 @@ struct output_desc {
43 47
 	unsigned int	routed_to;
44 48
 	bool			locked;
45 49
 	bool			locked_other;
50
+	char			status[8];
46 51
 };
47 52
 
48 53
 struct videohub_data {

+ 23
- 10
display.c View File

@@ -11,8 +11,10 @@
11 11
  */
12 12
 
13 13
 #include <stdio.h>
14
+#include <string.h>
14 15
 
15 16
 #include "data.h"
17
+#include "util.h"
16 18
 #include "display.h"
17 19
 
18 20
 static void printf_line(int len) {
@@ -23,6 +25,14 @@ static void printf_line(int len) {
23 25
 	printf("\n");
24 26
 }
25 27
 
28
+static char format_status(char *status) {
29
+	if (!strlen(status))          return ' ';
30
+	if (streq(status, "BNC"))     return 'B';
31
+	if (streq(status, "Optical")) return 'o';
32
+	if (streq(status, "None"))    return 'x';
33
+	return '?';
34
+}
35
+
26 36
 void print_device_info(struct videohub_data *d) {
27 37
 	int len = 59;
28 38
 	printf("Device info\n");
@@ -45,12 +55,12 @@ void print_device_info(struct videohub_data *d) {
45 55
 }
46 56
 
47 57
 void print_device_video_inputs(struct videohub_data *d) {
48
-	unsigned int i, r, len = 64;
58
+	unsigned int i, r, len = 68;
49 59
 	if (!d->device.num_video_inputs)
50 60
 		return;
51 61
 	printf("Video inputs\n");
52 62
 	printf_line(len);
53
-	printf("  | ## | %-24s | n | %-24s |\n", "Video input name", "Routed to output");
63
+	printf("  | ## | %-24s | n | %-24s | s |\n", "Video input name", "Routed to output");
54 64
 	printf_line(len);
55 65
 	for(i = 0; i < d->device.num_video_inputs; i++) {
56 66
 		unsigned int num_outputs = 0, routed_to = 0;
@@ -61,11 +71,12 @@ void print_device_video_inputs(struct videohub_data *d) {
61 71
 					routed_to = r; // The first output
62 72
 			}
63 73
 		}
64
-		printf("  | %2d | %-24s | %d | ", i + 1, d->inputs[i].name, num_outputs);
74
+		printf("  | %2d | %-24s | %d | ", i + 1, d->inputs[i].name,
75
+			 num_outputs);
65 76
 		if (num_outputs == 0) {
66
-			printf("%-24s |\n", "-");
77
+			printf("%-24s | %c |\n", "-", format_status(d->inputs[i].status));
67 78
 		} else {
68
-			printf("%-24s |\n", d->outputs[routed_to].name);
79
+			printf("%-24s | %c |\n", d->outputs[routed_to].name, format_status(d->inputs[i].status));
69 80
 			bool first_skipped = false;
70 81
 			for(r = 0; r < d->device.num_video_outputs; r++) {
71 82
 				if (d->outputs[r].routed_to == i) {
@@ -73,7 +84,8 @@ void print_device_video_inputs(struct videohub_data *d) {
73 84
 						first_skipped = true;
74 85
 						continue;
75 86
 					}
76
-					printf("  | %2s | %-24s | %s | %-24s |\n", " ", " ", ".", d->outputs[r].name);
87
+					printf("  | %2s | %-24s | %s | %-24s | %c |\n",
88
+						" ", " ", " ", d->outputs[r].name, ' ');
77 89
 				}
78 90
 			}
79 91
 		}
@@ -83,19 +95,20 @@ void print_device_video_inputs(struct videohub_data *d) {
83 95
 }
84 96
 
85 97
 void print_device_video_outputs(struct videohub_data *d) {
86
-	unsigned int i, len = 64;
98
+	unsigned int i, len = 68;
87 99
 	if (!d->device.num_video_outputs)
88 100
 		return;
89 101
 	printf("Video outputs\n");
90 102
 	printf_line(len);
91
-	printf("  | ## | x | %-24s | %-24s |\n", "Video output name", "Connected video input");
103
+	printf("  | ## | x | %-24s | %-24s | s |\n", "Video output name", "Connected video input");
92 104
 	printf_line(len);
93 105
 	for(i = 0; i < d->device.num_video_outputs; i++) {
94
-		printf("  | %2d | %c | %-24s | %-24s |\n",
106
+		printf("  | %2d | %c | %-24s | %-24s | %c |\n",
95 107
 			i + 1,
96 108
 			d->outputs[i].locked ? (d->outputs[i].locked_other ? 'L' : 'O') : ' ',
97 109
 			d->outputs[i].name,
98
-			d->inputs[d->outputs[i].routed_to].name
110
+			d->inputs[d->outputs[i].routed_to].name,
111
+			format_status(d->outputs[i].status)
99 112
 		);
100 113
 	}
101 114
 	printf_line(len);

+ 25
- 0
vh_test_commands.txt View File

@@ -82,3 +82,28 @@ VIDEO OUTPUT ROUTING:
82 82
 13 13
83 83
 14 14
84 84
 15 15
85
+
86
+VIDEO INPUT STATUS:
87
+0 BNC
88
+1 BNC
89
+2 BNC
90
+3 BNC
91
+4 Optical
92
+5 Optical
93
+6 Optical
94
+7 Optical
95
+13 None
96
+14 None
97
+
98
+VIDEO OUTPUT STATUS:
99
+4 None
100
+5 None
101
+6 None
102
+8 BNC
103
+9 BNC
104
+10 BNC
105
+11 BNC
106
+12 Optical
107
+13 Optical
108
+14 Optical
109
+15 Optical

+ 22
- 4
videohubctrl.1 View File

@@ -45,14 +45,32 @@ Show the command line that will restore the device to it's configuration.
45 45
 Display main device info including model, number of ports, etc.
46 46
 .TP
47 47
 \fB\-\-list\-vinputs\fR
48
-Display device video inputs and their names, how many outputs an input
49
-is being routed to and a list of the outputs.
48
+Display device video inputs, port numbers, names, how many outputs an
49
+input is being routed to, the list of the outputs and the port status
50
+(type).
51
+
52
+The port statuses (type) are reported by Universal Videohub and can be
53
+these:
54
+.nf
55
+     - Empty means that the device do not support port status.
56
+  x  - The port type is "None". This means that the port is not
57
+       installed in the device.
58
+  B  - The port type is "BNC".
59
+  o  - The port type is "Optical".
60
+.fi
50 61
 .TP
51 62
 \fB\-\-list\-voutputs\fR
52
-Display device video outputs, their names, locking status and which
53
-input is routed to a given output. There are two locking statuses:
63
+Display device video outputs, port numbers, names, locking status, which
64
+input is routed to a given output and the port status (type).
65
+
66
+There are two locking statuses:
67
+.nf
54 68
   L - The port is locked by another IP address (user)
55 69
   O - The port is locked by me (from my IP address)
70
+.fi
71
+
72
+The port status field (s) have the same format as input ports (described
73
+in \fB\-\-list\-vinputs\fR option).
56 74
 .SH VIDEO INPUT/OUTPUT CONFIGURATION
57 75
 .PP
58 76
 Everywhere where port number is accepted, you can use the port

Loading…
Cancel
Save