]> git.sesse.net Git - vlc/commitdiff
Add audio connection selection.
authorSteinar Gunderson <sgunderson@bigfoot.com>
Fri, 24 Sep 2010 23:25:48 +0000 (01:25 +0200)
committerSteinar Gunderson <sgunderson@bigfoot.com>
Fri, 24 Sep 2010 23:25:48 +0000 (01:25 +0200)
modules/access/sdi.cpp

index ccef07114c7ef3b45053891e5441f9edf834c246..b539074f6e3fad85d648cccad93909962f4956dc 100644 (file)
@@ -36,6 +36,12 @@ static void Close( vlc_object_t * );
     "Caching value for SDI captures. This " \
     "value should be set in milliseconds." )
 
+#define AUDIO_CONNECTION_TEXT N_("Audio connection")
+#define AUDIO_CONNECTION_LONGTEXT N_( \
+    "Audio connection to use for SDI captures. " \
+    "Valid choices: embedded, aesebu, analog. " \
+    "Leave blank for card default." )
+
 #define RATE_TEXT N_("Audio sampling rate in Hz")
 #define RATE_LONGTEXT N_( \
     "Audio sampling rate (in hertz) for SDI captures. " \
@@ -60,6 +66,8 @@ vlc_module_begin ()
                  MODE_TEXT, MODE_LONGTEXT, true )
     add_integer( "sdi-caching", DEFAULT_PTS_DELAY / 1000, NULL,
                  CACHING_TEXT, CACHING_LONGTEXT, true )
+    add_string( "sdi-audio-connection", 0, NULL,
+                 AUDIO_CONNECTION_TEXT, AUDIO_CONNECTION_LONGTEXT, true )
     add_integer( "sdi-audio-rate", 48000, NULL,
                  RATE_TEXT, RATE_LONGTEXT, true )
     add_integer( "sdi-audio-channels", 2, NULL,
@@ -246,7 +254,43 @@ static int Open( vlc_object_t *p_this )
         msg_Err( p_demux, "Card has no inputs" );
         return VLC_EGENERIC;
     }
+   
+    // Set up the video and audio sources. 
+    IDeckLinkConfiguration *p_config;
+    if( p_sys->p_card->QueryInterface( IID_IDeckLinkConfiguration, (void**)&p_config) != S_OK )
+    {
+        msg_Err( p_demux, "Failed to get configuration interface" );
+        return VLC_EGENERIC;
+    }
+
+    char *psz_tmp = var_CreateGetNonEmptyString( p_demux, "sdi-audio-connection" );
+    if( psz_tmp )
+    {
+        BMDAudioConnection conn;
+        if ( !strcmp( psz_tmp, "embedded" ) )
+            conn = bmdAudioConnectionEmbedded;
+        else if ( !strcmp( psz_tmp, "aesebu" ) )
+            conn = bmdAudioConnectionAESEBU;
+        else if ( !strcmp( psz_tmp, "analog" ) )
+            conn = bmdAudioConnectionAnalog;
+        else
+        {
+            msg_Err( p_demux, "Invalid --sdi-audio-connection specified; choose one of " \
+                              "embedded, aesebu, or analog." );
+            return VLC_EGENERIC;
+        }
+        free( psz_tmp );
 
+        msg_Dbg( p_demux, "Setting audio input format to 0x%x", conn);
+        result = p_config->SetAudioInputFormat( conn );
+        if( result != S_OK )
+        {
+            msg_Err( p_demux, "Failed to set audio input connection" );
+            return VLC_EGENERIC;
+        }
+    } 
+
+    // Get the list of display modes.
     IDeckLinkDisplayModeIterator *p_display_iterator;
     result = p_sys->p_input->GetDisplayModeIterator( &p_display_iterator );
     if( result != S_OK )
@@ -356,7 +400,8 @@ static int Open( vlc_object_t *p_this )
         msg_Err( p_demux, "Failed to enable video input" );
         return VLC_EGENERIC;
     }
-   
+  
+    // Set up audio. 
     p_sys->i_rate = var_CreateGetInteger( p_demux, "sdi-audio-rate" );
     p_sys->i_channels = var_CreateGetInteger( p_demux, "sdi-audio-channels" );
     if( p_sys->i_rate > 0 && p_sys->i_channels > 0 )
@@ -390,7 +435,7 @@ static int Open( vlc_object_t *p_this )
     video_fmt.video.i_frame_rate_base = p_sys->i_fps_den;
     video_fmt.i_bitrate = video_fmt.video.i_width * video_fmt.video.i_height * video_fmt.video.i_frame_rate * 2;
     
-    char *psz_tmp = var_CreateGetNonEmptyString( p_demux, "sdi-aspect-ratio" );
+    psz_tmp = var_CreateGetNonEmptyString( p_demux, "sdi-aspect-ratio" );
     if( psz_tmp )
     {
         char *psz_denominator = strchr( psz_tmp, ':' );