From 5a4eb3f1041b8a53826cebe570f9d201f3d35826 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 29 Feb 2004 18:00:00 +0100 Subject: =?UTF-8?q?Version=201.3.5=20-=20Fixed=20reading=20the=20EPG=20pre?= =?UTF-8?q?ferred=20language=20parameter=20from=20'setup.conf'.=20-=20Fixe?= =?UTF-8?q?d=20switching=20to=20a=20visible=20programme=20in=20case=20the?= =?UTF-8?q?=20current=20channel=20has=20neither=20=20=20a=20video=20nor=20?= =?UTF-8?q?an=20audio=20PID.=20-=20Fixed=20editing=20channels=20(SID=20now?= =?UTF-8?q?=20range=20checked)=20and=20creating=20new=20channels=20(NID,?= =?UTF-8?q?=20=20=20TID=20and=20RID=20are=20now=20set=20to=200).=20-=20Fix?= =?UTF-8?q?ed=20transponder=20handling=20to=20make=20it=20work=20with=20sa?= =?UTF-8?q?tellites=20that=20provide=20two=20=20=20transponders=20on=20the?= =?UTF-8?q?=20same=20frequency,=20with=20different=20polarization,=20like?= =?UTF-8?q?=20Hispasat=20=20=20at=20S30.0W=20(thanks=20to=20Thomas=20Bergw?= =?UTF-8?q?inkl=20for=20pointing=20this=20out).=20See=20man=20vdr(5)=20=20?= =?UTF-8?q?=20for=20details=20about=20the=20enhanced=20channel=20ID=20form?= =?UTF-8?q?at.=20-=20Since=20there=20appears=20to=20be=20no=20general=20so?= =?UTF-8?q?lution=20for=20the=20UPT=20error=20yet,=20a=20recording=20=20?= =?UTF-8?q?=20now=20initiates=20an=20"emergency=20exit"=20if=20the=20numbe?= =?UTF-8?q?r=20of=20UPT=20errors=20during=20one=20=20=20recording=20exceed?= =?UTF-8?q?s=2010=20(suggested=20by=20Gregoire=20Favre).=20Since=20the=20U?= =?UTF-8?q?PT=20error=20doesn't=20=20=20happen=20on=20my=20system,=20this?= =?UTF-8?q?=20has=20not=20been=20explicitly=20tested.=20=20=20The=20"preli?= =?UTF-8?q?minary=20fix"=20for=20the=20UPT=20error=20in=20VDR/dvbdevice.c?= =?UTF-8?q?=20has=20been=20disabled=20=20=20by=20default,=20since=20it=20m?= =?UTF-8?q?akes=20channel=20switching=20unpleasently=20slow.=20If=20you=20?= =?UTF-8?q?want=20=20=20to=20have=20that=20workaround=20back,=20you=20can?= =?UTF-8?q?=20uncomment=20the=20line=20=20=20//#define=20WAIT=5FFOR=5FLOCK?= =?UTF-8?q?=5FAFTER=5FTUNING=201=20=20=20in=20VDR/dvbdevice.c.=20-=20Adapt?= =?UTF-8?q?ed=20the=20'sky'=20plugin=20to=20use=20the=20actual=20channel?= =?UTF-8?q?=20IDs,=20and=20to=20fetch=20EPG=20data=20=20=20from=20www.bleb?= =?UTF-8?q?.org.=20-=20Limited=20automatic=20retuning=20to=20devices=20tha?= =?UTF-8?q?t=20actually=20provide=20the=20transponder=20=20=20(necessary?= =?UTF-8?q?=20for=20the=20'sky'=20plugin).=20-=20Fixed=20handling=20receiv?= =?UTF-8?q?ers=20in=20the=20'sky'=20plugin,=20so=20that=20a=20recording=20?= =?UTF-8?q?on=20the=20same=20=20=20channel=20won't=20interrupt=20an=20ongo?= =?UTF-8?q?ing=20Transfer=20Mode.=20-=20Added=20subtable=20ID=20and=20TSDT?= =?UTF-8?q?=20handling=20to=20'libsi'=20(thanks=20to=20Marcel=20Wiesweg).?= =?UTF-8?q?=20-=20Fixed=20some=20Russian=20OSD=20texts=20(thanks=20to=20Vy?= =?UTF-8?q?acheslav=20Dikonov).=20-=20Added=20the=20'running=20status'=20t?= =?UTF-8?q?o=20the=20EPG=20events.=20This=20is=20necessary=20for=20impleme?= =?UTF-8?q?nting=20=20=20the=20VPS=20function=20for=20recording.=20-=20Rem?= =?UTF-8?q?oved=20the=20obsolete=20'present'=20and=20'following'=20handlin?= =?UTF-8?q?g=20from=20the=20EPG=20data.=20-=20The=20EPG=20data=20is=20now?= =?UTF-8?q?=20always=20kept=20sorted=20chronologically=20in=20the=20intern?= =?UTF-8?q?al=20data=20=20=20structures.=20This=20also=20means=20that=20an?= =?UTF-8?q?y=20EPG=20data=20retrieved=20through=20the=20SVRDP=20=20=20comm?= =?UTF-8?q?and=20LSTE=20is=20guaranteed=20to=20be=20sorted=20by=20start=20?= =?UTF-8?q?time.=20-=20Now=20using=20the=20'running=20status'=20in=20the?= =?UTF-8?q?=20channel=20display,=20so=20that=20a=20programme=20=20=20that?= =?UTF-8?q?=20has=20an=20end=20time=20that=20is=20before=20the=20current?= =?UTF-8?q?=20time,=20but=20is=20still=20running,=20=20=20will=20still=20b?= =?UTF-8?q?e=20shown=20in=20the=20display=20(provided=20the=20broadcasters?= =?UTF-8?q?=20handle=20the=20=20=20'running=20status'=20flag=20correctly).?= =?UTF-8?q?=20This=20also=20applies=20to=20programmes=20that=20have=20=20?= =?UTF-8?q?=20a=20start=20time=20that=20is=20in=20the=20future,=20but=20ar?= =?UTF-8?q?e=20already=20running.=20-=20Implemented=20an=20"EPG=20linger?= =?UTF-8?q?=20time",=20which=20can=20be=20set=20to=20have=20older=20EPG=20?= =?UTF-8?q?information=20=20=20still=20displayed=20in=20the=20"Schedule"?= =?UTF-8?q?=20menu=20(thanks=20to=20Jaakko=20Hyv=C3=A4tti).=20-=20Added=20?= =?UTF-8?q?PDCDescriptor=20handling=20to=20'libsi'.=20-=20Implemented=20ha?= =?UTF-8?q?ndling=20the=20VPS=20timestamps=20(aka=20"Programme=20Identific?= =?UTF-8?q?ation=20Label")=20=20=20for=20full=20VPS=20support=20for=20time?= =?UTF-8?q?rs=20(provided=20the=20tv=20stations=20actually=20broadcast=20?= =?UTF-8?q?=20=20this=20information).=20The=20VPS=20time=20is=20displayed?= =?UTF-8?q?=20in=20the=20event=20info=20page=20if=20it=20exists=20=20=20an?= =?UTF-8?q?d=20is=20different=20than=20the=20event's=20start=20time.=20-?= =?UTF-8?q?=20Extended=20the=20SVDRP=20command=20LSTE=20to=20allow=20limit?= =?UTF-8?q?ing=20the=20listed=20data=20to=20a=20given=20=20=20channel,=20t?= =?UTF-8?q?he=20present=20or=20following=20events,=20or=20events=20at=20a?= =?UTF-8?q?=20given=20time=20(thanks=20to=20=20=20Thomas=20Heiligenmann).?= =?UTF-8?q?=20-=20Fixed=20a=20typo=20in=20libsi/si.h=20(thanks=20to=20St?= =?UTF-8?q?=C3=A9phane=20Est=C3=A9-Gracias).=20-=20Timers=20can=20now=20be?= =?UTF-8?q?=20set=20to=20use=20the=20VPS=20information=20to=20control=20re?= =?UTF-8?q?cording=20a=20programme.=20=20=20The=20new=20setup=20options=20?= =?UTF-8?q?"Recording/Use=20VPS"=20and=20"Recording/VPS=20margin",=20as=20?= =?UTF-8?q?well=20as=20=20=20the=20"VPS"=20option=20in=20the=20individual?= =?UTF-8?q?=20timers,=20can=20be=20used=20to=20control=20this=20feature=20?= =?UTF-8?q?=20=20(see=20MANUAL=20for=20details).=20=20=20Note=20that=20thi?= =?UTF-8?q?s=20feature=20will=20certainly=20need=20a=20lot=20of=20testing?= =?UTF-8?q?=20before=20it=20can=20be=20=20=20called=20"safe"!=20-=20The=20?= =?UTF-8?q?"Schedule"=20and=20"What's=20on=20now/next=3F"=20menus=20now=20?= =?UTF-8?q?have=20an=20additional=20column=20=20=20which=20displays=20info?= =?UTF-8?q?rmation=20on=20whether=20there=20is=20a=20timer=20defined=20for?= =?UTF-8?q?=20an=20event,=20=20=20whether=20an=20event=20has=20a=20VPS=20t?= =?UTF-8?q?ime=20that's=20different=20than=20its=20start=20time,=20and=20?= =?UTF-8?q?=20=20whether=20an=20event=20is=20currently=20running=20(see=20?= =?UTF-8?q?MANUAL=20under=20"The=20"Schedule"=20Menu"=20=20=20for=20detail?= =?UTF-8?q?s).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PLUGINS/src/sky/HISTORY | 8 +++ PLUGINS/src/sky/README | 29 ++++---- PLUGINS/src/sky/channels.conf.sky | 38 +++++++++-- PLUGINS/src/sky/getskyepg.pl | 136 ++++++++++++++++++++++++-------------- PLUGINS/src/sky/sky.c | 96 ++++++++++++++++++++++----- 5 files changed, 221 insertions(+), 86 deletions(-) (limited to 'PLUGINS') diff --git a/PLUGINS/src/sky/HISTORY b/PLUGINS/src/sky/HISTORY index d3da71e..c1c5f98 100644 --- a/PLUGINS/src/sky/HISTORY +++ b/PLUGINS/src/sky/HISTORY @@ -16,3 +16,11 @@ VDR Plugin 'sky' Revision History 2004-01-04: Version 0.2.0 - Implemented automatic PID switching and channel detection + +2004-02-15: Version 0.3.0 + +- Now using the actual channel IDs a derived from the data stream. +- Switched EPG data retrieval to http://www.bleb.org. +- Added automatic DST detection to getskyepg.pl. +- Fixed handling receivers, so that a recording on the same channel + won't interrupt an ongoing Transfer mode. diff --git a/PLUGINS/src/sky/README b/PLUGINS/src/sky/README index bd089cc..185a98b 100644 --- a/PLUGINS/src/sky/README +++ b/PLUGINS/src/sky/README @@ -28,23 +28,18 @@ control the Digibox. In order to access the Sky channels VDR needs to know the channel number under which each channel is stored in the Sky Digibox. These numbers are -used as 'frequency' parameters in the channels.conf definitions of the Sky -channels (see the file 'channels.conf.sky'). Since these numbers are always -less than 1000, they can be easily distinguished from normal satellite -transponder frequencies. The VPID is 160 and the APID is 80 for all Sky -channels. These are just fake PIDs, since the Kfir card always uses these -fixed PIDs. The 'Ca' parameter of the Sky channels is set to 301, which -is defined as "Videoguard, Sky Digital" in VDR's 'ca.conf' file. Again, please -note that VDR doesn't do any decrypting here, this is just to mark these -channels as "conditionally accessible" and have a way of setting the CICAM -value for the Kfir device in VDR's Setup menu. - -The Sky EPG is available on the Internet at http://www.ananova.com. +stored in the file 'channels.conf.sky', together with the channel IDs as +derived from the actual channel data and the names under which the EPG +data for each channel can be found (see below). Copy this file to your +plugins config directory, in a subdirectory named 'sky', as in + +/video/plugins/sky/channels.conf.sky + +The Sky EPG is available on the Internet at http://www.bleb.org. The Perl script getskyepg.pl extracts the EPG data from these pages -and sends it to VDR via an SVDRP connection. The channel numbers Sky -uses to generate the EPG pages are stored as the 'sid' parameter in -the channels.conf definitions of the Sky channels. You can keep your -EPG data up-to-date by entering a call to getskyepg.pl into your -/etc/crontab. Call 'getskyepg.pl -h' for a list of options. +and sends it to VDR via an SVDRP connection. The channel names as +used on the bleb.org pages are defined in the channels.conf.sky file. +You can keep your EPG data up-to-date by entering a call to getskyepg.pl +into your /etc/crontab. Call 'getskyepg.pl -h' for a list of options. The getskyepg.pl script requires the programs /usr/bin/wget and /usr/bin/logger to be installed on your system. diff --git a/PLUGINS/src/sky/channels.conf.sky b/PLUGINS/src/sky/channels.conf.sky index f4a437b..ba262f8 100644 --- a/PLUGINS/src/sky/channels.conf.sky +++ b/PLUGINS/src/sky/channels.conf.sky @@ -1,4 +1,34 @@ -Sky One:106:h:S28.2E:0:160:80:0:301:222 -itv2:226:h:S28.2E:0:160:80:0:301:451 -sci-fi:130:h:S28.2E:0:160:80:0:301:161 -Paramount Comedy:127:h:S28.2E:0:160:80:0:301:185 +# Sky channel definitions +# +# Syntax: +# +# ChannelID:ChannelNumber:EPGname +# +# where +# +# ChannelID is the channel ID as derived from the actual channel +# data as broadcast in the data stream (see man vdr(5)). +# +# ChannelNumber is the number of this channel as you have to +# enter it on the DigiBox remote control. +# +# EPGname is the name of the page at www.bleb.org that has EPG +# data for this channel (without the '.xml'). If no such +# page exists, 'x' is entered. +# +S28.2E-2-2027-4705:106:sky_one +S28.2E-2-2027-5104:107:sky_one_mix +S28.2E-2-2054-10240:226:itv2 +S28.2E-2-2023-4905:130:scifi +S28.2E-2-2025-5904:127:paramount +S28.2E-2-2009-6201:551:discovery +S28.2E-2-2020-4809:310:sky_cinema +S28.2E-2-2007-4303:301:sky_movies1 +S28.2E-2-2007-4302:302:sky_movies2 +S28.2E-2-2007-4403:303:sky_movies3 +S28.2E-2-2011-4402:304:sky_movies4 +S28.2E-2-2011-4503:305:sky_movies5 +S28.2E-2-2011-4502:306:sky_movies6 +S28.2E-2-2020-4603:307:sky_movies7 +S28.2E-2-2007-5502:308:sky_movies8 +S28.2E-2-2020-4602:309:x diff --git a/PLUGINS/src/sky/getskyepg.pl b/PLUGINS/src/sky/getskyepg.pl index 46c2d7f..77768ad 100755 --- a/PLUGINS/src/sky/getskyepg.pl +++ b/PLUGINS/src/sky/getskyepg.pl @@ -1,14 +1,14 @@ #!/usr/bin/perl -# getskyepg.pl: Get EPG data from Sky's web pages +# getskyepg.pl: Get EPG data for Sky channels from the Internet # # Connects to a running VDR instance via SVDRP, gets the channel data -# for the Sky channels and connects to Sky's web pages to extract the +# for the Sky channels and connects to Internet web pages to extract the # EPG data for these channels. The result is sent to VDR via SVDRP. # # See the README file for copyright information and how to reach the author. # -# $Id: getskyepg.pl 1.2 2003/04/02 16:21:47 kls Exp $ +# $Id: getskyepg.pl 1.3 2004/02/15 13:35:52 kls Exp $ use Getopt::Std; use Time::Local; @@ -16,31 +16,33 @@ use Time::Local; $Usage = qq{ Usage: $0 [options] -Options: -d hostname destination hostname (default: localhost) +Options: -c filename channel config file name (default: channels.conf.sky) + -d hostname destination hostname (default: localhost) -p port SVDRP port number (default: 2001) -S source channel source (default: S28.2E) -D days days to get EPG for (1..7, default: 2) }; -die $Usage if (!getopts("d:D:hp:S:") || $opt_h); +die $Usage if (!getopts("c:d:D:hp:S:") || $opt_h); +$Conf = $opt_c || "channels.conf.sky"; $Dest = $opt_d || "localhost"; $Port = $opt_p || 2001; $Source = $opt_S || "S28.2E"; $Days = $opt_D || 2; -$SkyWebPage = "www.ananova.com/tv/frontpage.html"; +$SkyWebPage = "www.bleb.org/tv/data/listings"; $WGET = "/usr/bin/wget -q -O-"; $LOGGER = "/usr/bin/logger -t SKYEPG"; -$DST = -3600; ##XXX TODO find out whether DST is active! +$DST = -3600; # Daylight Saving Time offset $SecsInDay = 86400; -$MaxFrequency = 1000; -$idxName = 0; -$idxFrequency = 1; -$idxSource = 3; -$idxSid = 9; +@Channels = (); + +$idxSource = 0; +$idxNumber = 1; +$idxName = 2; Error("days out of range: $Days") unless (1 <= $Days && $Days <= 7); @@ -57,34 +59,52 @@ sub Error sub GetChannels { - SVDRPsend("LSTC"); - my @channels = (); - for (SVDRPreceive(250)) { - my @a = split(':', substr($_, 4)); - if ($a[$idxSource] eq $Source && $a[$idxFrequency] < $MaxFrequency) { - push(@channels, [@a]); - } - } - return @channels; + open(CHANNELS, $Conf) || Error("$Conf: $!"); + while () { + chomp; + next if (/^#/); + my @a = split(":"); + push(@Channels, [@a]) unless ($a[$idxName] eq "x"); + } + close(CHANNELS); } +GetChannels(); + sub GetPage { my $channel = shift; my $day = shift; - my $url = "$SkyWebPage?c=$channel&day=day$day"; + $day--; + my $url = "$SkyWebPage/$day/$channel.xml"; Log("reading $url"); my @page = split("\n", `$WGET '$url'`); Log("received " . ($#page + 1) . " lines"); return @page; } +sub StripWhitespace +{ + my $s = shift; + $s =~ s/\s*(.*)\s*/$1/; + $s =~ s/\s+/ /g; + return $s; +} + +sub Extract +{ + my $s = shift; + my $t = shift; + $s =~ /<$t>([^<]*)<\/$t>/; + return StripWhitespace($1); +} + # In order to get the duration we need to buffer the last event: $Id = ""; $Time = 0; $Title = ""; -$Episode = ""; -$Descr = ""; +$Subtitle = ""; +$Desc = ""; sub GetEpgData { @@ -94,40 +114,64 @@ sub GetEpgData $Time = 0; for $day (1 .. $Days) { my $dt = 0; - my $ap = ""; my @page = GetPage($channel, $day); + my $data = ""; for $line (@page) { - if ($line =~ /^<\/tr>(.*?)<\/b>.*?(.*?)<\/b> *(.*?<\/i>)? *(.*?) *<\/small>/); - my ($h, $m, $a) = ($time =~ /([0-9]+)\.([0-9]+)(.)m/); - # handle am/pm: - $dt = $SecsInDay if ($ap eq "p" && $a eq "a"); - $ap = $a; - $h += 12 if ($a eq "p" && $h < 12); - $h -= 12 if ($a eq "a" && $h == 12); + chomp($line); + if ($line =~ //) { + $data = ""; + } + elsif ($line =~ /<\/programme>/) { + my $title = Extract($data, "title"); + my $subtitle = Extract($data, "subtitle"); + my $desc = Extract($data, "desc"); + my $start = Extract($data, "start"); + # 'end' is useless, because it is sometimes missing :-( + # my $end = Extract($data, "end"); + if (!$subtitle) { + # They sometimes write all info into the description, as in + # Episode: some description. + # Why don't they just fill in the data correctly? + my ($s, $d) = ($desc =~ /([^:]*)[:](.*)/); + if ($s && $d) { + $subtitle = $s; + $desc = $d; + } + } + # 'start' and 'end' as time of day isn't of much use here, since + # the page for one day contains data that actually belongs to the + # next day (after midnight). Oh well, lets reconstruct the missing + # information: + $start = "0" . $start if (length($start) < 4); + my ($h, $m) = ($start =~ /(..)(..)/); + $dt = $SecsInDay if ($h > 12); # convert to time_t: my @gmt = gmtime; $gmt[0] = 0; # seconds $gmt[1] = $m; # minutes $gmt[2] = $h; # hours - $time = timegm(@gmt) + ($day - 1) * $SecsInDay + $dt + $DST; + $time = timegm(@gmt) + ($day - 1) * $SecsInDay + ($h < 12 ? $dt : 0); + # comensate for DST: + $time += $DST if (localtime($time))[8]; # create EPG data: if ($Time) { $duration = $time - $Time; SVDRPsend("E $Id $Time $duration"); SVDRPsend("T $Title"); - SVDRPsend("S $Episode"); - SVDRPsend("D $Descr"); + SVDRPsend("S $Subtitle"); + SVDRPsend("D $Desc"); SVDRPsend("e"); $numEvents++; } # buffer the last event: $Id = $time / 60 % 0xFFFF; # this gives us unique ids for every minute of over 6 weeks $Time = $time; - ($Title = $title) =~ s/<[^>]+>//g; - ($Episode = $episode) =~ s/<[^>]+>//g; - ($Descr = $descr) =~ s/<[^>]+>//g; + $Title = $title; + $Subtitle = $subtitle; + $Desc = $desc; + } + else { + $data .= $line; } } } @@ -137,14 +181,10 @@ sub GetEpgData sub ProcessEpg { - Log("getting Sky channel definitions"); - my @channels = GetChannels(); - Error("no Sky channels found") unless @channels; - Log("found " . ($#channels + 1) . " channels"); - for (@channels) { - my $channel = @$_[$idxSid]; - my $channelID = "@$_[$idxSource]-0-@$_[$idxFrequency]-$channel"; - Log("processing channel @$_[0]"); + for (@Channels) { + my $channel = @$_[$idxName]; + my $channelID = @$_[$idxSource]; + Log("processing channel $channel - $channelID"); SVDRPsend("PUTE"); SVDRPreceive(354); GetEpgData($channel, $channelID); diff --git a/PLUGINS/src/sky/sky.c b/PLUGINS/src/sky/sky.c index 750d778..6196eef 100644 --- a/PLUGINS/src/sky/sky.c +++ b/PLUGINS/src/sky/sky.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: sky.c 1.4 2004/01/04 15:29:15 kls Exp $ + * $Id: sky.c 1.6 2004/02/15 14:59:46 kls Exp $ */ #include @@ -14,16 +14,53 @@ #include #include -static const char *VERSION = "0.2.0"; +static const char *VERSION = "0.3.0"; static const char *DESCRIPTION = "Sky Digibox interface"; // --- cDigiboxDevice -------------------------------------------------------- +#define DUMMYAPID 80 +#define DUMMYVPID 160 + +class cSkyChannel : public cListObject { +public: + tChannelID channelID; + int digiboxChannelNumber; + bool Parse(const char *s); + }; + +bool cSkyChannel::Parse(const char *s) +{ + char *id = NULL; + if (2 == sscanf(s, "%a[^:]:%d", &id, &digiboxChannelNumber)) + channelID = tChannelID::FromString(id); + free(id); + return digiboxChannelNumber && channelID.Valid(); +} + +class cSkyChannels : public cConfig { +public: + cSkyChannel *GetSkyChannel(const cChannel *Channel); + }; + +cSkyChannel *cSkyChannels::GetSkyChannel(const cChannel *Channel) +{ + tChannelID ChannelID = Channel->GetChannelID(); + for (cSkyChannel *sc = First(); sc; sc = Next(sc)) { + if (ChannelID == sc->channelID) + return sc; + } + return NULL; +} + +cSkyChannels SkyChannels; + class cDigiboxDevice : public cDevice { private: int source; int digiboxChannelNumber; int fd_dvr; + int apid, vpid; cTSBuffer *tsBuffer; int fd_lirc; void LircSend(const char *s); @@ -47,6 +84,7 @@ cDigiboxDevice::cDigiboxDevice(void) source = cSource::FromString("S28.2E");//XXX parameter??? digiboxChannelNumber = 0; fd_dvr = -1; + apid = vpid = 0; struct sockaddr_un addr; addr.sun_family = AF_UNIX; strn0cpy(addr.sun_path, "/dev/lircd", sizeof(addr.sun_path));//XXX parameter??? @@ -93,7 +131,7 @@ void cDigiboxDevice::LircSend(int n) bool cDigiboxDevice::SetPid(cPidHandle *Handle, int Type, bool On) { - dsyslog("SetPid %d %d", Handle->pid, On); + //dsyslog("SetPid %d %d", Handle->pid, On); return true; } @@ -122,6 +160,16 @@ bool cDigiboxDevice::GetTSPacket(uchar *&Data) int r = tsBuffer->Read(); if (r >= 0) { Data = tsBuffer->Get(); + if (Data) { + // insert the actual PIDs: + int Pid = (((uint16_t)Data[1] & PID_MASK_HI) << 8) | Data[2]; + if (Pid == DUMMYAPID) + Pid = apid; + else if (Pid == DUMMYVPID) + Pid = vpid; + Data[1] = ((Pid >> 8) & 0xFF) | (Data[1] & ~PID_MASK_HI); + Data[2] = Pid & 0xFF; + } return true; } else if (FATALERRNO) { @@ -149,9 +197,10 @@ bool cDigiboxDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool bool hasPriority = Priority < 0 || Priority > this->Priority(); bool needsDetachReceivers = true; - if (ProvidesSource(Channel->Source()) && Channel->Ca() == 0x30) {//XXX - if (Receiving()) { - if (digiboxChannelNumber == Channel->Frequency()) { + cSkyChannel *SkyChannel = SkyChannels.GetSkyChannel(Channel); + if (SkyChannel) { + if (Receiving(true)) { + if (digiboxChannelNumber == SkyChannel->digiboxChannelNumber) { needsDetachReceivers = false; result = true; } @@ -168,16 +217,21 @@ bool cDigiboxDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool bool cDigiboxDevice::SetChannelDevice(const cChannel *Channel, bool LiveView) { - if (fd_lirc >= 0 && !Receiving()) { // if we are receiving the channel is already set! - digiboxChannelNumber = Channel->Frequency(); - //XXX only when recording??? -> faster channel switching! - LircSend("SKY"); // makes sure the Digibox is "on" - //XXX lircprint(fd_lirc, "BACKUP"); - //XXX lircprint(fd_lirc, "BACKUP"); - //XXX lircprint(fd_lirc, "BACKUP"); - LircSend(digiboxChannelNumber); + if (fd_lirc >= 0 && !Receiving(true)) { // if we are receiving the channel is already set! + cSkyChannel *SkyChannel = SkyChannels.GetSkyChannel(Channel); + if (SkyChannel) { + digiboxChannelNumber = SkyChannel->digiboxChannelNumber; + apid = Channel->Apid1(); + vpid = Channel->Vpid(); + //XXX only when recording??? -> faster channel switching! + LircSend("SKY"); // makes sure the Digibox is "on" + //XXX lircprint(fd_lirc, "BACKUP"); + //XXX lircprint(fd_lirc, "BACKUP"); + //XXX lircprint(fd_lirc, "BACKUP"); + LircSend(digiboxChannelNumber); + } } -return true; + return true; } // --- cPluginSky ------------------------------------------------------------ @@ -225,8 +279,16 @@ bool cPluginSky::ProcessArgs(int argc, char *argv[]) bool cPluginSky::Initialize(void) { // Initialize any background activities the plugin shall perform. - new cDigiboxDevice; - return true; + const char *ConfigDir = ConfigDirectory(Name()); + if (ConfigDir) { + if (SkyChannels.Load(AddDirectory(ConfigDir, "channels.conf.sky"), true)) { + new cDigiboxDevice; + return true; + } + } + else + esyslog("ERROR: can't get config directory"); + return false; } void cPluginSky::Housekeeping(void) -- cgit v1.2.3