📄 input.c
字号:
input_ControlVarNavigation( p_input ); input_ControlVarTitle( p_input, 0 ); } /* Global flag */ p_input->b_can_pace_control = p_input->input.b_can_pace_control; p_input->b_can_pause = p_input->input.b_can_pause; /* Fix pts delay */ if( p_input->i_pts_delay < 0 ) p_input->i_pts_delay = 0; /* If the desynchronisation requested by the user is < 0, we need to * cache more data. */ var_Get( p_input, "audio-desync", &val ); if( val.i_int < 0 ) p_input->i_pts_delay -= (val.i_int * 1000); /* Update cr_average depending on the caching */ p_input->input.i_cr_average *= (10 * p_input->i_pts_delay / 200000); p_input->input.i_cr_average /= 10; if( p_input->input.i_cr_average < 10 ) p_input->input.i_cr_average = 10; } /* Load master infos */ /* Init length */ if( !demux2_Control( p_input->input.p_demux, DEMUX_GET_LENGTH, &val.i_time ) && val.i_time > 0 ) { var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL ); UpdateItemLength( p_input, val.i_time, b_quick ); p_input->input.p_item->i_duration = val.i_time; } /* Start title/chapter */ if( !b_quick ) { val.i_int = p_input->input.i_title_start - p_input->input.i_title_offset; if( val.i_int > 0 && val.i_int < p_input->input.i_title ) input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &val ); val.i_int = p_input->input.i_seekpoint_start - p_input->input.i_seekpoint_offset; if( val.i_int > 0 /* TODO: check upper boundary */ ) input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &val ); /* Start time*/ /* Set start time */ p_input->i_start = (int64_t)var_GetInteger( p_input, "start-time" ) * I64C(1000000); p_input->i_stop = (int64_t)var_GetInteger( p_input, "stop-time" ) * I64C(1000000); if( p_input->i_start > 0 ) { if( p_input->i_start >= val.i_time ) { msg_Warn( p_input, "invalid start-time ignored" ); } else { vlc_value_t s; msg_Dbg( p_input, "starting at time: %ds", (int)( p_input->i_start / I64C(1000000) ) ); s.i_time = p_input->i_start; input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &s ); } } if( p_input->i_stop > 0 && p_input->i_stop <= p_input->i_start ) { msg_Warn( p_input, "invalid stop-time ignored" ); p_input->i_stop = 0; } /* Load subtitles */ /* Get fps and set it if not already set */ if( !demux2_Control( p_input->input.p_demux, DEMUX_GET_FPS, &f_fps ) && f_fps > 1.0 ) { float f_requested_fps; var_Create( p_input, "sub-original-fps", VLC_VAR_FLOAT ); var_SetFloat( p_input, "sub-original-fps", f_fps ); f_requested_fps = var_CreateGetFloat( p_input, "sub-fps" ); if( f_requested_fps != f_fps ) { var_Create( p_input, "sub-fps", VLC_VAR_FLOAT| VLC_VAR_DOINHERIT ); var_SetFloat( p_input, "sub-fps", f_requested_fps ); } } i_delay = var_CreateGetInteger( p_input, "sub-delay" ); if( i_delay != 0 ) { var_SetTime( p_input, "spu-delay", (mtime_t)i_delay * 100000 ); } /* Look for and add subtitle files */ psz_subtitle = var_GetString( p_input, "sub-file" ); if( *psz_subtitle ) { msg_Dbg( p_input, "forced subtitle: %s", psz_subtitle ); input_AddSubtitles( p_input, psz_subtitle, VLC_FALSE ); } var_Get( p_input, "sub-autodetect-file", &val ); if( val.b_bool ) { char *psz_autopath = var_GetString( p_input, "sub-autodetect-path" ); char **subs = subtitles_Detect( p_input, psz_autopath, p_input->input.p_item->psz_uri ); input_source_t *sub; i = 0; /* Try to autoselect the first autodetected subtitles file * if no subtitles file was specified */ if( *psz_subtitle == 0 && subs && subs[0] ) { input_AddSubtitles( p_input, subs[0], VLC_FALSE ); free( subs[0] ); i = 1; } /* Then, just add the following subtitles files */ for( ; subs && subs[i]; i++ ) { if( strcmp( psz_subtitle, subs[i] ) ) { sub = InputSourceNew( p_input ); if( !InputSourceInit( p_input, sub, subs[i], "subtitle", VLC_FALSE ) ) { TAB_APPEND( p_input->i_slave, p_input->slave, sub ); } else free( sub ); } free( subs[i] ); } if( subs ) free( subs ); if( psz_autopath ) free( psz_autopath ); } free( psz_subtitle ); /* Look for slave */ psz = var_GetString( p_input, "input-slave" ); if( *psz ) { char *psz_delim; input_source_t *slave; while( psz && *psz ) { while( *psz == ' ' || *psz == '#' ) { psz++; } if( ( psz_delim = strchr( psz, '#' ) ) ) { *psz_delim++ = '\0'; } if( *psz == 0 ) { break; } msg_Dbg( p_input, "adding slave input '%s'", psz ); slave = InputSourceNew( p_input ); if( !InputSourceInit( p_input, slave, psz, NULL, VLC_FALSE ) ) { TAB_APPEND( p_input->i_slave, p_input->slave, slave ); } else free( slave ); psz = psz_delim; } } if( psz ) free( psz ); } else { p_input->i_start = 0; p_input->i_start = 0; } /* Set up es_out */ if( !b_quick ) { es_out_Control( p_input->p_es_out, ES_OUT_SET_ACTIVE, VLC_TRUE ); i_es_out_mode = ES_OUT_MODE_AUTO; val.p_list = NULL; if( p_input->p_sout ) { var_Get( p_input, "sout-all", &val ); if ( val.b_bool ) { i_es_out_mode = ES_OUT_MODE_ALL; val.p_list = NULL; } else { var_Get( p_input, "programs", &val ); if ( val.p_list && val.p_list->i_count ) { i_es_out_mode = ES_OUT_MODE_PARTIAL; /* Note : we should remove the "program" callback. */ } else var_Change( p_input, "programs", VLC_VAR_FREELIST, &val, NULL ); } } es_out_Control( p_input->p_es_out, ES_OUT_SET_MODE, i_es_out_mode ); /* Inform the demuxer about waited group (needed only for DVB) */ if( i_es_out_mode == ES_OUT_MODE_ALL ) { demux2_Control( p_input->input.p_demux, DEMUX_SET_GROUP, -1, NULL ); } else if( i_es_out_mode == ES_OUT_MODE_PARTIAL ) { demux2_Control( p_input->input.p_demux, DEMUX_SET_GROUP, -1, val.p_list ); } else { demux2_Control( p_input->input.p_demux, DEMUX_SET_GROUP, (int) var_GetInteger( p_input, "program" ), NULL ); } if( p_input->p_sout ) { if( p_input->p_sout->i_out_pace_nocontrol > 0 ) { p_input->b_out_pace_control = VLC_FALSE; } else { p_input->b_out_pace_control = VLC_TRUE; } if( p_input->b_can_pace_control && p_input->b_out_pace_control ) { /* We don't want a high input priority here or we'll * end-up sucking up all the CPU time */ vlc_thread_set_priority( p_input, VLC_THREAD_PRIORITY_LOW ); } msg_Dbg( p_input, "starting in %s mode", p_input->b_out_pace_control ? "async" : "sync" ); } } /* Get meta data from users */ p_meta_tmp = InputMetaUser( p_input ); /* Get meta data from master input */ if( demux2_Control( p_input->input.p_demux, DEMUX_GET_META, &p_meta ) ) p_meta = NULL; /* Merge them */ if( p_meta == NULL ) { p_meta = p_meta_tmp; } else if( p_meta_tmp ) { vlc_meta_Merge( p_meta, p_meta_tmp ); vlc_meta_Delete( p_meta_tmp ); } /* Access_file does not give any meta, and there are no slave */ if( !b_quick ) { if( !p_input->input.p_access || access2_Control( p_input->input.p_access, ACCESS_GET_META, &p_meta_tmp)) p_meta_tmp = NULL; if( p_meta == NULL ) { p_meta = p_meta_tmp; } else if( p_meta_tmp ) { vlc_meta_Merge( p_meta, p_meta_tmp ); vlc_meta_Delete( p_meta_tmp ); } /* Get meta data from slave input */ for( i = 0; i < p_input->i_slave; i++ ) { vlc_meta_t *p_meta_slave; if( !demux2_Control( p_input->slave[i]->p_demux, DEMUX_GET_META, &p_meta_slave ) ) { if( p_meta == NULL ) { p_meta = p_meta_slave; } else if( p_meta_slave ) { vlc_meta_Merge( p_meta, p_meta_slave ); vlc_meta_Delete( p_meta_slave ); } } if( p_input->slave[i]->p_access && !access2_Control( p_input->slave[i]->p_access, ACCESS_GET_META, &p_meta_slave ) ) { if( p_meta == NULL ) { p_meta = p_meta_slave; } else if( p_meta_slave ) { vlc_meta_Merge( p_meta, p_meta_slave ); vlc_meta_Delete( p_meta_slave ); } } } } p_input->p_meta = p_meta; UpdateMeta( p_input, b_quick ); if( !b_quick ) { msg_Dbg( p_input, "`%s' successfully opened", p_input->input.p_item->psz_uri ); } /* initialization is complete */ input_ChangeState( p_input, PLAYING_S ); return VLC_SUCCESS;error: input_ChangeState( p_input, ERROR_S ); if( p_input->p_es_out ) input_EsOutDelete( p_input->p_es_out ); if( p_input->p_sout ) sout_DeleteInstance( p_input->p_sout ); /* Mark them deleted */ p_input->input.p_demux = NULL; p_input->input.p_stream = NULL; p_input->input.p_access = NULL; p_input->p_es_out = NULL; p_input->p_sout = NULL; return VLC_EGENERIC;}/***************************************************************************** * Error: RunThread() error loop ***************************************************************************** * This function is called when an error occurred during thread main's loop. *****************************************************************************/static void Error( input_thread_t *p_input ){ while( !p_input->b_die ) { /* Sleep a while */ input_ChangeState( p_input, ERROR_S ); msleep( INPUT_IDLE_SLEEP ); }}/***************************************************************************** * End: end the input thread *****************************************************************************/static void End( input_thread_t * p_input ){ int i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -