Merged revisions 134915 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r134915 | russell | 2008-07-31 14:37:26 -0500 (Thu, 31 Jul 2008) | 9 lines

Get app_ices working again

(closes issue #12981)
Reported by: dlogan
Patches:
      20080709__app_ices_v2_update_trunk.diff uploaded by bbryant (license 36)
      20080709__app_ices_v2_update_14.diff uploaded by bbryant (license 36)
Tested by: bbryant

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@134917 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant 2008-07-31 19:39:50 +00:00
parent 6d5979ff7e
commit 2a6ce7b40a
1 changed files with 23 additions and 11 deletions

View File

@ -45,8 +45,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/translate.h" #include "asterisk/translate.h"
#include "asterisk/app.h" #include "asterisk/app.h"
#define ICES "/usr/bin/ices" #define path_BIN "/usr/bin/"
#define LOCAL_ICES "/usr/local/bin/ices" #define path_LOCAL "/usr/local/bin/"
static char *app = "ICES"; static char *app = "ICES";
@ -55,7 +55,9 @@ static char *synopsis = "Encode and stream using 'ices'";
static char *descrip = static char *descrip =
" ICES(config.xml) Streams to an icecast server using ices\n" " ICES(config.xml) Streams to an icecast server using ices\n"
"(available separately). A configuration file must be supplied\n" "(available separately). A configuration file must be supplied\n"
"for ices (see examples/asterisk-ices.conf). \n"; "for ices (see contrib/asterisk-ices.xml). \n"
"\n"
"- ICES version 2 cient and server required.\n";
static int icesencode(char *filename, int fd) static int icesencode(char *filename, int fd)
@ -73,13 +75,23 @@ static int icesencode(char *filename, int fd)
ast_set_priority(0); ast_set_priority(0);
dup2(fd, STDIN_FILENO); dup2(fd, STDIN_FILENO);
ast_close_fds_above_n(STDERR_FILENO); ast_close_fds_above_n(STDERR_FILENO);
/* Most commonly installed in /usr/local/bin */
execl(ICES, "ices", filename, (char *)NULL); /* Most commonly installed in /usr/local/bin
/* But many places has it in /usr/bin */ * But many places has it in /usr/bin
execl(LOCAL_ICES, "ices", filename, (char *)NULL); * As a last-ditch effort, try to use PATH
/* As a last-ditch effort, try to use PATH */ */
execlp("ices", "ices", filename, (char *)NULL); execl(path_LOCAL "ices2", "ices", filename, NULL);
ast_log(LOG_WARNING, "Execute of ices failed\n"); execl(path_BIN "ices2", "ices", filename, NULL);
execlp("ices2", "ices", filename, NULL);
ast_debug(1, "Couldn't find ices version 2, attempting to use ices version 1.");
execl(path_LOCAL "ices", "ices", filename, NULL);
execl(path_BIN "ices", "ices", filename, NULL);
execlp("ices", "ices", filename, NULL);
ast_log(LOG_WARNING, "Execute of ices failed, could not find command.\n");
close(fd);
_exit(0); _exit(0);
} }
@ -139,7 +151,6 @@ static int ices_exec(struct ast_channel *chan, void *data)
if (c) if (c)
*c = '\0'; *c = '\0';
res = icesencode(filename, fds[0]); res = icesencode(filename, fds[0]);
close(fds[0]);
if (res >= 0) { if (res >= 0) {
pid = res; pid = res;
for (;;) { for (;;) {
@ -170,6 +181,7 @@ static int ices_exec(struct ast_channel *chan, void *data)
ast_frfree(f); ast_frfree(f);
} }
} }
close(fds[0]);
close(fds[1]); close(fds[1]);
if (pid > -1) if (pid > -1)