[vlc-commits] mux: constify stream format

Rémi Denis-Courmont git at videolan.org
Sat Feb 21 11:24:22 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb 21 11:37:20 2015 +0200| [862771a804bb72e0150234f8ffc0f4a11fd5e3bd] | committer: Rémi Denis-Courmont

mux: constify stream format

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

 include/vlc_sout.h                |   10 +++++-----
 modules/mux/ogg.c                 |    5 +++--
 src/stream_output/stream_output.c |    9 +++++++--
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/include/vlc_sout.h b/include/vlc_sout.h
index ce0f654..467c427 100644
--- a/include/vlc_sout.h
+++ b/include/vlc_sout.h
@@ -146,15 +146,15 @@ enum sout_mux_query_e
 
 struct sout_input_t
 {
-    es_format_t     *p_fmt;
-    block_fifo_t    *p_fifo;
-
-    void            *p_sys;
+    const es_format_t *p_fmt;
+    block_fifo_t      *p_fifo;
+    void              *p_sys;
+    es_format_t        fmt;
 };
 
 
 VLC_API sout_mux_t * sout_MuxNew( sout_instance_t*, const char *, sout_access_out_t * ) VLC_USED;
-VLC_API sout_input_t * sout_MuxAddStream( sout_mux_t *, es_format_t * ) VLC_USED;
+VLC_API sout_input_t *sout_MuxAddStream( sout_mux_t *, const es_format_t * ) VLC_USED;
 VLC_API void sout_MuxDeleteStream( sout_mux_t *, sout_input_t * );
 VLC_API void sout_MuxDelete( sout_mux_t * );
 VLC_API int sout_MuxSendBuffer( sout_mux_t *, sout_input_t  *, block_t * );
diff --git a/modules/mux/ogg.c b/modules/mux/ogg.c
index 1045922..9b661bf 100644
--- a/modules/mux/ogg.c
+++ b/modules/mux/ogg.c
@@ -381,8 +381,9 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
             !p_input->p_fmt->video.i_frame_rate_base )
         {
             msg_Warn( p_mux, "Missing frame rate, assuming 25fps" );
-            p_input->p_fmt->video.i_frame_rate = 25;
-            p_input->p_fmt->video.i_frame_rate_base = 1;
+            assert(p_input->p_fmt == &p_input->fmt);
+            p_input->fmt.video.i_frame_rate = 25;
+            p_input->fmt.video.i_frame_rate_base = 1;
         }
 
         switch( p_stream->i_fourcc )
diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index b8e4f40..fbc9f34 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -433,7 +433,7 @@ void sout_MuxDelete( sout_mux_t *p_mux )
 /*****************************************************************************
  * sout_MuxAddStream:
  *****************************************************************************/
-sout_input_t *sout_MuxAddStream( sout_mux_t *p_mux, es_format_t *p_fmt )
+sout_input_t *sout_MuxAddStream( sout_mux_t *p_mux, const es_format_t *p_fmt )
 {
     sout_input_t *p_input;
 
@@ -450,7 +450,11 @@ sout_input_t *sout_MuxAddStream( sout_mux_t *p_mux, es_format_t *p_fmt )
     p_input = malloc( sizeof( sout_input_t ) );
     if( !p_input )
         return NULL;
-    p_input->p_fmt  = p_fmt;
+
+    // FIXME: remove either fmt or p_fmt...
+    es_format_Copy( &p_input->fmt, p_fmt );
+    p_input->p_fmt = &p_input->fmt;
+
     p_input->p_fifo = block_FifoNew();
     p_input->p_sys  = NULL;
 
@@ -500,6 +504,7 @@ void sout_MuxDeleteStream( sout_mux_t *p_mux, sout_input_t *p_input )
         }
 
         block_FifoRelease( p_input->p_fifo );
+        es_format_Clean( &p_input->fmt );
         free( p_input );
     }
 }



More information about the vlc-commits mailing list