SourceCaps patch for VDR 1.3.33.

Message ID 433910D0.3040207@icem.com
State New
Headers

Commit Message

Carsten Koch Sept. 27, 2005, 9:28 a.m. UTC
  The attached patch allows a VDR system with multiple
cards to attach each card to an individual dish
pointing at a different satellite.

I have 3 DVB cards in my VDR system:

1) FF card connected to one output of LNB at a dish
      pointed at Astra 19.2E.

2) budget card connected to another output of LNB at a dish
      pointed at Astra 19.2E.

3) budget card connected to output of LNB at a dish
      pointed at Eutelsat 13.0E.

I am using the following entries for that in my setup.conf:

SourceCaps = 1 S19.2E
SourceCaps = 2 S19.2E
SourceCaps = 3 S13.0E
  

Comments

Andreas Brugger Sept. 28, 2005, 3:25 p.m. UTC | #1
Hi!

Carsten Koch schrieb:

> The attached patch allows a VDR system with multiple
> cards to attach each card to an individual dish
> pointing at a different satellite.

Thank you for the great patch, but with this version I get the following 
on a plain vdr-1.3.33:
(BTW, if you wonder about the naming: it is really your patch ... I just 
renamed it)

> vdrNG vdr_plain # cat ../VDR/PATCHES/vdr-1.3.33-SourceCaps.patch | 
> patch -p1 --dry-run
> patching file config.c
> Hunk #1 FAILED at 15.
> Hunk #2 FAILED at 301.
> Hunk #3 FAILED at 404.
> Hunk #4 FAILED at 504.
> Hunk #5 FAILED at 570.
> 5 out of 5 hunks FAILED -- saving rejects to file config.c.rej
> patching file config.h
> Hunk #1 FAILED at 30.
> Hunk #2 FAILED at 201.
> Hunk #3 FAILED at 257.
> 3 out of 3 hunks FAILED -- saving rejects to file config.h.rej
> patching file device.c
> Hunk #1 FAILED at 174.
> Hunk #2 FAILED at 315.
> 2 out of 2 hunks FAILED -- saving rejects to file device.c.rej
> patching file device.h
> Hunk #1 FAILED at 23.
> Hunk #2 FAILED at 132.
> Hunk #3 FAILED at 141.
> 3 out of 3 hunks FAILED -- saving rejects to file device.h.rej
> patching file dvbdevice.c
> Hunk #1 FAILED at 754.
> 1 out of 1 hunk FAILED -- saving rejects to file dvbdevice.c.rej
  
Carsten Koch Sept. 28, 2005, 5:31 p.m. UTC | #2
Andreas Brugger wrote:
...
> Thank you for the great patch, but with this version I get the following 
> on a plain vdr-1.3.33:
...
>> Hunk #1 FAILED at 15.

I tested it again here. Works just fine:

/tmp/vdr-1.3.33> patch <../SourceCaps-1.3.33.patch
patching file config.c
patching file config.h
patching file device.c
patching file device.h
patching file dvbdevice.c
/tmp/vdr-1.3.33> ls -l ../SourceCaps-1.3.33.patch
-rw-r--r--  1 cko users 7355 Sep 26 20:01 ../SourceCaps-1.3.33.patch

Is your SourceCaps-1.3.33.patch 7355 bytes long?

Carsten.
  
Andreas Brugger Sept. 28, 2005, 6:07 p.m. UTC | #3
Carsten Koch schrieb:

> I tested it again here. Works just fine: 

Very funny thing. If I copy the patch-file from the message, I get an 
other patch than if I copy the text in the message ... This has to be a 
bug of Thunderbird (win-version) or samba or I don't know. Maybe it's 
just another format ...
Now it worked.

>
> Is your SourceCaps-1.3.33.patch 7355 bytes long?

If I copy the file it is 7559 Bytes, if I copy the text of the patch and 
paste it to a file it is 7358 Bytes ...
Maybe I'm just too tired today. ;-)

Thanks for the help.
  
Luca Olivetti Sept. 28, 2005, 7:43 p.m. UTC | #4
En/na Andreas Brugger ha escrit:
> Carsten Koch schrieb:
> 
>> I tested it again here. Works just fine: 
> 
> 
> Very funny thing. If I copy the patch-file from the message, I get an
> other patch than if I copy the text in the message ... This has to be a
> bug of Thunderbird (win-version) or samba or I don't know.

If you "save as.." the attached file, you should get the same file, no
matter if it is windows or linux. If you copy and paste under windows
you'll get a different file (windows uses cr+lf as a line terminator
while unix just uses lf).

Bye
  
Udo Richter Sept. 28, 2005, 11:18 p.m. UTC | #5
Luca Olivetti wrote:
> If you "save as.." the attached file, you should get the same file, no
> matter if it is windows or linux. 

Unfortunately, not. If the file is attached as plain text, eg. not 
base64 encoded, then line endings may be converted to platform default, 
and may even be converted while passing through mail servers.

However, GNU patch is smart enough to detect CRLF diffs and and to 
convert them to proper LF diffs.

The only safe way is to attach it as .diff.gz to force base64 encoding.

Cheers,

Udo
  
Klaus Schmidinger Sept. 29, 2005, 6:27 a.m. UTC | #6
Udo Richter wrote:
> Luca Olivetti wrote:
> 
>> If you "save as.." the attached file, you should get the same file, no
>> matter if it is windows or linux. 
> 
> 
> Unfortunately, not. If the file is attached as plain text, eg. not 
> base64 encoded, then line endings may be converted to platform default, 
> and may even be converted while passing through mail servers.
> 
> However, GNU patch is smart enough to detect CRLF diffs and and to 
> convert them to proper LF diffs.
> 
> The only safe way is to attach it as .diff.gz to force base64 encoding.
> 
> Cheers,
> 
> Udo

If somebody posts a patch for plain VDR, please do it as a plain text
diff file attachment. This allows me to see it directly in the mail
reader, without having to extract and unzip it first. It also allows me
to search my mailbox in case I'm looking for things to do, and reach
into the diff attachments. If I have to first extract and unzip a diff,
I tend to postpone it to later... ;-)

Klaus
  

Patch

diff -ur vdr-1.3.33/config.c vdr-1.3.33+SourceCaps/config.c
--- vdr-1.3.33/config.c	2005-09-09 17:08:59.000000000 +0200
+++ vdr-1.3.33+SourceCaps/config.c	2005-09-25 20:25:45.869496656 +0200
@@ -15,6 +15,7 @@ 
 #include "interface.h"
 #include "plugin.h"
 #include "recording.h"
+#include "sources.h"
 
 // IMPORTANT NOTE: in the 'sscanf()' calls there is a blank after the '%d'
 // format characters in order to allow any number of blanks after a numeric
@@ -300,6 +301,8 @@ 
   MultiSpeedMode = 0;
   ShowReplayMode = 0;
   ResumeID = 0;
+  memset(SourceCaps, 0, sizeof SourceCaps);
+  SourceCapsSet = false;
   CurrentChannel = -1;
   CurrentVolume = MAXVOLUME;
   CurrentDolby = 0;
@@ -401,6 +404,49 @@ 
   return true;
 }
 
+void cSetup::StoreSourceCaps(const char *Name)
+{
+  cSetupLine *l;
+  while ((l = Get(Name)) != NULL)
+        Del(l);
+
+  for (int i = 0; i < MAXDEVICES; i++) {
+      char buffer[MAXPARSEBUFFER]={0,}, *q = buffer;
+      int j = 0;
+      while (SourceCaps[i][j] && j < MAXSOURCECAPS) {
+            if (j==0) 
+               q += snprintf(buffer, sizeof(buffer), "%i ", i+1);
+            q += snprintf(q, sizeof(buffer) - (q-buffer), "%s ", *cSource::ToString(SourceCaps[i][j++]));
+      }
+      if (*buffer)
+         Store(Name, buffer, NULL, true);
+      }
+}
+
+bool cSetup::ParseSourceCaps(const char *Value)
+{
+  char *p;
+  int d = strtol(Value, &p, 10)-1, i = 0;
+  while (p < Value+strlen(Value)) {
+     	if (*p==0) return true;
+     	if (isblank(*p)) ++p;
+     	if (isalpha(*p)) {
+	   int source = cSource::FromString(p);
+	   if (source != cSource::stNone) {
+	      SourceCaps[d][i++] = source;
+	      SourceCapsSet = true;
+	      }
+	   else
+	      return false;
+	   while (!isblank(*p) && *p)
+		 ++p;
+	   if (i>MAXSOURCECAPS) 
+	      return false;
+     	   }
+        }
+  return true;
+}
+
 bool cSetup::Parse(const char *Name, const char *Value)
 {
   if      (!strcasecmp(Name, "OSDLanguage"))         OSDLanguage        = atoi(Value);
@@ -458,6 +504,7 @@ 
   else if (!strcasecmp(Name, "MultiSpeedMode"))      MultiSpeedMode     = atoi(Value);
   else if (!strcasecmp(Name, "ShowReplayMode"))      ShowReplayMode     = atoi(Value);
   else if (!strcasecmp(Name, "ResumeID"))            ResumeID           = atoi(Value);
+  else if (!strcasecmp(Name, "SourceCaps"))          return ParseSourceCaps(Value);
   else if (!strcasecmp(Name, "CurrentChannel"))      CurrentChannel     = atoi(Value);
   else if (!strcasecmp(Name, "CurrentVolume"))       CurrentVolume      = atoi(Value);
   else if (!strcasecmp(Name, "CurrentDolby"))        CurrentDolby       = atoi(Value);
@@ -523,6 +570,7 @@ 
   Store("MultiSpeedMode",     MultiSpeedMode);
   Store("ShowReplayMode",     ShowReplayMode);
   Store("ResumeID",           ResumeID);
+  if (SourceCapsSet) StoreSourceCaps("SourceCaps");
   Store("CurrentChannel",     CurrentChannel);
   Store("CurrentVolume",      CurrentVolume);
   Store("CurrentDolby",       CurrentDolby);
diff -ur vdr-1.3.33/config.h vdr-1.3.33+SourceCaps/config.h
--- vdr-1.3.33/config.h	2005-09-14 18:04:09.000000000 +0200
+++ vdr-1.3.33+SourceCaps/config.h	2005-09-25 20:25:45.871496352 +0200
@@ -30,6 +30,9 @@ 
 #define MINOSDHEIGHT 324
 #define MAXOSDHEIGHT 567
 
+#define MAXDEVICES         16 // the maximum number of devices in the system
+#define MAXSOURCECAPS     128 // the maximum number of different sources per device
+
 #define MaxFileName 256
 #define MaxSkinName 16
 #define MaxThemeName 16
@@ -198,6 +201,8 @@ 
   void StoreLanguages(const char *Name, int *Values);
   bool ParseLanguages(const char *Value, int *Values);
   bool Parse(const char *Name, const char *Value);
+  void StoreSourceCaps(const char *Name);
+  bool ParseSourceCaps(const char *Value);
   cSetupLine *Get(const char *Name, const char *Plugin = NULL);
   void Store(const char *Name, const char *Value, const char *Plugin = NULL, bool AllowMultiple = false);
   void Store(const char *Name, int Value, const char *Plugin = NULL);
@@ -252,6 +257,8 @@ 
   int MultiSpeedMode;
   int ShowReplayMode;
   int ResumeID;
+  int SourceCaps[MAXDEVICES][MAXSOURCECAPS];
+  bool SourceCapsSet;
   int CurrentChannel;
   int CurrentVolume;
   int CurrentDolby;
diff -ur vdr-1.3.33/device.c vdr-1.3.33+SourceCaps/device.c
--- vdr-1.3.33/device.c	2005-09-17 16:29:44.000000000 +0200
+++ vdr-1.3.33+SourceCaps/device.c	2005-09-25 20:25:45.873496048 +0200
@@ -174,8 +174,10 @@ 
   for (int i = 0; i < MAXRECEIVERS; i++)
       receiver[i] = NULL;
 
-  if (numDevices < MAXDEVICES)
+  if (numDevices < MAXDEVICES) {
      device[numDevices++] = this;
+     SetSourceCaps(cardIndex);
+     }
   else
      esyslog("ERROR: too many devices!");
 }
@@ -313,6 +315,17 @@ 
   return d;
 }
 
+void cDevice::SetSourceCaps(int Index)
+{
+  for (int d = 0; d < numDevices; d++) {
+      if (Index < 0 || Index == device[d]->CardIndex()) {
+	 for (int i = 0; i < MAXSOURCECAPS; i++)
+	     device[d]->sourceCaps[i] = Setup.SourceCaps[device[d]->CardIndex()][i];
+	 }
+      }
+}
+
+
 void cDevice::Shutdown(void)
 {
   primaryDevice = NULL;
Only in vdr-1.3.33+SourceCaps: device.c.orig
diff -ur vdr-1.3.33/device.h vdr-1.3.33+SourceCaps/device.h
--- vdr-1.3.33/device.h	2005-09-17 16:29:28.000000000 +0200
+++ vdr-1.3.33+SourceCaps/device.h	2005-09-25 20:25:45.874495896 +0200
@@ -23,7 +23,6 @@ 
 #include "thread.h"
 #include "tools.h"
 
-#define MAXDEVICES         16 // the maximum number of devices in the system
 #define MAXPIDHANDLES      64 // the maximum number of different PIDs per device
 #define MAXRECEIVERS       16 // the maximum number of receivers per device
 #define MAXVOLUME         255
@@ -133,6 +132,8 @@ 
          ///< given Priority.
          ///< See ProvidesChannel() for more information on how
          ///< priorities are handled, and the meaning of NeedsDetachReceivers.
+  static void SetSourceCaps(int Index = -1);
+	 ///< Sets the SourceCaps of the given device according to the Setup data.
   static void Shutdown(void);
          ///< Closes down all devices.
          ///< Must be called at the end of the program.
@@ -140,6 +141,7 @@ 
   static int nextCardIndex;
   int cardIndex;
 protected:
+  int sourceCaps[MAXSOURCECAPS];
   cDevice(void);
   virtual ~cDevice();
   virtual bool Ready(void);
diff -ur vdr-1.3.33/dvbdevice.c vdr-1.3.33+SourceCaps/dvbdevice.c
--- vdr-1.3.33/dvbdevice.c	2005-08-21 11:17:20.000000000 +0200
+++ vdr-1.3.33+SourceCaps/dvbdevice.c	2005-09-25 20:25:45.876495592 +0200
@@ -754,10 +754,17 @@ 
 bool cDvbDevice::ProvidesSource(int Source) const
 {
   int type = Source & cSource::st_Mask;
-  return type == cSource::stNone
-      || type == cSource::stCable && frontendType == FE_QAM
-      || type == cSource::stSat   && frontendType == FE_QPSK
-      || type == cSource::stTerr  && frontendType == FE_OFDM;
+  if (Setup.SourceCapsSet && type == cSource::stSat && frontendType == FE_QPSK) {
+     for (int i = 0; i < MAXSOURCECAPS; i++)
+         if (sourceCaps[i] == Source)
+            return true;
+     return false;
+     }
+  else
+     return type == cSource::stNone				 
+    	 || type == cSource::stCable && frontendType == FE_QAM	 
+    	 || type == cSource::stSat   && frontendType == FE_QPSK  
+    	 || type == cSource::stTerr  && frontendType == FE_OFDM; 
 }
 
 bool cDvbDevice::ProvidesTransponder(const cChannel *Channel) const