aja-common.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 NTV2PixelFormat kDefaultAJAPixelFormat = NTV2_FBF_8BIT_YCBCR;
  17. // Common OBS property helpers used by both the capture and output plugins
  18. extern void filter_io_selection_input_list(const std::string &cardID,
  19. const std::string &channelOwner,
  20. obs_property_t *list);
  21. extern void filter_io_selection_output_list(const std::string &cardID,
  22. const std::string &channelOwner,
  23. obs_property_t *list);
  24. extern void populate_io_selection_input_list(const std::string &cardID,
  25. const std::string &channelOwner,
  26. NTV2DeviceID deviceID,
  27. obs_property_t *list);
  28. extern void populate_io_selection_output_list(const std::string &cardID,
  29. const std::string &channelOwner,
  30. NTV2DeviceID deviceID,
  31. obs_property_t *list);
  32. extern void
  33. populate_video_format_list(NTV2DeviceID deviceID, obs_property_t *list,
  34. NTV2VideoFormat genlockFormat = NTV2_FORMAT_UNKNOWN);
  35. extern void populate_pixel_format_list(NTV2DeviceID deviceID,
  36. obs_property_t *list);
  37. extern void populate_sdi_transport_list(obs_property_t *list, IOSelection io);
  38. extern void populate_sdi_4k_transport_list(obs_property_t *list);
  39. extern bool aja_video_format_changed(obs_properties_t *props,
  40. obs_property_t *list,
  41. obs_data_t *settings);
  42. // Additional helpers for AJA channel and signal routing configuration not found in the NTV2 SDK
  43. namespace aja {
  44. template<typename T> bool vec_contains(const std::vector<T> &vec, const T &elem)
  45. {
  46. return std::find(vec.begin(), vec.end(), elem) != vec.end();
  47. }
  48. extern video_format AJAPixelFormatToOBSVideoFormat(NTV2PixelFormat pf);
  49. extern void GetSortedVideoFormats(NTV2DeviceID id,
  50. const VideoStandardList &standards,
  51. VideoFormatList &videoFormats);
  52. extern NTV2VideoFormat
  53. HandleSpecialCaseFormats(IOSelection io, NTV2VideoFormat vf, NTV2DeviceID id);
  54. extern uint32_t CardNumFramestores(NTV2DeviceID id);
  55. extern uint32_t CardNumAudioSystems(NTV2DeviceID id);
  56. extern bool CardCanDoSDIMonitorOutput(NTV2DeviceID id);
  57. extern bool CardCanDoHDMIMonitorOutput(NTV2DeviceID id);
  58. extern bool CardCanDo1xSDI12G(NTV2DeviceID id);
  59. extern bool Is3GLevelB(CNTV2Card *card, NTV2Channel channel);
  60. extern NTV2VideoFormat GetLevelAFormatForLevelBFormat(NTV2VideoFormat vf);
  61. extern NTV2VideoFormat InterlacedFormatForPsfFormat(NTV2VideoFormat vf);
  62. extern bool IsSingleSDIDevice(NTV2DeviceID id);
  63. extern bool IsIODevice(NTV2DeviceID id);
  64. extern bool IsRetail12GSDICard(NTV2DeviceID id);
  65. extern bool IsOutputOnlyDevice(NTV2DeviceID id);
  66. extern std::string SDITransportToString(SDITransport mode);
  67. extern std::string SDITransport4KToString(SDITransport4K mode);
  68. extern std::string IOSelectionToString(IOSelection io);
  69. extern void IOSelectionToInputSources(IOSelection io,
  70. NTV2InputSourceSet &inputSources);
  71. extern void IOSelectionToOutputDests(IOSelection io,
  72. NTV2OutputDestinations &outputDests);
  73. extern bool DeviceCanDoIOSelectionIn(NTV2DeviceID id, IOSelection io);
  74. extern bool DeviceCanDoIOSelectionOut(NTV2DeviceID id, IOSelection io);
  75. extern bool IsSDIOneWireIOSelection(IOSelection io);
  76. extern bool IsSDITwoWireIOSelection(IOSelection io);
  77. extern bool IsSDIFourWireIOSelection(IOSelection io);
  78. extern bool IsMonitorOutputSelection(NTV2DeviceID id, IOSelection io);
  79. extern bool IsIOSelectionSDI(IOSelection io);
  80. extern std::string MakeCardID(CNTV2Card &card);
  81. extern RasterDefinition DetermineRasterDefinition(NTV2VideoFormat vf);
  82. extern VPIDStandard DetermineVPIDStandard(NTV2DeviceID id, IOSelection io,
  83. NTV2VideoFormat vf,
  84. NTV2PixelFormat pf, SDITransport trx,
  85. SDITransport4K t4k);
  86. } // aja