]> git.sesse.net Git - vlc/commitdiff
Enable video input and receive frames.
authorSteinar Gunderson <sgunderson@bigfoot.com>
Thu, 23 Sep 2010 23:03:20 +0000 (01:03 +0200)
committerSteinar Gunderson <sgunderson@bigfoot.com>
Thu, 23 Sep 2010 23:03:20 +0000 (01:03 +0200)
modules/access/sdi.cpp

index 3bdb3c37daa1e552e5a0d81f58a308a290f6213e..8b405ee3d71eb665a4325826dea18287d1f64618 100644 (file)
@@ -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 );