Creating an instance of IDeckLinkVideoFrame

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

oierlauzi

  • Posts: 1
  • Joined: Wed Mar 21, 2018 9:36 pm
  • Real Name: Oier Lauzirika

Creating an instance of IDeckLinkVideoFrame

PostWed Mar 21, 2018 9:51 pm

Hello; I'm new to the SDK. I need to use VideoConvert in my program (C++), and for that I need an output frame which is an instance of IDeckLinkVideoFrame . There is no constructor for IDeckLinkVideoFrame, but as I have read in the manual, it can be obtained via a) a function of IDeckLinkOutput or b) creating a subclass of IDeckLinkVideoFrame. Option a) is unsuitable for me, as there may not exist an instance of IDeckLinkOutput. Therefore, Im forced to create a subclass of IDeckLinkVideoFrame, but I can't get it to work. Can anyone post a example of the subclass?
Thank you and sorry for my bad English.
Oier
Offline

Rajat_Shetty

  • Posts: 11
  • Joined: Thu Dec 21, 2017 11:07 am

Re: Creating an instance of IDeckLinkVideoFrame

PostThu Mar 22, 2018 10:51 am

Not exactly sure what you are trying to do but you can use the IDeckLinkOutput::CreateVideoFrame method to obtain a new IDeckLinkVideoFrame.

HRESULT CreateVideoFrame (long width, long height, long rowBytes,
BMDPixelFormat pixelFormat, BMDFrameFlags flags,
IDeckLinkMutableVideoFrame **outFrame);
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 443
  • Joined: Mon Sep 04, 2017 4:05 am

Re: Creating an instance of IDeckLinkVideoFrame

PostFri Mar 23, 2018 1:30 am

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

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 8 guests