aja-source.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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, 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, NTV2VideoFormat &vf, NTV2PixelFormat &pf,
  40. VPIDDataList &vpids);
  41. void ResetVideoBuffer(NTV2VideoFormat vf, NTV2PixelFormat pf);
  42. void ResetAudioBuffer(size_t size);
  43. NTV2_POINTER mVideoBuffer;
  44. NTV2_POINTER mAudioBuffer;
  45. private:
  46. CNTV2Card *mCard;
  47. std::string mSourceName;
  48. std::string mCardID;
  49. UWord mDeviceIndex;
  50. bool mBuffering;
  51. bool mIsCapturing;
  52. SourceProps mSourceProps;
  53. NTV2TestPatternBuffer mTestPattern;
  54. AJAThread *mCaptureThread;
  55. std::mutex mMutex;
  56. obs_source_t *mSource;
  57. NTV2XptConnections mCrosspoints;
  58. };