--- apps/app_mp3.c.orig 2009-04-02 14:52:12.000000000 -0700 +++ apps/app_mp3.c 2009-04-03 09:31:20.000000000 -0700 @@ -21,6 +21,9 @@ * \brief Silly application to play an MP3 file -- uses mpg123 * * \author Mark Spencer + * + * \note Add feature to play M3U playlist file + * Vincent Li * * \ingroup applications */ @@ -89,6 +92,14 @@ /* As a last-ditch effort, try to use PATH */ execlp("mpg123", "mpg123", "-q", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL); } + else if (strstr(filename, ".m3u")) { + /* Most commonly installed in /usr/local/bin */ + execl(LOCAL_MPG_123, "mpg123", "-q", "-z", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL); + /* But many places has it in /usr/bin */ + execl(MPG_123, "mpg123", "-q", "-z", "-s", "-b", "1024","-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL); + /* As a last-ditch effort, try to use PATH */ + execlp("mpg123", "mpg123", "-q", "-z", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL); + } else { /* Most commonly installed in /usr/local/bin */ execl(MPG_123, "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL); @@ -125,6 +136,7 @@ int pid = -1; int owriteformat; int timeout = 2000; + char *tmp; struct timeval next; struct ast_frame *f; struct myframe { @@ -132,12 +144,20 @@ char offset[AST_FRIENDLY_OFFSET]; short frdata[160]; } myf; - + + AST_DECLARE_APP_ARGS(args, + AST_APP_ARG(filename); + ); + if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "MP3 Playback requires an argument (filename)\n"); return -1; } + tmp = ast_strdupa(data); + + AST_STANDARD_APP_ARGS(args, tmp); + if (pipe(fds)) { ast_log(LOG_WARNING, "Unable to create pipe\n"); return -1; @@ -152,8 +172,8 @@ return -1; } - res = mp3play((char *)data, fds[1]); - if (!strncasecmp((char *)data, "http://", 7)) { + res = mp3play(args.filename, fds[1]); + if (!strncasecmp(args.filename, "http://", 7)) { timeout = 10000; } /* Wait 1000 ms first */