aja-source.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #include "aja-props.hpp"
  3. #include "audio-repack.hpp"
  4. #include <obs-module.h>
  5. #include <ajantv2/includes/ajatypes.h>
  6. #include <ajantv2/includes/ntv2testpatterngen.h>
  7. #include <ajabase/common/types.h>
  8. #include <ajabase/system/thread.h>
  9. #include <mutex>
  10. class CNTV2Card;
  11. class AJASource {
  12. public:
  13. explicit AJASource(obs_source_t *source);
  14. ~AJASource();
  15. void SetCard(CNTV2Card *card);
  16. CNTV2Card *GetCard();
  17. void SetOBSSource(obs_source_t *source);
  18. obs_source_t *GetOBSSource(void) const;
  19. void SetName(const std::string &name);
  20. std::string GetName() const;
  21. void GenerateTestPattern(NTV2VideoFormat vf, NTV2PixelFormat pf,
  22. NTV2TestPatternSelect ps);
  23. // Capture Thread stuff
  24. static void CaptureThread(AJAThread *thread, void *data);
  25. void Activate(bool enable = false);
  26. void Deactivate();
  27. bool IsCapturing() const;
  28. void SetCapturing(bool capturing);
  29. // CardEntry/Device stuff
  30. std::string CardID() const;
  31. void SetCardID(const std::string &cardID);
  32. uint32_t DeviceIndex() const;
  33. void SetDeviceIndex(uint32_t index);
  34. // Source Props
  35. void SetSourceProps(const SourceProps &props);
  36. SourceProps GetSourceProps() const;
  37. void CacheConnections(const NTV2XptConnections &cnx);
  38. void ClearConnections();
  39. bool ReadChannelVPIDs(NTV2Channel channel, VPIDData &vpids);
  40. bool ReadWireFormats(NTV2DeviceID device_id, IOSelection io_select,
  41. NTV2VideoFormat &vf, NTV2PixelFormat &pf,
  42. VPIDDataList &vpids);
  43. void ResetVideoBuffer(NTV2VideoFormat vf, NTV2PixelFormat pf);
  44. void ResetAudioBuffer(size_t size);
  45. NTV2_POINTER mVideoBuffer;
  46. NTV2_POINTER mAudioBuffer;
  47. private:
  48. CNTV2Card *mCard;
  49. std::string mSourceName;
  50. std::string mCardID;
  51. UWord mDeviceIndex;
  52. bool mBuffering;
  53. bool mIsCapturing;
  54. SourceProps mSourceProps;
  55. NTV2TestPatternBuffer mTestPattern;
  56. AJAThread *mCaptureThread;
  57. std::mutex mMutex;
  58. obs_source_t *mSource;
  59. NTV2XptConnections mCrosspoints;
  60. };