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
  * Display where each input is being routed.
5
  * Display where each input is being routed.
6
  * Add support for testing the program using pre-recorded commands
6
  * Add support for testing the program using pre-recorded commands
7
    in text file by using -T / --test-input option.
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
 2014-11-28 : Version 0.3
11
 2014-11-28 : Version 0.3
10
  * Rename -v / --verbose parameter to -d / --debug.
12
  * Rename -v / --verbose parameter to -d / --debug.

+ 63
- 47
README View File

12
   - Video output port names
12
   - Video output port names
13
   - Video output routing
13
   - Video output routing
14
   - Video output locking
14
   - Video output locking
15
+  - Input/Output port statuses
15
 
16
 
16
 The following features found in bigger Videohub models are currently
17
 The following features found in bigger Videohub models are currently
17
 not supported (I don't have the hardware):
18
 not supported (I don't have the hardware):
37
 videohubctrl is controlled using command line parameters. Here is a list
38
 videohubctrl is controlled using command line parameters. Here is a list
38
 of supported command line parameters:
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
 Main options:
41
 Main options:
45
  -h --host <host>           | Set device host name.
42
  -h --host <host>           | Set device host name.
46
  -p --port <port_number>    | Set device port (default: 9990).
43
  -p --port <port_number>    | Set device port (default: 9990).
154
   -----------------------------------------------------------
151
   -----------------------------------------------------------
155
 
152
 
156
 Video inputs
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
 Video outputs
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
 Video outputs Legend
219
 Video outputs Legend
205
 ====================
220
 ====================
206
 
221
 
207
- Column 1 (##) - Input port number
222
+ Column 1 (##) - Output port number
208
  Column 2 (x)  - Output port lock status
223
  Column 2 (x)  - Output port lock status
209
                   L - The port is locked by another IP address (user)
224
                   L - The port is locked by another IP address (user)
210
                   O - The port is locked by me (from my IP address)
225
                   O - The port is locked by me (from my IP address)
211
  Column 3      - Output port names
226
  Column 3      - Output port names
212
  Column 4      - Which input port is routed to this output
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
 Development
231
 Development

+ 20
- 0
cmd.c View File

28
 	{ CMD_OUTPUT_LABELS,           "OUTPUT LABELS" },
28
 	{ CMD_OUTPUT_LABELS,           "OUTPUT LABELS" },
29
 	{ CMD_VIDEO_OUTPUT_LOCKS,      "VIDEO OUTPUT LOCKS" },
29
 	{ CMD_VIDEO_OUTPUT_LOCKS,      "VIDEO OUTPUT LOCKS" },
30
 	{ CMD_VIDEO_OUTPUT_ROUTING,    "VIDEO OUTPUT ROUTING" },
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
 	{ CMD_PING,                    "PING" },
33
 	{ CMD_PING,                    "PING" },
32
 	{ CMD_ACK,                     "ACK" },
34
 	{ CMD_ACK,                     "ACK" },
33
 	{ CMD_NAK,                     "NAK" },
35
 	{ CMD_NAK,                     "NAK" },
92
 		switch (v->cmd) {
94
 		switch (v->cmd) {
93
 		case CMD_INPUT_LABELS:
95
 		case CMD_INPUT_LABELS:
94
 		case CMD_OUTPUT_LABELS:
96
 		case CMD_OUTPUT_LABELS:
97
+		case CMD_VIDEO_INPUT_STATUS:
98
+		case CMD_VIDEO_OUTPUT_STATUS:
95
 		case CMD_VIDEO_OUTPUT_LOCKS:
99
 		case CMD_VIDEO_OUTPUT_LOCKS:
96
 		case CMD_VIDEO_OUTPUT_ROUTING:
100
 		case CMD_VIDEO_OUTPUT_ROUTING:
97
 			slot_data = strchr(line, ' ');
101
 			slot_data = strchr(line, ' ');
152
 				snprintf(data->outputs[slot_pos].name, sizeof(data->inputs[slot_pos].name), "%s", slot_data);
156
 				snprintf(data->outputs[slot_pos].name, sizeof(data->inputs[slot_pos].name), "%s", slot_data);
153
 			break;
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
 		case CMD_VIDEO_OUTPUT_LOCKS:
169
 		case CMD_VIDEO_OUTPUT_LOCKS:
156
 			if (valid_slot) {
170
 			if (valid_slot) {
157
 				// L is lock owned by somebody else (set from other IP address)
171
 				// L is lock owned by somebody else (set from other IP address)
279
 				die("Unknown input port number/name: %s", e->param2);
293
 				die("Unknown input port number/name: %s", e->param2);
280
 		}
294
 		}
281
 		break;
295
 		break;
296
+	case CMD_VIDEO_INPUT_STATUS:
297
+	case CMD_VIDEO_OUTPUT_STATUS:
282
 	case CMD_PROTOCOL_PREAMBLE:
298
 	case CMD_PROTOCOL_PREAMBLE:
283
 	case CMD_VIDEOHUB_DEVICE:
299
 	case CMD_VIDEOHUB_DEVICE:
284
 	case CMD_PING:
300
 	case CMD_PING:
306
 		snprintf(buf, bufsz, "%s:\n%u %u\n\n", get_cmd_text(e->cmd),
322
 		snprintf(buf, bufsz, "%s:\n%u %u\n\n", get_cmd_text(e->cmd),
307
 			e->port_no1 - 1, e->port_no2 - 1);
323
 			e->port_no1 - 1, e->port_no2 - 1);
308
 		break;
324
 		break;
325
+	case CMD_VIDEO_INPUT_STATUS:
326
+	case CMD_VIDEO_OUTPUT_STATUS:
309
 	case CMD_PROTOCOL_PREAMBLE:
327
 	case CMD_PROTOCOL_PREAMBLE:
310
 	case CMD_VIDEOHUB_DEVICE:
328
 	case CMD_VIDEOHUB_DEVICE:
311
 	case CMD_PING:
329
 	case CMD_PING:
346
 			e->port_no2, d->inputs [e->port_no2 - 1].name
364
 			e->port_no2, d->inputs [e->port_no2 - 1].name
347
 		);
365
 		);
348
 		break;
366
 		break;
367
+	case CMD_VIDEO_INPUT_STATUS:
368
+	case CMD_VIDEO_OUTPUT_STATUS:
349
 	case CMD_PROTOCOL_PREAMBLE:
369
 	case CMD_PROTOCOL_PREAMBLE:
350
 	case CMD_VIDEOHUB_DEVICE:
370
 	case CMD_VIDEOHUB_DEVICE:
351
 	case CMD_PING:
371
 	case CMD_PING:

+ 2
- 0
cmd.h View File

22
 	CMD_OUTPUT_LABELS,
22
 	CMD_OUTPUT_LABELS,
23
 	CMD_VIDEO_OUTPUT_LOCKS,
23
 	CMD_VIDEO_OUTPUT_LOCKS,
24
 	CMD_VIDEO_OUTPUT_ROUTING,
24
 	CMD_VIDEO_OUTPUT_ROUTING,
25
+	CMD_VIDEO_INPUT_STATUS,
26
+	CMD_VIDEO_OUTPUT_STATUS,
25
 	CMD_PING,
27
 	CMD_PING,
26
 	CMD_ACK,
28
 	CMD_ACK,
27
 	CMD_NAK,
29
 	CMD_NAK,

+ 5
- 0
data.h View File

36
 
36
 
37
 struct input_desc {
37
 struct input_desc {
38
 	char			name[MAX_NAME_LEN];
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
 struct output_desc {
45
 struct output_desc {
43
 	unsigned int	routed_to;
47
 	unsigned int	routed_to;
44
 	bool			locked;
48
 	bool			locked;
45
 	bool			locked_other;
49
 	bool			locked_other;
50
+	char			status[8];
46
 };
51
 };
47
 
52
 
48
 struct videohub_data {
53
 struct videohub_data {

+ 23
- 10
display.c View File

11
  */
11
  */
12
 
12
 
13
 #include <stdio.h>
13
 #include <stdio.h>
14
+#include <string.h>
14
 
15
 
15
 #include "data.h"
16
 #include "data.h"
17
+#include "util.h"
16
 #include "display.h"
18
 #include "display.h"
17
 
19
 
18
 static void printf_line(int len) {
20
 static void printf_line(int len) {
23
 	printf("\n");
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
 void print_device_info(struct videohub_data *d) {
36
 void print_device_info(struct videohub_data *d) {
27
 	int len = 59;
37
 	int len = 59;
28
 	printf("Device info\n");
38
 	printf("Device info\n");
45
 }
55
 }
46
 
56
 
47
 void print_device_video_inputs(struct videohub_data *d) {
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
 	if (!d->device.num_video_inputs)
59
 	if (!d->device.num_video_inputs)
50
 		return;
60
 		return;
51
 	printf("Video inputs\n");
61
 	printf("Video inputs\n");
52
 	printf_line(len);
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
 	printf_line(len);
64
 	printf_line(len);
55
 	for(i = 0; i < d->device.num_video_inputs; i++) {
65
 	for(i = 0; i < d->device.num_video_inputs; i++) {
56
 		unsigned int num_outputs = 0, routed_to = 0;
66
 		unsigned int num_outputs = 0, routed_to = 0;
61
 					routed_to = r; // The first output
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
 		if (num_outputs == 0) {
76
 		if (num_outputs == 0) {
66
-			printf("%-24s |\n", "-");
77
+			printf("%-24s | %c |\n", "-", format_status(d->inputs[i].status));
67
 		} else {
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
 			bool first_skipped = false;
80
 			bool first_skipped = false;
70
 			for(r = 0; r < d->device.num_video_outputs; r++) {
81
 			for(r = 0; r < d->device.num_video_outputs; r++) {
71
 				if (d->outputs[r].routed_to == i) {
82
 				if (d->outputs[r].routed_to == i) {
73
 						first_skipped = true;
84
 						first_skipped = true;
74
 						continue;
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
 }
95
 }
84
 
96
 
85
 void print_device_video_outputs(struct videohub_data *d) {
97
 void print_device_video_outputs(struct videohub_data *d) {
86
-	unsigned int i, len = 64;
98
+	unsigned int i, len = 68;
87
 	if (!d->device.num_video_outputs)
99
 	if (!d->device.num_video_outputs)
88
 		return;
100
 		return;
89
 	printf("Video outputs\n");
101
 	printf("Video outputs\n");
90
 	printf_line(len);
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
 	printf_line(len);
104
 	printf_line(len);
93
 	for(i = 0; i < d->device.num_video_outputs; i++) {
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
 			i + 1,
107
 			i + 1,
96
 			d->outputs[i].locked ? (d->outputs[i].locked_other ? 'L' : 'O') : ' ',
108
 			d->outputs[i].locked ? (d->outputs[i].locked_other ? 'L' : 'O') : ' ',
97
 			d->outputs[i].name,
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
 	printf_line(len);
114
 	printf_line(len);

+ 25
- 0
vh_test_commands.txt View File

82
 13 13
82
 13 13
83
 14 14
83
 14 14
84
 15 15
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
 Display main device info including model, number of ports, etc.
45
 Display main device info including model, number of ports, etc.
46
 .TP
46
 .TP
47
 \fB\-\-list\-vinputs\fR
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
 .TP
61
 .TP
51
 \fB\-\-list\-voutputs\fR
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
   L - The port is locked by another IP address (user)
68
   L - The port is locked by another IP address (user)
55
   O - The port is locked by me (from my IP address)
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
 .SH VIDEO INPUT/OUTPUT CONFIGURATION
74
 .SH VIDEO INPUT/OUTPUT CONFIGURATION
57
 .PP
75
 .PP
58
 Everywhere where port number is accepted, you can use the port
76
 Everywhere where port number is accepted, you can use the port

Loading…
Cancel
Save