Hi Oier,
The following is an example of class header for such as subclass to IDeckLinkVideoFrame[1], you need to implement all methods defined by the interface, the constructor/deconstructor are design dependent.
In my case I have implemented a frame that uses pixel format bmdFormat8BitBGRA. In your constructor, you will need to allocate sufficient buffer to hold the video frame, based on resolution and pixel format. Output a pointer to the buffer in the GetBytes command so it can be referenced by the IDeckLinkVideoConversion interface [2].
- Code: Select all
// BGRA32 video frame class
class Bgra32VideoFrame : public IDeckLinkVideoFrame
{
public:
Bgra32VideoFrame(long width, long height, BMDFrameFlags flags);
virtual ~Bgra32VideoFrame();
virtual long STDMETHODCALLTYPE GetWidth(void) { return m_width; };
virtual long STDMETHODCALLTYPE GetHeight(void) { return m_height; };
virtual long STDMETHODCALLTYPE GetRowBytes(void) { return m_width * 4; };
virtual HRESULT STDMETHODCALLTYPE GetBytes(void** buffer);
virtual BMDFrameFlags STDMETHODCALLTYPE GetFlags(void) { return m_flags; };
virtual BMDPixelFormat STDMETHODCALLTYPE GetPixelFormat(void) { return bmdFormat8BitBGRA; };
// Dummy implementations of remaining methods
virtual HRESULT STDMETHODCALLTYPE GetAncillaryData(IDeckLinkVideoFrameAncillary** ancillary) { return E_NOTIMPL; };
virtual HRESULT STDMETHODCALLTYPE GetTimecode(BMDTimecodeFormat format, IDeckLinkTimecode** timecode) { return E_NOTIMPL; };
// Implement IUnknown
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv);
virtual ULONG STDMETHODCALLTYPE AddRef();
virtual ULONG STDMETHODCALLTYPE Release();
private:
long m_width;
long m_height;
BMDFrameFlags m_flags;
LPVOID m_pixelBuffer = NULL;
ULONG m_refCount;
};
Regards
Cameron
Refs (DeckLink SDK Manual)
[1] 2.5.5 IDeckLinkVideoFrame Interface
[2] 2.5.41 IDeckLinkVideoConversion Interface