aja-common.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #include "aja-enums.hpp"
  2. #include <obs-module.h>
  3. #include <algorithm>
  4. #include <map>
  5. #include <string>
  6. #include <vector>
  7. #include <ajantv2/includes/ntv2enums.h>
  8. #include <ajantv2/includes/ntv2card.h>
  9. using VideoFormatMap = std::map<NTV2Standard, std::vector<NTV2VideoFormat>>;
  10. using VideoFormatList = std::vector<NTV2VideoFormat>;
  11. using VideoStandardList = std::vector<NTV2Standard>;
  12. static const uint32_t kDefaultAudioChannels = 8;
  13. static const uint32_t kDefaultAudioSampleRate = 48000;
  14. static const uint32_t kDefaultAudioSampleSize = 4;
  15. static const int kAutoDetect = -1;
  16. static const NTV2VideoFormat kDefaultAJAVideoFormat = NTV2_FORMAT_720p_5994;
  17. static const NTV2PixelFormat kDefaultAJAPixelFormat = NTV2_FBF_8BIT_YCBCR;
  18. static const SDITransport kDefaultAJASDITransport = SDITransport::SingleLink;
  19. static const SDITransport4K kDefaultAJASDITransport4K =
  20. SDITransport4K::TwoSampleInterleave;
  21. // Common OBS property helpers used by both the capture and output plugins
  22. extern void filter_io_selection_input_list(const std::string &cardID,
  23. const std::string &channelOwner,
  24. obs_property_t *list);
  25. extern void filter_io_selection_output_list(const std::string &cardID,
  26. const std::string &channelOwner,
  27. obs_property_t *list);
  28. extern void populate_io_selection_input_list(const std::string &cardID,
  29. const std::string &channelOwner,
  30. NTV2DeviceID deviceID,
  31. obs_property_t *list);
  32. extern void populate_io_selection_output_list(const std::string &cardID,
  33. const std::string &channelOwner,
  34. NTV2DeviceID deviceID,
  35. obs_property_t *list);
  36. extern void
  37. populate_video_format_list(NTV2DeviceID deviceID, obs_property_t *list,
  38. NTV2VideoFormat genlockFormat = NTV2_FORMAT_UNKNOWN,
  39. bool want4KHFR = false);
  40. extern void populate_pixel_format_list(NTV2DeviceID deviceID,
  41. obs_property_t *list);
  42. extern void populate_sdi_transport_list(obs_property_t *list, IOSelection io,
  43. NTV2DeviceID deviceID,
  44. bool capture = false);
  45. extern void populate_sdi_4k_transport_list(obs_property_t *list);
  46. extern bool aja_video_format_changed(obs_properties_t *props,
  47. obs_property_t *list,
  48. obs_data_t *settings);
  49. // Additional helpers for AJA channel and signal routing configuration not found in the NTV2 SDK
  50. namespace aja {
  51. template<typename T> bool vec_contains(const std::vector<T> &vec, const T &elem)
  52. {
  53. return std::find(vec.begin(), vec.end(), elem) != vec.end();
  54. }
  55. extern video_format AJAPixelFormatToOBSVideoFormat(NTV2PixelFormat pf);
  56. extern void GetSortedVideoFormats(NTV2DeviceID id,
  57. const VideoStandardList &standards,
  58. VideoFormatList &videoFormats);
  59. extern NTV2VideoFormat
  60. HandleSpecialCaseFormats(IOSelection io, NTV2VideoFormat vf, NTV2DeviceID id);
  61. extern NTV2Channel WidgetIDToChannel(NTV2WidgetID id);
  62. extern uint32_t CardNumFramestores(NTV2DeviceID id);
  63. extern uint32_t CardNumAudioSystems(NTV2DeviceID id);
  64. extern bool CardCanDoSDIMonitorOutput(NTV2DeviceID id);
  65. extern bool CardCanDoHDMIMonitorInput(NTV2DeviceID id);
  66. extern bool CardCanDoHDMIMonitorOutput(NTV2DeviceID id);
  67. extern bool CardCanDo1xSDI12G(NTV2DeviceID id);
  68. extern bool Is3GLevelB(CNTV2Card *card, NTV2Channel channel);
  69. extern NTV2VideoFormat GetLevelAFormatForLevelBFormat(NTV2VideoFormat vf);
  70. extern NTV2VideoFormat InterlacedFormatForPsfFormat(NTV2VideoFormat vf);
  71. extern bool IsSingleSDIDevice(NTV2DeviceID id);
  72. extern bool IsIODevice(NTV2DeviceID id);
  73. extern bool IsRetail12GSDICard(NTV2DeviceID id);
  74. extern bool IsOutputOnlyDevice(NTV2DeviceID id);
  75. extern std::string SDITransportToString(SDITransport mode);
  76. extern std::string SDITransport4KToString(SDITransport4K mode);
  77. extern std::string IOSelectionToString(IOSelection io);
  78. extern void IOSelectionToInputSources(IOSelection io,
  79. NTV2InputSourceSet &inputSources);
  80. extern void IOSelectionToOutputDests(IOSelection io,
  81. NTV2OutputDestinations &outputDests);
  82. extern bool DeviceCanDoIOSelectionIn(NTV2DeviceID id, IOSelection io);
  83. extern bool DeviceCanDoIOSelectionOut(NTV2DeviceID id, IOSelection io);
  84. extern bool IsSDIOneWireIOSelection(IOSelection io);
  85. extern bool IsSDITwoWireIOSelection(IOSelection io);
  86. extern bool IsSDIFourWireIOSelection(IOSelection io);
  87. extern bool IsMonitorOutputSelection(NTV2DeviceID id, IOSelection io);
  88. extern bool IsIOSelectionSDI(IOSelection io);
  89. extern bool IsIOSelectionHDMI(IOSelection io);
  90. extern std::string MakeCardID(CNTV2Card &card);
  91. extern RasterDefinition DetermineRasterDefinition(NTV2VideoFormat vf);
  92. extern VPIDStandard DetermineVPIDStandard(NTV2DeviceID id, IOSelection io,
  93. NTV2VideoFormat vf,
  94. NTV2PixelFormat pf, SDITransport trx,
  95. SDITransport4K t4k);
  96. extern std::vector<NTV2DeviceID> MultiViewCards();
  97. } // aja