decklink-device-instance.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. DeckLinkDeviceMode *mode = nullptr;
  10. ComPtr<IDeckLinkInput> input;
  11. volatile long refCount = 1;
  12. void HandleAudioPacket(IDeckLinkAudioInputPacket *audioPacket,
  13. const uint64_t timestamp);
  14. void HandleVideoFrame(IDeckLinkVideoInputFrame *videoFrame,
  15. const uint64_t timestamp);
  16. public:
  17. DeckLinkDeviceInstance(DeckLink *decklink, DeckLinkDevice *device);
  18. virtual ~DeckLinkDeviceInstance();
  19. inline DeckLinkDevice *GetDevice() const {return device;}
  20. inline long long GetActiveModeId() const
  21. {
  22. return mode ? mode->GetId() : 0;
  23. }
  24. inline DeckLinkDeviceMode *GetMode() const {return mode;}
  25. bool StartCapture(DeckLinkDeviceMode *mode);
  26. bool StopCapture(void);
  27. HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(
  28. IDeckLinkVideoInputFrame *videoFrame,
  29. IDeckLinkAudioInputPacket *audioPacket);
  30. HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(
  31. BMDVideoInputFormatChangedEvents events,
  32. IDeckLinkDisplayMode *newMode,
  33. BMDDetectedVideoInputFormatFlags detectedSignalFlags);
  34. ULONG STDMETHODCALLTYPE AddRef(void);
  35. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv);
  36. ULONG STDMETHODCALLTYPE Release(void);
  37. };