updated transtreamproxy and removed filestreamproxy.
[vuplus_openembedded] / recipes / enigma2 / enigma2-transtreamproxy / transcoding.patch
diff --git a/recipes/enigma2/enigma2-transtreamproxy/transcoding.patch b/recipes/enigma2/enigma2-transtreamproxy/transcoding.patch
deleted file mode 100644 (file)
index e730924..0000000
+++ /dev/null
@@ -1,336 +0,0 @@
-diff --git a/src/streamproxy.c b/src/streamproxy.c
-index 03d1fac..f999982 100644
---- a/src/streamproxy.c
-+++ b/src/streamproxy.c
-@@ -8,6 +8,7 @@
- #include <sys/ioctl.h>
- #include <linux/dvb/dmx.h>
- #include <linux/dvb/version.h>
-+#include <errno.h>
- #define MAX_PIDS 32
- #define MAX_LINE_LENGTH 512
-@@ -41,6 +42,25 @@ char *reason = "";
- int active_pids[MAX_PIDS];
-+int g_video_pid = 0;
-+int g_audio_pid = 0;
-+int g_pcr_pid = 0;
-+int g_pmt_pid = 0;
-+
-+struct proc_dmx_pid
-+{
-+      char *proc_path;
-+      char *str_match;        
-+      int pid;
-+};
-+
-+struct proc_dmx_pid proc_dmx_setup[] = {
-+      {"/proc/stb/encoder/0/video_pid", "video", 0},
-+      {"/proc/stb/encoder/0/audio_pid", "audio", 0},
-+      {"/proc/stb/encoder/0/pcr_pid", "pcr", 0},
-+      {"/proc/stb/encoder/0/pmt_pid", "pmt", 0},
-+};
-+
- int handle_upstream(void);
- int handle_upstream_line(void);
-@@ -70,7 +90,8 @@ int main(int argc, char **argv)
-       int i;
-       for (i=0; i<MAX_PIDS; ++i)
-               active_pids[i] = -1;
--      
-+
-+                      
-       while (1)
-       {
-               char option[MAX_LINE_LENGTH];
-@@ -102,9 +123,14 @@ int main(int argc, char **argv)
-               goto bad_gateway;
-       }
-+      memset(upstream_request, 0, 256);
-+      
-       snprintf(upstream_request, sizeof(upstream_request), "GET /web/stream?StreamService=%s HTTP/1.0\r\n%s\r\n", service_ref, authorization);
-+
-+      
-       if (write(upstream, upstream_request, strlen(upstream_request)) != strlen(upstream_request))
-               goto bad_gateway;
-+
-       
-       while (1)
-       {
-@@ -116,22 +142,33 @@ int main(int argc, char **argv)
-                       FD_SET(demux_fd, &r);
-               
-               if (select(5, &r, 0, 0, 0) < 0)
-+              {
-                       break;
-+              }
-               if (FD_ISSET(0, &r)) /* check for client disconnect */
-                       if (read(0, request, sizeof(request)) <= 0)
-+                      {
-                               break;
-+                      }
-               
-                               /* handle enigma responses */
-               if (FD_ISSET(upstream, &r))
-                       if (handle_upstream())
-+                      {
-                               break;
-+                      }
-               if (demux_fd > 0 && FD_ISSET(demux_fd, &r))
-               {
-                       static unsigned char buffer[BSIZE];
-                       int r = read(demux_fd, buffer, BSIZE);
--                      if (r < 0)
--                              break;
-+                      if (r < 0 )
-+                      {
-+                              if(errno == EOVERFLOW)
-+                                      continue;
-+                              else
-+                                      break;
-+                      }
-                       write(1, buffer, r);
-               }
-       }
-@@ -153,6 +190,7 @@ bad_gateway:
- int handle_upstream(void)
- {
-       char buffer[MAX_LINE_LENGTH];
-+      memset(buffer, 0, MAX_LINE_LENGTH);
-       int n = read(upstream, buffer, MAX_LINE_LENGTH);
-       if (n == 0)
-               return 1;
-@@ -165,6 +203,7 @@ int handle_upstream(void)
-       
-       char *c = buffer;
-       
-+      
-       while (n)
-       {
-               char *next_line;
-@@ -203,6 +242,9 @@ int handle_upstream(void)
- int handle_upstream_line(void)
- {
-+      int i;
-+      const char *str;
-+
-       switch (upstream_state)
-       {
-       case 0:
-@@ -229,104 +271,137 @@ int handle_upstream_line(void)
-               if (response_line[0] == '+') {
-                                       /* parse (and possibly open) demux */
-                       int demux = atoi(response_line + 1);
--                      
-+                      {
-+                              FILE *f = fopen("/proc/stb/encoder/0/demux", "w");
-+                              if(f)
-+                              {
-+                                      fprintf(f, "%d\n", demux);
-+                                      fclose(f);
-+                              }
-+                      }
--                                      /* parse new pids */
--                      const char *p = strchr(response_line, ':');
--                      int old_active_pids[MAX_PIDS];
--                      
--                      memcpy(old_active_pids, active_pids, sizeof(active_pids));
--                      
--                      int nr_pids = 0, i, j;
--                      while (p)
-+                      for(i = 0 ; i < sizeof(proc_dmx_setup)/sizeof(proc_dmx_setup[0]) ; i++)
-                       {
--                              ++p;
--                              int pid = strtoul(p, 0, 0x10);
--                              p = strchr(p, ',');
-+                              str = strstr(response_line, proc_dmx_setup[i].str_match);
-+                              if(str)
-+                              {
-+                                      while(*str != ',') str--;
-+                                      proc_dmx_setup[i].pid = strtoul(str+1, 0, 0x10);                        
-+                                      FILE *f = fopen(proc_dmx_setup[i].proc_path, "w");
-+                                      if(f)
-+                                      {
-+                                              fprintf(f, "%d\n", proc_dmx_setup[i].pid);
-+                                              fclose(f);
-+                                      }
-+                              }
-                               
--                                      /* do not add pids twice */
--                              for (i = 0; i < nr_pids; ++i)
--                                      if (active_pids[i] == pid)
--                                              break;
-+                      }
--                              if (i != nr_pids)
--                                      continue;
--                              active_pids[nr_pids++] = pid;
-+                      if(proc_dmx_setup[3].pid && ( (g_video_pid != proc_dmx_setup[0].pid) || (g_audio_pid != proc_dmx_setup[1].pid) || (g_pcr_pid != proc_dmx_setup[2].pid)) )
-+                      {
-+                              g_video_pid = proc_dmx_setup[0].pid;
-+                              g_audio_pid = proc_dmx_setup[1].pid;
-+                              g_pcr_pid = proc_dmx_setup[2].pid;
-+
-+
-+                              /* parse new pids */
-+                              const char *p = strchr(response_line, ':');
-+                              int old_active_pids[MAX_PIDS];
-                               
--                              if (nr_pids == MAX_PIDS)
--                                      break;
--                      }
--                      
--                      for (i = nr_pids; i < MAX_PIDS; ++i)
--                              active_pids[i] = -1;
-+                              memcpy(old_active_pids, active_pids, sizeof(active_pids));
-                               
--                                      /* check for added pids */
--                      for (i = 0; i < nr_pids; ++i)
--                      {
--                              for (j = 0; j < MAX_PIDS; ++j)
--                                      if (active_pids[i] == old_active_pids[j])
-+                              int nr_pids = 0, i, j;
-+                              while (p)
-+                              {
-+                                      ++p;
-+                                      int pid = strtoul(p, 0, 0x10);
-+                                      p = strchr(p, ',');
-+                                      
-+                                              /* do not add pids twice */
-+                                      for (i = 0; i < nr_pids; ++i)
-+                                              if (active_pids[i] == pid)
-+                                                      break;
-+
-+                                      if (i != nr_pids)
-+                                              continue;
-+
-+                                      active_pids[nr_pids++] = pid;
-+                                      
-+                                      if (nr_pids == MAX_PIDS)
-                                               break;
--                              if (j == MAX_PIDS) {
--                                      if (demux_fd < 0) {
--                                              struct dmx_pes_filter_params flt; 
--                                              char demuxfn[32];
--                                              sprintf(demuxfn, "/dev/dvb/adapter0/demux%d", demux);
--                                              demux_fd = open(demuxfn, O_RDWR | O_NONBLOCK);
-+                              }
-+                              
-+                              for (i = nr_pids; i < MAX_PIDS; ++i)
-+                                      active_pids[i] = -1;
-+                                      
-+                                              /* check for added pids */
-+                              for (i = 0; i < nr_pids; ++i)
-+                              {
-+                                      for (j = 0; j < MAX_PIDS; ++j)
-+                                              if (active_pids[i] == old_active_pids[j])
-+                                                      break;
-+                                      if (j == MAX_PIDS) {
-                                               if (demux_fd < 0) {
--                                                      reason = "DEMUX OPEN FAILED";
--                                                      return 2;
--                                              }
-+                                                      struct dmx_pes_filter_params flt; 
-+                                                      char demuxfn[32];
-+                                                      sprintf(demuxfn, "/dev/dvb/adapter0/demux%d", demux);
-+                                                      demux_fd = open(demuxfn, O_RDWR | O_NONBLOCK);
-+                                                      if (demux_fd < 0) {
-+                                                              reason = "DEMUX OPEN FAILED";
-+                                                              return 2;
-+                                                      }
--                                              ioctl(demux_fd, DMX_SET_BUFFER_SIZE, 1024*1024);
-+                                                      ioctl(demux_fd, DMX_SET_BUFFER_SIZE, 1024*1024);
--                                              flt.pid = active_pids[i];
--                                              flt.input = DMX_IN_FRONTEND;
-+                                                      flt.pid = active_pids[i];
-+                                                      flt.input = DMX_IN_FRONTEND;
- #if DVB_API_VERSION > 3
--                                              flt.output = DMX_OUT_TSDEMUX_TAP;
--                                              flt.pes_type = DMX_PES_OTHER;
-+                                                      flt.output = DMX_OUT_TSDEMUX_TAP;
-+                                                      flt.pes_type = DMX_PES_OTHER;
- #else
--                                              flt.output = DMX_OUT_TAP;
--                                              flt.pes_type = DMX_TAP_TS;
-+                                                      flt.output = DMX_OUT_TAP;
-+                                                      flt.pes_type = DMX_TAP_TS;
- #endif
--                                              flt.flags = DMX_IMMEDIATE_START;
-+                                                      flt.flags = DMX_IMMEDIATE_START;
--                                              if (ioctl(demux_fd, DMX_SET_PES_FILTER, &flt) < 0) {
--                                                      reason = "DEMUX PES FILTER SET FAILED";
--                                                      return 2;
-+                                                      if (ioctl(demux_fd, DMX_SET_PES_FILTER, &flt) < 0) {
-+                                                              reason = "DEMUX PES FILTER SET FAILED";
-+                                                              return 2;
-+                                                      }
-                                               }
--                                      }
--                                      else {
--                                              uint16_t pid = active_pids[i];
--                                              int ret;
-+                                              else {
-+                                                      uint16_t pid = active_pids[i];
-+                                                      int ret;
- #if DVB_API_VERSION > 3
--                                              ret = ioctl(demux_fd, DMX_ADD_PID, &pid);
-+                                                      ret = ioctl(demux_fd, DMX_ADD_PID, &pid);
- #else
--                                              ret = ioctl(demux_fd, DMX_ADD_PID, pid);
-+                                                      ret = ioctl(demux_fd, DMX_ADD_PID, pid);
- #endif
--                                              if (ret < 0) {
--                                                      reason = "DMX_ADD_PID FAILED";
--                                                      return 2;
-+                                                      if (ret < 0) {
-+                                                              reason = "DMX_ADD_PID FAILED";
-+                                                              return 2;
-+                                                      }
-                                               }
-                                       }
-                               }
--                      }
--                      
--                                      /* check for removed pids */
--                      for (i = 0; i < MAX_PIDS; ++i)
--                      {
--                              if (old_active_pids[i] == -1)
--                                      continue;
--                              for (j = 0; j < nr_pids; ++j)
--                                      if (old_active_pids[i] == active_pids[j])
--                                              break;
--                              if (j == nr_pids) {
-+                              
-+                                              /* check for removed pids */
-+                              for (i = 0; i < MAX_PIDS; ++i)
-+                              {
-+                                      if (old_active_pids[i] == -1)
-+                                              continue;
-+                                      for (j = 0; j < nr_pids; ++j)
-+                                              if (old_active_pids[i] == active_pids[j])
-+                                                      break;
-+                                      if (j == nr_pids) {
- #if DVB_API_VERSION > 3
--                                      uint16_t pid = old_active_pids[i];
--                                      ioctl(demux_fd, DMX_REMOVE_PID, &pid);
-+                                              uint16_t pid = old_active_pids[i];
-+                                              ioctl(demux_fd, DMX_REMOVE_PID, &pid);
- #else
--                                      ioctl(demux_fd, DMX_REMOVE_PID, old_active_pids[i]);
-+                                              ioctl(demux_fd, DMX_REMOVE_PID, old_active_pids[i]);
- #endif
-+                                      }
-                               }
-                       }
-                       if (upstream_state == 2) {