]> git.sesse.net Git - vlc/blobdiff - src/stream_output/stream_output.c
Force VLM stream to not use sout-keep.
[vlc] / src / stream_output / stream_output.c
index adbb23d8fd122b68d010be81ecce40540a67c33e..dc586418eabd50b02bcce1b795d3a6ee47c67811 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * stream_output.c : stream output module
  *****************************************************************************
- * Copyright (C) 2002-2004 the VideoLAN team
+ * Copyright (C) 2002-2007 the VideoLAN team
  * $Id$
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
@@ -34,6 +34,7 @@
 #include <string.h>                                            /* strerror() */
 
 #include <vlc_sout.h>
+#include <vlc_playlist.h>
 
 #include "stream_output.h"
 
@@ -74,40 +75,39 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
     sout_instance_t *p_sout;
     vlc_value_t keep;
 
-    if( var_Get( p_parent, "sout-keep", &keep ) < 0 )
+    if( var_Get( p_parent, "sout-keep", &keep ) >= 0 && keep.b_bool )
     {
-        msg_Warn( p_parent, "cannot get sout-keep value" );
-        keep.b_bool = VLC_FALSE;
-    }
-    if( keep.b_bool )
-    {
-        if( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT,
-                                        FIND_ANYWHERE ) ) != NULL )
+        /* Remove the sout from the playlist garbage collector */
+        playlist_t *p_playlist = pl_Yield( p_parent );
+
+        vlc_mutex_lock( &p_playlist->gc_lock );
+        p_sout = vlc_object_find( p_playlist, VLC_OBJECT_SOUT, FIND_CHILD );
+        if( p_sout && p_sout->p_parent != (vlc_object_t *)p_playlist )
+        {
+            vlc_object_release( p_sout );
+            p_sout = NULL;
+        }
+        if( p_sout )
+            vlc_object_detach( p_sout );    /* Remove it from the GC */
+        vlc_mutex_unlock( &p_playlist->gc_lock );
+
+        pl_Release( p_parent );
+
+        /* */
+
+        if( p_sout )
         {
             if( !strcmp( p_sout->psz_sout, psz_dest ) )
             {
                 msg_Dbg( p_parent, "sout keep: reusing sout" );
                 msg_Dbg( p_parent, "sout keep: you probably want to use "
                           "gather stream_out" );
-                vlc_object_detach( p_sout );
                 vlc_object_attach( p_sout, p_parent );
                 vlc_object_release( p_sout );
                 return p_sout;
             }
-            else
-            {
-                msg_Dbg( p_parent, "sout keep: destroying unusable sout" );
-                vlc_object_release( p_sout );
-                sout_DeleteInstance( p_sout );
-            }
-        }
-    }
-    else if( !keep.b_bool )
-    {
-        while( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT,
-                                           FIND_PARENT ) ) != NULL )
-        {
-            msg_Dbg( p_parent, "sout keep: destroying old sout" );
+
+            msg_Dbg( p_parent, "sout keep: destroying unusable sout" );
             vlc_object_release( p_sout );
             sout_DeleteInstance( p_sout );
         }
@@ -275,7 +275,7 @@ int sout_InputSendBuffer( sout_packetizer_input_t *p_input,
  * sout_AccessOutNew: allocate a new access out
  *****************************************************************************/
 sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
-                                      char *psz_access, char *psz_name )
+                                      const char *psz_access, const char *psz_name )
 {
     sout_access_out_t *p_access;
     char              *psz_next;
@@ -293,12 +293,13 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
     {
         free( psz_next );
     }
-    p_access->psz_name   = strdup( psz_name ? psz_name : "" );
+    p_access->psz_path   = strdup( psz_name ? psz_name : "" );
     p_access->p_sout     = p_sout;
     p_access->p_sys = NULL;
     p_access->pf_seek    = NULL;
     p_access->pf_read    = NULL;
     p_access->pf_write   = NULL;
+    p_access->pf_control = NULL;
     p_access->p_module   = NULL;
 
     p_access->i_writes = 0;
@@ -312,7 +313,7 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
     if( !p_access->p_module )
     {
         free( p_access->psz_access );
-        free( p_access->psz_name );
+        free( p_access->psz_path );
         vlc_object_detach( p_access );
         vlc_object_destroy( p_access );
         return( NULL );
@@ -334,7 +335,7 @@ void sout_AccessOutDelete( sout_access_out_t *p_access )
 
     config_ChainDestroy( p_access->p_cfg );
 
-    free( p_access->psz_name );
+    free( p_access->psz_path );
 
     vlc_object_destroy( p_access );
 }
@@ -385,6 +386,15 @@ int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer )
     return p_access->pf_write( p_access, p_buffer );
 }
 
+/**
+ * sout_AccessOutControl
+ */
+int sout_AccessOutControl (sout_access_out_t *access, int query, va_list args)
+{
+    return (access->pf_control) ? access->pf_control (access, query, args)
+                                : VLC_EGENERIC;
+}
+
 /*****************************************************************************
  * sout_MuxNew: create a new mux
  *****************************************************************************/
@@ -609,8 +619,8 @@ static int mrl_Parse( mrl_t *p_mrl, const char *psz_mrl )
 {
     char * psz_dup = strdup( psz_mrl );
     char * psz_parser = psz_dup;
-    char * psz_access;
-    char * psz_way;
+    const char * psz_access;
+    const char * psz_way;
     char * psz_name;
 
     /* *** first parse psz_dest */