11#include <promeki/config.h>
12#if PROMEKI_ENABLE_NTV2
29PROMEKI_NAMESPACE_BEGIN
31class Ntv2DeviceRegistry;
87 Mutex &mutex() {
return _mutex; }
90 const Ntv2Capabilities &caps()
const {
return _caps; }
95 const String &displayName()
const {
return _displayName; }
103 const String &serial()
const {
return _serial; }
113 const String &key()
const {
return _key; }
116 int deviceIndex()
const {
return _deviceIndex; }
130 Error reserveChannel(
int channel, Ntv2MediaIO *owner);
138 Error releaseChannel(
int channel, Ntv2MediaIO *owner);
148 Error reservePorts(
const SdiSignalConfig::PortList &ports, Ntv2MediaIO *owner);
156 void releasePortsOwnedBy(Ntv2MediaIO *owner);
166 Error reserveAudioSystem(
int sysIndex, Ntv2MediaIO *owner);
169 Error releaseAudioSystem(
int sysIndex, Ntv2MediaIO *owner);
183 Error setReference(
const VideoReferenceConfig &ref, Ntv2MediaIO *requester);
203 Clock::Ptr sampleClock();
216 static int resolveDeviceIndex(
const String &locator);
224 friend class Ntv2DeviceRegistry;
225 friend struct Ntv2DeviceTestAccess;
230 Ntv2Device(
const Ntv2Device &) =
delete;
231 Ntv2Device &operator=(
const Ntv2Device &) =
delete;
233 Error initialize(
int deviceIndex,
const String &locator,
bool retailServices,
235 void shutdown(
bool retailServices);
242 int firstReservedAudioSystem()
const;
244 UniquePtr<CNTV2Card> _card;
245 Ntv2Capabilities _caps;
246 mutable Mutex _mutex;
251 int _deviceIndex = -1;
256 Map<int, Ntv2MediaIO *> _channelOwners;
257 Map<int, Ntv2MediaIO *> _audioSystemOwners;
262 Map<int, Ntv2MediaIO *> _portOwners;
267 bool _refSet =
false;
268 int _currentReferenceRaw = 0;
269 Ntv2MediaIO *_refOwner =
nullptr;
272 Clock::Ptr _sampleClock;
290class Ntv2DeviceRegistry {
293 static Ntv2DeviceRegistry &instance();
317 Error acquire(
int deviceIndex,
const String &locator,
bool retailServices,
318 bool multiFormat, Ntv2Device **outDevice);
326 void release(Ntv2Device *device);
335 List<Ntv2Device *> liveDevices()
const;
338 Ntv2DeviceRegistry() =
default;
339 ~Ntv2DeviceRegistry();
341 Ntv2DeviceRegistry(
const Ntv2DeviceRegistry &) =
delete;
342 Ntv2DeviceRegistry &operator=(
const Ntv2DeviceRegistry &) =
delete;
345 UniquePtr<Ntv2Device> device;
347 bool retailServices =
false;
350 mutable Mutex _mutex;
351 Map<String, Entry> _entries;
368struct Ntv2DeviceTestAccess {
378 static UniquePtr<Ntv2Device> create(
int deviceIndex,
const String &displayName,
379 const Ntv2Capabilities &caps);
382 static size_t channelOwnerCount(
const Ntv2Device &dev);
385 static const Ntv2MediaIO *channelOwner(
const Ntv2Device &dev,
int channel);
388 static size_t portOwnerCount(
const Ntv2Device &dev);
391 static size_t audioSystemOwnerCount(
const Ntv2Device &dev);
394 static const Ntv2MediaIO *audioSystemOwner(
const Ntv2Device &dev,
int sysIndex);
397 static bool referenceSet(
const Ntv2Device &dev);
400 static int currentReferenceRaw(
const Ntv2Device &dev);
403 static const Ntv2MediaIO *referenceOwner(
const Ntv2Device &dev);