AJA NTV2 SDK  18.0.0.2717
NTV2 SDK 18.0.0.2717
ntv2link.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 #include "ntv2link.h"
10 #include "ntv2card.h"
11 
12 bool ntv2card_open(int index, void** card)
13 {
14  CNTV2Card* pCard = new CNTV2Card(index);
15  if (!pCard->IsOpen())
16  {
17  delete pCard;
18  return false;
19  }
20 
21  *card = (void*)pCard;
22  return true;
23 }
24 
25 void ntv2card_close(void* card)
26 {
27  CNTV2Card* pCard = (CNTV2Card*)card;
28  if (pCard != NULL)
29  {
30  delete pCard;
31  }
32 }
33 
34 bool ntv2card_get_display_name(void* card, char* display, int size)
35 {
36  if ((card == NULL) || (display == NULL) || (size == 0))
37  return false;
38  CNTV2Card* pCard = (CNTV2Card*)card;
39  std::string str = pCard->GetModelName();
40  snprintf(display, size, "%s", str.c_str());
41  return true;
42 }
43 
44 bool ntv2card_get_description(void* card, char* description, int size)
45 {
46  if ((card == NULL) || (description == NULL) || (size == 0))
47  return false;
48  CNTV2Card* pCard = (CNTV2Card*)card;
49  std::string str = pCard->GetDisplayName();
50  snprintf(description, size, "%s", str.c_str());
51  return true;
52 }
53 
54 bool ntv2card_get_serial_number(void* card, char* serial, int size)
55 {
56  if ((card == NULL) || (serial == NULL) || (size == 0))
57  return false;
58  CNTV2Card* pCard = (CNTV2Card*)card;
59  std::string str;
60  if (!pCard->GetSerialNumberString(str))
61  str = "Unknown";
62  snprintf(serial, size, "%s", str.c_str());
63  return true;
64 }
65 
66 bool ntv2card_register_read(void* card, unsigned int reg, unsigned int* data)
67 {
68  if ((card == NULL) || (data == NULL))
69  return false;
70  CNTV2Card* pCard = (CNTV2Card*)card;
71  return pCard->ReadRegister(reg, *data);
72 }
73 
74 bool ntv2card_register_write(void* card, unsigned int reg, unsigned int data)
75 {
76  if (card == NULL)
77  return false;
78  CNTV2Card* pCard = (CNTV2Card*)card;
79  return pCard->WriteRegister(reg, data);
80 }
81 
82 
83 
CNTV2MacDriverInterface::ReadRegister
virtual bool ReadRegister(const ULWord inRegNum, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Reads all or part of the 32-bit contents of a specific register (real or virtual) on the AJA device....
Definition: ntv2macdriverinterface.cpp:405
NULL
#define NULL
Definition: ntv2caption608types.h:19
CNTV2Card::GetModelName
virtual std::string GetModelName(void)
Answers with this device's model name.
Definition: ntv2card.cpp:80
CNTV2Card::GetDisplayName
virtual std::string GetDisplayName(void)
Answers with this device's display name.
Definition: ntv2card.cpp:86
ntv2card.h
Declares the CNTV2Card class.
CNTV2Card::GetSerialNumberString
virtual bool GetSerialNumberString(std::string &outSerialNumberString)
Answers with a string that contains my human-readable serial number.
Definition: ntv2card.cpp:227
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
CNTV2MacDriverInterface::WriteRegister
virtual bool WriteRegister(const ULWord inRegNum, const ULWord inValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Updates or replaces all or part of the 32-bit contents of a specific register (real or virtual) on th...
Definition: ntv2macdriverinterface.cpp:454