52552c5
diff --git a/MANUAL b/MANUAL
52552c5
index 3c4003e..e8de3ad 100644
52552c5
--- a/MANUAL
52552c5
+++ b/MANUAL
52552c5
@@ -810,6 +810,9 @@ Version 2.2
52552c5
                          background transparency. By default the values as broadcast
52552c5
                          are used.
52552c5
 
52552c5
+  Enable teletext support = yes
52552c5
+                         If set to 'yes', enables teletext subtitles.
52552c5
+
52552c5
   LNB:
52552c5
 
52552c5
   Use DiSEqC = no        Generally turns DiSEqC support on or off.
52552c5
diff --git a/Makefile b/Makefile
52552c5
index 9722036..92db319 100644
52552c5
--- a/Makefile
52552c5
+++ b/Makefile
52552c5
@@ -74,6 +74,8 @@ OBJS = args.o audio.o channels.o ci.o config.o cutter.o device.o diseqc.o dvbdev
52552c5
        skinclassic.o skinlcars.o skins.o skinsttng.o sourceparams.o sources.o spu.o status.o svdrp.o themes.o thread.o\
52552c5
        timers.o tools.o transfer.o vdr.o videodir.o
52552c5
 
52552c5
+OBJS += vdrttxtsubshooks.o
52552c5
+
52552c5
 DEFINES  += $(CDEFINES)
52552c5
 INCLUDES += $(CINCLUDES)
52552c5
 
52552c5
diff --git a/channels.c b/channels.c
52552c5
index 564088f..d0fc3d8 100644
52552c5
--- a/channels.c
52552c5
+++ b/channels.c
52552c5
@@ -421,6 +421,26 @@ void cChannel::SetSubtitlingDescriptors(uchar *SubtitlingTypes, uint16_t *Compos
52552c5
      }
52552c5
 }
52552c5
 
52552c5
+void cChannel::SetTeletextSubtitlePages(tTeletextSubtitlePage pages[], int numberOfPages)
52552c5
+{
52552c5
+  int mod = CHANNELMOD_NONE;
52552c5
+  if (totalTtxtSubtitlePages != (fixedTtxtSubtitlePages + numberOfPages))
52552c5
+     mod |= CHANNELMOD_PIDS;
52552c5
+  totalTtxtSubtitlePages = fixedTtxtSubtitlePages;
52552c5
+  for (int i = 0; (i < numberOfPages) && (totalTtxtSubtitlePages < MAXTXTPAGES); i++) {
52552c5
+      if (teletextSubtitlePages[totalTtxtSubtitlePages].ttxtMagazine != pages[i].ttxtMagazine ||
52552c5
+          teletextSubtitlePages[totalTtxtSubtitlePages].ttxtPage != pages[i].ttxtPage ||
52552c5
+          teletextSubtitlePages[totalTtxtSubtitlePages].ttxtType != pages[i].ttxtType ||
52552c5
+          strcmp(teletextSubtitlePages[totalTtxtSubtitlePages].ttxtLanguage, pages[i].ttxtLanguage)) {
52552c5
+         mod |= CHANNELMOD_PIDS;
52552c5
+         teletextSubtitlePages[totalTtxtSubtitlePages] = pages[i];
52552c5
+         }
52552c5
+      totalTtxtSubtitlePages++;
52552c5
+      }
52552c5
+  modification |= mod;
52552c5
+  Channels.SetModified();
52552c5
+}
52552c5
+
52552c5
 void cChannel::SetSeen(void)
52552c5
 {
52552c5
   seen = time(NULL);
52552c5
@@ -556,10 +576,17 @@ cString cChannel::ToText(const cChannel *Channel)
52552c5
         q += IntArrayToString(q, Channel->dpids, 10, Channel->dlangs, Channel->dtypes);
52552c5
         }
52552c5
      *q = 0;
52552c5
-     const int TBufferSize = MAXSPIDS * (5 + 1 + MAXLANGCODE2) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod+cod', +10: paranoia and tpid
52552c5
+     const int TBufferSize = (MAXTXTPAGES * MAXSPIDS) * (5 + 1 + MAXLANGCODE2) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod+cod', +10: paranoia and tpid
52552c5
      char tpidbuf[TBufferSize];
52552c5
      q = tpidbuf;
52552c5
      q += snprintf(q, sizeof(tpidbuf), "%d", Channel->tpid);
52552c5
+     if (Channel->fixedTtxtSubtitlePages > 0) {
52552c5
+        *q++ = '+';
52552c5
+        for (int i = 0; i < Channel->fixedTtxtSubtitlePages; ++i) {
52552c5
+            tTeletextSubtitlePage page = Channel->teletextSubtitlePages[i];
52552c5
+            q += snprintf(q, sizeof(tpidbuf) - (q - tpidbuf), "%d=%s", page.PageNumber(), page.ttxtLanguage);
52552c5
+            }
52552c5
+        }
52552c5
      if (Channel->spids[0]) {
52552c5
         *q++ = ';';
52552c5
         q += IntArrayToString(q, Channel->spids, 10, Channel->slangs);
52552c5
@@ -730,6 +757,32 @@ bool cChannel::Parse(const char *s)
52552c5
                     }
52552c5
               spids[NumSpids] = 0;
52552c5
               }
52552c5
+           fixedTtxtSubtitlePages = 0;
52552c5
+           if ((p = strchr(tpidbuf, '+')) != NULL) {
52552c5
+              *p++ = 0;
52552c5
+              char *q;
52552c5
+              char *strtok_next;
52552c5
+              while ((q = strtok_r(p, ",", &strtok_next)) != NULL) {
52552c5
+                    if (fixedTtxtSubtitlePages < MAXTXTPAGES) {
52552c5
+                       int page;
52552c5
+                       char *l = strchr(q, '=');
52552c5
+                       if (l)
52552c5
+                          *l++ = 0;
52552c5
+                       if (sscanf(q, "%d", &page) == 1) {
52552c5
+                          teletextSubtitlePages[fixedTtxtSubtitlePages] = tTeletextSubtitlePage(page);
52552c5
+                          if (l)
52552c5
+                             strn0cpy(teletextSubtitlePages[fixedTtxtSubtitlePages].ttxtLanguage, l, MAXLANGCODE2);
52552c5
+                          fixedTtxtSubtitlePages++;
52552c5
+                          }
52552c5
+                       else
52552c5
+                          esyslog("ERROR: invalid Teletext page!"); // no need to set ok to 'false'
52552c5
+                       }
52552c5
+                    else
52552c5
+                       esyslog("ERROR: too many Teletext pages!"); // no need to set ok to 'false'
52552c5
+                    p = NULL;
52552c5
+                    }
52552c5
+              totalTtxtSubtitlePages = fixedTtxtSubtitlePages;
52552c5
+              }
52552c5
            if (sscanf(tpidbuf, "%d", &tpid) != 1)
52552c5
               return false;
52552c5
            if (caidbuf) {
52552c5
diff --git a/channels.h b/channels.h
52552c5
index 3323882..c62fdec 100644
52552c5
--- a/channels.h
52552c5
+++ b/channels.h
52552c5
@@ -36,6 +36,7 @@
52552c5
 #define MAXDPIDS 16 // dolby (AC3 + DTS)
52552c5
 #define MAXSPIDS 32 // subtitles
52552c5
 #define MAXCAIDS 12 // conditional access
52552c5
+#define MAXTXTPAGES 8 // teletext pages
52552c5
 
52552c5
 #define MAXLANGCODE1 4 // a 3 letter language code, zero terminated
52552c5
 #define MAXLANGCODE2 8 // up to two 3 letter language codes, separated by '+' and zero terminated
52552c5
@@ -72,6 +73,16 @@ public:
52552c5
   static const tChannelID InvalidID;
52552c5
   };
52552c5
 
52552c5
+struct tTeletextSubtitlePage {
52552c5
+  tTeletextSubtitlePage(void) { ttxtPage = ttxtMagazine = 0; ttxtType = 0x02; strcpy(ttxtLanguage, "und"); }
52552c5
+  tTeletextSubtitlePage(int page) { ttxtMagazine = (page / 100) & 0x7; ttxtPage = (((page % 100) / 10) << 4) + (page % 10); ttxtType = 0x02; strcpy(ttxtLanguage, "und"); }
52552c5
+  char ttxtLanguage[MAXLANGCODE1];
52552c5
+  uchar ttxtPage;
52552c5
+  uchar ttxtMagazine;
52552c5
+  uchar ttxtType;
52552c5
+  int PageNumber(void) const { return BCDCHARTOINT(ttxtMagazine) * 100 + BCDCHARTOINT(ttxtPage); }
52552c5
+  };
52552c5
+
52552c5
 class cChannel;
52552c5
 
52552c5
 class cLinkChannel : public cListObject {
52552c5
@@ -116,6 +127,9 @@ private:
52552c5
   uint16_t compositionPageIds[MAXSPIDS];
52552c5
   uint16_t ancillaryPageIds[MAXSPIDS];
52552c5
   int tpid;
52552c5
+  int fixedTtxtSubtitlePages;
52552c5
+  int totalTtxtSubtitlePages;
52552c5
+  tTeletextSubtitlePage teletextSubtitlePages[MAXTXTPAGES];
52552c5
   int caids[MAXCAIDS + 1]; // list is zero-terminated
52552c5
   int nid;
52552c5
   int tid;
52552c5
@@ -169,6 +183,8 @@ public:
52552c5
   uint16_t CompositionPageId(int i) const { return (0 <= i && i < MAXSPIDS) ? compositionPageIds[i] : uint16_t(0); }
52552c5
   uint16_t AncillaryPageId(int i) const { return (0 <= i && i < MAXSPIDS) ? ancillaryPageIds[i] : uint16_t(0); }
52552c5
   int Tpid(void) const { return tpid; }
52552c5
+  const tTeletextSubtitlePage *TeletextSubtitlePages() const { return teletextSubtitlePages; }
52552c5
+  int TotalTeletextSubtitlePages() const { return totalTtxtSubtitlePages; }
52552c5
   const int *Caids(void) const { return caids; }
52552c5
   int Ca(int Index = 0) const { return Index < MAXCAIDS ? caids[Index] : 0; }
52552c5
   int Nid(void) const { return nid; }
52552c5
@@ -198,6 +214,7 @@ public:
52552c5
   void SetName(const char *Name, const char *ShortName, const char *Provider);
52552c5
   void SetPortalName(const char *PortalName);
52552c5
   void SetPids(int Vpid, int Ppid, int Vtype, int *Apids, int *Atypes, char ALangs[][MAXLANGCODE2], int *Dpids, int *Dtypes, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
52552c5
+  void SetTeletextSubtitlePages(tTeletextSubtitlePage pages[], int numberOfPages);
52552c5
   void SetCaIds(const int *CaIds); // list must be zero-terminated
52552c5
   void SetCaDescriptors(int Level);
52552c5
   void SetLinkChannels(cLinkChannels *LinkChannels);
52552c5
diff --git a/ci.c b/ci.c
52552c5
index ffc7ff7..b6c5753 100644
52552c5
--- a/ci.c
52552c5
+++ b/ci.c
52552c5
@@ -2155,6 +2155,8 @@ void cCamSlot::AddChannel(const cChannel *Channel)
52552c5
          AddPid(Channel->Sid(), *Dpid, STREAM_TYPE_PRIVATE);
52552c5
      for (const int *Spid = Channel->Spids(); *Spid; Spid++)
52552c5
          AddPid(Channel->Sid(), *Spid, STREAM_TYPE_PRIVATE);
52552c5
+     if (Channel->Tpid() && Setup.SupportTeletext)
52552c5
+        AddPid(Channel->Sid(), Channel->Tpid(), STREAM_TYPE_PRIVATE);
52552c5
      }
52552c5
 }
52552c5
 
52552c5
@@ -2178,6 +2180,9 @@ bool cCamSlot::CanDecrypt(const cChannel *Channel)
52552c5
          CaPmt.AddPid(*Dpid, STREAM_TYPE_PRIVATE);
52552c5
      for (const int *Spid = Channel->Spids(); *Spid; Spid++)
52552c5
          CaPmt.AddPid(*Spid, STREAM_TYPE_PRIVATE);
52552c5
+     if (Channel->Tpid() && Setup.SupportTeletext) {
52552c5
+        CaPmt.AddPid(Channel->Tpid(), STREAM_TYPE_PRIVATE);
52552c5
+        }
52552c5
      cas->SendPMT(&CaPmt);
52552c5
      cTimeMs Timeout(QUERY_REPLY_TIMEOUT);
52552c5
      do {
52552c5
diff --git a/config.c b/config.c
52552c5
index 9c6b71e..83e2e6f 100644
52552c5
--- a/config.c
52552c5
+++ b/config.c
52552c5
@@ -403,6 +403,7 @@ cSetup::cSetup(void)
52552c5
   MarginStop = 10;
52552c5
   AudioLanguages[0] = -1;
52552c5
   DisplaySubtitles = 0;
52552c5
+  SupportTeletext = 1;
52552c5
   SubtitleLanguages[0] = -1;
52552c5
   SubtitleOffset = 0;
52552c5
   SubtitleFgTransparency = 0;
52552c5
@@ -625,6 +626,7 @@ bool cSetup::Parse(const char *Name, const char *Value)
52552c5
   else if (!strcasecmp(Name, "MarginStop"))          MarginStop         = atoi(Value);
52552c5
   else if (!strcasecmp(Name, "AudioLanguages"))      return ParseLanguages(Value, AudioLanguages);
52552c5
   else if (!strcasecmp(Name, "DisplaySubtitles"))    DisplaySubtitles   = atoi(Value);
52552c5
+  else if (!strcasecmp(Name, "SupportTeletext"))     SupportTeletext    = atoi(Value);
52552c5
   else if (!strcasecmp(Name, "SubtitleLanguages"))   return ParseLanguages(Value, SubtitleLanguages);
52552c5
   else if (!strcasecmp(Name, "SubtitleOffset"))      SubtitleOffset     = atoi(Value);
52552c5
   else if (!strcasecmp(Name, "SubtitleFgTransparency")) SubtitleFgTransparency = atoi(Value);
52552c5
@@ -751,6 +753,7 @@ bool cSetup::Save(void)
52552c5
   Store("MarginStop",         MarginStop);
52552c5
   StoreLanguages("AudioLanguages", AudioLanguages);
52552c5
   Store("DisplaySubtitles",   DisplaySubtitles);
52552c5
+  Store("SupportTeletext",    SupportTeletext);
52552c5
   StoreLanguages("SubtitleLanguages", SubtitleLanguages);
52552c5
   Store("SubtitleOffset",     SubtitleOffset);
52552c5
   Store("SubtitleFgTransparency", SubtitleFgTransparency);
52552c5
diff --git a/config.h b/config.h
52552c5
index d1bae04..db1cbe1 100644
52552c5
--- a/config.h
52552c5
+++ b/config.h
52552c5
@@ -280,6 +280,7 @@ public:
52552c5
   int MarginStart, MarginStop;
52552c5
   int AudioLanguages[I18N_MAX_LANGUAGES + 1];
52552c5
   int DisplaySubtitles;
52552c5
+  int SupportTeletext;
52552c5
   int SubtitleLanguages[I18N_MAX_LANGUAGES + 1];
52552c5
   int SubtitleOffset;
52552c5
   int SubtitleFgTransparency, SubtitleBgTransparency;
52552c5
diff --git a/device.c b/device.c
52552c5
index 14ab07d..d4a6f5d 100644
52552c5
--- a/device.c
52552c5
+++ b/device.c
52552c5
@@ -19,6 +19,7 @@
52552c5
 #include "receiver.h"
52552c5
 #include "status.h"
52552c5
 #include "transfer.h"
52552c5
+#include "vdrttxtsubshooks.h"
52552c5
 
52552c5
 // --- cLiveSubtitle ---------------------------------------------------------
52552c5
 
52552c5
@@ -1321,6 +1322,13 @@ int cDevice::PlayPesPacket(const uchar *Data, int Length, bool VideoOnly)
52552c5
                   }
52552c5
                break;
52552c5
           case 0xBD: { // private stream 1
52552c5
+               // EBU Teletext data, ETSI EN 300 472
52552c5
+               // if PES data header length = 24 and data_identifier = 0x10..0x1F (EBU Data)
52552c5
+               if (Data[8] == 0x24 && Data[45] >= 0x10 && Data[45] < 0x20) {
52552c5
+                  cVDRTtxtsubsHookListener::Hook()->PlayerTeletextData((uint8_t*)Data, Length);
52552c5
+                  break;
52552c5
+                  }
52552c5
+
52552c5
                int PayloadOffset = Data[8] + 9;
52552c5
 
52552c5
                // Compatibility mode for old subtitles plugin:
52552c5
@@ -1480,6 +1488,7 @@ int cDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly)
52552c5
      tsToPesVideo.Reset();
52552c5
      tsToPesAudio.Reset();
52552c5
      tsToPesSubtitle.Reset();
52552c5
+     tsToPesTeletext.Reset();
52552c5
      }
52552c5
   else if (Length < TS_SIZE) {
52552c5
      esyslog("ERROR: skipped %d bytes of TS fragment", Length);
52552c5
@@ -1524,6 +1533,17 @@ int cDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly)
52552c5
                     if (!VideoOnly || HasIBPTrickSpeed())
52552c5
                        PlayTsSubtitle(Data, TS_SIZE);
52552c5
                     }
52552c5
+                 else if (Pid == patPmtParser.Tpid()) {
52552c5
+                    if (!VideoOnly || HasIBPTrickSpeed()) {
52552c5
+                       int l;
52552c5
+                       tsToPesTeletext.PutTs(Data, Length);
52552c5
+                       if (const uchar *p = tsToPesTeletext.GetPes(l)) {
52552c5
+                          if ((l > 45) && (p[0] == 0x00) && (p[1] == 0x00) && (p[2] == 0x01) && (p[3] == 0xbd) && (p[8] == 0x24) && (p[45] >= 0x10) && (p[45] < 0x20))
52552c5
+                             cVDRTtxtsubsHookListener::Hook()->PlayerTeletextData((uchar *)p, l, false, patPmtParser.TeletextSubtitlePages(), patPmtParser.TotalTeletextSubtitlePages());
52552c5
+                          tsToPesTeletext.Reset();
52552c5
+                          }
52552c5
+                       }
52552c5
+                    }
52552c5
                  }
52552c5
               }
52552c5
            else if (Pid == patPmtParser.Ppid()) {
52552c5
diff --git a/device.h b/device.h
52552c5
index b06d977..25a7bbe 100644
52552c5
--- a/device.h
52552c5
+++ b/device.h
52552c5
@@ -602,6 +602,7 @@ private:
52552c5
   cTsToPes tsToPesVideo;
52552c5
   cTsToPes tsToPesAudio;
52552c5
   cTsToPes tsToPesSubtitle;
52552c5
+  cTsToPes tsToPesTeletext;
52552c5
   bool isPlayingVideo;
52552c5
 protected:
52552c5
   const cPatPmtParser *PatPmtParser(void) const { return &patPmtParser; }
52552c5
diff --git a/menu.c b/menu.c
52552c5
index ae61c64..a0dba1b 100644
52552c5
--- a/menu.c
52552c5
+++ b/menu.c
52552c5
@@ -3326,6 +3326,7 @@ void cMenuSetupDVB::Setup(void)
52552c5
      Add(new cMenuEditIntItem( tr("Setup.DVB$Subtitle foreground transparency"), &data.SubtitleFgTransparency, 0, 9));
52552c5
      Add(new cMenuEditIntItem( tr("Setup.DVB$Subtitle background transparency"), &data.SubtitleBgTransparency, 0, 10));
52552c5
      }
52552c5
+  Add(new cMenuEditBoolItem(tr("Setup.DVB$Enable teletext support"), &data.SupportTeletext));
52552c5
 
52552c5
   SetCurrent(Get(current));
52552c5
   Display();
52552c5
diff --git a/pat.c b/pat.c
52552c5
index 98d306e..4ca0d5a 100644
52552c5
--- a/pat.c
52552c5
+++ b/pat.c
52552c5
@@ -12,6 +12,7 @@
52552c5
 #include "channels.h"
52552c5
 #include "libsi/section.h"
52552c5
 #include "libsi/descriptor.h"
52552c5
+#include "vdrttxtsubshooks.h"
52552c5
 
52552c5
 #define PMT_SCAN_TIMEOUT  1000 // ms
52552c5
 
52552c5
@@ -426,6 +427,8 @@ void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length
52552c5
         char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" };
52552c5
         char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" };
52552c5
         int Tpid = 0;
52552c5
+        tTeletextSubtitlePage TeletextSubtitlePages[MAXTXTPAGES];
52552c5
+        int NumTPages = 0;
52552c5
         int NumApids = 0;
52552c5
         int NumDpids = 0;
52552c5
         int NumSpids = 0;
52552c5
@@ -517,8 +520,21 @@ void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length
52552c5
                                     NumSpids++;
52552c5
                                     }
52552c5
                                  break;
52552c5
-                            case SI::TeletextDescriptorTag:
52552c5
+                            case SI::TeletextDescriptorTag: {
52552c5
                                  Tpid = esPid;
52552c5
+                                 SI::TeletextDescriptor *sd = (SI::TeletextDescriptor *)d;
52552c5
+                                 SI::TeletextDescriptor::Teletext ttxt;
52552c5
+                                 for (SI::Loop::Iterator it; sd->teletextLoop.getNext(ttxt, it); ) {
52552c5
+                                     bool isSubtitlePage = (ttxt.getTeletextType() == 0x02) || (ttxt.getTeletextType() == 0x05);
52552c5
+                                     if ((NumTPages < MAXTXTPAGES) && ttxt.languageCode[0] && isSubtitlePage) {
52552c5
+                                        strn0cpy(TeletextSubtitlePages[NumTPages].ttxtLanguage, I18nNormalizeLanguageCode(ttxt.languageCode), MAXLANGCODE1);
52552c5
+                                        TeletextSubtitlePages[NumTPages].ttxtPage = ttxt.getTeletextPageNumber();
52552c5
+                                        TeletextSubtitlePages[NumTPages].ttxtMagazine = ttxt.getTeletextMagazineNumber();
52552c5
+                                        TeletextSubtitlePages[NumTPages].ttxtType = ttxt.getTeletextType();
52552c5
+                                        NumTPages++;
52552c5
+                                        }
52552c5
+                                     }
52552c5
+                                 }
52552c5
                                  break;
52552c5
                             case SI::ISO639LanguageDescriptorTag: {
52552c5
                                  SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d;
52552c5
@@ -630,6 +646,12 @@ void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length
52552c5
             }
52552c5
         if (Setup.UpdateChannels >= 2) {
52552c5
            Channel->SetPids(Vpid, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
52552c5
+           if (NumTPages < MAXTXTPAGES) {
52552c5
+              int manualPageNumber = cVDRTtxtsubsHookListener::Hook()->ManualPageNumber(Channel);
52552c5
+              if (manualPageNumber)
52552c5
+                 TeletextSubtitlePages[NumTPages++] = tTeletextSubtitlePage(manualPageNumber);
52552c5
+              }
52552c5
+           Channel->SetTeletextSubtitlePages(TeletextSubtitlePages, NumTPages);
52552c5
            Channel->SetCaIds(CaDescriptors->CaIds());
52552c5
            Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds);
52552c5
            }
52552c5
diff --git a/po/ca_ES.po b/po/ca_ES.po
52552c5
index 8ea7bd3..5554051 100644
52552c5
--- a/po/ca_ES.po
52552c5
+++ b/po/ca_ES.po
52552c5
@@ -1059,6 +1059,9 @@ msgstr "Transpar
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "TransparŤncia fons subtŪtols"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "Configuraciů de l'LNB"
52552c5
 
52552c5
diff --git a/po/cs_CZ.po b/po/cs_CZ.po
52552c5
index 6c5ac1b..91625a8 100644
52552c5
--- a/po/cs_CZ.po
52552c5
+++ b/po/cs_CZ.po
52552c5
@@ -1059,6 +1059,9 @@ msgstr "PrŇĮhlednost p√≠sma titulkŇĮ"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "PrŇĮhlednost pozad√≠ titulkŇĮ"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/da_DK.po b/po/da_DK.po
52552c5
index d0fbbf8..6504096 100644
52552c5
--- a/po/da_DK.po
52552c5
+++ b/po/da_DK.po
52552c5
@@ -1056,6 +1056,9 @@ msgstr "Undertekst forgrundsgennemsigtighed"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Undertekst baggrundsgennemsigtighed"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/de_DE.po b/po/de_DE.po
52552c5
index 762c6fa..0e28962 100644
52552c5
--- a/po/de_DE.po
52552c5
+++ b/po/de_DE.po
52552c5
@@ -1057,6 +1057,9 @@ msgstr "Untertitel-Transparenz Vordergrund"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Untertitel-Transparenz Hintergrund"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr "Videotext-UnterstŁtzung aktivieren"
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/el_GR.po b/po/el_GR.po
52552c5
index a131cd7..6f131a3 100644
52552c5
--- a/po/el_GR.po
52552c5
+++ b/po/el_GR.po
52552c5
@@ -1056,6 +1056,9 @@ msgstr ""
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr ""
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/es_ES.po b/po/es_ES.po
52552c5
index b2827b5..139da7a 100644
52552c5
--- a/po/es_ES.po
52552c5
+++ b/po/es_ES.po
52552c5
@@ -1057,6 +1057,9 @@ msgstr "Transparencia primer plano subt
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Transparencia fondo subtŪtulos"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/et_EE.po b/po/et_EE.po
52552c5
index 8bf931a..a4c9a09 100644
52552c5
--- a/po/et_EE.po
52552c5
+++ b/po/et_EE.po
52552c5
@@ -1056,6 +1056,9 @@ msgstr "Subtiitri läbipaistvus"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Subtiitri tausta läbipaistvus"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr "Teleteksti tugi"
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/fi_FI.po b/po/fi_FI.po
52552c5
index 05d4b0f..9d55f39 100644
52552c5
--- a/po/fi_FI.po
52552c5
+++ b/po/fi_FI.po
52552c5
@@ -1060,6 +1060,9 @@ msgstr "Tekstityksen läpinäkyvyys"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Tekstityksen taustan läpinäkyvyys"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr "Salli teksti-TV-tuki"
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/fr_FR.po b/po/fr_FR.po
52552c5
index 06bb125..d3276f5 100644
52552c5
--- a/po/fr_FR.po
52552c5
+++ b/po/fr_FR.po
52552c5
@@ -1067,6 +1067,9 @@ msgstr "Transparence de l'avant-plan des sous-titres"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Transparence du fond des sous-titres"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/hr_HR.po b/po/hr_HR.po
52552c5
index 0424a44..109af41 100644
52552c5
--- a/po/hr_HR.po
52552c5
+++ b/po/hr_HR.po
52552c5
@@ -1058,6 +1058,9 @@ msgstr "Transparentnost titla"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Transparentnost pozadine titla"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/hu_HU.po b/po/hu_HU.po
52552c5
index c34bc0e..32a0ee3 100644
52552c5
--- a/po/hu_HU.po
52552c5
+++ b/po/hu_HU.po
52552c5
@@ -1061,6 +1061,9 @@ msgstr "Felirat transzparenci√°ja"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Felirat hátterének transzparenciája"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/it_IT.po b/po/it_IT.po
52552c5
index 79946ff..0b93c4a 100644
52552c5
--- a/po/it_IT.po
52552c5
+++ b/po/it_IT.po
52552c5
@@ -1062,6 +1062,9 @@ msgstr "Trasparenza sottotitoli"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Trasparenza sfondo sottotitoli"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/lt_LT.po b/po/lt_LT.po
52552c5
index a77dfcc..3ad927d 100644
52552c5
--- a/po/lt_LT.po
52552c5
+++ b/po/lt_LT.po
52552c5
@@ -1056,6 +1056,9 @@ msgstr "SubtitrŇ≥ fonto permatomumas"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "SubtitrŇ≥ fono permatomumas"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "Konverteris (LNB)"
52552c5
 
52552c5
diff --git a/po/nl_NL.po b/po/nl_NL.po
52552c5
index ab3fabd..b6e1a10 100644
52552c5
--- a/po/nl_NL.po
52552c5
+++ b/po/nl_NL.po
52552c5
@@ -1062,6 +1062,9 @@ msgstr "Transparantie voorgrond ondertiteling"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Transparantie achtergrond ondertiteling"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/nn_NO.po b/po/nn_NO.po
52552c5
index ba20fc6..11ce81e 100644
52552c5
--- a/po/nn_NO.po
52552c5
+++ b/po/nn_NO.po
52552c5
@@ -1057,6 +1057,9 @@ msgstr ""
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr ""
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/pl_PL.po b/po/pl_PL.po
52552c5
index becb8cb..9addb46 100644
52552c5
--- a/po/pl_PL.po
52552c5
+++ b/po/pl_PL.po
52552c5
@@ -1059,6 +1059,9 @@ msgstr "Prze
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Przeľrocze podtytu≥ůw: T≥o"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/pt_PT.po b/po/pt_PT.po
52552c5
index 9a0f792..6a11cda 100644
52552c5
--- a/po/pt_PT.po
52552c5
+++ b/po/pt_PT.po
52552c5
@@ -1057,6 +1057,9 @@ msgstr "Transpar
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "TransparÍncia de fundo das legendas"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/ro_RO.po b/po/ro_RO.po
52552c5
index c88dd0a..4f67d1c 100644
52552c5
--- a/po/ro_RO.po
52552c5
+++ b/po/ro_RO.po
52552c5
@@ -1058,6 +1058,9 @@ msgstr "TransparenŇ£a prim-planului subtitrńÉrii"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "TransparenŇ£a fundalului subtitrńÉrii"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/ru_RU.po b/po/ru_RU.po
52552c5
index 3e5057d..5d50264 100644
52552c5
--- a/po/ru_RU.po
52552c5
+++ b/po/ru_RU.po
52552c5
@@ -1057,6 +1057,9 @@ msgstr "
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Ņŗř◊ŗ–Á›řŠ‚ž šř›– Š„—‚ō‚ŗř“"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "ļř›“’ŗ‚’ŗ"
52552c5
 
52552c5
diff --git a/po/sk_SK.po b/po/sk_SK.po
52552c5
index cfc9bde..4fa36d0 100644
52552c5
--- a/po/sk_SK.po
52552c5
+++ b/po/sk_SK.po
52552c5
@@ -1057,6 +1057,9 @@ msgstr "Prieh
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "PriehĶadnosĽ pozadia titulkov"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB (nŪzko ĻumovŠ jednotka)"
52552c5
 
52552c5
diff --git a/po/sl_SI.po b/po/sl_SI.po
52552c5
index d12ccb2..dd86028 100644
52552c5
--- a/po/sl_SI.po
52552c5
+++ b/po/sl_SI.po
52552c5
@@ -1057,6 +1057,9 @@ msgstr "Transparentnost podnapisov"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Transparentnost ozadja podnapisov"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/sv_SE.po b/po/sv_SE.po
52552c5
index c164fa1..1c07570 100644
52552c5
--- a/po/sv_SE.po
52552c5
+++ b/po/sv_SE.po
52552c5
@@ -1061,6 +1061,9 @@ msgstr "Transparent f
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Transparent bakgrund textremsa"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/tr_TR.po b/po/tr_TR.po
52552c5
index 46a6a08..b4a8c55 100644
52552c5
--- a/po/tr_TR.po
52552c5
+++ b/po/tr_TR.po
52552c5
@@ -1056,6 +1056,9 @@ msgstr "Altyaz
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Altyazż arka Ģeffaflżk"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "LNB"
52552c5
 
52552c5
diff --git a/po/uk_UA.po b/po/uk_UA.po
52552c5
index 9d7328b..feba2ca 100644
52552c5
--- a/po/uk_UA.po
52552c5
+++ b/po/uk_UA.po
52552c5
@@ -1057,6 +1057,9 @@ msgstr "–ü—Ä–ĺ–∑–ĺ—Ä—Ė—Ā—ā—Ć –Ņ–Ķ—Ä–Ķ–ī–Ĺ—Ć–ĺ–≥–ĺ –Ņ–Ľ–į–Ĺ—É —Ā—É–Ī—ā–ł—ā—Ä—Ė–≤"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "–ü—Ä–ĺ–∑–ĺ—Ä—Ė—Ā—ā—Ć –∑–į–ī–Ĺ—Ć–ĺ–≥–ĺ –Ņ–Ľ–į–Ĺ—É —Ā—É–Ī—ā–ł—ā—Ä—Ė–≤"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "–ö–ĺ–Ĺ–≤–Ķ—Ä—ā–Ķ—Ä"
52552c5
 
52552c5
diff --git a/po/zh_CN.po b/po/zh_CN.po
52552c5
index 0dfbd6c..9c16c46 100644
52552c5
--- a/po/zh_CN.po
52552c5
+++ b/po/zh_CN.po
52552c5
@@ -1058,6 +1058,9 @@ msgstr "Ś≠óŚĻēŚČćśôĮťÄŹśėéŚļ¶"
52552c5
 msgid "Setup.DVB$Subtitle background transparency"
52552c5
 msgstr "Ś≠óŚĻēŤÉĆśôĮťÄŹśėéŚļ¶"
52552c5
 
52552c5
+msgid "Setup.DVB$Enable teletext support"
52552c5
+msgstr ""
52552c5
+
52552c5
 msgid "LNB"
52552c5
 msgstr "ŚąáśćĘŚô®ŤģĺÁĹģ"
52552c5
 
52552c5
diff --git a/receiver.c b/receiver.c
52552c5
index d8f51e6..7e1c252 100644
52552c5
--- a/receiver.c
52552c5
+++ b/receiver.c
52552c5
@@ -72,7 +72,8 @@ bool cReceiver::SetPids(const cChannel *Channel)
52552c5
             (Channel->Ppid() == Channel->Vpid() || AddPid(Channel->Ppid())) &&
52552c5
             AddPids(Channel->Apids()) &&
52552c5
             AddPids(Channel->Dpids()) &&
52552c5
-            AddPids(Channel->Spids());
52552c5
+            AddPids(Channel->Spids()) &&
52552c5
+            (!Setup.SupportTeletext || AddPid(Channel->Tpid()));
52552c5
      }
52552c5
   return true;
52552c5
 }
52552c5
diff --git a/remux.c b/remux.c
52552c5
index 23e8387..f1bf562 100644
52552c5
--- a/remux.c
52552c5
+++ b/remux.c
52552c5
@@ -416,6 +416,29 @@ int cPatPmtGenerator::MakeSubtitlingDescriptor(uchar *Target, const char *Langua
52552c5
   return i;
52552c5
 }
52552c5
 
52552c5
+int cPatPmtGenerator::MakeTeletextDescriptor(uchar *Target, const tTeletextSubtitlePage *pages, int pageCount)
52552c5
+{
52552c5
+  int i = 0, j = 0;
52552c5
+  Target[i++] = SI::TeletextDescriptorTag;
52552c5
+  int l = i;
52552c5
+  Target[i++] = 0x00; // length
52552c5
+  for (int n = 0; n < pageCount; n++) {
52552c5
+      const char* Language = pages[n].ttxtLanguage;
52552c5
+      Target[i++] = *Language++;
52552c5
+      Target[i++] = *Language++;
52552c5
+      Target[i++] = *Language++;
52552c5
+      Target[i++] = (pages[n].ttxtType << 3) + pages[n].ttxtMagazine;
52552c5
+      Target[i++] = pages[n].ttxtPage;
52552c5
+      j++;
52552c5
+      }
52552c5
+  if (j > 0) {
52552c5
+     Target[l] = j * 5; // update length
52552c5
+     IncEsInfoLength(i);
52552c5
+     return i;
52552c5
+     }
52552c5
+  return 0;
52552c5
+}
52552c5
+
52552c5
 int cPatPmtGenerator::MakeLanguageDescriptor(uchar *Target, const char *Language)
52552c5
 {
52552c5
   int i = 0;
52552c5
@@ -503,6 +526,7 @@ void cPatPmtGenerator::GeneratePmt(const cChannel *Channel)
52552c5
   if (Channel) {
52552c5
      int Vpid = Channel->Vpid();
52552c5
      int Ppid = Channel->Ppid();
52552c5
+     int Tpid = Channel->Tpid();
52552c5
      uchar *p = buf;
52552c5
      int i = 0;
52552c5
      p[i++] = 0x02; // table id
52552c5
@@ -535,6 +559,10 @@ void cPatPmtGenerator::GeneratePmt(const cChannel *Channel)
52552c5
          i += MakeStream(buf + i, 0x06, Channel->Spid(n));
52552c5
          i += MakeSubtitlingDescriptor(buf + i, Channel->Slang(n), Channel->SubtitlingType(n), Channel->CompositionPageId(n), Channel->AncillaryPageId(n));
52552c5
          }
52552c5
+     if (Tpid) {
52552c5
+        i += MakeStream(buf + i, 0x06, Tpid);
52552c5
+        i += MakeTeletextDescriptor(buf + i, Channel->TeletextSubtitlePages(), Channel->TotalTeletextSubtitlePages());
52552c5
+        }
52552c5
 
52552c5
      int sl = i - SectionLength - 2 + 4; // -2 = SectionLength storage, +4 = length of CRC
52552c5
      buf[SectionLength] |= (sl >> 8) & 0x0F;
52552c5
@@ -608,6 +636,7 @@ void cPatPmtParser::Reset(void)
52552c5
   pmtPids[0] = 0;
52552c5
   vpid = vtype = 0;
52552c5
   ppid = 0;
52552c5
+  tpid = 0;
52552c5
 }
52552c5
 
52552c5
 void cPatPmtParser::ParsePat(const uchar *Data, int Length)
52552c5
@@ -696,11 +725,13 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length)
52552c5
      int NumSpids = 0;
52552c5
      vpid = vtype = 0;
52552c5
      ppid = 0;
52552c5
+     tpid = 0;
52552c5
      apids[0] = 0;
52552c5
      dpids[0] = 0;
52552c5
      spids[0] = 0;
52552c5
      atypes[0] = 0;
52552c5
      dtypes[0] = 0;
52552c5
+     totalTtxtSubtitlePages = 0;
52552c5
      SI::PMT::Stream stream;
52552c5
      for (SI::Loop::Iterator it; Pmt.streamLoop.getNext(stream, it); ) {
52552c5
          dbgpatpmt("     stream type = %02X, pid = %d", stream.getStreamType(), stream.getPid());
52552c5
@@ -799,6 +830,28 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length)
52552c5
                                     spids[NumSpids] = 0;
52552c5
                                     }
52552c5
                                  break;
52552c5
+                            case SI::TeletextDescriptorTag: {
52552c5
+                                 dbgpatpmt(" teletext");
52552c5
+                                 tpid = stream.getPid();
52552c5
+                                 SI::TeletextDescriptor *sd = (SI::TeletextDescriptor *)d;
52552c5
+                                 SI::TeletextDescriptor::Teletext ttxt;
52552c5
+                                 if (totalTtxtSubtitlePages < MAXTXTPAGES) {
52552c5
+                                    for (SI::Loop::Iterator it; sd->teletextLoop.getNext(ttxt, it); ) {
52552c5
+                                        bool isSubtitlePage = (ttxt.getTeletextType() == 0x02) || (ttxt.getTeletextType() == 0x05);
52552c5
+                                        if (isSubtitlePage && ttxt.languageCode[0]) {
52552c5
+                                           dbgpatpmt(" '%s:%x.%x'", ttxt.languageCode, ttxt.getTeletextMagazineNumber(), ttxt.getTeletextPageNumber());
52552c5
+                                           strn0cpy(teletextSubtitlePages[totalTtxtSubtitlePages].ttxtLanguage, I18nNormalizeLanguageCode(ttxt.languageCode), MAXLANGCODE1);
52552c5
+                                           teletextSubtitlePages[totalTtxtSubtitlePages].ttxtPage = ttxt.getTeletextPageNumber();
52552c5
+                                           teletextSubtitlePages[totalTtxtSubtitlePages].ttxtMagazine = ttxt.getTeletextMagazineNumber();
52552c5
+                                           teletextSubtitlePages[totalTtxtSubtitlePages].ttxtType = ttxt.getTeletextType();
52552c5
+                                           totalTtxtSubtitlePages++;
52552c5
+                                           if (totalTtxtSubtitlePages >= MAXTXTPAGES)
52552c5
+                                              break;
52552c5
+                                           }
52552c5
+                                        }
52552c5
+                                    }
52552c5
+                                 }
52552c5
+                                 break;
52552c5
                             case SI::ISO639LanguageDescriptorTag: {
52552c5
                                  SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d;
52552c5
                                  dbgpatpmt(" '%s'", ld->languageCode);
52552c5
diff --git a/remux.h b/remux.h
52552c5
index 6bc91ad..039525d 100644
52552c5
--- a/remux.h
52552c5
+++ b/remux.h
52552c5
@@ -302,6 +302,7 @@ protected:
52552c5
   int MakeStream(uchar *Target, uchar Type, int Pid);
52552c5
   int MakeAC3Descriptor(uchar *Target, uchar Type);
52552c5
   int MakeSubtitlingDescriptor(uchar *Target, const char *Language, uchar SubtitlingType, uint16_t CompositionPageId, uint16_t AncillaryPageId);
52552c5
+  int MakeTeletextDescriptor(uchar *Target, const tTeletextSubtitlePage *pages, int pageCount);
52552c5
   int MakeLanguageDescriptor(uchar *Target, const char *Language);
52552c5
   int MakeCRC(uchar *Target, const uchar *Data, int Length);
52552c5
   void GeneratePmtPid(const cChannel *Channel);
52552c5
@@ -349,6 +350,7 @@ private:
52552c5
   int vpid;
52552c5
   int ppid;
52552c5
   int vtype;
52552c5
+  int tpid;
52552c5
   int apids[MAXAPIDS + 1]; // list is zero-terminated
52552c5
   int atypes[MAXAPIDS + 1]; // list is zero-terminated
52552c5
   char alangs[MAXAPIDS][MAXLANGCODE2];
52552c5
@@ -361,6 +363,8 @@ private:
52552c5
   uint16_t compositionPageIds[MAXSPIDS];
52552c5
   uint16_t ancillaryPageIds[MAXSPIDS];
52552c5
   bool updatePrimaryDevice;
52552c5
+  int totalTtxtSubtitlePages;
52552c5
+  tTeletextSubtitlePage teletextSubtitlePages[MAXTXTPAGES];
52552c5
 protected:
52552c5
   int SectionLength(const uchar *Data, int Length) { return (Length >= 3) ? ((int(Data[1]) & 0x0F) << 8)| Data[2] : 0; }
52552c5
 public:
52552c5
@@ -397,6 +401,9 @@ public:
52552c5
   int Vtype(void) const { return vtype; }
52552c5
        ///< Returns the video stream type as defined by the current PMT, or 0 if no video
52552c5
        ///< stream type has been detected, yet.
52552c5
+  int Tpid(void) { return tpid; }
52552c5
+       ///< Returns the teletext pid as defined by the current PMT, or 0 if no teletext
52552c5
+       ///< pid has been detected, yet.
52552c5
   const int *Apids(void) const { return apids; }
52552c5
   const int *Dpids(void) const { return dpids; }
52552c5
   const int *Spids(void) const { return spids; }
52552c5
@@ -411,6 +418,8 @@ public:
52552c5
   uchar SubtitlingType(int i) const { return (0 <= i && i < MAXSPIDS) ? subtitlingTypes[i] : uchar(0); }
52552c5
   uint16_t CompositionPageId(int i) const { return (0 <= i && i < MAXSPIDS) ? compositionPageIds[i] : uint16_t(0); }
52552c5
   uint16_t AncillaryPageId(int i) const { return (0 <= i && i < MAXSPIDS) ? ancillaryPageIds[i] : uint16_t(0); }
52552c5
+  const tTeletextSubtitlePage *TeletextSubtitlePages() const { return teletextSubtitlePages; }
52552c5
+  int TotalTeletextSubtitlePages() const { return totalTtxtSubtitlePages; }
52552c5
   };
52552c5
 
52552c5
 // TS to PES converter:
52552c5
diff --git a/vdr.5 b/vdr.5
52552c5
index fa233d7..cc06655 100644
52552c5
--- a/vdr.5
52552c5
+++ b/vdr.5
52552c5
@@ -249,6 +249,12 @@ by an '=' sign, as in
52552c5
 
52552c5
 .B ...:201;2001=deu,2002=eng:...
52552c5
 
52552c5
+Manual teletext subtitling pages can be defined separated by a '+' sign.
52552c5
+The pages (separated by commas) can contain language codes, delimited by a '='
52552c5
+sign, as in
52552c5
+
52552c5
+.B ...:201+150=deu,151=fin;2001,2002:...
52552c5
+
52552c5
 .TP
52552c5
 .B Conditional access
52552c5
 A hexadecimal integer defining how this channel can be accessed:
52552c5
diff --git a/vdrttxtsubshooks.c b/vdrttxtsubshooks.c
52552c5
new file mode 100644
52552c5
index 0000000..2471788
52552c5
--- /dev/null
52552c5
+++ b/vdrttxtsubshooks.c
52552c5
@@ -0,0 +1,63 @@
52552c5
+/*
52552c5
+ * vdr-ttxtsubs - A plugin for the Linux Video Disk Recorder
52552c5
+ * Copyright (c) 2003 - 2008 Ragnar Sundblad <ragge@nada.kth.se>
52552c5
+ *
52552c5
+ * This program is free software; you can redistribute it and/or modify it
52552c5
+ * under the terms of the GNU General Public License as published by the
52552c5
+ * Free Software Foundation; either version 2 of the License, or (at your option)
52552c5
+ * any later version.
52552c5
+ *
52552c5
+ * This program is distributed in the hope that it will be useful, but
52552c5
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
52552c5
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
52552c5
+ * details.
52552c5
+ *
52552c5
+ * You should have received a copy of the GNU General Public License along with
52552c5
+ * this program; if not, write to the Free Software Foundation, Inc.,
52552c5
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
52552c5
+ *
52552c5
+ */
52552c5
+
52552c5
+#include <stdlib.h>
52552c5
+#include <stdio.h>
52552c5
+#include <stdint.h>
52552c5
+
52552c5
+#include "vdrttxtsubshooks.h"
52552c5
+
52552c5
+// XXX Really should be a list...
52552c5
+static cVDRTtxtsubsHookListener *gListener;
52552c5
+
52552c5
+// ------ class cVDRTtxtsubsHookProxy ------
52552c5
+
52552c5
+class cVDRTtxtsubsHookProxy : public cVDRTtxtsubsHookListener
52552c5
+{
52552c5
+ public:
52552c5
+  virtual void HideOSD(void) { if(gListener) gListener->HideOSD(); };
52552c5
+  virtual void ShowOSD(void) { if(gListener) gListener->ShowOSD(); };
52552c5
+  virtual void PlayerTeletextData(uint8_t *p, int length, bool IsPesRecording, const struct tTeletextSubtitlePage teletextSubtitlePages[] = NULL, int pageCount = 0)
52552c5
+    { if(gListener) gListener->PlayerTeletextData(p, length, IsPesRecording, teletextSubtitlePages, pageCount); };
52552c5
+  virtual int ManualPageNumber(const cChannel *channel)
52552c5
+    { if(gListener) return gListener->ManualPageNumber(channel); else return 0; };
52552c5
+};
52552c5
+
52552c5
+
52552c5
+// ------ class cVDRTtxtsubsHookListener ------
52552c5
+
52552c5
+cVDRTtxtsubsHookListener::~cVDRTtxtsubsHookListener()
52552c5
+{
52552c5
+  gListener = 0;
52552c5
+}
52552c5
+
52552c5
+void cVDRTtxtsubsHookListener::HookAttach(void)
52552c5
+{
52552c5
+  gListener = this;
52552c5
+  //printf("cVDRTtxtsubsHookListener::HookAttach\n");
52552c5
+}
52552c5
+
52552c5
+static cVDRTtxtsubsHookProxy gProxy;
52552c5
+
52552c5
+cVDRTtxtsubsHookListener *cVDRTtxtsubsHookListener::Hook(void)
52552c5
+{
52552c5
+  return &gProxy;
52552c5
+}
52552c5
+
52552c5
diff --git a/vdrttxtsubshooks.h b/vdrttxtsubshooks.h
52552c5
new file mode 100644
52552c5
index 0000000..2f97969
52552c5
--- /dev/null
52552c5
+++ b/vdrttxtsubshooks.h
52552c5
@@ -0,0 +1,46 @@
52552c5
+/*
52552c5
+ * vdr-ttxtsubs - A plugin for the Linux Video Disk Recorder
52552c5
+ * Copyright (c) 2003 - 2008 Ragnar Sundblad <ragge@nada.kth.se>
52552c5
+ *
52552c5
+ * This program is free software; you can redistribute it and/or modify it
52552c5
+ * under the terms of the GNU General Public License as published by the
52552c5
+ * Free Software Foundation; either version 2 of the License, or (at your option)
52552c5
+ * any later version.
52552c5
+ *
52552c5
+ * This program is distributed in the hope that it will be useful, but
52552c5
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
52552c5
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
52552c5
+ * details.
52552c5
+ *
52552c5
+ * You should have received a copy of the GNU General Public License along with
52552c5
+ * this program; if not, write to the Free Software Foundation, Inc.,
52552c5
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
52552c5
+ *
52552c5
+ */
52552c5
+
52552c5
+#ifndef __VDRTTXTSUBSHOOKS_H
52552c5
+#define __VDRTTXTSUBSHOOKS_H
52552c5
+
52552c5
+#define TTXTSUBSVERSNUM 2
52552c5
+
52552c5
+class cDevice;
52552c5
+class cChannel;
52552c5
+struct tTeletextSubtitlePage;
52552c5
+
52552c5
+class cVDRTtxtsubsHookListener {
52552c5
+ public:
52552c5
+  cVDRTtxtsubsHookListener(void) {};
52552c5
+  virtual ~cVDRTtxtsubsHookListener();
52552c5
+
52552c5
+  void HookAttach(void);
52552c5
+
52552c5
+  virtual void HideOSD(void) {};
52552c5
+  virtual void ShowOSD(void) {};
52552c5
+  virtual void PlayerTeletextData(uint8_t *p, int length, bool IsPesRecording = true, const struct tTeletextSubtitlePage teletextSubtitlePages[] = NULL, int pageCount = 0) {};
52552c5
+  virtual int ManualPageNumber(const cChannel *channel) { return 0; };
52552c5
+
52552c5
+  // used by VDR to call hook listeners
52552c5
+  static cVDRTtxtsubsHookListener *Hook(void);
52552c5
+};
52552c5
+
52552c5
+#endif