AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
devicenotifier.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 #if !defined (__DEVICE_NOTIFIER_H__)
10  #define __DEVICE_NOTIFIER_H__
11 
12  #include <CoreFoundation/CoreFoundation.h>
13  #include <Carbon/Carbon.h>
14  #include <IOKit/IOMessage.h>
15  #include <IOKit/usb/IOUSBLib.h>
16  #include <vector>
17  #include <map>
18  #include <list>
19 
20  #define kAJADeviceInitialOpen 0xAA1
21  #define kAJADeviceTerminate 0xAA2
22 
23 
27  typedef void (*DeviceClientCallback)(unsigned long message, void * refcon);
28 
29 
34  {
35  // Instance Methods
36  public:
37 
38  DeviceNotifier (DeviceClientCallback callback, void *refcon);
39  virtual ~DeviceNotifier ();
40  virtual bool Install (CFMutableDictionaryRef dict = NULL);
41  virtual void Uninstall ();
42 
43  // alternate way to set callback
44  virtual void SetCallback (DeviceClientCallback callback, void *refcon);
45 
46  protected:
47  // override these
48  inline virtual CFMutableDictionaryRef CreateMatchingDictionary () {return NULL;}
49  virtual CFMutableDictionaryRef CreateMatchingDictionary (CFStringRef deviceDriverName);
50 
51  // callbacks
52  virtual void DeviceAdded (io_iterator_t iterator);
53  virtual void DeviceRemoved (io_iterator_t iterator);
54  virtual void DeviceChanged (io_service_t unitService, natural_t messageType, void* message);
55 
56  // util
57  virtual void AddGeneralInterest (io_object_t service);
58 
59  // Class Methods
60  public:
61  //static void SetDebugLogging (const uint64_t inWhichUserClientCommands);
62  static std::string MessageTypeToStr (const natural_t messageType);
63 
64  // Non-Public Class Methods
65  static void DeviceAddedCallback ( DeviceNotifier* thisObject, io_iterator_t iterator);
66  static void DeviceRemovedCallback ( DeviceNotifier* thisObject, io_iterator_t iterator);
67  static void DeviceChangedCallback ( DeviceNotifier * thisObject,
68  io_service_t unitService,
69  natural_t messageType,
70  void * message);
71  // Instance Data
72  protected:
73  void * m_refcon;
75  mach_port_t m_masterPort;
76  IONotificationPortRef m_notificationPort;
77  CFMutableDictionaryRef m_matchingDictionary;
78  std::list<io_object_t> m_deviceMatchList;
79  std::list<io_object_t> m_deviceInterestList;
80 
81  }; // DeviceNotifier
82 
83 
88  {
89  public:
90  inline KonaNotifier (DeviceClientCallback callback, void *refcon)
91  : DeviceNotifier (callback, refcon) {}
92  inline virtual ~KonaNotifier () {}
93  virtual bool Install (CFMutableDictionaryRef dict = NULL);
94  };
95 
96 #endif // __DEVICE_NOTIFIER_H__
DeviceNotifier::m_refcon
void * m_refcon
Definition: devicenotifier.h:73
DeviceNotifier::m_deviceMatchList
std::list< io_object_t > m_deviceMatchList
Definition: devicenotifier.h:78
NULL
#define NULL
Definition: ntv2caption608types.h:19
DeviceNotifier::DeviceRemoved
virtual void DeviceRemoved(io_iterator_t iterator)
Definition: devicenotifier.cpp:254
DeviceNotifier::m_masterPort
mach_port_t m_masterPort
Definition: devicenotifier.h:75
KonaNotifier
Subclass of DeviceNotifier that notifies clients when Kona/Corvid/Io/TTap devices are attached/detach...
Definition: devicenotifier.h:87
KonaNotifier::~KonaNotifier
virtual ~KonaNotifier()
Definition: devicenotifier.h:92
nlohmann::json_abiNLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON_v3_11_NLOHMANN_JSON_VERSION_PATCH::detail::void
j template void())
Definition: json.hpp:4893
DeviceNotifier::Install
virtual bool Install(CFMutableDictionaryRef dict=NULL)
Definition: devicenotifier.cpp:86
KonaNotifier::Install
virtual bool Install(CFMutableDictionaryRef dict=NULL)
Definition: devicenotifier.cpp:356
DeviceNotifier::SetCallback
virtual void SetCallback(DeviceClientCallback callback, void *refcon)
Definition: devicenotifier.cpp:75
DeviceNotifier::DeviceAddedCallback
static void DeviceAddedCallback(DeviceNotifier *thisObject, io_iterator_t iterator)
Definition: devicenotifier.cpp:212
DeviceClientCallback
void(* DeviceClientCallback)(unsigned long message, void *refcon)
Mac-specific device add/change/remove event notification callback function.
Definition: devicenotifier.h:27
DeviceNotifier::DeviceAdded
virtual void DeviceAdded(io_iterator_t iterator)
Definition: devicenotifier.cpp:221
DeviceNotifier::MessageTypeToStr
static std::string MessageTypeToStr(const natural_t messageType)
Definition: devicenotifier.cpp:324
DeviceNotifier::m_deviceInterestList
std::list< io_object_t > m_deviceInterestList
Definition: devicenotifier.h:79
KonaNotifier::KonaNotifier
KonaNotifier(DeviceClientCallback callback, void *refcon)
Definition: devicenotifier.h:90
DeviceNotifier::Uninstall
virtual void Uninstall()
Definition: devicenotifier.cpp:156
DeviceNotifier::~DeviceNotifier
virtual ~DeviceNotifier()
Definition: devicenotifier.cpp:61
DeviceNotifier::m_matchingDictionary
CFMutableDictionaryRef m_matchingDictionary
Definition: devicenotifier.h:77
DeviceNotifier::DeviceRemovedCallback
static void DeviceRemovedCallback(DeviceNotifier *thisObject, io_iterator_t iterator)
Definition: devicenotifier.cpp:245
DeviceNotifier::AddGeneralInterest
virtual void AddGeneralInterest(io_object_t service)
Definition: devicenotifier.cpp:275
DeviceNotifier::DeviceChanged
virtual void DeviceChanged(io_service_t unitService, natural_t messageType, void *message)
Definition: devicenotifier.cpp:309
DeviceNotifier::m_notificationPort
IONotificationPortRef m_notificationPort
Definition: devicenotifier.h:76
DeviceNotifier::DeviceChangedCallback
static void DeviceChangedCallback(DeviceNotifier *thisObject, io_service_t unitService, natural_t messageType, void *message)
Definition: devicenotifier.cpp:300
DeviceNotifier::m_clientCallback
DeviceClientCallback m_clientCallback
Definition: devicenotifier.h:74
DeviceNotifier::CreateMatchingDictionary
virtual CFMutableDictionaryRef CreateMatchingDictionary()
Definition: devicenotifier.h:48
DeviceNotifier
Mac-specific class that notifies clients when AJA devices are attached/detached, etc.
Definition: devicenotifier.h:33
DeviceNotifier::DeviceNotifier
DeviceNotifier(DeviceClientCallback callback, void *refcon)
Definition: devicenotifier.cpp:48