From 75dbaf8b8bc4b3f10033ef6e7d1a00475ed5db62 Mon Sep 17 00:00:00 2001 From: Steinar Gunderson Date: Fri, 24 Sep 2010 23:36:36 +0200 Subject: [PATCH] Parametrize SDI audio rate and channels. --- modules/access/sdi.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/modules/access/sdi.cpp b/modules/access/sdi.cpp index 266937451e..0613bf8f62 100644 --- a/modules/access/sdi.cpp +++ b/modules/access/sdi.cpp @@ -36,6 +36,16 @@ static void Close( vlc_object_t * ); "Caching value for SDI captures. This " \ "value should be set in milliseconds." ) +#define RATE_TEXT N_("Audio sampling rate in Hz") +#define RATE_LONGTEXT N_( \ + "Audio sampling rate (in hertz) for SDI captures. " \ + "0 disables audio input." ) + +#define CHANNELS_TEXT N_("Number of audio channels") +#define CHANNELS_LONGTEXT N_( \ + "Number of input audio channels for SDI captures. " \ + "Must be 2, 8 or 16. 0 disables audio input." ) + vlc_module_begin () set_shortname( N_("SDI") ) set_description( N_("BlackMagic SDI input") ) @@ -46,6 +56,10 @@ vlc_module_begin () MODE_TEXT, MODE_LONGTEXT, true ) add_integer( "sdi-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, true ) + add_integer( "sdi-audio-rate", 48000, NULL, + RATE_TEXT, RATE_LONGTEXT, true ) + add_integer( "sdi-audio-channels", 2, NULL, + CHANNELS_TEXT, CHANNELS_LONGTEXT, true ) add_shortcut( "sdi" ) set_capability( "access_demux", 10 ) @@ -147,7 +161,7 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame if( audioFrame ) { - const int i_bytes = audioFrame->GetSampleFrameCount() * sizeof(int16_t) * 2; + const int i_bytes = audioFrame->GetSampleFrameCount() * sizeof(int16_t) * p_sys->i_channels; p_audio_frame = block_New( p_demux_, i_bytes ); if( !p_audio_frame ) @@ -333,13 +347,18 @@ static int Open( vlc_object_t *p_this ) return VLC_EGENERIC; } - result = p_sys->p_input->EnableAudioInput( 48000, bmdAudioSampleType16bitInteger, 2 ); - if( result != S_OK ) + int i_rate = var_CreateGetInteger( p_demux, "sdi-audio-rate" ); + int i_channels = var_CreateGetInteger( p_demux, "sdi-audio-channels" ); + if( i_rate > 0 && i_channels > 0 ) { - msg_Err( p_demux, "Failed to enable audio input" ); - return VLC_EGENERIC; + result = p_sys->p_input->EnableAudioInput( i_rate, bmdAudioSampleType16bitInteger, i_channels ); + if( result != S_OK ) + { + msg_Err( p_demux, "Failed to enable audio input" ); + return VLC_EGENERIC; + } } - + p_sys->p_delegate = new DeckLinkCaptureDelegate( p_demux ); p_sys->p_input->SetCallback( p_sys->p_delegate ); @@ -367,8 +386,8 @@ static int Open( vlc_object_t *p_this ) es_format_t audio_fmt; es_format_Init( &audio_fmt, AUDIO_ES, VLC_CODEC_S16N ); - audio_fmt.audio.i_channels = 2; - audio_fmt.audio.i_rate = 48000; + audio_fmt.audio.i_channels = i_channels; + audio_fmt.audio.i_rate = i_rate; audio_fmt.audio.i_bitspersample = 16; audio_fmt.audio.i_blockalign = audio_fmt.audio.i_channels * audio_fmt.audio.i_bitspersample / 8; audio_fmt.i_bitrate = audio_fmt.audio.i_channels * audio_fmt.audio.i_rate * audio_fmt.audio.i_bitspersample; -- 2.39.2