static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
+#define MODE_TEXT N_("Desired input video mode")
+#define MODE_LONGTEXT N_( \
+ "Desired input video mode for SDI captures. " \
+ "This value should be a FOURCC code in textual " \
+ "form, e.g. \"ntsc\"." )
+
#define CACHING_TEXT N_("Caching value in ms")
#define CACHING_LONGTEXT N_( \
"Caching value for SDI captures. This " \
set_description( N_("BlackMagic SDI input") )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_ACCESS )
-
+
+ add_string( "sdi-mode", "pal ", NULL,
+ MODE_TEXT, MODE_LONGTEXT, true )
add_integer( "sdi-caching", DEFAULT_PTS_DELAY / 1000, NULL,
CACHING_TEXT, CACHING_LONGTEXT, true )
IDeckLink *p_card;
IDeckLinkInput *p_input;
DeckLinkCaptureDelegate *p_delegate;
+
es_out_id_t *p_video_es;
es_out_id_t *p_audio_es;
bool b_first_frame;
+ int i_width, i_height, i_fps_num, i_fps_den;
+ // FIXME: field dominance
+
vlc_mutex_t frame_lock;
block_t *p_video_frame; // protected by <frame_lock>
block_t *p_audio_frame; // protected by <frame_lock>
return VLC_EGENERIC;
}
- 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;
- }
-
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;
}
+
+ char *mode_string = var_CreateGetString( p_demux, "sdi-mode" );
+ if( !mode_string || strlen( mode_string ) == 0 || strlen( mode_string ) > 4 ) {
+ msg_Err( p_demux, "Missing or invalid --sdi-mode string" );
+ return VLC_EGENERIC;
+ }
+
+ // Pad the --sdi-mode string to four characters, so the user can specify e.g. "pal"
+ // without having to add the trailing space.
+ char mode_string_padded[5];
+ strcpy(mode_string_padded, " ");
+ for( int i = 0; i < strlen(mode_string); ++i )
+ mode_string_padded[i] = mode_string[i];
+
+ BMDDisplayMode wanted_mode_id;
+ memcpy( &wanted_mode_id, &mode_string_padded, sizeof(wanted_mode_id) );
+
+ bool b_found_mode = false;
for (;;)
{
p_display_mode->GetWidth(), p_display_mode->GetHeight(),
double(time_scale) / frame_duration, field_dominance );
msg_Dbg( p_demux, buf );
+
+ if( wanted_mode_id == mode_id )
+ {
+ b_found_mode = true;
+ p_sys->i_width = p_display_mode->GetWidth();
+ p_sys->i_height = p_display_mode->GetHeight();
+ p_sys->i_fps_num = time_scale;
+ p_sys->i_fps_den = frame_duration;
+ }
+ }
+
+ if( !b_found_mode )
+ {
+ msg_Err( p_demux, "Unknown SDI mode specified. " \
+ "Run VLC with -v --verbose-objects=-all,+sdi " \
+ "to get a list of supported modes." );
+ return VLC_EGENERIC;
+ }
+
+ result = p_sys->p_input->EnableVideoInput( htonl( wanted_mode_id ), bmdFormat8BitYUV, 0 );
+ if( result != S_OK )
+ {
+ msg_Err( p_demux, "Failed to enable video input" );
+ return VLC_EGENERIC;
}
result = p_sys->p_input->EnableAudioInput( 48000, bmdAudioSampleType16bitInteger, 2 );
/* Declare elementary streams */
es_format_t video_fmt;
es_format_Init( &video_fmt, VIDEO_ES, VLC_CODEC_UYVY );
- video_fmt.video.i_width = 720;
- video_fmt.video.i_height = 576;
+ video_fmt.video.i_width = p_sys->i_width;
+ video_fmt.video.i_height = p_sys->i_height;
video_fmt.video.i_sar_num = 16 * video_fmt.video.i_height;
video_fmt.video.i_sar_den = 9 * video_fmt.video.i_width;
- video_fmt.video.i_frame_rate = 25;
- video_fmt.video.i_frame_rate_base = 1;
+ video_fmt.video.i_frame_rate = p_sys->i_fps_num;
+ 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;
msg_Dbg( p_demux, "added new video es %4.4s %dx%d",