]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/duplicate.c
sout: allow duplicate outputs to be merged
[vlc] / modules / stream_out / duplicate.c
index 852327a0817a1dcb6e2af97bf11d5e51af40c440..26cfeffd6e75ff88bc12b53a7d1cb7ad30ca83ad 100644 (file)
@@ -64,6 +64,9 @@ struct sout_stream_sys_t
     int             i_nb_streams;
     sout_stream_t   **pp_streams;
 
+    int             i_nb_last_streams;
+    sout_stream_t   **pp_last_streams;
+
     int             i_nb_select;
     char            **ppsz_select;
 };
@@ -92,20 +95,24 @@ static int Open( vlc_object_t *p_this )
         return VLC_ENOMEM;
 
     TAB_INIT( p_sys->i_nb_streams, p_sys->pp_streams );
+    TAB_INIT( p_sys->i_nb_last_streams, p_sys->pp_last_streams );
     TAB_INIT( p_sys->i_nb_select, p_sys->ppsz_select );
 
     for( p_cfg = p_stream->p_cfg; p_cfg != NULL; p_cfg = p_cfg->p_next )
     {
         if( !strncmp( p_cfg->psz_name, "dst", strlen( "dst" ) ) )
         {
-            sout_stream_t *s;
+            sout_stream_t *s, *p_last;
 
             msg_Dbg( p_stream, " * adding `%s'", p_cfg->psz_value );
-            s = sout_StreamNew( p_stream->p_sout, p_cfg->psz_value );
+            s = sout_StreamChainNew( p_stream->p_sout, p_cfg->psz_value,
+                p_stream->p_next, &p_last );
 
             if( s )
             {
                 TAB_APPEND( p_sys->i_nb_streams, p_sys->pp_streams, s );
+                TAB_APPEND( p_sys->i_nb_last_streams, p_sys->pp_last_streams,
+                    p_last );
                 TAB_APPEND( p_sys->i_nb_select,  p_sys->ppsz_select, NULL );
             }
         }
@@ -164,10 +171,11 @@ static void Close( vlc_object_t * p_this )
     msg_Dbg( p_stream, "closing a duplication" );
     for( i = 0; i < p_sys->i_nb_streams; i++ )
     {
-        sout_StreamDelete( p_sys->pp_streams[i] );
+        sout_StreamChainDelete(p_sys->pp_streams[i], p_sys->pp_last_streams[i]);
         free( p_sys->ppsz_select[i] );
     }
     free( p_sys->pp_streams );
+    free( p_sys->pp_last_streams );
     free( p_sys->ppsz_select );
 
     free( p_sys );