#include <vlc_common.h>
#include <vlc_stream.h>
+#include <vlc_modules.h>
#include <libvlc.h>
+#include <assert.h>
+
#include "stream.h"
static void StreamDelete( stream_t * );
const char *psz_stream_filter )
{
stream_t *s;
+ assert( p_source != NULL );
s = stream_CommonNew( VLC_OBJECT( p_source ) );
if( s == NULL )
return NULL;
+ s->p_input = p_source->p_input;
+
/* */
+ s->psz_path = strdup( p_source->psz_path );
+ if( !s->psz_path )
+ {
+ stream_CommonDelete( s );
+ return NULL;
+ }
s->p_source = p_source;
/* */
return s;
}
+stream_t *stream_FilterChainNew( stream_t *p_source,
+ const char *psz_chain,
+ bool b_record )
+{
+ /* Add auto stream filter */
+ for( ;; )
+ {
+ stream_t *p_filter = stream_FilterNew( p_source, NULL );
+ if( !p_filter )
+ break;
+
+ msg_Dbg( p_filter, "Inserted a stream filter" );
+ p_source = p_filter;
+ }
+
+ /* Add user stream filter */
+ char *psz_tmp = psz_chain ? strdup( psz_chain ) : NULL;
+ char *psz = psz_tmp;
+ while( psz && *psz )
+ {
+ stream_t *p_filter;
+ char *psz_end = strchr( psz, ':' );
+
+ if( psz_end )
+ *psz_end++ = '\0';
+
+ p_filter = stream_FilterNew( p_source, psz );
+ if( p_filter )
+ p_source = p_filter;
+ else
+ msg_Warn( p_source, "failed to insert stream filter %s", psz );
+
+ psz = psz_end;
+ }
+ free( psz_tmp );
+
+ /* Add record filter if useful */
+ if( b_record )
+ {
+ stream_t *p_filter = stream_FilterNew( p_source,
+ "stream_filter_record" );
+ if( p_filter )
+ p_source = p_filter;
+ }
+ return p_source;
+}
+
static void StreamDelete( stream_t *s )
{
module_unneed( s, s->p_module );