@ -407,6 +407,16 @@ static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
return ret ;
return ret ;
}
}
static int packet_queue_put_nullpacket ( PacketQueue * q , int stream_index )
{
AVPacket pkt1 , * pkt = & pkt1 ;
av_init_packet ( pkt ) ;
pkt - > data = NULL ;
pkt - > size = 0 ;
pkt - > stream_index = stream_index ;
return packet_queue_put ( q , pkt ) ;
}
/* packet queue handling */
/* packet queue handling */
static void packet_queue_init ( PacketQueue * q )
static void packet_queue_init ( PacketQueue * q )
{
{
@ -2894,6 +2904,7 @@ static int read_thread(void *arg)
if ( ( ret = av_copy_packet ( & copy , & is - > video_st - > attached_pic ) ) < 0 )
if ( ( ret = av_copy_packet ( & copy , & is - > video_st - > attached_pic ) ) < 0 )
goto fail ;
goto fail ;
packet_queue_put ( & is - > videoq , & copy ) ;
packet_queue_put ( & is - > videoq , & copy ) ;
packet_queue_put_nullpacket ( & is - > videoq , is - > video_stream ) ;
}
}
is - > queue_attachments_req = 0 ;
is - > queue_attachments_req = 0 ;
}
}
@ -2922,20 +2933,10 @@ static int read_thread(void *arg)
}
}
}
}
if ( eof ) {
if ( eof ) {
if ( is - > video_stream > = 0 ) {
if ( is - > video_stream > = 0 )
av_init_packet ( pkt ) ;
packet_queue_put_nullpacket ( & is - > videoq , is - > video_stream ) ;
pkt - > data = NULL ;
if ( is - > audio_stream > = 0 )
pkt - > size = 0 ;
packet_queue_put_nullpacket ( & is - > audioq , is - > audio_stream ) ;
pkt - > stream_index = is - > video_stream ;
packet_queue_put ( & is - > videoq , pkt ) ;
}
if ( is - > audio_stream > = 0 ) {
av_init_packet ( pkt ) ;
pkt - > data = NULL ;
pkt - > size = 0 ;
pkt - > stream_index = is - > audio_stream ;
packet_queue_put ( & is - > audioq , pkt ) ;
}
SDL_Delay ( 10 ) ;
SDL_Delay ( 10 ) ;
eof = 0 ;
eof = 0 ;
continue ;
continue ;
@ -3043,6 +3044,8 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
int start_index , stream_index ;
int start_index , stream_index ;
int old_index ;
int old_index ;
AVStream * st ;
AVStream * st ;
AVProgram * p = NULL ;
int nb_streams = is - > ic - > nb_streams ;
if ( codec_type = = AVMEDIA_TYPE_VIDEO ) {
if ( codec_type = = AVMEDIA_TYPE_VIDEO ) {
start_index = is - > last_video_stream ;
start_index = is - > last_video_stream ;
@ -3055,8 +3058,22 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
old_index = is - > subtitle_stream ;
old_index = is - > subtitle_stream ;
}
}
stream_index = start_index ;
stream_index = start_index ;
if ( codec_type ! = AVMEDIA_TYPE_VIDEO & & is - > video_stream ! = - 1 ) {
p = av_find_program_from_stream ( ic , NULL , is - > video_stream ) ;
if ( p ) {
nb_streams = p - > nb_stream_indexes ;
for ( start_index = 0 ; start_index < nb_streams ; start_index + + )
if ( p - > stream_index [ start_index ] = = stream_index )
break ;
if ( start_index = = nb_streams )
start_index = - 1 ;
stream_index = start_index ;
}
}
for ( ; ; ) {
for ( ; ; ) {
if ( + + stream_index > = is - > ic - > nb_streams )
if ( + + stream_index > = nb_streams )
{
{
if ( codec_type = = AVMEDIA_TYPE_SUBTITLE )
if ( codec_type = = AVMEDIA_TYPE_SUBTITLE )
{
{
@ -3070,7 +3087,7 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
}
}
if ( stream_index = = start_index )
if ( stream_index = = start_index )
return ;
return ;
st = ic - > streams [ stream_index ] ;
st = is - > i c - > streams [ p ? p - > stream_index [ stream_index ] : stream_index ] ;
if ( st - > codec - > codec_type = = codec_type ) {
if ( st - > codec - > codec_type = = codec_type ) {
/* check that parameters are OK */
/* check that parameters are OK */
switch ( codec_type ) {
switch ( codec_type ) {
@ -3088,6 +3105,8 @@ static void stream_cycle_channel(VideoState *is, int codec_type)
}
}
}
}
the_end :
the_end :
if ( p & & stream_index ! = - 1 )
stream_index = p - > stream_index [ stream_index ] ;
stream_component_close ( is , old_index ) ;
stream_component_close ( is , old_index ) ;
stream_component_open ( is , stream_index ) ;
stream_component_open ( is , stream_index ) ;
}
}
@ -3175,6 +3194,11 @@ static void event_loop(VideoState *cur_stream)
case SDLK_v :
case SDLK_v :
stream_cycle_channel ( cur_stream , AVMEDIA_TYPE_VIDEO ) ;
stream_cycle_channel ( cur_stream , AVMEDIA_TYPE_VIDEO ) ;
break ;
break ;
case SDLK_c :
stream_cycle_channel ( cur_stream , AVMEDIA_TYPE_VIDEO ) ;
stream_cycle_channel ( cur_stream , AVMEDIA_TYPE_AUDIO ) ;
stream_cycle_channel ( cur_stream , AVMEDIA_TYPE_SUBTITLE ) ;
break ;
case SDLK_t :
case SDLK_t :
stream_cycle_channel ( cur_stream , AVMEDIA_TYPE_SUBTITLE ) ;
stream_cycle_channel ( cur_stream , AVMEDIA_TYPE_SUBTITLE ) ;
break ;
break ;
@ -3479,6 +3503,7 @@ void show_help_default(const char *opt, const char *arg)
" a cycle audio channel \n "
" a cycle audio channel \n "
" v cycle video channel \n "
" v cycle video channel \n "
" t cycle subtitle channel \n "
" t cycle subtitle channel \n "
" c cycle program \n "
" w show audio waves \n "
" w show audio waves \n "
" s activate frame-step mode \n "
" s activate frame-step mode \n "
" left/right seek backward/forward 10 seconds \n "
" left/right seek backward/forward 10 seconds \n "