[vlc-commits] sout: record: keep interleaving when unbuffering

Francois Cartegnie git at videolan.org
Sat Apr 2 22:32:19 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Apr  2 16:14:55 2016 +0200| [4ed8dd94d0b717a29c9d5b244058fb3c905c467b] | committer: Francois Cartegnie

sout: record: keep interleaving when unbuffering

record module outputs buffered data stream by stream
which breaks most muxers (as long as we have no sout pcr)

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

 modules/stream_out/record.c |   40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/modules/stream_out/record.c b/modules/stream_out/record.c
index 8931111..46b5f80 100644
--- a/modules/stream_out/record.c
+++ b/modules/stream_out/record.c
@@ -525,29 +525,39 @@ static void OutputStart( sout_stream_t *p_stream )
             p_sys->i_dts_start = i_dts;
     }
 
-    /* Send buffered data */
-    for( int i = 0; i < p_sys->i_id; i++ )
+    sout_stream_id_sys_t *p_cand;
+    do
     {
-        sout_stream_id_sys_t *id = p_sys->id[i];
-
-        if( !id->id )
-            continue;
+        /* dequeue candidate */
+        p_cand = NULL;
 
-        block_t *p_block = id->p_first;
-        while( p_block )
+        /* Send buffered data in dts order */
+        for( int i = 0; i < p_sys->i_id; i++ )
         {
-            block_t *p_next = p_block->p_next;
+            sout_stream_id_sys_t *id = p_sys->id[i];
 
-            p_block->p_next = NULL;
+            if( !id->id || id->p_first == NULL )
+                continue;
 
-            OutputSend( p_stream, id, p_block );
+            if( p_cand == NULL || id->p_first->i_dts < p_cand->p_first->i_dts )
+                p_cand = id;
+        }
 
-            p_block = p_next;
+        if( p_cand != NULL )
+        {
+            block_t *p_block = p_cand->p_first;
+            p_cand->p_first = p_block->p_next;
+            if( p_cand->p_first == NULL )
+                p_cand->pp_last = &p_cand->p_first;
+            p_block->p_next = NULL;
+
+            if( p_block->i_dts >= p_sys->i_dts_start )
+                OutputSend( p_stream, p_cand, p_block );
+            else
+                block_Release( p_block );
         }
 
-        id->p_first = NULL;
-        id->pp_last = &id->p_first;
-    }
+    } while( p_cand != NULL );
 }
 
 static void OutputSend( sout_stream_t *p_stream, sout_stream_id_sys_t *id, block_t *p_block )



More information about the vlc-commits mailing list