Commit f516f420 authored by Laurent Aimar's avatar Laurent Aimar

Added a INPUT_GET_VIDEO_FPS (get the fps of the main video, should works with

input slave) Untested.
media_instance.c no longer depends on input_internal.h
Clean up a bit es_out pause handling.
Fixed DEMUX_GET_FPS description (double not float)
parent f105c367
...@@ -104,7 +104,7 @@ enum demux_query_e ...@@ -104,7 +104,7 @@ enum demux_query_e
*/ */
DEMUX_SET_NEXT_DEMUX_TIME, /* arg1= int64_t * can fail */ DEMUX_SET_NEXT_DEMUX_TIME, /* arg1= int64_t * can fail */
/* FPS for correct subtitles handling */ /* FPS for correct subtitles handling */
DEMUX_GET_FPS, /* arg1= float * res=can fail */ DEMUX_GET_FPS, /* arg1= double * res=can fail */
/* Meta data */ /* Meta data */
DEMUX_GET_META, /* arg1= vlc_meta_t ** res=can fail */ DEMUX_GET_META, /* arg1= vlc_meta_t ** res=can fail */
......
...@@ -741,6 +741,7 @@ enum input_query_e ...@@ -741,6 +741,7 @@ enum input_query_e
/* Input properties */ /* Input properties */
INPUT_GET_BYTE_POSITION, /* arg1= int64_t * res= */ INPUT_GET_BYTE_POSITION, /* arg1= int64_t * res= */
INPUT_SET_BYTE_SIZE, /* arg1= int64_t * res= */ INPUT_SET_BYTE_SIZE, /* arg1= int64_t * res= */
INPUT_GET_VIDEO_FPS, /* arg1= double * res=can fail */
/* bookmarks */ /* bookmarks */
INPUT_GET_BOOKMARKS, /* arg1= seekpoint_t *** arg2= int * res=can fail */ INPUT_GET_BOOKMARKS, /* arg1= seekpoint_t *** arg2= int * res=can fail */
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include <vlc/libvlc.h> #include <vlc/libvlc.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_input.h> #include <vlc_input.h>
#include "input/input_internal.h"
#include "libvlc_internal.h" #include "libvlc_internal.h"
#include "libvlc.h"
/* /*
* Release the associated input thread * Release the associated input thread
...@@ -592,25 +592,16 @@ float libvlc_media_instance_get_fps( ...@@ -592,25 +592,16 @@ float libvlc_media_instance_get_fps(
libvlc_media_instance_t *p_mi, libvlc_media_instance_t *p_mi,
libvlc_exception_t *p_e) libvlc_exception_t *p_e)
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
double f_fps = 0.0; double f_fps = 0.0;
input_thread_t *p_input_thread;
p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
if( !p_input_thread )
return 0.0;
if( (NULL == p_input_thread->p->input.p_demux) if( p_input_thread )
|| demux2_Control( p_input_thread->p->input.p_demux, DEMUX_GET_FPS, &f_fps )
|| f_fps < 0.1 )
{
vlc_object_release( p_input_thread );
return 0.0;
}
else
{ {
if( input_Control( p_input_thread, INPUT_GET_VIDEO_FPS, &f_fps ) )
f_fps = 0.0;
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
return( f_fps );
} }
return f_fps;
} }
vlc_bool_t libvlc_media_instance_will_play( vlc_bool_t libvlc_media_instance_will_play(
......
...@@ -540,6 +540,18 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) ...@@ -540,6 +540,18 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
stream_Size( p_input->p->input.p_stream ); stream_Size( p_input->p->input.p_stream );
return VLC_SUCCESS; return VLC_SUCCESS;
case INPUT_GET_VIDEO_FPS:
{
int i;
pf = (double*)va_arg( args, double * );
vlc_mutex_lock( &p_input->p->input.p_item->lock );
*pf = p_input->p->input.f_fps;
for( i = 0; i < p_input->p->i_slave && *pf <= 0.001; i++ )
*pf = p_input->p->slave[i]->f_fps;
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
return VLC_SUCCESS;
}
case INPUT_ADD_SLAVE: case INPUT_ADD_SLAVE:
psz = (char*)va_arg( args, char * ); psz = (char*)va_arg( args, char * );
if( psz && *psz ) if( psz && *psz )
......
...@@ -317,11 +317,13 @@ void input_EsOutDiscontinuity( es_out_t *out, vlc_bool_t b_flush, vlc_bool_t b_a ...@@ -317,11 +317,13 @@ void input_EsOutDiscontinuity( es_out_t *out, vlc_bool_t b_flush, vlc_bool_t b_a
input_DecoderDiscontinuity( es->p_dec, b_flush ); input_DecoderDiscontinuity( es->p_dec, b_flush );
} }
} }
void input_EsOutSetRate( es_out_t *out ) void input_EsOutChangeRate( es_out_t *out )
{ {
es_out_sys_t *p_sys = out->p_sys; es_out_sys_t *p_sys = out->p_sys;
int i; int i;
input_EsOutDiscontinuity( out, VLC_FALSE, VLC_FALSE );
for( i = 0; i < p_sys->i_pgrm; i++ ) for( i = 0; i < p_sys->i_pgrm; i++ )
input_ClockSetRate( p_sys->p_input, &p_sys->pgrm[i]->clock ); input_ClockSetRate( p_sys->p_input, &p_sys->pgrm[i]->clock );
} }
...@@ -335,6 +337,23 @@ void input_EsOutSetDelay( es_out_t *out, int i_cat, int64_t i_delay ) ...@@ -335,6 +337,23 @@ void input_EsOutSetDelay( es_out_t *out, int i_cat, int64_t i_delay )
else if( i_cat == SPU_ES ) else if( i_cat == SPU_ES )
p_sys->i_spu_delay = i_delay; p_sys->i_spu_delay = i_delay;
} }
void input_EsOutChangeState( es_out_t *out )
{
es_out_sys_t *p_sys = out->p_sys;
input_thread_t *p_input = p_sys->p_input;
if( p_input->i_state == PAUSE_S )
{
/* Send discontinuity to decoders (it will allow them to flush
* * if implemented */
input_EsOutDiscontinuity( out, VLC_FALSE, VLC_FALSE );
}
else
{
/* Out of pause, reset pcr */
es_out_Control( out, ES_OUT_RESET_PCR );
}
}
vlc_bool_t input_EsOutDecodersEmpty( es_out_t *out ) vlc_bool_t input_EsOutDecodersEmpty( es_out_t *out )
{ {
......
...@@ -1619,8 +1619,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, ...@@ -1619,8 +1619,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type,
val.i_int = PLAYING_S; val.i_int = PLAYING_S;
var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
/* Reset clock */ /* */
es_out_Control( p_input->p->p_es_out, ES_OUT_RESET_PCR ); if( !i_ret )
input_EsOutChangeState( p_input->p->p_es_out );
} }
else if( val.i_int == PAUSE_S && p_input->i_state == PLAYING_S && else if( val.i_int == PAUSE_S && p_input->i_state == PLAYING_S &&
p_input->p->b_can_pause ) p_input->p->b_can_pause )
...@@ -1649,9 +1650,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, ...@@ -1649,9 +1650,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type,
p_input->i_state = val.i_int; p_input->i_state = val.i_int;
var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
/* Send discontinuity to decoders (it will allow them to flush /* */
* if implemented */ if( !i_ret )
input_EsOutDiscontinuity( p_input->p->p_es_out, VLC_FALSE, VLC_FALSE ); input_EsOutChangeState( p_input->p->p_es_out );
} }
else if( val.i_int == PAUSE_S && !p_input->p->b_can_pause ) else if( val.i_int == PAUSE_S && !p_input->p->b_can_pause )
{ {
...@@ -1702,12 +1703,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, ...@@ -1702,12 +1703,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type,
val.i_int = i_rate; val.i_int = i_rate;
var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
input_EsOutDiscontinuity( p_input->p->p_es_out,
VLC_FALSE, VLC_FALSE );
p_input->p->i_rate = i_rate; p_input->p->i_rate = i_rate;
input_EsOutSetRate( p_input->p->p_es_out ); input_EsOutChangeRate( p_input->p->p_es_out );
b_force_update = VLC_TRUE; b_force_update = VLC_TRUE;
} }
...@@ -2085,6 +2083,7 @@ static input_source_t *InputSourceNew( input_thread_t *p_input ) ...@@ -2085,6 +2083,7 @@ static input_source_t *InputSourceNew( input_thread_t *p_input )
TAB_INIT( in->i_title, in->title ); TAB_INIT( in->i_title, in->title );
in->b_can_pace_control = VLC_TRUE; in->b_can_pace_control = VLC_TRUE;
in->b_eof = VLC_FALSE; in->b_eof = VLC_FALSE;
in->f_fps = 0.0;
in->i_cr_average = 0; in->i_cr_average = 0;
return in; return in;
...@@ -2104,6 +2103,7 @@ static int InputSourceInit( input_thread_t *p_input, ...@@ -2104,6 +2103,7 @@ static int InputSourceInit( input_thread_t *p_input,
char *psz_tmp; char *psz_tmp;
char *psz; char *psz;
vlc_value_t val; vlc_value_t val;
double f_fps;
strcpy( psz_dup, psz_mrl ); strcpy( psz_dup, psz_mrl );
...@@ -2345,27 +2345,34 @@ static int InputSourceInit( input_thread_t *p_input, ...@@ -2345,27 +2345,34 @@ static int InputSourceInit( input_thread_t *p_input,
in->b_title_demux = VLC_TRUE; in->b_title_demux = VLC_TRUE;
} }
} }
/* get attachment }
* FIXME improve for b_preparsing: move it after GET_META and check psz_arturl */
if( 1 || !p_input->b_preparsing ) /* get attachment
* FIXME improve for b_preparsing: move it after GET_META and check psz_arturl */
if( 1 || !p_input->b_preparsing )
{
int i_attachment;
input_attachment_t **attachment;
if( !demux2_Control( in->p_demux, DEMUX_GET_ATTACHMENTS,
&attachment, &i_attachment ) )
{ {
int i_attachment; int i;
input_attachment_t **attachment; vlc_mutex_lock( &p_input->p->input.p_item->lock );
if( !demux2_Control( in->p_demux, DEMUX_GET_ATTACHMENTS, p_input->p->attachment = realloc( p_input->p->attachment,
&attachment, &i_attachment ) ) sizeof(input_attachment_t**) * ( p_input->p->i_attachment + i_attachment ) );
{ for( i = 0; i < i_attachment; i++ )
int i; p_input->p->attachment[p_input->p->i_attachment++] = attachment[i];
vlc_mutex_lock( &p_input->p->input.p_item->lock ); if( attachment )
p_input->p->attachment = realloc( p_input->p->attachment, free( attachment );
sizeof(input_attachment_t**) * ( p_input->p->i_attachment + i_attachment ) ); vlc_mutex_unlock( &p_input->p->input.p_item->lock );
for( i = 0; i < i_attachment; i++ )
p_input->p->attachment[p_input->p->i_attachment++] = attachment[i];
if( attachment )
free( attachment );
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
}
} }
} }
if( !demux2_Control( in->p_demux, DEMUX_GET_FPS, &f_fps ) )
{
vlc_mutex_lock( &p_input->p->input.p_item->lock );
in->f_fps = f_fps;
vlc_mutex_unlock( &p_input->p->input.p_item->lock );
}
if( var_GetInteger( p_input, "clock-synchro" ) != -1 ) if( var_GetInteger( p_input, "clock-synchro" ) != -1 )
in->b_can_pace_control = !var_GetInteger( p_input, "clock-synchro" ); in->b_can_pace_control = !var_GetInteger( p_input, "clock-synchro" );
......
...@@ -59,6 +59,7 @@ typedef struct ...@@ -59,6 +59,7 @@ typedef struct
vlc_bool_t b_can_pace_control; vlc_bool_t b_can_pace_control;
vlc_bool_t b_can_pause; vlc_bool_t b_can_pause;
vlc_bool_t b_eof; /* eof of demuxer */ vlc_bool_t b_eof; /* eof of demuxer */
double f_fps;
/* Clock average variation */ /* Clock average variation */
int i_cr_average; int i_cr_average;
...@@ -265,7 +266,8 @@ void input_EsOutDelete( es_out_t * ); ...@@ -265,7 +266,8 @@ void input_EsOutDelete( es_out_t * );
es_out_id_t *input_EsOutGetFromID( es_out_t *, int i_id ); es_out_id_t *input_EsOutGetFromID( es_out_t *, int i_id );
void input_EsOutDiscontinuity( es_out_t *, vlc_bool_t b_flush, vlc_bool_t b_audio ); void input_EsOutDiscontinuity( es_out_t *, vlc_bool_t b_flush, vlc_bool_t b_audio );
void input_EsOutSetDelay( es_out_t *, int i_cat, int64_t ); void input_EsOutSetDelay( es_out_t *, int i_cat, int64_t );
void input_EsOutSetRate( es_out_t * ); void input_EsOutChangeRate( es_out_t * );
void input_EsOutChangeState( es_out_t * );
vlc_bool_t input_EsOutDecodersEmpty( es_out_t * ); vlc_bool_t input_EsOutDecodersEmpty( es_out_t * );
/* clock.c */ /* clock.c */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment