@ -792,7 +792,8 @@ struct ast_filestream *ast_openstream(struct ast_channel *chan, const char *file
return ast_openstream_full ( chan , filename , preflang , 0 ) ;
return ast_openstream_full ( chan , filename , preflang , 0 ) ;
}
}
struct ast_filestream * ast_openstream_full ( struct ast_channel * chan , const char * filename , const char * preflang , int asis )
struct ast_filestream * ast_openstream_full ( struct ast_channel * chan ,
const char * filename , const char * preflang , int asis )
{
{
/*
/*
* Use fileexists_core ( ) to find a file in a compatible
* Use fileexists_core ( ) to find a file in a compatible
@ -844,7 +845,8 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
return NULL ;
return NULL ;
}
}
struct ast_filestream * ast_openvstream ( struct ast_channel * chan , const char * filename , const char * preflang )
struct ast_filestream * ast_openvstream ( struct ast_channel * chan ,
const char * filename , const char * preflang )
{
{
/* As above, but for video. But here we don't have translators
/* As above, but for video. But here we don't have translators
* so we must enforce a format .
* so we must enforce a format .
@ -1288,14 +1290,31 @@ int ast_file_read_dirs(const char *dir_name, ast_file_on_file on_file, void *obj
return res ;
return res ;
}
}
int ast_streamfile ( struct ast_channel * chan , const char * filename , const char * preflang )
int ast_streamfile ( struct ast_channel * chan , const char * filename ,
const char * preflang )
{
{
struct ast_filestream * fs ;
struct ast_filestream * fs = NULL ;
struct ast_filestream * vfs = NULL ;
struct ast_filestream * vfs = NULL ;
off_t pos ;
off_t pos ;
int seekattempt ;
int seekattempt ;
int res ;
int res ;
char custom_filename [ 256 ] ;
char * tmp_filename ;
/* If file with the same name exists in /var/lib/asterisk/sounds/custom directory, use that file.
* Otherwise , use the original file */
if ( ast_opt_sounds_search_custom & & ! is_absolute_path ( filename ) ) {
memset ( custom_filename , 0 , sizeof ( custom_filename ) ) ;
snprintf ( custom_filename , sizeof ( custom_filename ) , " custom/%s " , filename ) ;
fs = ast_openstream ( chan , custom_filename , preflang ) ;
if ( fs ) {
tmp_filename = custom_filename ;
ast_debug ( 3 , " Found file %s in custom directory \n " , filename ) ;
}
}
if ( ! fs ) {
fs = ast_openstream ( chan , filename , preflang ) ;
fs = ast_openstream ( chan , filename , preflang ) ;
if ( ! fs ) {
if ( ! fs ) {
struct ast_str * codec_buf = ast_str_alloca ( AST_FORMAT_CAP_NAMES_LEN ) ;
struct ast_str * codec_buf = ast_str_alloca ( AST_FORMAT_CAP_NAMES_LEN ) ;
@ -1305,6 +1324,8 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
ast_channel_unlock ( chan ) ;
ast_channel_unlock ( chan ) ;
return - 1 ;
return - 1 ;
}
}
tmp_filename = ( char * ) filename ;
}
/* check to see if there is any data present (not a zero length file),
/* check to see if there is any data present (not a zero length file),
* done this way because there is no where for ast_openstream_full to
* done this way because there is no where for ast_openstream_full to
@ -1322,7 +1343,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
fseeko ( fs - > f , pos , SEEK_SET ) ;
fseeko ( fs - > f , pos , SEEK_SET ) ;
}
}
vfs = ast_openvstream ( chan , filename, preflang ) ;
vfs = ast_openvstream ( chan , tmp_ filename, preflang ) ;
if ( vfs ) {
if ( vfs ) {
ast_debug ( 1 , " Ooh, found a video stream, too, format %s \n " , ast_format_get_name ( vfs - > fmt - > format ) ) ;
ast_debug ( 1 , " Ooh, found a video stream, too, format %s \n " , ast_format_get_name ( vfs - > fmt - > format ) ) ;
}
}
@ -1333,14 +1354,14 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
return - 1 ;
return - 1 ;
if ( vfs & & ast_applystream ( chan , vfs ) )
if ( vfs & & ast_applystream ( chan , vfs ) )
return - 1 ;
return - 1 ;
ast_test_suite_event_notify ( " PLAYBACK " , " Message: %s \r \n Channel: %s " , filename, ast_channel_name ( chan ) ) ;
ast_test_suite_event_notify ( " PLAYBACK " , " Message: %s \r \n Channel: %s " , tmp_ filename, ast_channel_name ( chan ) ) ;
res = ast_playstream ( fs ) ;
res = ast_playstream ( fs ) ;
if ( ! res & & vfs )
if ( ! res & & vfs )
res = ast_playstream ( vfs ) ;
res = ast_playstream ( vfs ) ;
if ( VERBOSITY_ATLEAST ( 3 ) ) {
if ( VERBOSITY_ATLEAST ( 3 ) ) {
ast_channel_lock ( chan ) ;
ast_channel_lock ( chan ) ;
ast_verb ( 3 , " <%s> Playing '%s.%s' (language '%s') \n " , ast_channel_name ( chan ) , filename, ast_format_get_name ( ast_channel_writeformat ( chan ) ) , preflang ? preflang : " default " ) ;
ast_verb ( 3 , " <%s> Playing '%s.%s' (language '%s') \n " , ast_channel_name ( chan ) , tmp_ filename, ast_format_get_name ( ast_channel_writeformat ( chan ) ) , preflang ? preflang : " default " ) ;
ast_channel_unlock ( chan ) ;
ast_channel_unlock ( chan ) ;
}
}