videohubctrl can be used to control Blackmagic Design Videohub SDI router device over the network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

display.c 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. #include <stdio.h>
  13. #include <string.h>
  14. #include "data.h"
  15. #include "util.h"
  16. #include "display.h"
  17. static void printf_line(int len) {
  18. int i;
  19. printf(" ");
  20. for (i = 0; i < len; i++)
  21. printf("-");
  22. printf("\n");
  23. }
  24. static char format_status(char *status) {
  25. if (!strlen(status)) return ' ';
  26. if (streq(status, "BNC")) return 'B';
  27. if (streq(status, "Optical")) return 'o';
  28. if (streq(status, "None")) return 'x';
  29. return '?';
  30. }
  31. void print_device_info(struct videohub_data *d) {
  32. int len = 59;
  33. printf("Device info\n");
  34. printf_line(len);
  35. printf(" | %-26s | %-26s |\n", "Device address", d->dev_host);
  36. printf(" | %-26s | %-26s |\n", "Device port", d->dev_port);
  37. printf(" | %-26s | %-26s |\n", "Model name", d->device.model_name);
  38. printf(" | %-26s | %-26s |\n", "Unique ID", d->device.unique_id);
  39. printf(" | %-26s | %-26s |\n", "Protocol", d->device.protocol_ver);
  40. printf(" | %-26s | %-26u |\n", "Video inputs", d->device.num_video_inputs);
  41. printf(" | %-26s | %-26u |\n", "Video outputs", d->device.num_video_outputs);
  42. if (d->device.num_serial_ports)
  43. printf(" | %-26s | %-26u |\n", "Serial ports", d->device.num_serial_ports);
  44. if (d->device.num_video_processing_units)
  45. printf(" | %-26s | %-26u |\n", "Video processing units", d->device.num_video_processing_units);
  46. if (d->device.num_video_monitoring_outputs)
  47. printf(" | %-26s | %-26u |\n", "Video monitoring outputs", d->device.num_video_monitoring_outputs);
  48. printf_line(len);
  49. printf("\n");
  50. }
  51. void print_device_video_inputs(struct videohub_data *d) {
  52. unsigned int i, r, len = 68;
  53. if (!d->device.num_video_inputs)
  54. return;
  55. printf("Video inputs\n");
  56. printf_line(len);
  57. printf(" | ## | %-24s | n | %-24s | s |\n", "Video input name", "Routed to output");
  58. printf_line(len);
  59. for(i = 0; i < d->device.num_video_inputs; i++) {
  60. unsigned int num_outputs = 0, routed_to = 0;
  61. for(r = 0; r < d->device.num_video_outputs; r++) {
  62. if (d->outputs[r].routed_to == i) {
  63. num_outputs++;
  64. if (num_outputs == 1)
  65. routed_to = r; // The first output
  66. }
  67. }
  68. printf(" | %2d | %-24s | %d | ", i + 1, d->inputs[i].name,
  69. num_outputs);
  70. if (num_outputs == 0) {
  71. printf("%-24s | %c |\n", "-", format_status(d->inputs[i].status));
  72. } else {
  73. printf("%-24s | %c |\n", d->outputs[routed_to].name, format_status(d->inputs[i].status));
  74. bool first_skipped = false;
  75. for(r = 0; r < d->device.num_video_outputs; r++) {
  76. if (d->outputs[r].routed_to == i) {
  77. if (!first_skipped) {
  78. first_skipped = true;
  79. continue;
  80. }
  81. printf(" | %2s | %-24s | %s | %-24s | %c |\n",
  82. " ", " ", " ", d->outputs[r].name, ' ');
  83. }
  84. }
  85. }
  86. }
  87. printf_line(len);
  88. printf("\n");
  89. }
  90. void print_device_video_outputs(struct videohub_data *d) {
  91. unsigned int i, len = 68;
  92. if (!d->device.num_video_outputs)
  93. return;
  94. printf("Video outputs\n");
  95. printf_line(len);
  96. printf(" | ## | x | %-24s | %-24s | s |\n", "Video output name", "Connected video input");
  97. printf_line(len);
  98. for(i = 0; i < d->device.num_video_outputs; i++) {
  99. printf(" | %2d | %c | %-24s | %-24s | %c |\n",
  100. i + 1,
  101. d->outputs[i].locked ? (d->outputs[i].locked_other ? 'L' : 'O') : ' ',
  102. d->outputs[i].name,
  103. d->inputs[d->outputs[i].routed_to].name,
  104. format_status(d->outputs[i].status)
  105. );
  106. }
  107. printf_line(len);
  108. printf("\n");
  109. }
  110. void print_device_backup(struct videohub_data *d) {
  111. unsigned int i;
  112. printf("videohubctrl \\\n");
  113. for(i = 0; i < d->device.num_video_inputs; i++)
  114. printf(" --vi-name %2d \"%s\" \\\n", i + 1, d->inputs[i].name);
  115. for(i = 0; i < d->device.num_video_outputs; i++)
  116. printf(" --vo-name %2d \"%s\" \\\n", i + 1, d->outputs[i].name);
  117. for(i = 0; i < d->device.num_video_outputs; i++)
  118. printf(" --vo-route %2d %2d \\\n", i + 1, d->outputs[i].routed_to + 1);
  119. for(i = 0; i < d->device.num_video_outputs; i++) {
  120. if (d->outputs[i].locked) {
  121. printf(" --vo-unlock %2d --vo-lock %2d%s\n", i + 1, i + 1,
  122. i + 1 < d->device.num_video_outputs ? " \\" : "");
  123. } else {
  124. printf(" --vo-unlock %2d%s\n", i + 1,
  125. i + 1 < d->device.num_video_outputs ? " \\" : "");
  126. }
  127. }
  128. printf("\n");
  129. }