obs-studio/plugins/aja/aja-common.hpp
Paul Hindt ce3ae8e423
aja: Capture and Output plugin for AJA Video Systems IO devices
* aja: Initial commit of AJA capture/output plugin

* aja: Fix clang-format on aja-output-ui code

* aja: Remove script used during dev/testing

* aja: Address pull request feedback from @RytoEX

* aja: Remove the SDK sources and update CMakeLists to point to new headers-only/static libs dependency distribution.

* aja: Only build AJA plugin on x64 on macOS for now

* aja: Remove the non-English placeholder locale files. The english strings/files will be produced via crowdin, according to @ddrboxman.

* aja: Add FindLibAJANTV2.cmake script to locate the ajantv2 headers and static libs in the OBS external deps package(s). Tested on Windows x64. macOS and Linux x64 TBD.

* aja: Add ajantv2/includes to FindLibAJANTV2 include search paths

* aja: Remove commented code from aja CMakeLists

* aja: Remove debug code and comments that are no longer needed.

* aja: Fix indentation

* aja: Remove disablement of clang-format in routing table and SDIWireFormat map

* aja: Use spaces for all indentation in widget crosspoint arrays where we disable clang-format

* aja: Address code style comments made by @RytoEX

* aja: Fix uneven indentation

* aja: More fixes to if/else placement and remove superfluous comments.

* aja: Rename 'dwns' to 'deactivateWhileNotShowing' for clarity. The DeckLink plugin still uses the variable name 'dwns' and should be changed, if desired, in a separate PR.

* aja: Remove X11Extras dependency from AJA Output frontend plugin

* aja: Add patch from Jim to find AJA release/debug libs

* aja: Improve AV sync of queued video/audio sent to the AJA card in the AJA Output plugin.
2021-11-23 20:31:11 -06:00

93 lines
3.7 KiB
C++

#include "aja-enums.hpp"
#include <obs-module.h>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <ajantv2/includes/ntv2enums.h>
#include <ajantv2/includes/ntv2card.h>
using VideoFormatMap = std::map<NTV2Standard, std::vector<NTV2VideoFormat>>;
using VideoFormatList = std::vector<NTV2VideoFormat>;
using VideoStandardList = std::vector<NTV2Standard>;
static const uint32_t kDefaultAudioChannels = 8;
static const uint32_t kDefaultAudioSampleRate = 48000;
static const uint32_t kDefaultAudioSampleSize = 4;
static const int kVideoFormatAuto = -1;
static const int kPixelFormatAuto = -1;
static const NTV2PixelFormat kDefaultAJAPixelFormat = NTV2_FBF_8BIT_YCBCR;
// Common OBS property helpers used by both the capture and output plugins
extern void filter_io_selection_input_list(const std::string &cardID,
const std::string &channelOwner,
obs_property_t *list);
extern void filter_io_selection_output_list(const std::string &cardID,
const std::string &channelOwner,
obs_property_t *list);
extern void populate_io_selection_input_list(const std::string &cardID,
const std::string &channelOwner,
NTV2DeviceID deviceID,
obs_property_t *list);
extern void populate_io_selection_output_list(const std::string &cardID,
const std::string &channelOwner,
NTV2DeviceID deviceID,
obs_property_t *list);
extern void
populate_video_format_list(NTV2DeviceID deviceID, obs_property_t *list,
NTV2VideoFormat genlockFormat = NTV2_FORMAT_UNKNOWN);
extern void populate_pixel_format_list(NTV2DeviceID deviceID,
obs_property_t *list);
extern void populate_sdi_4k_transport_list(obs_property_t *list);
extern bool aja_video_format_changed(obs_properties_t *props,
obs_property_t *list,
obs_data_t *settings);
// Additional helpers for AJA channel and signal routing configuration not found in the NTV2 SDK
namespace aja {
template<typename T> bool vec_contains(const std::vector<T> &vec, const T &elem)
{
return std::find(vec.begin(), vec.end(), elem) != vec.end();
}
extern video_format AJAPixelFormatToOBSVideoFormat(NTV2PixelFormat pf);
extern void GetSortedVideoFormats(NTV2DeviceID id,
const VideoStandardList &standards,
VideoFormatList &videoFormats);
extern uint32_t CardNumFramestores(NTV2DeviceID id);
extern uint32_t CardNumAudioSystems(NTV2DeviceID id);
extern bool CardCanDoSDIMonitorOutput(NTV2DeviceID id);
extern bool CardCanDoHDMIMonitorOutput(NTV2DeviceID id);
extern bool CardCanDo1xSDI12G(NTV2DeviceID id);
extern bool Is3GLevelB(CNTV2Card *card, NTV2Channel channel);
extern NTV2VideoFormat GetLevelAFormatForLevelBFormat(NTV2VideoFormat vf);
extern NTV2VideoFormat InterlacedFormatForPsfFormat(NTV2VideoFormat vf);
extern bool IsSingleSDIDevice(NTV2DeviceID id);
extern bool IsIODevice(NTV2DeviceID id);
extern bool IsRetailSDI12G(NTV2DeviceID id);
extern bool IsOutputOnlyDevice(NTV2DeviceID id);
extern std::string SDI4KTransportToString(SDI4KTransport mode);
extern std::string IOSelectionToString(IOSelection io);
extern void IOSelectionToInputSources(IOSelection io,
NTV2InputSourceSet &inputSources);
extern void IOSelectionToOutputDests(IOSelection io,
NTV2OutputDestinations &outputDests);
extern bool DeviceCanDoIOSelectionIn(NTV2DeviceID id, IOSelection io);
extern bool DeviceCanDoIOSelectionOut(NTV2DeviceID id, IOSelection io);
extern bool IsSDIOneWireIOSelection(IOSelection io);
extern bool IsSDITwoWireIOSelection(IOSelection io);
extern bool IsSDIFourWireIOSelection(IOSelection io);
extern bool IsMonitorOutputSelection(NTV2DeviceID id, IOSelection io);
extern std::string MakeCardID(CNTV2Card &card);
} // aja