]> git.sesse.net Git - vlc/commitdiff
Enumerate all modes from the card, and print them out.
authorSteinar Gunderson <sgunderson@bigfoot.com>
Fri, 24 Sep 2010 20:48:00 +0000 (22:48 +0200)
committerSteinar Gunderson <sgunderson@bigfoot.com>
Fri, 24 Sep 2010 20:48:00 +0000 (22:48 +0200)
modules/access/sdi.cpp

index 5d0f1e804bda9c0cc654f8cff13759ad8858d3c6..691cd1f35f9409a86478293204e399f781949cf4 100644 (file)
@@ -17,6 +17,8 @@
 #include <vlc_charset.h>
 #include <vlc_fs.h>
 
+#include <arpa/inet.h>
+
 #include "DeckLinkAPI.h"
 #include "DeckLinkAPIDispatch.cpp"
 
@@ -217,7 +219,73 @@ static int Open( vlc_object_t *p_this )
         msg_Err( p_demux, "Failed to enable video input" );
         return VLC_EGENERIC;
     }
-    
+        
+    IDeckLinkDisplayModeIterator *p_display_iterator;
+    result = p_sys->p_input->GetDisplayModeIterator( &p_display_iterator );
+    if( result != S_OK )
+    {
+        msg_Err( p_demux, "Failed to enumerate display modes" );
+        return VLC_EGENERIC;
+    }
+
+    for (;;)
+    {
+        IDeckLinkDisplayMode *p_display_mode;
+        result = p_display_iterator->Next( &p_display_mode );
+        if( result != S_OK || !p_display_mode )
+        {
+            break; 
+        }
+
+        char mode_id_text[5] = {0};
+        BMDDisplayMode mode_id = ntohl( p_display_mode->GetDisplayMode() );
+        memcpy( mode_id_text, &mode_id, sizeof(mode_id) );
+
+        const char *mode_name;
+        result = p_display_mode->GetName( &mode_name );
+        if( result != S_OK )
+        {
+            msg_Err( p_demux, "Failed to get display mode name" );
+            return VLC_EGENERIC;
+        }
+
+        BMDTimeValue frame_duration, time_scale;
+        result = p_display_mode->GetFrameRate( &frame_duration, &time_scale );
+        if( result != S_OK )
+        {
+            msg_Err( p_demux, "Failed to get frame rate" );
+            return VLC_EGENERIC;
+        }
+
+        const char *field_dominance;
+        switch( p_display_mode->GetFieldDominance() )
+        {
+        case bmdProgressiveFrame:
+            field_dominance = "";
+            break;
+        case bmdProgressiveSegmentedFrame:
+            field_dominance = ", segmented";
+            break;
+        case bmdLowerFieldFirst:
+            field_dominance = ", interlaced [BFF]";
+            break;
+        case bmdUpperFieldFirst:
+            field_dominance = ", interlaced [TFF]";
+            break;
+        case bmdUnknownFieldDominance:
+        default:
+            field_dominance = ", unknown field dominance";
+            break;
+        }
+
+        char buf[256];
+        sprintf( buf, "Found mode '%s': %s (%dx%d, %.3f fps%s)",
+                 mode_id_text, mode_name,
+                 p_display_mode->GetWidth(), p_display_mode->GetHeight(),
+                 double(time_scale) / frame_duration, field_dominance );
+        msg_Dbg( p_demux, buf );
+    }
+   
     result = p_sys->p_input->EnableAudioInput( 48000, bmdAudioSampleType16bitInteger, 2 );
     if( result != S_OK )
     {