]> git.sesse.net Git - vlc/commitdiff
* modules/access_output/udp.c: more debug
authorChristophe Massiot <massiot@videolan.org>
Mon, 17 Nov 2003 14:46:37 +0000 (14:46 +0000)
committerChristophe Massiot <massiot@videolan.org>
Mon, 17 Nov 2003 14:46:37 +0000 (14:46 +0000)
* modules/mux/mpeg/ts.c: new dts-delay option to add delay between the
  PCR and the DTS of the current frame.
  When deleting a video or audio stream (in case of PMT change), the
  new video and audio ES will take again the pid-video and pid-audio if
  they have been specified.

modules/access_output/udp.c
modules/mux/mpeg/ts.c

index ddc705d573388234611b213da55fa7e495f96928..25f248adc817c46549617cc4aea5966845106752 100644 (file)
@@ -2,7 +2,7 @@
  * udp.c
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: udp.c,v 1.15 2003/11/07 19:30:28 massiot Exp $
+ * $Id: udp.c,v 1.16 2003/11/17 14:46:37 massiot Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Eric Petit <titer@videolan.org>
@@ -292,7 +292,7 @@ static void Close( vlc_object_t * p_this )
 }
 
 /*****************************************************************************
- * Read: standard read on a file descriptor.
+ * Write: standard write on a file descriptor.
  *****************************************************************************/
 static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )
 {
@@ -413,7 +413,7 @@ static void ThreadWrite( vlc_object_t *p_this )
     while( ! p_thread->b_die )
     {
         sout_buffer_t *p_pk;
-        mtime_t       i_date;
+        mtime_t       i_date, i_sent;
 
         p_pk = sout_FifoGet( p_thread->p_fifo );
 
@@ -428,7 +428,7 @@ static void ThreadWrite( vlc_object_t *p_this )
                 i_date_last = i_date;
                 continue;
             }
-            else if( i_date - i_date_last < -100000 )
+            else if( i_date - i_date_last < 0 )
             {
                 msg_Dbg( p_thread, "mmh, paquets in the past -> drop" );
 
@@ -438,9 +438,14 @@ static void ThreadWrite( vlc_object_t *p_this )
             }
         }
 
-
         mwait( i_date );
         send( p_thread->i_handle, p_pk->p_buffer, p_pk->i_size, 0 );
+        i_sent = mdate();
+        if ( i_sent > i_date + 20000 )
+        {
+            msg_Dbg( p_thread, "packet has been sent too late (" I64Fd ")",
+                     i_sent - i_date );
+        }
         sout_BufferDelete( p_sout, p_pk );
         i_date_last = i_date;
     }
index 5f4581ea93465d57a69dfb94b806413f37c89d30..04eb902c92d5998ae570865587223d78c5bd6091 100644 (file)
@@ -2,7 +2,7 @@
  * ts.c: MPEG-II TS Muxer
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: ts.c,v 1.34 2003/11/17 11:25:54 fenrir Exp $
+ * $Id: ts.c,v 1.35 2003/11/17 14:46:37 massiot Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Eric Petit <titer@videolan.org>
@@ -212,6 +212,8 @@ struct sout_mux_sys_t
     int64_t             i_caching_delay;
     int64_t             i_pcr_delay;
 
+    int64_t             i_dts_delay;
+
     mtime_t             i_pcr;  /* last PCR emited */
 };
 
@@ -362,6 +364,12 @@ static int Open( vlc_object_t *p_this )
     msg_Dbg( p_mux, "caching="I64Fd" pcr="I64Fd,
              p_sys->i_caching_delay, p_sys->i_pcr_delay );
 
+    p_sys->i_dts_delay = 200000;
+    if( ( val = sout_cfg_find_value( p_mux->p_cfg, "dts-delay" ) ) )
+    {
+        p_sys->i_dts_delay = (int64_t)atoi( val ) * 1000;
+    }
+
     /* for TS generation */
     p_sys->i_pcr    = 0;
     return VLC_SUCCESS;
@@ -540,6 +548,7 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
 {
     sout_mux_sys_t  *p_sys = p_mux->p_sys;
     ts_stream_t     *p_stream;
+    char            *val;
 
     msg_Dbg( p_mux, "removing input" );
     p_stream = (ts_stream_t*)p_input->p_sys;
@@ -591,6 +600,22 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
     {
         p_sys->i_mpeg4_streams--;
     }
+    if( ( val = sout_cfg_find_value( p_mux->p_cfg, "pid-video" ) ) )
+    {
+        int i_pid_video = strtol( val, NULL, 0 );
+        if ( i_pid_video == p_stream->i_pid )
+        {
+            p_sys->i_pid_video = i_pid_video;
+        }
+    }
+    if( ( val = sout_cfg_find_value( p_mux->p_cfg, "pid-audio" ) ) )
+    {
+        int i_pid_audio = strtol( val, NULL, 0 );
+        if ( i_pid_audio == p_stream->i_pid )
+        {
+            p_sys->i_pid_audio = i_pid_audio;
+        }
+    }
     free( p_stream );
 
     /* We only change PMT version (PAT isn't changed) */
@@ -807,7 +832,7 @@ static int Mux( sout_mux_t *p_mux )
             if( p_ts->i_flags&SOUT_BUFFER_FLAGS_PRIVATE_PCR )
             {
                 /* msg_Dbg( p_mux, "pcr=%lld ms", p_ts->i_dts / 1000 ); */
-                TSSetPCR( p_ts, p_ts->i_dts );
+                TSSetPCR( p_ts, p_ts->i_dts - p_sys->i_dts_delay );
             }
 
             /* latency */
@@ -927,7 +952,7 @@ static sout_buffer_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream, vlc_bool_
 
 static void TSSetPCR( sout_buffer_t *p_ts, mtime_t i_dts )
 {
-    mtime_t i_pcr = 9 * p_ts->i_dts / 100;
+    mtime_t i_pcr = 9 * i_dts / 100;
 
     p_ts->p_buffer[6]  = ( i_pcr >> 25 )&0xff;
     p_ts->p_buffer[7]  = ( i_pcr >> 17 )&0xff;