aja-common.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. extern void populate_pixel_format_list(NTV2DeviceID deviceID,
  40. obs_property_t *list);
  41. extern void populate_sdi_transport_list(obs_property_t *list, IOSelection io);
  42. extern void populate_sdi_4k_transport_list(obs_property_t *list);
  43. extern bool aja_video_format_changed(obs_properties_t *props,
  44. obs_property_t *list,
  45. obs_data_t *settings);
  46. // Additional helpers for AJA channel and signal routing configuration not found in the NTV2 SDK
  47. namespace aja {
  48. template<typename T> bool vec_contains(const std::vector<T> &vec, const T &elem)
  49. {
  50. return std::find(vec.begin(), vec.end(), elem) != vec.end();
  51. }
  52. extern video_format AJAPixelFormatToOBSVideoFormat(NTV2PixelFormat pf);
  53. extern void GetSortedVideoFormats(NTV2DeviceID id,
  54. const VideoStandardList &standards,
  55. VideoFormatList &videoFormats);
  56. extern NTV2VideoFormat
  57. HandleSpecialCaseFormats(IOSelection io, NTV2VideoFormat vf, NTV2DeviceID id);
  58. extern uint32_t CardNumFramestores(NTV2DeviceID id);
  59. extern uint32_t CardNumAudioSystems(NTV2DeviceID id);
  60. extern bool CardCanDoSDIMonitorOutput(NTV2DeviceID id);
  61. extern bool CardCanDoHDMIMonitorInput(NTV2DeviceID id);
  62. extern bool CardCanDoHDMIMonitorOutput(NTV2DeviceID id);
  63. extern bool CardCanDo1xSDI12G(NTV2DeviceID id);
  64. extern bool Is3GLevelB(CNTV2Card *card, NTV2Channel channel);
  65. extern NTV2VideoFormat GetLevelAFormatForLevelBFormat(NTV2VideoFormat vf);
  66. extern NTV2VideoFormat InterlacedFormatForPsfFormat(NTV2VideoFormat vf);
  67. extern bool IsSingleSDIDevice(NTV2DeviceID id);
  68. extern bool IsIODevice(NTV2DeviceID id);
  69. extern bool IsRetail12GSDICard(NTV2DeviceID id);
  70. extern bool IsOutputOnlyDevice(NTV2DeviceID id);
  71. extern std::string SDITransportToString(SDITransport mode);
  72. extern std::string SDITransport4KToString(SDITransport4K mode);
  73. extern std::string IOSelectionToString(IOSelection io);
  74. extern void IOSelectionToInputSources(IOSelection io,
  75. NTV2InputSourceSet &inputSources);
  76. extern void IOSelectionToOutputDests(IOSelection io,
  77. NTV2OutputDestinations &outputDests);
  78. extern bool DeviceCanDoIOSelectionIn(NTV2DeviceID id, IOSelection io);
  79. extern bool DeviceCanDoIOSelectionOut(NTV2DeviceID id, IOSelection io);
  80. extern bool IsSDIOneWireIOSelection(IOSelection io);
  81. extern bool IsSDITwoWireIOSelection(IOSelection io);
  82. extern bool IsSDIFourWireIOSelection(IOSelection io);
  83. extern bool IsMonitorOutputSelection(NTV2DeviceID id, IOSelection io);
  84. extern bool IsIOSelectionSDI(IOSelection io);
  85. extern std::string MakeCardID(CNTV2Card &card);
  86. extern RasterDefinition DetermineRasterDefinition(NTV2VideoFormat vf);
  87. extern VPIDStandard DetermineVPIDStandard(NTV2DeviceID id, IOSelection io,
  88. NTV2VideoFormat vf,
  89. NTV2PixelFormat pf, SDITransport trx,
  90. SDITransport4K t4k);
  91. extern std::vector<NTV2DeviceID> MultiViewCards();
  92. } // aja