first try, added Makefile
authorhackbard <hackbard>
Fri, 13 Dec 2002 19:16:59 +0000 (19:16 +0000)
committerhackbard <hackbard>
Fri, 13 Dec 2002 19:16:59 +0000 (19:16 +0000)
Makefile [new file with mode: 0644]
dmsd.c
dmsd.h

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..f61c666
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,13 @@
+# Makefile of dmsd
+
+INCLUDEDIR = /usr/include
+
+CFLAGS = -O3 -Wall
+LIBS =
+
+OBJS = dmsd
+
+all: dmsd
+
+clean:
+       rm $(OBJS)
diff --git a/dmsd.c b/dmsd.c
index 8c29f52..6154927 100644 (file)
--- a/dmsd.c
+++ b/dmsd.c
@@ -7,6 +7,12 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 
 #include "dmsd.h"
 
@@ -17,15 +23,20 @@ int main(int argc,char *argv[]) {
   /* pid's */
   int vpid,apid;
   /* ip */
-  sockaddr_in dbox_addr;
+  struct sockaddr_in dbox_addr;
+  /* some ints */
+  int status,recvd_bytes;
 
   if(argc!=4) {
     printf("usage: %s <video pid> <audio pid> <dbox ip address>\n",argv[1]);
     return -1;
   }
 
-  sscanf(argv[2],"%x",vpid);
-  sscanf(argv[3],"%x",apid);
+  //sscanf(argv[1],"%x",vpid);
+  vpid=atoi(argv[1]);
+  //sscanf(argv[2],"%x",apid);
+  apid=atoi(argv[2]);
+
   printf("using video pid %x & audio pid %x ...\n",vpid,apid);
 
   if((v_fd=socket(AF_INET,SOCK_STREAM,0)) == -1) {
@@ -39,10 +50,25 @@ int main(int argc,char *argv[]) {
 
   memset(&dbox_addr,0,sizeof(dbox_addr));
   dbox_addr.sin_family=AF_INET;
-  target_addr.sin_port=htons(DBOX2_TS_PORT));
-  target_addr.sin_addr.s_addr=inet_addr(argv[4]);
+  dbox_addr.sin_port=htons(DBOX2_TS_PORT);
+  dbox_addr.sin_addr.s_addr=inet_addr(argv[3]);
 
   if(connect(v_fd,(struct sockaddr *)&dbox_addr,sizeof(dbox_addr))==-1) {
+    printf("unable to connect. (video pid)\n");
+    perror("connect");
+    exit(1);
+  }
+
+  dprintf(v_fd,"GET /%x HTTP/1.0\r\n\r\n",vpid);
 
+  status=1; 
+  while(status) {
+    unsigned char buf[BUFFER_LENGTH];
+
+    status=recv(v_fd,buf,sizeof(buf),0);
+    write(1,buf,status);
+  }
+  
+  return 0;
 }
 
diff --git a/dmsd.h b/dmsd.h
index eda770b..1200b9c 100644 (file)
--- a/dmsd.h
+++ b/dmsd.h
@@ -9,7 +9,11 @@
 #define DMSD_H
 #endif
 
+#define _GNU_SOURCE
+
 #ifdef DMSD_H
-#define DBOX2_TS_PORT 31338
+#define DBOX2_TS_PORT 31339
+#define BUFFER_LENGTH 188
+#define TS_LENGTH 192;
 #endif