Radio in analogtv plugin

Message ID 200505241620.20731.jareguero@telefonica.net
State New
Headers

Commit Message

Jose Alberto Reguero May 24, 2005, 2:20 p.m. UTC
  I am triying to make analogtv plugin with a pvr-350 to work with analog
radio. 
Here is a second patch.
When I play a radio recorded program the time that appear in vdr OSD is about 
1 minute for 1 hour of real time.
It is normal for radio recordings, or I am doing something wrong?
Thanks.
Jose Alberto
  

Patch

diff -aur /usr/local/src/analogtv/analogtv.c analogtv/analogtv.c
--- /usr/local/src/analogtv/analogtv.c	2005-01-12 09:28:55.000000000 +0100
+++ analogtv/analogtv.c	2005-04-03 22:55:11.000000000 +0200
@@ -303,6 +303,7 @@ 
   sc.backupHack = -1;
   sc.backupInterval = -1;
   sc.fastdigibox_change = -1;
+  fd_radio = -1;
 }
 
 cPluginAnalogtv::~cPluginAnalogtv()
diff -aur /usr/local/src/analogtv/device.c analogtv/device.c
--- /usr/local/src/analogtv/device.c	2005-01-17 12:28:52.000000000 +0100
+++ analogtv/device.c	2005-05-24 14:21:43.000000000 +0200
@@ -284,11 +284,17 @@ 
 
   firstVideoPts = 0;
 
-
-  if (pids[2] == -1) {
-    Apid = pids[1]; // ptAudio
-    Vpid = pids[0]; // ptVideo
-    Ppid = -1;      // ptPcr
+  if (fd_radio >= 0) {
+    Apid = pids[0];
+    Vpid = -1;
+    Ppid = -1;
+    dropAudio = false;
+    d(1, "NEW Audio-PID=%d", Apid);
+  }
+  else if (pids[2] == -1) {
+      Apid = pids[1]; // ptAudio
+      Vpid = pids[0]; // ptVideo
+      Ppid = -1;      // ptPcr
 
     d(1, "NEW Audio-PID=%d, Video-PID=%d", Apid, Vpid);
   }
@@ -300,12 +306,14 @@ 
   d(1, "NEW Audio-PID=%d, Video-PID=%d, PCR-PID=%d", Apid, Vpid, Ppid);
   }
 
+#if 0
   if (isPVR) {
     if (setPVRpids(Apid, Vpid, Ppid)) {
       d(0, "Cannot set Pids on PVR-card%s", ciao);
       return false;
     }
   }
+#endif
 
 #ifdef DBG
   log = fopen("/tmp/mpeg.log", "w");
diff -aur /usr/local/src/analogtv/player-analogtv.c analogtv/player-analogtv.c
--- /usr/local/src/analogtv/player-analogtv.c	2005-01-17 12:29:02.000000000 +0100
+++ analogtv/player-analogtv.c	2005-05-23 16:39:07.000000000 +0200
@@ -28,6 +28,7 @@ 
 #include <sys/soundcard.h>
 
 #include <transform.h>
+#include <ctools.h>
 extern void pes_in_ts(p2p *p);
 #undef MIN
 #undef MAX
@@ -40,6 +41,7 @@ 
 #define MAXRETRIES        3
 
 static p2p p2t;
+static p2t_t p2t_coque;
 
 static UC *rbuffer[NUM_BUFS];
 
@@ -863,6 +865,26 @@ 
   return cc;
 }
 
+UC   buffer_coque[BUFFSIZE];
+int  r_coque;
+
+void pes_filt_coque(p2p *p)
+{
+    int factor = p->mpeg-1;
+    int aux;
+
+    if ( p->cid == 0xc0) {
+      aux = p->plength+6;
+      memcpy(buffer_coque + r_coque, p->buf, aux);
+      r_coque += aux;
+    }
+}
+
+void twrite_coque(uint8_t const *buf)
+{
+    write_buffer((UC*)buf, TS_SIZE, &p2t);
+}
+
 int readPVR(int Apid, int Vpid)
 {
   register int  f, r = 0, rv, rmax = 0, cc = 0, i;
@@ -880,6 +902,7 @@ 
   p2t.vcounter = 0;
   p2t.count1 = 0;
   p2t.count0 = 0;
+  init_p2t(&p2t_coque,twrite_coque);
 
   while (ReaderLoopRunning) {
     if (dropPES) {
@@ -936,8 +959,16 @@ 
       pes++;
       spes += r;
 
-      if (r > 0)
-        get_pes(buffer, r, &p2t, pes_in_ts); // PES -> TS
+      if (r > 0) {
+        if (fd_radio >= 0) {
+          r_coque = 0;
+          get_pes(buffer, r, &p2t, pes_filt_coque); // SOLO AUDIO
+          if (r_coque > 0)
+            pes_to_ts(buffer_coque, r_coque, Apid, &p2t_coque); // PES -> TS
+        }
+        else
+          get_pes(buffer, r, &p2t, pes_in_ts); // PES -> TS
+      }
     }
   }
 
diff -aur /usr/local/src/analogtv/player-analogtv.h analogtv/player-analogtv.h
--- /usr/local/src/analogtv/player-analogtv.h	2005-01-12 09:28:55.000000000 +0100
+++ analogtv/player-analogtv.h	2005-05-17 14:11:02.000000000 +0200
@@ -171,6 +171,8 @@ 
 } CHANNELNAMES;
 
 
+_EXTERN int fd_radio;
+
 _EXTERN SETUP s, sx, sc, sy;
 
 _EXTERN char video_device[MAX_DEV_NAME];
Sólo en analogtv/: player-analogtv.o
diff -aur /usr/local/src/analogtv/pvr.c analogtv/pvr.c
--- /usr/local/src/analogtv/pvr.c	2005-01-12 09:28:55.000000000 +0100
+++ analogtv/pvr.c	2005-05-24 14:19:23.000000000 +0200
@@ -183,9 +183,27 @@ 
       }
 
       if (opts & FREQUENCY) {
+        if (freq < 108000) {
+          if (fd_radio == -1) {
+            fd_radio = open ("/dev/radio",O_RDONLY);
+          }
+            freq = int((freq/1000.0f + .5/16) * 16);
+        }
+        else {
+          if (fd_radio >=0) {
+            close (fd_radio);
+            fd_radio = -1;
+          }
+          ofs = (ofs - 16) * FREQDELTA; // 16 is "ground zero"
+
+          freq = (freq + ofs) * 16 / 1000;
+        }
+        
+#if 0
         ofs = (ofs - 16) * FREQDELTA; // 16 is "ground zero"
 
         freq = (freq + ofs) * 16 / 1000;
+#endif
 
         memset(&vf, 0, sizeof(f));
         vf.tuner = analogModule; // FIXME??