|
|
|
@ -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" ); |
|
|
|
@ -761,10 +763,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 ); |
|
|
|
@ -902,16 +905,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 ) && |
|
|
|
|