From: michael Date: Sat, 1 Jul 2006 18:22:56 +0000 (+0000) Subject: add dump-mcast for dumping multicast-streams to stdout X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/record-dvb/commitdiff_plain/cc319f8b578acbc41ef1282c064a8041b196d0ee?ds=inline;hp=fbc24ab023eb1ae6572fccff3fa1140c3e01c8b7 add dump-mcast for dumping multicast-streams to stdout --- diff --git a/.cvsignore b/.cvsignore index 5a75ec1..7cbdd82 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1,2 +1,3 @@ record-dvb +dump-mcast *.d diff --git a/Makefile b/Makefile index f3306ce..74c1037 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,16 @@ CFLAGS =-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -g -OBJS = record-dvb.o http.o mcast.o common.o +COMMONOBJS = http.o mcast.o common.o +OBJS = record-dvb.o dump-mcast.o $(COMMONOBJS) -all: record-dvb +all: record-dvb dump-mcast DEPEND=$(OBJS:.o=.d) -include $(DEPEND) -record-dvb: $(OBJS) +record-dvb: record-dvb.o $(COMMONOBJS) + +dump-mcast: dump-mcast.o $(COMMONOBJS) clean: rm -f record-dvb $(OBJS) $(DEPEND) diff --git a/dump-stream.c b/dump-stream.c new file mode 100644 index 0000000..1cbaad2 --- /dev/null +++ b/dump-stream.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mcast.h" + +#define CHUNKSIZE 1500 + +int main(int argc, char **argv) +{ + char *url; + int bytes, written, i; + int in; + char buffer[CHUNKSIZE]; + + if (argc == 2) { + url = argv[1]; + } else { + fprintf(stderr,"Syntax: %s URL\n", argv[0]); + exit(EXIT_FAILURE); + } + + if ((in = open_mcast(url)) < 0) { + fprintf(stderr,"Can't open url %s!\n",url); + exit(EXIT_FAILURE); + } + + while(1) { + if ((bytes = recv(in, buffer, CHUNKSIZE, 0)) < 1) { + perror("recv"); + exit(EXIT_FAILURE); + } + + written = 0; + do { + if ((i = write(STDOUT_FILENO, buffer, bytes-written)) < 0) { + perror("write"); + exit(EXIT_FAILURE); + } + written += i; + } while(written < bytes); + } + + close(in); + + return EXIT_SUCCESS; +}