]> cvs.zerfleddert.de Git - record-dvb/commitdiff
add dump-mcast for dumping multicast-streams to stdout
authormichael <michael>
Sat, 1 Jul 2006 18:22:56 +0000 (18:22 +0000)
committermichael <michael>
Sat, 1 Jul 2006 18:22:56 +0000 (18:22 +0000)
.cvsignore
Makefile
dump-stream.c [new file with mode: 0644]

index 5a75ec11e3212ad96625882cf1102d54b9bf3caa..7cbdd82cf59d4a40ef625283f1951ab6ebac8f5b 100644 (file)
@@ -1,2 +1,3 @@
 record-dvb
 record-dvb
+dump-mcast
 *.d
 *.d
index f3306cee8f65d61413dfa155b1398ff10b446ebe..74c1037c2ebc8a6ccca4f46c9cde57e1039354c7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,16 @@
 CFLAGS =-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -Wall -g
 
 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)
 
 
 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)
 
 clean:
        rm -f record-dvb $(OBJS) $(DEPEND)
diff --git a/dump-stream.c b/dump-stream.c
new file mode 100644 (file)
index 0000000..1cbaad2
--- /dev/null
@@ -0,0 +1,55 @@
+#include <features.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <strings.h>
+
+#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;
+}
Impressum, Datenschutz