aja-source.hpp 1.9 KB

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