+ vlc_value_t keep;
+
+ if( var_Get( p_parent, "sout-keep", &keep ) < 0 )
+ {
+ msg_Warn( p_parent, "cannot get sout-keep value" );
+ keep.b_bool = VLC_FALSE;
+ }
+ else if( keep.b_bool )
+ {
+ msg_Warn( p_parent, "sout-keep true" );
+ if( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT, FIND_ANYWHERE ) ) )
+ {
+ if( !strcmp( p_sout->psz_sout, psz_dest ) )
+ {
+ msg_Warn( p_parent, "sout keep : reusing sout" );
+ msg_Warn( 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_Warn( p_parent, "sout keep : destroying unusable sout" );
+ sout_DeleteInstance( p_sout );
+ }
+ }
+ }
+ else if( !keep.b_bool )
+ {
+ while( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT, FIND_PARENT ) ) )
+ {
+ msg_Warn( p_parent, "sout keep : destroying old sout" );
+ sout_DeleteInstance( p_sout );
+ }
+ }