From 7feb1ed4d07a586f4b4e796421f0ae87843c51d1 Mon Sep 17 00:00:00 2001 From: Steinar Gunderson Date: Fri, 24 Sep 2010 01:03:20 +0200 Subject: [PATCH] Enable video input and receive frames. --- modules/access/sdi.cpp | 50 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/modules/access/sdi.cpp b/modules/access/sdi.cpp index 3bdb3c37da..8b405ee3d7 100644 --- a/modules/access/sdi.cpp +++ b/modules/access/sdi.cpp @@ -45,13 +45,45 @@ vlc_module_end () static int Demux ( demux_t * ); static int Control( demux_t *, int, va_list ); +class DeckLinkCaptureDelegate; + struct demux_sys_t { IDeckLink *p_card; IDeckLinkInput *p_input; + DeckLinkCaptureDelegate *p_delegate; es_out_id_t *p_es; }; +class DeckLinkCaptureDelegate : public IDeckLinkInputCallback +{ +public: + DeckLinkCaptureDelegate( demux_t *p_demux ) : p_demux_(p_demux) {} + + // FIXME: These leak. + virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; } + virtual ULONG STDMETHODCALLTYPE AddRef(void) { return 1; } + virtual ULONG STDMETHODCALLTYPE Release(void) { return 1; } + + virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags); + virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*); + +private: + demux_t *p_demux_; +}; + +HRESULT DeckLinkCaptureDelegate::VideoInputFormatChanged(BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *mode, BMDDetectedVideoInputFormatFlags) +{ + msg_Dbg( p_demux_, "Video input format changed" ); + return S_OK; +} + +HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame* videoFrame, IDeckLinkAudioInputPacket* audioFrame) +{ + msg_Dbg( p_demux_, "Received a frame" ); + return S_OK; +} + static int Open( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t*)p_this; @@ -84,7 +116,7 @@ static int Open( vlc_object_t *p_this ) result = decklink_iterator->Next( &p_sys->p_card ); if ( result != S_OK ) { - msg_Err( p_demux, "No DeckLink PCI cards found." ); + msg_Err( p_demux, "No DeckLink PCI cards found" ); return VLC_EGENERIC; } @@ -93,6 +125,22 @@ static int Open( vlc_object_t *p_this ) return VLC_EGENERIC; } + p_sys->p_delegate = new DeckLinkCaptureDelegate( p_demux ); + p_sys->p_input->SetCallback( p_sys->p_delegate ); + + result = p_sys->p_input->EnableVideoInput(bmdModePAL, bmdFormat8BitYUV, 0); + if ( result != S_OK ) { + msg_Err( p_demux, "Failed to enable video input" ); + return VLC_EGENERIC; + } + + // FIXME: add audio + result = p_sys->p_input->StartStreams(); + if ( result != S_OK ) { + msg_Err( p_demux, "Failed to start streams" ); + return VLC_EGENERIC; + } + /*eDeclare elementary streams */ es_format_t fmt; es_format_Init( &fmt, VIDEO_ES, VLC_CODEC_YUYV ); -- 2.39.2