aja-source.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. bool ReadChannelVPIDs(NTV2Channel channel, VPIDData &vpids);
  37. bool ReadWireFormats(NTV2DeviceID device_id,
  38. const NTV2InputSourceSet &srcs,
  39. 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. };