[vdr] [PATCH] Move new channels to separate radio and TV groups

Dick Streefland Dick.Streefland at xs4all.nl
Mon Aug 22 21:20:20 CEST 2005


Here is a patch to move newly added channels to separate radio/TV
groups for every satellite position. It is based on an old patch that
adds new channels to different groups based on the source (satellite
position). New in this patch is that two groups are used for every
satellite position: a radio group and a TV group.

Because when a new channel is added, it's PIDs are still zero, you
cannot differentiate between radio and TV channels at that time. So
the channel is first added to the end of the channel list, and moved
to the appropriate group when the PIDs are updated for the first time,
which is usually a few seconds later.

diff -pu vdr-1.3.30/channels.c.orig vdr-1.3.30/channels.c
--- vdr-1.3.30/channels.c.orig	Sat Aug  6 14:22:41 2005
+++ vdr-1.3.30/channels.c	Mon Aug 22 20:06:33 2005
@@ -444,6 +444,25 @@ void cChannel::SetPids(int Vpid, int Ppi
         }
      *q = 0;
      dsyslog("changing pids of channel %d from %d+%d:%s:%d to %d+%d:%s:%d", Number(), vpid, ppid, OldApidsBuf, tpid, Vpid, Ppid, NewApidsBuf, Tpid);
+     if (!vpid && !apids[0]) {
+         // new channel: find group seperator for the source of this channel
+         char sepname[64];
+         snprintf(sepname, sizeof(sepname), "New %s Channels @ %s",
+            (Vpid ? "TV" : "Radio"), *cSource::ToString(source));
+         cChannel *groupSep = Channels.GetByName(sepname);
+         if (!groupSep) {
+             // group separator doesn't exist, create it
+             groupSep = new cChannel();
+             groupSep->SetName(sepname, "", "");
+             groupSep->SetGroupSep(true);
+             Channels.Add(groupSep);
+             isyslog("creating separator '%s'", sepname);
+             }
+         isyslog("%s: %s,%s;%s", sepname, Name(), ShortName(), Provider());
+         Channels.Del(this, false);
+         Channels.Add(this, groupSep);  // move new channel
+         Channels.ReNumber();
+         }
      vpid = Vpid;
      ppid = Ppid;
      for (int i = 0; i < MAXAPIDS; i++) {
@@ -543,6 +562,11 @@ void cChannel::SetRefChannel(cChannel *R
   refChannel = RefChannel;
 }
 
+void cChannel::SetGroupSep(bool Sep)
+{
+   groupSep = Sep;
+}
+
 static int PrintParameter(char *p, char Name, int Value)
 {
   return Value >= 0 && Value != 999 ? sprintf(p, "%c%d", Name, Value) : 0;
@@ -948,6 +972,16 @@ cChannel *cChannels::GetByChannelID(tCha
             return channel;
          }
      }
+  return NULL;
+}
+
+cChannel *cChannels::GetByName(char *Name)
+{
+  for (cChannel *channel = First(); channel; channel = Next(channel))
+  {
+      if (strcmp(channel->Name(), Name)==0)
+         return channel;
+  }
   return NULL;
 }
 
diff -pu vdr-1.3.30/channels.h.orig vdr-1.3.30/channels.h
--- vdr-1.3.30/channels.h.orig	Sat Aug  6 13:23:32 2005
+++ vdr-1.3.30/channels.h	Mon Aug 22 20:06:33 2005
@@ -193,6 +193,7 @@ public:
   void SetCaDescriptors(int Level);
   void SetLinkChannels(cLinkChannels *LinkChannels);
   void SetRefChannel(cChannel *RefChannel);
+  void SetGroupSep(bool Sep = true);
   };
 
 class cChannels : public cRwLock, public cConfig<cChannel> {
@@ -211,6 +212,7 @@ public:
   cChannel *GetByNumber(int Number, int SkipGap = 0);
   cChannel *GetByServiceID(int Source, int Transponder, unsigned short ServiceID);
   cChannel *GetByChannelID(tChannelID ChannelID, bool TryWithoutRid = false, bool TryWithoutPolarization = false);
+  cChannel *GetByName(char *Name);
   int BeingEdited(void) { return beingEdited; }
   void IncBeingEdited(void) { beingEdited++; }
   void DecBeingEdited(void) { beingEdited--; }

-- 
Dick Streefland                    ////               De Bilt
dick.streefland at xs4all.nl         (@ @)       The Netherlands
------------------------------oOO--(_)--OOo------------------



More information about the vdr mailing list