]> git.sesse.net Git - vlc/blobdiff - modules/mux/mpeg/ts.c
Update slightly INSTALL.win32
[vlc] / modules / mux / mpeg / ts.c
index 5ddf023c84f72ef1df9a1a407d95eaf6798edeec..eb0ce1243aa75823a414a7c191ca0d4a4eabbd0e 100644 (file)
@@ -37,8 +37,8 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
-#include <vlc_codecs.h>
 #include <vlc_block.h>
+#include <vlc_rand.h>
 
 #include <vlc_iso_lang.h>
 
@@ -520,7 +520,6 @@ static int Open( vlc_object_t *p_this )
     p_mux->pf_mux       = Mux;
     p_mux->p_sys        = p_sys;
 
-    srand( (uint32_t)mdate() );
     for ( i = 0; i < MAX_PMT; i++ )
         p_sys->sdt_descriptors[i].psz_service_name
             = p_sys->sdt_descriptors[i].psz_provider = NULL;
@@ -582,7 +581,9 @@ static int Open( vlc_object_t *p_this )
     }
     free( val.psz_string );
 
-    p_sys->i_pat_version_number = rand() % 32;
+    unsigned short subi[3];
+    vlc_rand_bytes(subi, sizeof(subi));
+    p_sys->i_pat_version_number = nrand48(subi) & 0x1f;
     p_sys->pat.i_pid = 0;
     p_sys->pat.i_continuity_counter = 0;
     p_sys->pat.b_discontinuity = false;
@@ -591,16 +592,16 @@ static int Open( vlc_object_t *p_this )
     if ( val.i_int )
         p_sys->i_tsid = val.i_int;
     else
-        p_sys->i_tsid = rand() % 65536;
+        p_sys->i_tsid = nrand48(subi) & 0xffff;
 
-    p_sys->i_netid = rand() % 65536;
+    p_sys->i_netid = nrand48(subi) & 0xffff;
 #ifdef HAVE_DVBPSI_SDT
     var_Get( p_mux, SOUT_CFG_PREFIX "netid", &val );
     if ( val.i_int )
         p_sys->i_netid = val.i_int;
 #endif
 
-    p_sys->i_pmt_version_number = rand() % 32;
+    p_sys->i_pmt_version_number = nrand48(subi) & 0x1f;
     for( i = 0; i < p_sys->i_num_pmt; i++ )
     {
         p_sys->pmt[i].i_continuity_counter = 0;
@@ -829,7 +830,8 @@ static int Open( vlc_object_t *p_this )
             var_Get( p_mux, SOUT_CFG_PREFIX "csa-pkt", &pkt_val );
             if( pkt_val.i_int < 12 || pkt_val.i_int > 188 )
             {
-                msg_Err( p_mux, "wrong packet size %d specified.", pkt_val.i_int );
+                msg_Err( p_mux, "wrong packet size %"PRId64" specified.",
+                         pkt_val.i_int );
                 msg_Warn( p_mux, "using default packet size of 188 bytes" );
                 p_sys->i_csa_pkt_size = 188;
             }
@@ -856,16 +858,13 @@ static void Close( vlc_object_t * p_this )
     sout_mux_sys_t      *p_sys = p_mux->p_sys;
     int i;
 
-    vlc_mutex_lock( &p_sys->csa_lock );
     if( p_sys->csa )
     {
         var_DelCallback( p_mux, SOUT_CFG_PREFIX "csa-ck", ChangeKeyCallback, NULL );
         var_DelCallback( p_mux, SOUT_CFG_PREFIX "csa2-ck", ChangeKeyCallback, NULL );
         var_DelCallback( p_mux, SOUT_CFG_PREFIX "csa-use", ActiveKeyCallback, NULL );
         csa_Delete( p_sys->csa );
-        p_sys->csa = NULL;
     }
-    vlc_mutex_unlock( &p_sys->csa_lock );
 
     for( i = 0; i < MAX_PMT; i++ )
     {
@@ -2020,6 +2019,12 @@ static block_t *TSNew( sout_mux_t *p_mux, ts_stream_t *p_stream,
     }
 
     p_ts = block_New( p_mux, 188 );
+
+    if (b_new_pes && !(p_pes->i_flags & BLOCK_FLAG_NO_KEYFRAME) && p_pes->i_flags & BLOCK_FLAG_TYPE_I)
+    {
+        p_ts->i_flags |= BLOCK_FLAG_TYPE_I;
+    }
+
     p_ts->i_dts = p_pes->i_dts;
 
     p_ts->p_buffer[0] = 0x47;