Commit 682e1602 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

stream_filter: revector, use strtok_r()

parent 70a513b9
...@@ -2311,10 +2311,12 @@ static int InputSourceInit( input_thread_t *p_input, ...@@ -2311,10 +2311,12 @@ static int InputSourceInit( input_thread_t *p_input,
/* Add stream filters */ /* Add stream filters */
p_stream = stream_FilterAutoNew( p_stream ); p_stream = stream_FilterAutoNew( p_stream );
char *psz_stream_filter = var_GetNonEmptyString( p_input, char *filters = var_GetNonEmptyString( p_input, "stream-filter" );
"stream-filter" ); if( filters != NULL )
p_stream = stream_FilterChainNew( p_stream, psz_stream_filter ); {
free( psz_stream_filter ); p_stream = stream_FilterChainNew( p_stream, filters );
free( filters );
}
if( var_GetBool( p_input, "input-record-native" ) ) if( var_GetBool( p_input, "input-record-native" ) )
p_stream = stream_FilterChainNew( p_stream, "record" ); p_stream = stream_FilterChainNew( p_stream, "record" );
......
...@@ -88,31 +88,26 @@ stream_t *stream_FilterAutoNew( stream_t *p_source ) ...@@ -88,31 +88,26 @@ stream_t *stream_FilterAutoNew( stream_t *p_source )
return p_source; return p_source;
} }
/* Add specified stream filter(s) */
stream_t *stream_FilterChainNew( stream_t *p_source, const char *psz_chain ) stream_t *stream_FilterChainNew( stream_t *p_source, const char *psz_chain )
{ {
if( psz_chain == NULL ) /* Add user stream filter */
char *chain = strdup( psz_chain );
if( unlikely(chain == NULL) )
return p_source; return p_source;
/* Add user stream filter */ char *buf;
char *psz_tmp = strdup( psz_chain ); for( const char *name = strtok_r( chain, ":", &buf );
char *psz = psz_tmp; name != NULL;
while( psz && *psz ) name = strtok_r( NULL, ":", &buf ) )
{ {
stream_t *p_filter; stream_t *p_filter = stream_FilterNew( p_source, name );
char *psz_end = strchr( psz, ':' ); if( p_filter != NULL )
if( psz_end )
*psz_end++ = '\0';
p_filter = stream_FilterNew( p_source, psz );
if( p_filter )
p_source = p_filter; p_source = p_filter;
else else
msg_Warn( p_source, "failed to insert stream filter %s", psz ); msg_Warn( p_source, "cannot insert stream filter %s", name );
psz = psz_end;
} }
free( psz_tmp ); free( chain );
return p_source; return p_source;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment