Commit e2399254 authored by Ilkka Ollakka's avatar Ilkka Ollakka

livehttp: try to take account discontiunity timestamps

(cherry picked from commit f2a7d85dbd41e357e981dbac5290b6788d730e9b)
Signed-off-by: default avatarIlkka Ollakka <ileoo@videolan.org>
parent c006c5fc
......@@ -182,6 +182,7 @@ struct sout_access_out_sys_t
char *psz_keyfile;
mtime_t i_keyfile_modification;
mtime_t i_opendts;
mtime_t i_dts_offset;
mtime_t i_seglenm;
uint32_t i_segment;
size_t i_seglen;
......@@ -245,6 +246,7 @@ static int Open( vlc_object_t *p_this )
p_sys->stuffing_size = 0;
p_sys->i_opendts = VLC_TS_INVALID;
p_sys->i_dts_offset = 0;
p_sys->psz_indexPath = NULL;
psz_idx = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "index" );
......@@ -762,10 +764,11 @@ static void Close( vlc_object_t * p_this )
/* Since we are flushing, check the segment change by hand and don't wait
* possible keyframe*/
if( ((float) output_block->i_length +
(float) (output_block->i_dts - p_sys->i_opendts)) >= p_sys->i_seglenm )
if( (float)(output_block->i_length + p_sys->i_dts_offset +
output_block->i_dts - p_sys->i_opendts) >= p_sys->i_seglenm )
{
closeCurrentSegment( p_access, p_sys, false );
p_sys->i_dts_offset = 0;
if( unlikely(openNextFile( p_access, p_sys ) < 0 ) )
{
block_ChainRelease( output_block );
......@@ -903,16 +906,29 @@ static int CheckSegmentChange( sout_access_out_t *p_access, block_t *p_buffer )
sout_access_out_sys_t *p_sys = p_access->p_sys;
block_t *output = p_sys->block_buffer;
/* let's check if we need to store offset to keep
* better count of actual duration */
if( unlikely( p_buffer->i_dts < p_sys->i_opendts ) )
{
block_t *last_buffer = p_sys->block_buffer;
while( last_buffer->p_next )
last_buffer = last_buffer->p_next;
p_sys->i_dts_offset += last_buffer->i_dts - p_sys->i_opendts;
p_sys->i_opendts = p_buffer->i_dts;
msg_Dbg( p_access, "dts offset %"PRId64, p_sys->i_dts_offset );
}
if( p_sys->i_handle > 0 &&
(( p_buffer->i_dts - p_sys->i_opendts +
p_buffer->i_length
p_buffer->i_length + p_sys->i_dts_offset
) >= p_sys->i_seglenm ) )
{
{
closeCurrentSegment( p_access, p_sys, false );
}
}
if ( p_sys->i_handle < 0 )
{
p_sys->i_dts_offset = 0;
p_sys->i_opendts = output ? output->i_dts : p_buffer->i_dts;
//For first segment we can get negative duration otherwise...?
if( ( p_sys->i_opendts != VLC_TS_INVALID ) &&
......
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