/*****************************************************************************
* 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>
#include <string.h> /* strerror() */
#include <vlc_sout.h>
+#include <vlc_playlist.h>
#include "stream_output.h"
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 );
}
* 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;
{
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;
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 );
config_ChainDestroy( p_access->p_cfg );
- free( p_access->psz_name );
+ free( p_access->psz_path );
vlc_object_destroy( p_access );
}
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
*****************************************************************************/
{
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 */