]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/switcher.c
Fixed rtsp broadcast streaming(sdp=rtsp://) and a potential double free.
[vlc] / modules / stream_out / switcher.c
index 7d5b9c7beeb2ad29794a9efc59929e012cdde273..bbdffcea0cd9da3d49505e93908b026b5ab601b6 100644 (file)
 #include <math.h>
 
 #include <vlc/vlc.h>
-#include <vlc/sout.h>
-#include <vlc/vout.h>
+#include <vlc_sout.h>
+#include <vlc_vout.h>
 
-#include <charset.h>
-#include <network.h>
+#include <vlc_charset.h>
+#include <vlc_network.h>
 
 #define HAVE_MMX
 #ifdef HAVE_FFMPEG_AVCODEC_H
@@ -162,7 +162,7 @@ struct sout_stream_id_t
     AVCodec         *ff_enc;
     AVCodecContext  *ff_enc_c;
     AVFrame         *p_frame;
-    char            *p_buffer_out;
+    uint8_t         *p_buffer_out;
     int             i_nb_pred;
     int16_t         *p_samples;
 };
@@ -189,7 +189,7 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    sout_CfgParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options,
+    config_ChainParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options,
                    p_stream->p_cfg );
 
     var_Get( p_stream, SOUT_CFG_PREFIX "files", &val );
@@ -257,7 +257,7 @@ static int Open( vlc_object_t *p_this )
     }
 
     var_Get( p_stream, SOUT_CFG_PREFIX "port", &val );
-    p_sys->i_fd = net_OpenUDP( p_stream, NULL, val.i_int, NULL, 0 );
+    p_sys->i_fd = net_ListenUDP1( p_stream, NULL, val.i_int );
     if ( p_sys->i_fd < 0 )
     {
         free( p_sys );
@@ -649,12 +649,13 @@ static int UnpackFromFile( sout_stream_t *p_stream, const char *psz_file,
 static void NetCommand( sout_stream_t *p_stream )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
-    char psz_buffer[10];
-    int i_len = net_ReadNonBlock( p_stream, p_sys->i_fd, NULL, (char *)&psz_buffer[0],
-                                  sizeof( psz_buffer ), 0 );
+    char psz_buffer[11];
+    int i_len = net_ReadNonBlock( p_stream, p_sys->i_fd, NULL, (uint8_t *)&psz_buffer[0],
+                                  sizeof( psz_buffer ) - 1 );
 
     if ( i_len > 0 )
     {
+        psz_buffer[i_len] = '\0';
         int i_cmd = strtol( psz_buffer, NULL, 0 );
         if ( i_cmd < -1 || i_cmd > p_sys->i_nb_pictures )
         {