2015-02-18 15:15:38 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "decklink-device.hpp"
|
|
|
|
|
2017-03-30 21:03:38 -07:00
|
|
|
class AudioRepacker;
|
|
|
|
|
2015-02-18 15:15:38 -08:00
|
|
|
class DeckLinkDeviceInstance : public IDeckLinkInputCallback {
|
|
|
|
protected:
|
|
|
|
struct obs_source_frame currentFrame;
|
|
|
|
struct obs_source_audio currentPacket;
|
|
|
|
DeckLink *decklink = nullptr;
|
|
|
|
DeckLinkDevice *device = nullptr;
|
|
|
|
DeckLinkDeviceMode *mode = nullptr;
|
2017-05-05 05:55:06 -07:00
|
|
|
BMDDisplayMode displayMode = bmdModeNTSC;
|
2015-09-15 20:48:00 -07:00
|
|
|
BMDPixelFormat pixelFormat = bmdFormat8BitYUV;
|
2017-05-05 05:55:06 -07:00
|
|
|
video_colorspace colorSpace = VIDEO_CS_DEFAULT;
|
|
|
|
video_colorspace activeColorSpace = VIDEO_CS_DEFAULT;
|
|
|
|
video_range_type colorRange = VIDEO_RANGE_DEFAULT;
|
2015-02-18 15:15:38 -08:00
|
|
|
ComPtr<IDeckLinkInput> input;
|
|
|
|
volatile long refCount = 1;
|
2017-04-07 00:31:16 -07:00
|
|
|
int64_t audioOffset = 0;
|
|
|
|
uint64_t nextAudioTS = 0;
|
|
|
|
uint64_t lastVideoTS = 0;
|
2017-03-30 21:03:38 -07:00
|
|
|
AudioRepacker *audioRepacker = nullptr;
|
|
|
|
speaker_layout channelFormat = SPEAKERS_STEREO;
|
|
|
|
|
|
|
|
void FinalizeStream();
|
2017-05-05 05:55:06 -07:00
|
|
|
void SetupVideoFormat(DeckLinkDeviceMode *mode_);
|
2017-03-30 21:03:38 -07:00
|
|
|
|
2015-02-18 15:15:38 -08:00
|
|
|
void HandleAudioPacket(IDeckLinkAudioInputPacket *audioPacket,
|
|
|
|
const uint64_t timestamp);
|
|
|
|
void HandleVideoFrame(IDeckLinkVideoInputFrame *videoFrame,
|
|
|
|
const uint64_t timestamp);
|
|
|
|
|
|
|
|
public:
|
|
|
|
DeckLinkDeviceInstance(DeckLink *decklink, DeckLinkDevice *device);
|
2015-07-11 14:22:14 -07:00
|
|
|
virtual ~DeckLinkDeviceInstance();
|
2015-02-18 15:15:38 -08:00
|
|
|
|
|
|
|
inline DeckLinkDevice *GetDevice() const {return device;}
|
|
|
|
inline long long GetActiveModeId() const
|
|
|
|
{
|
|
|
|
return mode ? mode->GetId() : 0;
|
|
|
|
}
|
|
|
|
|
2015-10-08 10:42:33 -07:00
|
|
|
inline BMDPixelFormat GetActivePixelFormat() const {return pixelFormat;}
|
2017-05-05 05:55:06 -07:00
|
|
|
inline video_colorspace GetActiveColorSpace() const {return colorSpace;}
|
|
|
|
inline video_range_type GetActiveColorRange() const {return colorRange;}
|
2017-03-30 21:03:38 -07:00
|
|
|
inline speaker_layout GetActiveChannelFormat() const {return channelFormat;}
|
2015-10-08 10:42:33 -07:00
|
|
|
|
2015-02-18 15:15:38 -08:00
|
|
|
inline DeckLinkDeviceMode *GetMode() const {return mode;}
|
|
|
|
|
|
|
|
bool StartCapture(DeckLinkDeviceMode *mode);
|
|
|
|
bool StopCapture(void);
|
|
|
|
|
|
|
|
HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(
|
|
|
|
IDeckLinkVideoInputFrame *videoFrame,
|
|
|
|
IDeckLinkAudioInputPacket *audioPacket);
|
|
|
|
HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(
|
|
|
|
BMDVideoInputFormatChangedEvents events,
|
|
|
|
IDeckLinkDisplayMode *newMode,
|
|
|
|
BMDDetectedVideoInputFormatFlags detectedSignalFlags);
|
|
|
|
|
|
|
|
ULONG STDMETHODCALLTYPE AddRef(void);
|
|
|
|
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv);
|
|
|
|
ULONG STDMETHODCALLTYPE Release(void);
|
|
|
|
};
|