"composite, svideo. " \
"Leave blank for card default." )
+static const char *const ppsz_videoconns[] = {
+ "sdi", "hdmi", "opticalsdi", "component", "composite", "svideo"
+};
+static const char *const ppsz_videoconns_text[] = {
+ N_("SDI"), N_("HDMI"), N_("Optical SDI"), N_("Component"), N_("Composite"), N_("S-video")
+};
+
#define ASPECT_RATIO_TEXT N_("Aspect ratio")
#define ASPECT_RATIO_LONGTEXT N_( \
"Aspect ratio (4:3, 16:9). Default assumes square pixels." )
CHANNELS_TEXT, CHANNELS_LONGTEXT, true )
add_string( "decklink-video-connection", 0, NULL,
VIDEO_CONNECTION_TEXT, VIDEO_CONNECTION_LONGTEXT, true )
+ change_string_list( ppsz_videoconns, ppsz_videoconns_text, 0 )
add_string( "decklink-aspect-ratio", NULL, NULL,
ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, true )
set_callbacks( Open, Close )
vlc_module_end ()
-static int Demux ( demux_t * );
static int Control( demux_t *, int, va_list );
class DeckLinkCaptureDelegate;
es_out_id_t *p_video_es;
es_out_id_t *p_audio_es;
- bool b_first_frame;
- int i_last_pts;
+
+ vlc_mutex_t pts_lock;
+ int i_last_pts; /* protected by <pts_lock> */
uint32_t i_dominance_flags;
int i_channels;
-
- vlc_mutex_t frame_lock;
- block_t *p_video_frame; /* protected by <frame_lock> */
- block_t *p_audio_frame; /* protected by <frame_lock> */
- vlc_cond_t has_frame; /* related to <frame_lock> */
};
class DeckLinkCaptureDelegate : public IDeckLinkInputCallback
videoFrame->GetStreamTime( &stream_time, &frame_duration, CLOCK_FREQ );
p_video_frame->i_flags = BLOCK_FLAG_TYPE_I | p_sys->i_dominance_flags;
p_video_frame->i_pts = p_video_frame->i_dts = VLC_TS_0 + stream_time;
+
+ vlc_mutex_lock( &p_sys->pts_lock );
+ if( p_video_frame->i_pts > p_sys->i_last_pts )
+ p_sys->i_last_pts = p_video_frame->i_pts;
+ vlc_mutex_unlock( &p_sys->pts_lock );
+
+ es_out_Control( p_demux_->out, ES_OUT_SET_PCR, p_video_frame->i_pts );
+ es_out_Send( p_demux_->out, p_sys->p_video_es, p_video_frame );
}
if( audioFrame )
BMDTimeValue packet_time;
audioFrame->GetPacketTime( &packet_time, CLOCK_FREQ );
p_audio_frame->i_pts = p_audio_frame->i_dts = VLC_TS_0 + packet_time;
- }
-
- if( p_video_frame || p_audio_frame )
- {
- vlc_mutex_lock( &p_sys->frame_lock );
- if( p_video_frame )
- {
- if( p_sys->p_video_frame )
- block_Release( p_sys->p_video_frame );
- p_sys->p_video_frame = p_video_frame;
- }
- if( p_audio_frame )
- {
- if( p_sys->p_audio_frame )
- block_Release( p_sys->p_audio_frame );
- p_sys->p_audio_frame = p_audio_frame;
- }
- vlc_cond_signal( &p_sys->has_frame );
- vlc_mutex_unlock( &p_sys->frame_lock );
+
+ vlc_mutex_lock( &p_sys->pts_lock );
+ if( p_audio_frame->i_pts > p_sys->i_last_pts )
+ p_sys->i_last_pts = p_audio_frame->i_pts;
+ vlc_mutex_unlock( &p_sys->pts_lock );
+ if( p_audio_frame->i_pts > p_sys->i_last_pts )
+
+ es_out_Control( p_demux_->out, ES_OUT_SET_PCR, p_audio_frame->i_pts );
+ es_out_Send( p_demux_->out, p_sys->p_audio_es, p_audio_frame );
}
return S_OK;
int i_card_index;
int i_width, i_height, i_fps_num, i_fps_den;
int i_rate;
+ unsigned u_aspect_num, u_aspect_den;
/* Only when selected */
if( *p_demux->psz_access == '\0' )
return VLC_EGENERIC;
/* Set up p_demux */
- p_demux->pf_demux = Demux;
+ p_demux->pf_demux = NULL;
p_demux->pf_control = Control;
p_demux->info.i_update = 0;
p_demux->info.i_title = 0;
if( !p_sys )
return VLC_ENOMEM;
- vlc_mutex_init( &p_sys->frame_lock );
- vlc_cond_init( &p_sys->has_frame );
- p_sys->b_first_frame = true;
+ vlc_mutex_init( &p_sys->pts_lock );
IDeckLinkIterator *decklink_iterator = CreateDeckLinkIteratorInstance();
if( !decklink_iterator )
HRESULT result;
i_card_index = var_InheritInteger( p_demux, "decklink-card-index" );
+ if( i_card_index < 0 )
+ {
+ msg_Err( p_demux, "Invalid card index %d", i_card_index );
+ goto finish;
+ }
+
for( int i = 0; i <= i_card_index; ++i )
{
if( p_sys->p_card )
goto finish;
}
- psz_video_connection = var_CreateGetNonEmptyString( p_demux, "decklink-video-connection" );
+ psz_video_connection = var_InheritString( p_demux, "decklink-video-connection" );
if( psz_video_connection )
{
BMDVideoConnection conn;
goto finish;
}
- psz_display_mode = var_InheritString( p_demux, "decklink-mode" );
- if( !psz_display_mode || strlen( psz_display_mode ) == 0 || strlen( psz_display_mode ) > 4 ) {
+ psz_display_mode = var_CreateGetNonEmptyString( p_demux, "decklink-mode" );
+ if( !psz_display_mode || strlen( psz_display_mode ) > 4 ) {
msg_Err( p_demux, "Missing or invalid --decklink-mode string" );
goto finish;
}
video_fmt.video.i_frame_rate_base = i_fps_den;
video_fmt.i_bitrate = video_fmt.video.i_width * video_fmt.video.i_height * video_fmt.video.i_frame_rate * 2 * 8;
- psz_aspect = var_CreateGetNonEmptyString( p_demux, "decklink-aspect-ratio" );
- if( psz_aspect )
- {
- char *psz_denominator = strchr( psz_aspect, ':' );
- if( psz_denominator )
- {
- *psz_denominator++ = '\0';
- video_fmt.video.i_sar_num = atoi( psz_aspect ) * video_fmt.video.i_height;
- video_fmt.video.i_sar_den = atoi( psz_denominator ) * video_fmt.video.i_width;
- }
- free( psz_aspect );
+ if ( !var_InheritURational( p_demux, &u_aspect_num, &u_aspect_den, "decklink-aspect-ratio" ) &&
+ u_aspect_num > 0 && u_aspect_den > 0 ) {
+ video_fmt.video.i_sar_num = u_aspect_num * video_fmt.video.i_height;
+ video_fmt.video.i_sar_den = u_aspect_den * video_fmt.video.i_width;
}
msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
(char*)&audio_fmt.i_codec, audio_fmt.audio.i_rate, audio_fmt.audio.i_bitspersample, audio_fmt.audio.i_channels);
p_sys->p_audio_es = es_out_Add( p_demux->out, &audio_fmt );
- /* Update default_pts to a suitable value for access */
- var_Create( p_demux, "decklink-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-
ret = VLC_SUCCESS;
finish:
if( p_sys->p_delegate )
p_sys->p_delegate->Release();
- if( p_sys->p_video_frame )
- block_Release( p_sys->p_video_frame );
-
- if( p_sys->p_audio_frame )
- block_Release( p_sys->p_audio_frame );
-
free( p_sys );
}
case DEMUX_GET_PTS_DELAY:
pi64 = (int64_t*)va_arg( args, int64_t * );
- *pi64 = var_GetInteger( p_demux, "decklink-caching" ) * 1000;
+ *pi64 = var_InheritInteger( p_demux, "decklink-caching" ) * 1000;
return VLC_SUCCESS;
case DEMUX_GET_TIME:
pi64 = (int64_t*)va_arg( args, int64_t * );
+ vlc_mutex_lock( &p_sys->pts_lock );
*pi64 = p_sys->i_last_pts;
+ vlc_mutex_unlock( &p_sys->pts_lock );
return VLC_SUCCESS;
- /* TODO implement others */
default:
return VLC_EGENERIC;
}
return VLC_EGENERIC;
}
-
-static int Demux( demux_t *p_demux )
-{
- demux_sys_t *p_sys = p_demux->p_sys;
- block_t *p_video_block = NULL;
- block_t *p_audio_block = NULL;
-
- vlc_mutex_lock( &p_sys->frame_lock );
-
- while( !p_sys->p_video_frame && !p_sys->p_audio_frame )
- vlc_cond_wait( &p_sys->has_frame, &p_sys->frame_lock );
-
- p_video_block = p_sys->p_video_frame;
- p_sys->p_video_frame = NULL;
-
- p_audio_block = p_sys->p_audio_frame;
- p_sys->p_audio_frame = NULL;
-
- vlc_mutex_unlock( &p_sys->frame_lock );
-
- if( p_video_block )
- {
- if( p_video_block->i_pts > p_sys->i_last_pts )
- p_sys->i_last_pts = p_video_block->i_pts;
- es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_video_block->i_pts );
- es_out_Send( p_demux->out, p_sys->p_video_es, p_video_block );
- }
-
- if( p_audio_block )
- {
- if( p_audio_block->i_pts > p_sys->i_last_pts )
- p_sys->i_last_pts = p_audio_block->i_pts;
- es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_audio_block->i_pts );
- es_out_Send( p_demux->out, p_sys->p_audio_es, p_audio_block );
- }
-
- return 1;
-}
-