AJA NTV2 SDK  17.5.0.1492
NTV2 SDK 17.5.0.1492
ancillarylist.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef AJA_ANCILLARYLIST_H
9 #define AJA_ANCILLARYLIST_H
10 
11 #include "ancillarydata.h"
12 #include "ntv2formatdescriptor.h"
13 #include <map>
14 #include <set>
15 
16 // Starting with SDK 16.3, AJAAncillaryList is implemented using std::vector,
17 // which is faster than std::list, which is what was used in SDK 16.2.x and earlier.
18 #define AJAANCLISTIMPL_VECTOR // Comment out this line to revert to pre-16.3 behavior
19 #if defined(AJAANCLISTIMPL_VECTOR)
20  #include <vector>
21 #else
22  #include <list>
23 #endif
24 
25 
26 // used for "match any" searches and counts
27 const uint8_t AJAAncillaryDataWildcard_DID = 0xFF;
28 const uint8_t AJAAncillaryDataWildcard_SID = 0xFF;
29 
36 typedef std::map <uint16_t, AJAAncDataType> AJAAncillaryAnalogTypeMap;
37 
38 typedef std::vector<ULWordSequence> AJAU32Pkts;
39 typedef AJAU32Pkts::const_iterator AJAU32PktsConstIter;
40 typedef AJAU32Pkts::iterator AJAU32PktsIter;
41 
43 typedef AJAAncPktCounts::const_iterator AJAAncPktCountsConstIter;
44 class CNTV2Card;
45 
46 typedef std::set<AJAAncPktDIDSID> AJAAncPktDIDSIDSet;
47 typedef AJAAncPktDIDSIDSet::const_iterator AJAAncPktDIDSIDSetConstIter;
48 typedef AJAAncPktDIDSIDSet::iterator AJAAncPktDIDSIDSetIter;
49 
50 
65 {
66 public: // CLASS METHODS
67 
71 
83  static AJAStatus SetFromVANCData (const NTV2Buffer & inFrameBuffer,
84  const NTV2FormatDescriptor & inFormatDesc,
85  AJAAncillaryList & outPackets,
86  const uint32_t inFrameNum = 0);
87 
96  static AJAStatus SetFromDeviceAncBuffers (const NTV2Buffer & inF1AncBuffer,
97  const NTV2Buffer & inF2AncBuffer,
98  AJAAncillaryList & outPackets,
99  const uint32_t inFrameNum = 0);
100 
109  static AJAStatus SetFromDeviceAuxBuffers (const NTV2Buffer & inF1AuxBuffer,
110  const NTV2Buffer & inF2AuxBuffer,
111  AJAAncillaryList & outPackets,
112  const uint32_t inFrameNum = 0);
114 
118 
123  static AJAStatus ClearAnalogAncillaryDataTypeMap (void);
124 
125 
131  static AJAStatus SetAnalogAncillaryDataTypeMap (const AJAAncillaryAnalogTypeMap & inMap);
132 
133 
139  static AJAStatus GetAnalogAncillaryDataTypeMap (AJAAncillaryAnalogTypeMap & outMap);
140 
141 
149  static AJAStatus SetAnalogAncillaryDataTypeForLine (const uint16_t inLineNum, const AJAAncDataType inType);
150 
151 
158  static AJAAncDataType GetAnalogAncillaryDataTypeForLine (const uint16_t inLineNum);
159 
160 
165  static void SetIncludeZeroLengthPackets (const bool inExclude);
166  static uint32_t GetExcludedZeroLengthPacketCount (void);
167  static void ResetExcludedZeroLengthPacketCount (void);
168  static bool IsIncludingZeroLengthPackets (void);
169 
171 
172 public: // INSTANCE METHODS
176  AJAAncillaryList ();
178  inline AJAAncillaryList (const AJAAncillaryList & inRHS) {*this = inRHS;}
179  virtual ~AJAAncillaryList ();
180 
186  virtual AJAAncillaryList & operator = (const AJAAncillaryList & inRHS);
187 
188 #if defined(AJA_USE_CPLUSPLUS11)
189 
195  AJAAncillaryList (AJAAncillaryList && inRHS) noexcept; // (New in SDK 17.5)
202  virtual AJAAncillaryList & operator = (AJAAncillaryList && inRHS); // (New in SDK 17.5)
203 #endif // AJA_USE_CPLUSPLUS11
204 
206 
210 
216  virtual inline uint32_t CountAncillaryData (void) const {return uint32_t(m_ancList.size());}
217 
221  virtual inline bool IsEmpty (void) const {return !CountAncillaryData();}
222 
229  virtual AJAAncillaryData * GetAncillaryDataAtIndex (const uint32_t inIndex) const;
230 
236  virtual uint32_t CountAncillaryDataWithType (const AJAAncDataType inMatchType) const;
237 
245  virtual AJAAncillaryData * GetAncillaryDataWithType (const AJAAncDataType inMatchType, const uint32_t inIndex = 0) const;
246 
253  virtual uint32_t CountAncillaryDataWithID (const uint8_t inDID, const uint8_t inSID) const;
254 
263  virtual AJAAncillaryData * GetAncillaryDataWithID (const uint8_t inDID, const uint8_t inSID, const uint32_t inIndex = 0) const;
264 
265  virtual AJAAncPktDIDSIDSet GetAncillaryPacketIDs (void) const;
266 
268 
272 
278  virtual AJAStatus Clear (void);
279 
285  virtual AJAStatus AddAncillaryData (const AJAAncillaryList & inPackets);
286 
292  virtual AJAStatus AddAncillaryData (const AJAAncillaryData * pInAncData);
293 
299  virtual inline AJAStatus AddAncillaryData (const AJAAncillaryData & inAncData) {return AddAncillaryData(&inAncData);}
300 
307  virtual AJAStatus RemoveAncillaryData (AJAAncillaryData * pInAncData);
308 
314  virtual AJAStatus DeleteAncillaryData (AJAAncillaryData * pInAncData);
316 
317 
321 
327  virtual AJAStatus SortListByDID (void);
328 
333  virtual AJAStatus SortListBySID (void);
334 
340  virtual AJAStatus SortListByLocation (void);
341 
350  virtual AJAStatus Compare (const AJAAncillaryList & inCompareList, const bool inIgnoreLocation = true, const bool inIgnoreChecksum = true) const;
351 
362  virtual std::string CompareWithInfo (const AJAAncillaryList & inCompareList, const bool inIgnoreLocation = true, const bool inIgnoreChecksum = true) const;
363 
373  virtual bool CompareWithInfo (std::vector<std::string> & outDiffs, const AJAAncillaryList & inCompareList, const bool inIgnoreLocation = true, const bool inIgnoreChecksum = true) const; // New in SDK 16.3
375 
376 
380 
390  virtual AJAStatus GetAncillaryDataTransmitSize (const bool inIsProgressive, const uint32_t inF2StartLine,
391  uint32_t & outF1ByteCount, uint32_t & outF2ByteCount);
392 
393 
407  virtual AJAStatus GetAncillaryDataTransmitData (const bool inIsProgressive, const uint32_t inF2StartLine,
408  uint8_t * pOutF1AncData, const uint32_t inF1ByteCountMax,
409  uint8_t * pOutF2AncData, const uint32_t inF2ByteCountMax);
410 
423  virtual AJAStatus GetTransmitData (NTV2Buffer & F1Buffer, NTV2Buffer & F2Buffer,
424  const bool inIsProgressive = true, const uint32_t inF2StartLine = 0);
425 
426  virtual inline AJAStatus GetSDITransmitData (NTV2Buffer & F1Buffer, NTV2Buffer & F2Buffer,
427  const bool inIsProgressive = true, const uint32_t inF2StartLine = 0)
428  {return GetTransmitData(F1Buffer, F2Buffer, inIsProgressive, inF2StartLine);}
429 
438  virtual AJAStatus GetVANCTransmitData (NTV2Buffer & inFrameBuffer, const NTV2FormatDescriptor & inFormatDesc);
439 
454  virtual AJAStatus GetIPTransmitData (NTV2Buffer & F1Buffer, NTV2Buffer & F2Buffer,
455  const bool inIsProgressive = true, const uint32_t inF2StartLine = 0);
456 
469  virtual inline AJAStatus GetHDMITransmitData (NTV2Buffer & F1Buffer, NTV2Buffer & F2Buffer,
470  const bool inIsProgressive = true, const uint32_t inF2StartLine = 0)
471  {return AJA_STATUS_UNSUPPORTED;}
472 
483  virtual AJAStatus GetIPTransmitDataLength (uint32_t & outF1ByteCount, uint32_t & outF2ByteCount,
484  const bool inIsProgressive = true, const uint32_t inF2StartLine = 0);
485 
491  virtual inline bool AllowMultiRTPTransmit (void) const {return m_xmitMultiRTP;}
492 
499  virtual inline void SetAllowMultiRTPTransmit (const bool inAllow) {m_xmitMultiRTP = inAllow;}
501 
502 
506 
519  virtual AJAStatus AddReceivedAncillaryData (const NTV2Buffer & inReceivedData, const uint32_t inFrameNum = 0); // New in SDK 17.1
520 
532  virtual AJAStatus AddReceivedAuxiliaryData (const NTV2Buffer & inReceivedData, const uint32_t inFrameNum = 0); // New in SDK 17.1
533 
543  virtual AJAStatus AddReceivedAncillaryData (const ULWordSequence & inReceivedData);
544 
545 
555  virtual AJAStatus AddVANCData (const UWordSequence & inPacketWords,
556  const AJAAncillaryDataLocation & inLocation,
557  const uint32_t inFrameNum = 0);
558 
564  virtual inline bool AllowMultiRTPReceive (void) const {return m_rcvMultiRTP;}
565 
571  virtual inline void SetAllowMultiRTPReceive (const bool inAllow) {m_rcvMultiRTP = inAllow;}
572 
579  virtual inline bool IgnoreChecksumErrors (void) const {return m_ignoreCS;}
580 
586  virtual inline void SetIgnoreChecksumErrors (const bool inIgnore) {m_ignoreCS = inIgnore;}
587 
592  virtual AJAStatus ParseAllAncillaryData (void);
593 
594  virtual inline AJAStatus AddReceivedAncillaryData ( const uint8_t * rcvData, \
595  const uint32_t rcvCnt, \
596  const uint32_t frmNum = 0) \
597  { return AddReceivedAncillaryData (NTV2Buffer (rcvData, rcvCnt), frmNum); \
598  }
599 
601 
605 
613  virtual std::ostream & Print (std::ostream & inOutStream, const bool inDetailed = true) const;
615 
623  static bool StripNativeInserterGUMPPackets (const NTV2Buffer & inSrc, NTV2Buffer & outDst);
624 
625 protected:
626  friend class CNTV2Card; // CNTV2Card's member functions can call AJAAncillaryList's private & protected member functions
627 
628 #if defined(AJAANCLISTIMPL_VECTOR)
629  typedef std::vector <AJAAncillaryData*> AJAAncillaryDataList;
630 #else
631  typedef std::list <AJAAncillaryData*> AJAAncillaryDataList;
632 #endif
633  typedef AJAAncillaryDataList::const_iterator AJAAncDataListConstIter;
634  typedef AJAAncillaryDataList::iterator AJAAncDataListIter;
635 
636  virtual inline AJAAncDataType GetAnalogAncillaryDataType (const AJAAncillaryData & inAncData) {return GetAnalogAncillaryDataTypeForLine(inAncData.GetLocationLineNumber());}
637 
638  static inline bool BufferHasGUMPData (const NTV2Buffer & inBuffer) {return inBuffer ? inBuffer.U8(0) == 0xFF : false;}
639 
648  static AJAStatus AddFromDeviceAncBuffer (const NTV2Buffer & inAncBuffer,
649  AJAAncillaryList & outPacketList,
650  const uint32_t inFrameNum = 0);
651 
660  static AJAStatus AddFromDeviceAuxBuffer (const NTV2Buffer & inAuxBuffer,
661  AJAAncillaryList & outPacketList,
662  const uint32_t inFrameNum = 0);
663 
676  virtual AJAStatus GetRTPPackets (AJAU32Pkts & outF1U32Pkts,
677  AJAU32Pkts & outF2U32Pkts,
678  AJAAncPktCounts & outF1AncCounts,
679  AJAAncPktCounts & outF2AncCounts,
680  const bool inIsProgressive,
681  const uint32_t inF2StartLine);
695  static AJAStatus WriteRTPPackets (NTV2Buffer & theBuffer,
696  uint32_t & outBytesWritten,
697  const AJAU32Pkts & inRTPPkts,
698  const AJAAncPktCounts & inAncCounts,
699  const bool inIsF2,
700  const bool inIsProgressive);
701 
702 private:
703  AJAAncillaryDataList m_ancList;
704  bool m_rcvMultiRTP;
705  bool m_xmitMultiRTP;
706  bool m_ignoreCS;
707 
708 }; // AJAAncillaryList
709 
711 
712 
719 inline std::ostream & operator << (std::ostream & inOutStream, const AJAAncillaryList & inList) {return inList.Print(inOutStream);}
720 
727 AJAExport std::ostream & operator << (std::ostream & inOutStream, const AJAU32Pkts & inPkts);
728 
735 AJAExport std::ostream & operator << (std::ostream & inOutStream, const AJAAncPktDIDSIDSet & inSet); // New in SDK 16.0
736 
737 #endif // AJA_ANCILLARYLIST_H
AJAAncillaryList::AllowMultiRTPReceive
virtual bool AllowMultiRTPReceive(void) const
Answers true if multiple RTP packets are allowed for capture/receive. The default behavior is to proc...
Definition: ancillarylist.h:564
AJAAncillaryList::GetHDMITransmitData
virtual AJAStatus GetHDMITransmitData(NTV2Buffer &F1Buffer, NTV2Buffer &F2Buffer, const bool inIsProgressive=true, const uint32_t inF2StartLine=0)
Encodes my AJAAuxiliaryData packets into the given buffers in the default HDMI Aux Buffer Data Format...
Definition: ancillarylist.h:469
AJAAncPktCounts
UByteSequence AJAAncPktCounts
Ordered sequence of SMPTE Anc packet counts.
Definition: ancillarylist.h:42
AJAAncillaryList::AJAAncillaryDataList
std::vector< AJAAncillaryData * > AJAAncillaryDataList
Definition: ancillarylist.h:629
AJAAncDataLoc
Defines where the ancillary data can be found within a video stream.
Definition: ancillarydata.h:225
AJAAncillaryList::SetAllowMultiRTPTransmit
virtual void SetAllowMultiRTPTransmit(const bool inAllow)
Determines if multiple RTP packets will be encoded for playout (via GetIPTransmitData)....
Definition: ancillarylist.h:499
ancillarydata.h
Declares the AJAAncillaryData class.
AJAAncillaryList::SetIgnoreChecksumErrors
virtual void SetIgnoreChecksumErrors(const bool inIgnore)
Determines if checksum errors encountered during capture/ingest (via AddReceivedAncillaryData) will b...
Definition: ancillarylist.h:586
NTV2FormatDescriptor
Describes a video frame for a given video standard or format and pixel format, including the total nu...
Definition: ntv2formatdescriptor.h:41
NTV2Buffer
Describes a user-space buffer on the host computer. I have an address and a length,...
Definition: ntv2publicinterface.h:6094
UByteSequence
std::vector< uint8_t > UByteSequence
An ordered sequence of UByte (uint8_t) values.
Definition: ntv2publicinterface.h:38
AJAAncPktDIDSIDSet
std::set< AJAAncPktDIDSID > AJAAncPktDIDSIDSet
Set of distinct packet DID/SIDs (New in SDK 16.0)
Definition: ancillarylist.h:44
AJAU32PktsConstIter
AJAU32Pkts::const_iterator AJAU32PktsConstIter
Handy const iterator over AJAU32Pkts.
Definition: ancillarylist.h:39
AJAAncDataType
AJAAncDataType
Identifies the ancillary data types that are known to this module.
Definition: ancillarydata.h:44
AJAAuxList
AJAAncillaryList AJAAuxList
Definition: ancillarylist.h:710
AJAAncillaryList
I am an ordered collection of AJAAncillaryData instances which represent one or more SMPTE 291 data p...
Definition: ancillarylist.h:64
AJAAncillaryList::IsEmpty
virtual bool IsEmpty(void) const
Definition: ancillarylist.h:221
AJAStatus
AJAStatus
Definition: types.h:378
AJAAncillaryList::AJAAncDataListConstIter
AJAAncillaryDataList::const_iterator AJAAncDataListConstIter
Handy const iterator for iterating over members of an AJAAncillaryDataList.
Definition: ancillarylist.h:633
AJAAncillaryAnalogTypeMap
std::map< uint16_t, AJAAncDataType > AJAAncillaryAnalogTypeMap
Associates certain frame line numbers with specific types of "raw" or "analog" ancillary data....
Definition: ancillarylist.h:36
AJAAncillaryList::AJAAncDataListIter
AJAAncillaryDataList::iterator AJAAncDataListIter
Handy non-const iterator for iterating over members of an AJAAncillaryDataList.
Definition: ancillarylist.h:634
AJAAncillaryData
I am the principal class that stores a single SMPTE-291 SDI ancillary data packet OR the digitized co...
Definition: ancillarydata.h:552
AJAAncillaryList::AddAncillaryData
virtual AJAStatus AddAncillaryData(const AJAAncillaryData &inAncData)
Appends a copy of the given AJAAncillaryData object to me.
Definition: ancillarylist.h:299
UWordSequence
std::vector< uint16_t > UWordSequence
An ordered sequence of UWord (uint16_t) values.
Definition: ntv2publicinterface.h:42
AJAAncillaryDataWildcard_DID
const uint8_t AJAAncillaryDataWildcard_DID
Definition: ancillarylist.h:27
AJAAncList
AJAAncillaryList AJAAncList
Definition: ancillarylist.h:710
AJAU32Pkts
std::vector< ULWordSequence > AJAU32Pkts
Ordered sequence of U32 RTP packets (U32s in network byte order)
Definition: ancillarylist.h:38
AJAU32PktsIter
AJAU32Pkts::iterator AJAU32PktsIter
Handy non-const iterator over AJAU32Pkts.
Definition: ancillarylist.h:40
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
AJAAncPktCountsConstIter
AJAAncPktCounts::const_iterator AJAAncPktCountsConstIter
Handy const iterator over AJAAncPktCounts.
Definition: ancillarylist.h:43
AJAAncillaryList::Print
virtual std::ostream & Print(std::ostream &inOutStream, const bool inDetailed=true) const
Dumps a human-readable description of every packet in my list to the given output stream.
Definition: ancillarylist.cpp:1679
NTV2Buffer::U8
uint8_t U8(const int inIndex) const
Definition: ntv2publicinterface.h:6617
AJAAncillaryList::AllowMultiRTPTransmit
virtual bool AllowMultiRTPTransmit(void) const
Answers true if multiple RTP packets will be transmitted/encoded. The default behavior is to transmit...
Definition: ancillarylist.h:491
AJAAncillaryList::CountAncillaryData
virtual uint32_t CountAncillaryData(void) const
Answers with the number of AJAAncillaryData objects I contain (any/all types).
Definition: ancillarylist.h:216
AJA_STATUS_UNSUPPORTED
@ AJA_STATUS_UNSUPPORTED
Definition: types.h:394
ntv2formatdescriptor.h
Declares the NTV2FormatDescriptor class.
AJAAncillaryList::BufferHasGUMPData
static bool BufferHasGUMPData(const NTV2Buffer &inBuffer)
Definition: ancillarylist.h:638
AJAAuxiliaryList
AJAAncillaryList AJAAuxiliaryList
Definition: ancillarylist.h:710
AJAAncillaryDataWildcard_SID
const uint8_t AJAAncillaryDataWildcard_SID
Definition: ancillarylist.h:28
ULWordSequence
std::vector< uint32_t > ULWordSequence
An ordered sequence of ULWord (uint32_t) values.
Definition: ntv2publicinterface.h:46
AJAExport
#define AJAExport
Definition: export.h:33
AJAAncPktDIDSIDSetIter
AJAAncPktDIDSIDSet::iterator AJAAncPktDIDSIDSetIter
Handy non-const iterator for AJAAncPktDIDSIDSet (New in SDK 16.0)
Definition: ancillarylist.h:48
operator<<
std::ostream & operator<<(std::ostream &inOutStream, const AJAAncillaryList &inList)
Writes a human-readable rendition of the given AJAAncillaryList into the given output stream.
Definition: ancillarylist.h:719
AJAAncillaryList::GetAnalogAncillaryDataType
virtual AJAAncDataType GetAnalogAncillaryDataType(const AJAAncillaryData &inAncData)
Definition: ancillarylist.h:636
AJAAncillaryList::SetAllowMultiRTPReceive
virtual void SetAllowMultiRTPReceive(const bool inAllow)
Determines if more than one RTP packet will be processed/decoded (via AddReceivedAncillaryData).
Definition: ancillarylist.h:571
AJAAncillaryList::IgnoreChecksumErrors
virtual bool IgnoreChecksumErrors(void) const
Answers if checksum errors are to be ignored or not. The default behavior is to not ignore them.
Definition: ancillarylist.h:579
AJAAncPktDIDSIDSetConstIter
AJAAncPktDIDSIDSet::const_iterator AJAAncPktDIDSIDSetConstIter
Handy const iterator for AJAAncPktDIDSIDSet (New in SDK 16.0)
Definition: ancillarylist.h:47