[vlc-commits] livehttp: try to take account discontiunity timestamps

Ilkka Ollakka git at videolan.org
Tue Jul 15 15:09:30 CEST 2014


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Mon Jul  7 10:53:14 2014 +0300| [f2a7d85dbd41e357e981dbac5290b6788d730e9b] | committer: Ilkka Ollakka

livehttp: try to take account discontiunity timestamps

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f2a7d85dbd41e357e981dbac5290b6788d730e9b
---

 modules/access_output/livehttp.c |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/modules/access_output/livehttp.c b/modules/access_output/livehttp.c
index a6f4c9b..25039f8 100644
--- a/modules/access_output/livehttp.c
+++ b/modules/access_output/livehttp.c
@@ -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 ) &&



More information about the vlc-commits mailing list