[Asterisk-cvs] asterisk/utils streamplayer.c, NONE, 1.1 Makefile,
1.13, 1.14
kpfleming
kpfleming
Mon Aug 22 15:27:24 CDT 2005
Update of /usr/cvsroot/asterisk/utils
In directory mongoose.digium.com:/tmp/cvs-serv8900/utils
Modified Files:
Makefile
Added Files:
streamplayer.c
Log Message:
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)
--- NEW FILE: streamplayer.c ---
/*
* streamplayer.c
*
* A utility for reading from a stream
*
* Copyright (C) 2005, Digium, Inc.
*
* Russell Bryant <russell at 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);
}
Index: Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/utils/Makefile,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Makefile 21 Jun 2005 20:16:51 -0000 1.13
+++ Makefile 22 Aug 2005 19:29:29 -0000 1.14
@@ -21,7 +21,7 @@
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 @@
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
More information about the svn-commits
mailing list