aja-common.hpp 4.6 KB

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