Commit 3bd43453 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: ogg: eos workaround for seeking (fix #9601)

parent af1a7a95
...@@ -242,10 +242,16 @@ static int Demux( demux_t * p_demux ) ...@@ -242,10 +242,16 @@ static int Demux( demux_t * p_demux )
bool b_skipping = false; bool b_skipping = false;
bool b_canseek; bool b_canseek;
int i_active_streams = p_sys->i_streams;
for ( int i; i < p_sys->i_streams; i++ )
{
if ( p_sys->pp_stream[i]->b_finished )
i_active_streams--;
}
if( p_sys->i_eos == p_sys->i_streams ) if ( i_active_streams == 0 )
{ {
if( p_sys->i_eos ) if ( p_sys->i_streams ) /* All finished */
{ {
msg_Dbg( p_demux, "end of a group of logical streams" ); msg_Dbg( p_demux, "end of a group of logical streams" );
/* We keep the ES to try reusing it in Ogg_BeginningOfStream /* We keep the ES to try reusing it in Ogg_BeginningOfStream
...@@ -258,7 +264,6 @@ static int Demux( demux_t * p_demux ) ...@@ -258,7 +264,6 @@ static int Demux( demux_t * p_demux )
Ogg_EndOfStream( p_demux ); Ogg_EndOfStream( p_demux );
} }
p_sys->i_eos = 0;
if( Ogg_BeginningOfStream( p_demux ) != VLC_SUCCESS ) if( Ogg_BeginningOfStream( p_demux ) != VLC_SUCCESS )
return 0; return 0;
...@@ -314,9 +319,14 @@ static int Demux( demux_t * p_demux ) ...@@ -314,9 +319,14 @@ static int Demux( demux_t * p_demux )
} }
} }
/* FIXME that eos handling is innapropriate with seeking and concatenated streams */ for( i_stream = 0; i_stream < p_sys->i_streams; i_stream++ )
if ( ogg_page_granulepos( &p_sys->current_page ) != 0 ) /* skel workaround */ {
p_sys->i_eos++; if ( p_sys->pp_stream[i_stream]->i_serial_no == ogg_page_serialno( &p_sys->current_page ) )
{
p_sys->pp_stream[i_stream]->b_finished = true;
break;
}
}
} }
} }
...@@ -346,6 +356,7 @@ static int Demux( demux_t * p_demux ) ...@@ -346,6 +356,7 @@ static int Demux( demux_t * p_demux )
es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0); es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0);
} }
/* Does fail if serialno differs */
if( ogg_stream_pagein( &p_stream->os, &p_sys->current_page ) != 0 ) if( ogg_stream_pagein( &p_stream->os, &p_sys->current_page ) != 0 )
{ {
continue; continue;
...@@ -353,6 +364,9 @@ static int Demux( demux_t * p_demux ) ...@@ -353,6 +364,9 @@ static int Demux( demux_t * p_demux )
} }
/* clear the finished flag if pages after eos (ex: after a seek) */
if ( ! ogg_page_eos( &p_sys->current_page ) ) p_stream->b_finished = false;
DemuxDebug( DemuxDebug(
if ( p_stream->fmt.i_cat == VIDEO_ES ) if ( p_stream->fmt.i_cat == VIDEO_ES )
msg_Dbg(p_demux, "DEMUX READ pageno %ld g%"PRId64" (%d packets) cont %d %ld bytes eos %d ", msg_Dbg(p_demux, "DEMUX READ pageno %ld g%"PRId64" (%d packets) cont %d %ld bytes eos %d ",
...@@ -645,9 +659,10 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -645,9 +659,10 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
/* forbid seeking if we haven't initialized all logical bitstreams yet; /* forbid seeking if we haven't initialized all logical bitstreams yet;
if we allowed, some headers would not get backed up and decoder init if we allowed, some headers would not get backed up and decoder init
would fail, making that logical stream unusable */ would fail, making that logical stream unusable */
if( p_sys->i_bos > 0 ) for ( int i=0; i< p_sys->i_streams; i++ )
{ {
return VLC_EGENERIC; if ( p_sys->pp_stream[i]->b_initializing )
return VLC_EGENERIC;
} }
p_stream = Ogg_GetSelectedStream( p_demux ); p_stream = Ogg_GetSelectedStream( p_demux );
...@@ -718,9 +733,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -718,9 +733,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
case DEMUX_SET_SEEKPOINT: case DEMUX_SET_SEEKPOINT:
{ {
const int i_seekpoint = (int)va_arg( args, int ); const int i_seekpoint = (int)va_arg( args, int );
if( i_seekpoint > p_sys->i_seekpoints || p_sys->i_bos > 0 ) if( i_seekpoint > p_sys->i_seekpoints )
return VLC_EGENERIC; return VLC_EGENERIC;
for ( int i=0; i< p_sys->i_streams; i++ )
{
if ( p_sys->pp_stream[i]->b_initializing )
return VLC_EGENERIC;
}
i64 = p_sys->pp_seekpoints[i_seekpoint]->i_time_offset; i64 = p_sys->pp_seekpoints[i_seekpoint]->i_time_offset;
p_stream = Ogg_GetSelectedStream( p_demux ); p_stream = Ogg_GetSelectedStream( p_demux );
...@@ -1023,7 +1044,7 @@ static void Ogg_DecodePacket( demux_t *p_demux, ...@@ -1023,7 +1044,7 @@ static void Ogg_DecodePacket( demux_t *p_demux,
p_stream->p_headers, p_stream->i_headers ); p_stream->p_headers, p_stream->i_headers );
/* we're not at BOS anymore for this logical stream */ /* we're not at BOS anymore for this logical stream */
p_ogg->i_bos--; p_stream->b_initializing = false;
} }
} }
...@@ -1734,20 +1755,13 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux ) ...@@ -1734,20 +1755,13 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
p_ogg->i_streams--; p_ogg->i_streams--;
} }
/* we'll need to get all headers */
p_ogg->pp_stream[i_stream]->b_initializing |= p_ogg->pp_stream[i_stream]->b_force_backup;
if( Ogg_ReadPage( p_demux, &p_ogg->current_page ) != VLC_SUCCESS ) if( Ogg_ReadPage( p_demux, &p_ogg->current_page ) != VLC_SUCCESS )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* we'll need to get all headers for all of those streams
that we have to backup headers for */
p_ogg->i_bos = 0;
for( i_stream = 0; i_stream < p_ogg->i_streams; i_stream++ )
{
if( p_ogg->pp_stream[i_stream]->b_force_backup )
p_ogg->i_bos++;
}
/* This is the first data page, which means we are now finished /* This is the first data page, which means we are now finished
* with the initial pages. We just need to store it in the relevant * with the initial pages. We just need to store it in the relevant
* bitstream. */ * bitstream. */
......
...@@ -72,6 +72,8 @@ typedef struct logical_stream_s ...@@ -72,6 +72,8 @@ typedef struct logical_stream_s
mtime_t i_previous_pcr; mtime_t i_previous_pcr;
/* Misc */ /* Misc */
bool b_initializing;
bool b_finished;
bool b_reinit; bool b_reinit;
bool b_oggds; bool b_oggds;
int i_granule_shift; int i_granule_shift;
...@@ -130,10 +132,6 @@ struct demux_sys_t ...@@ -130,10 +132,6 @@ struct demux_sys_t
* the sub-streams */ * the sub-streams */
mtime_t i_pcr; mtime_t i_pcr;
/* stream state */
int i_bos; /* Begnning of stream, tell the demux to look for elementary streams. */
int i_eos;
/* bitrate */ /* bitrate */
int i_bitrate; int i_bitrate;
bool b_partial_bitrate; bool b_partial_bitrate;
......
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