fix showiframe.
authorchang <chang@dev3>
Wed, 9 Jan 2013 04:34:32 +0000 (13:34 +0900)
committerchang <chang@dev3>
Thu, 10 Jan 2013 08:19:09 +0000 (17:19 +0900)
meta-openvuplus/recipes-vuplus/showiframe/showiframe.bb [new file with mode: 0755]
meta-openvuplus/recipes-vuplus/showiframe/showiframe/showiframe.c [new file with mode: 0644]
meta-openvuplus/recipes-vuplus/showiframe/showiframe_1.8.bb [deleted file]

diff --git a/meta-openvuplus/recipes-vuplus/showiframe/showiframe.bb b/meta-openvuplus/recipes-vuplus/showiframe/showiframe.bb
new file mode 100755 (executable)
index 0000000..8a4eae1
--- /dev/null
@@ -0,0 +1,21 @@
+DESCRIPTION = "Small utilities specific to the Vuplus dvb receiver (for DVB v3)"
+SECTION = "base"
+PRIORITY = "optional"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://showiframe.c;md5=496e2fde81bc40a9879de703aa926fd6"
+
+PV = "1.81"
+PR = "r2"
+
+SRC_URI = "file://showiframe.c"
+
+S = "${WORKDIR}"
+
+do_compile() {
+        ${CC} -o showiframe showiframe.c
+}
+
+do_install() {
+        install -d ${D}/${bindir}/
+        install -m 0755 ${S}/showiframe ${D}/${bindir}/
+}
diff --git a/meta-openvuplus/recipes-vuplus/showiframe/showiframe/showiframe.c b/meta-openvuplus/recipes-vuplus/showiframe/showiframe/showiframe.c
new file mode 100644 (file)
index 0000000..3c99f73
--- /dev/null
@@ -0,0 +1,93 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+
+#include <linux/dvb/video.h>
+
+void c(int a)
+{
+       if (a < 0)
+       {
+               perror("ioctl");
+               exit(6);
+       }
+}
+
+int main(int argc, char **argv)
+{
+       struct stat s;
+       if (argc != 2)
+       {
+               printf("usage: %s <iframe>\n", *argv);
+               return 3;
+       }
+
+       int f = open(argv[1], O_RDONLY);
+       if (f < 0)
+       {
+               perror(argv[1]);
+               return 4;
+       }
+       fstat(f, &s);
+
+       int fd = open("/dev/dvb/adapter0/video0", O_WRONLY|O_NONBLOCK);
+
+       if (fd <= 0)
+       {
+               perror("/dev/dvb/adapter0/video0");
+               return 2;
+       }
+       else if (fork() != 0)
+               return 0;
+       else
+       {
+               size_t pos=0;
+               int seq_end_avail = 0;
+
+               int count = 7;
+               /* 0x0 0x0 0x1 0xffffffe0 0x10 0x8 0xffffff80 0xffffff80 0x5 0x21 0x0 0x1 0x0 0x1 */
+               
+               /* unsigned char pes_header[] = { 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x80, 0x00, 0x00 }; */
+
+               unsigned char pes_header[] = {0x0, 0x0, 0x1, 0xe0, 0x00, 0x00, 0x80, 0x80, 0x5, 0x21, 0x0, 0x1, 0x0, 0x1};
+               
+               unsigned char seq_end[] = { 0x00, 0x00, 0x01, 0xB7 };
+               unsigned char iframe[s.st_size];
+               unsigned char stuffing[8192];
+               memset(stuffing, 0, 8192);
+               read(f, iframe, s.st_size);
+               ioctl(fd, VIDEO_SET_STREAMTYPE, 0); // set to mpeg2
+               c(ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY));
+               c(ioctl(fd, VIDEO_PLAY));
+               c(ioctl(fd, VIDEO_CONTINUE));
+               c(ioctl(fd, VIDEO_CLEAR_BUFFER));
+               while(pos <= (s.st_size-4) && !(seq_end_avail = (!iframe[pos] && !iframe[pos+1] && iframe[pos+2] == 1 && iframe[pos+3] == 0xB7)))
+                       ++pos;
+               while(count--){
+                       if ((iframe[3] >> 4) != 0xE) // no pes header
+                       {
+                               write(fd, pes_header, sizeof(pes_header));
+                               usleep(8000);
+                       }
+                       else {
+                               iframe[4] = iframe[5] = 0x00;
+                       }
+                       write(fd, iframe, s.st_size);
+                       usleep(8000);
+               }
+               if (!seq_end_avail)
+                       write(fd, seq_end, sizeof(seq_end));
+               write(fd, stuffing, 8192);
+               usleep(150000);
+               c(ioctl(fd, VIDEO_STOP, 0));
+               c(ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX));
+       }
+       return 0;
+}
+
diff --git a/meta-openvuplus/recipes-vuplus/showiframe/showiframe_1.8.bb b/meta-openvuplus/recipes-vuplus/showiframe/showiframe_1.8.bb
deleted file mode 100644 (file)
index 1176e31..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-SUMMARY = "Displays an IFrame using a LinuxTV video decoder"
-SECTION = "base"
-LICENSE = "GPLv2"
-LIC_FILES_CHKSUM = "file://src/showiframe.c;endline=10;md5=513a8a3c6a14de8ef311dfa25fb0eaa6"
-PR = "r1"
-
-SRCREV = "f19e4b573ba755ca6300df72b0736e98c967aba5"
-
-inherit autotools opendreambox-git