diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-08-22 19:29:29 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-08-22 19:29:29 +0000 |
commit | 304aac9d8f68a374d9cd5d2b2204f8c26f10a948 (patch) | |
tree | e481d99c54cefe083c7ee461127c426a76ca3f23 /utils | |
parent | 19577acdfe461381b3de979cb5b0d0e39ed18ec4 (diff) |
support new format for musiconhold.conf (issue #4908)
support non-SLINEAR moh streams (issue #4908)
add external app to feed TCP stream into Asterisk for moh (issue #4908)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6353 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/Makefile | 5 | ||||
-rwxr-xr-x | utils/streamplayer.c | 84 |
2 files changed, 88 insertions, 1 deletions
diff --git a/utils/Makefile b/utils/Makefile index 689aacbd1..137b0b748 100755 --- a/utils/Makefile +++ b/utils/Makefile @@ -21,7 +21,7 @@ ifeq ($(findstring BSD,${OSARCH}),BSD) CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib endif -TARGET=stereorize +TARGET=stereorize streamplayer TARGET+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/usr/include/popt.h ]; then echo "smsq"; else if [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/popt.h ]; then echo "smsq"; fi ; fi) TARGET+=$(shell if [ -f $(CROSS_COMPILE_TARGET)/usr/include/newt.h ]; then echo "astman"; else if [ -f $(CROSS_COMPILE_TARGET)/usr/local/include/newt.h ]; then echo "astman"; fi ; fi) @@ -53,6 +53,9 @@ check_expr : check_expr.c ../ast_expr.a smsq: smsq.o $(CC) $(CFLAGS) -o smsq ${SOL} smsq.o -lpopt +streamplayer: streamplayer.o + $(CC) $(CFLAGS) -o streamplayer ${SOL} streamplayer.o + ifneq ($(wildcard .depend),) include .depend endif diff --git a/utils/streamplayer.c b/utils/streamplayer.c new file mode 100755 index 000000000..5ae742f08 --- /dev/null +++ b/utils/streamplayer.c @@ -0,0 +1,84 @@ +/* +* streamplayer.c +* +* A utility for reading from a stream +* +* Copyright (C) 2005, Digium, Inc. +* +* Russell Bryant <russell@digium.com> +* +* This program is free software, distributed under the terms of +* the GNU General Public License +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <netdb.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/time.h> + + +int main(int argc, char *argv[]) +{ + struct sockaddr_in sin; + struct hostent *hp; + int s; + int res; + char buf[2048]; + fd_set wfds; + struct timeval tv; + + if (argc != 3) { + fprintf(stderr, "Usage: ./streamplayer <ip> <port>\n"); + exit(1); + } + + hp = gethostbyname(argv[1]); + if (!hp) { + fprintf(stderr, "Unable to lookup IP for host '%s'\n", argv[1]); + exit(1); + } + + memset(&sin, 0, sizeof(sin)); + + sin.sin_family = AF_INET; + sin.sin_port = htons(atoi(argv[2])); + memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr)); + + s = socket(AF_INET, SOCK_STREAM, 0); + + if (s < 0) { + fprintf(stderr, "Unable to allocate socket!\n"); + exit(1); + } + + res = connect(s, (struct sockaddr *)&sin, sizeof(sin)); + + if (res) { + fprintf(stderr, "Unable to connect to host!\n"); + close(s); + exit(1); + } + + while (1) { + res = read(s, buf, sizeof(buf)); + + if (res < 1) + break; + + memset(&tv, 0, sizeof(tv)); + FD_ZERO(&wfds); + FD_SET(1, &wfds); + + select(2, NULL, &wfds, NULL, &tv); + + if (FD_ISSET(1, &wfds)) + write(1, buf, res); + } + + close(s); + exit(res); +} |