decklink-device-instance.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. BMDPixelFormat pixelFormat = bmdFormat8BitYUV;
  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 BMDPixelFormat GetActivePixelFormat() const {return pixelFormat;}
  26. inline DeckLinkDeviceMode *GetMode() const {return mode;}
  27. bool StartCapture(DeckLinkDeviceMode *mode);
  28. bool StopCapture(void);
  29. HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(
  30. IDeckLinkVideoInputFrame *videoFrame,
  31. IDeckLinkAudioInputPacket *audioPacket);
  32. HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(
  33. BMDVideoInputFormatChangedEvents events,
  34. IDeckLinkDisplayMode *newMode,
  35. BMDDetectedVideoInputFormatFlags detectedSignalFlags);
  36. ULONG STDMETHODCALLTYPE AddRef(void);
  37. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv);
  38. ULONG STDMETHODCALLTYPE Release(void);
  39. };