decklink-device-instance.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include "decklink-device.hpp"
  3. class DeckLinkDeviceInstance : public IDeckLinkInputCallback {
  4. protected:
  5. struct obs_source_frame currentFrame;
  6. struct obs_source_audio currentPacket;
  7. DeckLink *decklink = nullptr;
  8. DeckLinkDevice *device = nullptr;
  9. bool doRgb = false;
  10. DeckLinkDeviceMode *mode = nullptr;
  11. ComPtr<IDeckLinkInput> input;
  12. volatile long refCount = 1;
  13. void HandleAudioPacket(IDeckLinkAudioInputPacket *audioPacket,
  14. const uint64_t timestamp);
  15. void HandleVideoFrame(IDeckLinkVideoInputFrame *videoFrame,
  16. const uint64_t timestamp);
  17. public:
  18. DeckLinkDeviceInstance(DeckLink *decklink, DeckLinkDevice *device);
  19. virtual ~DeckLinkDeviceInstance();
  20. inline DeckLinkDevice *GetDevice() const {return device;}
  21. inline long long GetActiveModeId() const
  22. {
  23. return mode ? mode->GetId() : 0;
  24. }
  25. inline DeckLinkDeviceMode *GetMode() const {return mode;}
  26. bool StartCapture(DeckLinkDeviceMode *mode);
  27. bool StopCapture(void);
  28. HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(
  29. IDeckLinkVideoInputFrame *videoFrame,
  30. IDeckLinkAudioInputPacket *audioPacket);
  31. HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(
  32. BMDVideoInputFormatChangedEvents events,
  33. IDeckLinkDisplayMode *newMode,
  34. BMDDetectedVideoInputFormatFlags detectedSignalFlags);
  35. ULONG STDMETHODCALLTYPE AddRef(void);
  36. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv);
  37. ULONG STDMETHODCALLTYPE Release(void);
  38. };