Fix various typos
[vlc/asuraparaju-public.git] / src / input / stream_filter.c
blob73255e5555f0709a6601c29d20eb7ebe4c9bc013
1 /*****************************************************************************
2 * stream_filter.c
3 *****************************************************************************
4 * Copyright (C) 2008 Laurent Aimar
5 * $Id$
7 * Author: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
28 #include <vlc_common.h>
29 #include <vlc_stream.h>
30 #include <vlc_modules.h>
31 #include <libvlc.h>
33 #include <assert.h>
35 #include "stream.h"
37 static void StreamDelete( stream_t * );
39 stream_t *stream_FilterNew( stream_t *p_source,
40 const char *psz_stream_filter )
42 stream_t *s;
43 assert( p_source != NULL );
45 s = stream_CommonNew( VLC_OBJECT( p_source ) );
46 if( s == NULL )
47 return NULL;
49 s->p_input = p_source->p_input;
51 /* */
52 s->psz_path = strdup( p_source->psz_path );
53 if( !s->psz_path )
55 stream_CommonDelete( s );
56 return NULL;
58 s->p_source = p_source;
60 /* */
61 vlc_object_attach( s, p_source );
63 s->p_module = module_need( s, "stream_filter", psz_stream_filter, true );
65 if( !s->p_module )
67 stream_CommonDelete( s );
68 return NULL;
71 s->pf_destroy = StreamDelete;
73 return s;
76 stream_t *stream_FilterChainNew( stream_t *p_source,
77 const char *psz_chain,
78 bool b_record )
80 /* Add auto stream filter */
81 for( ;; )
83 stream_t *p_filter = stream_FilterNew( p_source, NULL );
84 if( !p_filter )
85 break;
87 msg_Dbg( p_filter, "Inserted a stream filter" );
88 p_source = p_filter;
91 /* Add user stream filter */
92 char *psz_tmp = psz_chain ? strdup( psz_chain ) : NULL;
93 char *psz = psz_tmp;
94 while( psz && *psz )
96 stream_t *p_filter;
97 char *psz_end = strchr( psz, ':' );
99 if( psz_end )
100 *psz_end++ = '\0';
102 p_filter = stream_FilterNew( p_source, psz );
103 if( p_filter )
104 p_source = p_filter;
105 else
106 msg_Warn( p_source, "failed to insert stream filter %s", psz );
108 psz = psz_end;
110 free( psz_tmp );
112 /* Add record filter if useful */
113 if( b_record )
115 stream_t *p_filter = stream_FilterNew( p_source,
116 "stream_filter_record" );
117 if( p_filter )
118 p_source = p_filter;
120 return p_source;
123 static void StreamDelete( stream_t *s )
125 module_unneed( s, s->p_module );
127 if( s->p_source )
128 stream_Delete( s->p_source );
130 stream_CommonDelete( s );