From patchwork Mon Aug 22 19:20:20 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dick Streefland X-Patchwork-Id: 11987 Received: from smtp-vbr15.xs4all.nl ([194.109.24.35]) by www.linuxtv.org with esmtp (Exim 4.34) id 1E7HqR-0007v2-Nb for vdr@linuxtv.org; Mon, 22 Aug 2005 21:20:31 +0200 Received: from zaphod.de.bilt (streefland.xs4all.nl [213.84.249.15]) by smtp-vbr15.xs4all.nl (8.13.3/8.13.3) with ESMTP id j7MJKLnA013755 for ; Mon, 22 Aug 2005 21:20:26 +0200 (CEST) (envelope-from dick@streefland.xs4all.nl) Received: by zaphod.de.bilt (Postfix, from userid 500) id CD0502C042; Mon, 22 Aug 2005 21:20:20 +0200 (CEST) Date: Mon, 22 Aug 2005 21:20:20 +0200 From: Dick Streefland To: vdr@linuxtv.org Message-ID: <20050822192020.GA4144@streefland.xs4all.nl> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Virus-Scanned: by XS4ALL Virus Scanner Subject: [vdr] [PATCH] Move new channels to separate radio and TV groups X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Aug 2005 19:20:31 -0000 Status: O X-Status: X-Keywords: X-UID: 4375 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 { @@ -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--; }