0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
obs-studio/plugins/aja/aja-card-manager.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

104 lines
3.5 KiB
C++

#pragma once
#include "aja-props.hpp"
#include <obs-module.h>
#include <ajantv2/includes/ntv2enums.h>
#include <ajantv2/includes/ntv2publicinterface.h>
#include <memory>
#include <map>
#include <mutex>
#include <vector>
class CNTV2Card;
class AJAOutput;
class AJASource;
namespace aja {
using ChannelPwnz = std::map<std::string, int32_t>;
/* A CardEntry for each physical AJA card is added to a map retained by the CardManager.
* Each CardEntry itself maintains a map representing the AJA card "Channels" the are
* owned by a particular capture or output plugin instance. The Channel ownership map is
* then used to determine which "IOSelection" (i.e. SDI1, SDI3+4, HDMI Monitor Output, etc.)
* drop-down menu items are either accessible or grayed out in the capture and output plugin UIs.
*/
class CardEntry {
public:
CardEntry(uint32_t cardIndex, const std::string &cardID);
virtual ~CardEntry();
CNTV2Card *GetCard();
virtual bool Initialize();
virtual uint32_t GetCardIndex() const;
virtual std::string GetCardID() const;
virtual std::string GetDisplayName() const;
virtual std::string GetSerial() const;
virtual NTV2DeviceID GetDeviceID() const;
virtual bool ChannelReady(NTV2Channel chan,
const std::string &owner) const;
virtual bool AcquireChannel(NTV2Channel chan, NTV2Mode mode,
const std::string &owner);
virtual bool ReleaseChannel(NTV2Channel chan, NTV2Mode mode,
const std::string &owner);
virtual bool InputSelectionReady(IOSelection io, NTV2DeviceID id,
const std::string &owner) const;
virtual bool OutputSelectionReady(IOSelection io, NTV2DeviceID id,
const std::string &owner) const;
virtual bool AcquireInputSelection(IOSelection io, NTV2DeviceID id,
const std::string &owner);
virtual bool ReleaseInputSelection(IOSelection io, NTV2DeviceID id,
const std::string &owner);
virtual bool AcquireOutputSelection(IOSelection io, NTV2DeviceID id,
const std::string &owner);
virtual bool ReleaseOutputSelection(IOSelection io, NTV2DeviceID id,
const std::string &owner);
virtual bool UpdateChannelOwnerName(const std::string &oldName,
const std::string &newName);
private:
virtual bool isAutoCirculateRunning(NTV2Channel);
protected:
uint32_t mCardIndex;
std::string mCardID;
std::unique_ptr<CNTV2Card> mCard;
ChannelPwnz mChannelPwnz;
mutable std::mutex mMutex;
};
using CardEntryPtr = std::shared_ptr<CardEntry>;
using CardEntries = std::map<std::string, CardEntryPtr>;
/* The CardManager enumerates the physical AJA cards in the system, reverts them to a default
* state on exit, and maintains a map of CardEntry objects corresponding to each physical card.
* Each CardEntry object holds a pointer to the CNTV2Card instance and a map of NTV2Channels
* that are "owned" by each plugin instance. NTV2Channels are essentially treated as indices
* for various firwmare Widgets and sub-systems throughout the AJA NTV2 SDK.
*/
class CardManager {
public:
static CardManager &Instance();
void ClearCardEntries();
void EnumerateCards();
size_t NumCardEntries() const;
const CardEntryPtr GetCardEntry(const std::string &cardID) const;
const CardEntries &GetCardEntries() const;
private:
CardManager() = default;
~CardManager() = default;
CardManager(const CardManager &) = delete;
CardManager(const CardManager &&) = delete;
CardManager &operator=(const CardManager &) = delete;
CardManager &operator=(const CardManager &&) = delete;
CardEntries mCardEntries;
mutable std::mutex mMutex;
};
} // aja