summaryrefslogtreecommitdiff
path: root/patches/patch-set/0001-Record-teletext-subtitles.patch
diff options
context:
space:
mode:
authorTobias Grimm <git@e-tobi.net>2010-02-13 16:59:35 +0100
committerTobias Grimm <git@e-tobi.net>2010-02-13 22:33:19 +0100
commit438ed4c380061d1f855e09e1c9625e233b5b0bb0 (patch)
tree46b9d8e5c63cf8e83f4f756b02c59e4205decf51 /patches/patch-set/0001-Record-teletext-subtitles.patch
parente19403cc5f7996348d23528fbe6a3bc113da5e7d (diff)
downloadvdr-plugin-ttxtsubs-438ed4c380061d1f855e09e1c9625e233b5b0bb0.tar.gz
vdr-plugin-ttxtsubs-438ed4c380061d1f855e09e1c9625e233b5b0bb0.tar.bz2
Updated VDR patch (Closes #117)
Diffstat (limited to 'patches/patch-set/0001-Record-teletext-subtitles.patch')
-rw-r--r--patches/patch-set/0001-Record-teletext-subtitles.patch210
1 files changed, 210 insertions, 0 deletions
diff --git a/patches/patch-set/0001-Record-teletext-subtitles.patch b/patches/patch-set/0001-Record-teletext-subtitles.patch
new file mode 100644
index 0000000..05122c6
--- /dev/null
+++ b/patches/patch-set/0001-Record-teletext-subtitles.patch
@@ -0,0 +1,210 @@
+From 43914f1e49c368fbcc4d97e63e0e878de1238594 Mon Sep 17 00:00:00 2001
+From: etobi <git@e-tobi.net>
+Date: Fri, 12 Feb 2010 21:55:04 +0100
+Subject: [PATCH 1/5] Record teletext subtitles
+
+---
+ channels.c | 7 +++++++
+ channels.h | 14 ++++++++++++++
+ pat.c | 18 +++++++++++++++++-
+ receiver.c | 2 +-
+ remux.c | 28 ++++++++++++++++++++++++++++
+ remux.h | 1 +
+ 6 files changed, 68 insertions(+), 2 deletions(-)
+
+diff --git a/channels.c b/channels.c
+index c14df19..817b7d3 100644
+--- a/channels.c
++++ b/channels.c
+@@ -551,6 +551,13 @@ void cChannel::SetSubtitlingDescriptors(uchar *SubtitlingTypes, uint16_t *Compos
+ }
+ }
+
++void cChannel::SetTeletextSubtitlePages(tTeletextSubtitlePage pages[])
++{
++ for (int i = 0; i < MAXTXTPAGES; i++)
++ teletextSubtitlePages[i] = pages[i];
++ teletextSubtitlePages[MAXTXTPAGES].ttxtType = 0;
++}
++
+ void cChannel::SetCaIds(const int *CaIds)
+ {
+ if (caids[0] && caids[0] <= CA_USER_MAX)
+diff --git a/channels.h b/channels.h
+index b465f6a..18ed7c6 100644
+--- a/channels.h
++++ b/channels.h
+@@ -35,6 +35,7 @@
+ #define MAXDPIDS 16 // dolby (AC3 + DTS)
+ #define MAXSPIDS 32 // subtitles
+ #define MAXCAIDS 8 // conditional access
++#define MAXTXTPAGES 8 // teletext pages
+
+ #define MAXLANGCODE1 4 // a 3 letter language code, zero terminated
+ #define MAXLANGCODE2 8 // up to two 3 letter language codes, separated by '+' and zero terminated
+@@ -92,6 +93,16 @@ public:
+ static const tChannelID InvalidID;
+ };
+
++struct tTeletextSubtitlePage {
++ tTeletextSubtitlePage(void) { ttxtPage = ttxtMagazine = ttxtType = ttxtLanguage[0] = 0; }
++ tTeletextSubtitlePage(int page) { ttxtMagazine = (page / 100) & 0x7; ttxtPage = (((page % 100) / 10) << 4) + (page % 10); ttxtType = 0x02; }
++ char ttxtLanguage[MAXLANGCODE1];
++ uchar ttxtPage;
++ uchar ttxtMagazine;
++ uchar ttxtType;
++ int PageNumber(void) const { return BCDCHARTOINT(ttxtMagazine) * 100 + BCDCHARTOINT(ttxtPage); }
++ };
++
+ class cChannel;
+
+ class cLinkChannel : public cListObject {
+@@ -133,6 +144,7 @@ private:
+ uint16_t compositionPageIds[MAXSPIDS];
+ uint16_t ancillaryPageIds[MAXSPIDS];
+ int tpid;
++ tTeletextSubtitlePage teletextSubtitlePages[MAXTXTPAGES + 1]; // list is termintated by ttxtType=0
+ int caids[MAXCAIDS + 1]; // list is zero-terminated
+ int nid;
+ int tid;
+@@ -192,6 +204,7 @@ public:
+ uint16_t CompositionPageId(int i) const { return (0 <= i && i < MAXSPIDS) ? compositionPageIds[i] : uint16_t(0); }
+ uint16_t AncillaryPageId(int i) const { return (0 <= i && i < MAXSPIDS) ? ancillaryPageIds[i] : uint16_t(0); }
+ int Tpid(void) const { return tpid; }
++ const tTeletextSubtitlePage TeletextSubtitlePage(int i) const { return (0 <= i && i < MAXTXTPAGES) ? teletextSubtitlePages[i] : tTeletextSubtitlePage(); };
+ const int *Caids(void) const { return caids; }
+ int Ca(int Index = 0) const { return Index < MAXCAIDS ? caids[Index] : 0; }
+ int Nid(void) const { return nid; }
+@@ -228,6 +241,7 @@ public:
+ void SetName(const char *Name, const char *ShortName, const char *Provider);
+ void SetPortalName(const char *PortalName);
+ void SetPids(int Vpid, int Ppid, int Vtype, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
++ void SetTeletextSubtitlePages(tTeletextSubtitlePage pages[]);
+ void SetCaIds(const int *CaIds); // list must be zero-terminated
+ void SetCaDescriptors(int Level);
+ void SetLinkChannels(cLinkChannels *LinkChannels);
+diff --git a/pat.c b/pat.c
+index 9b3ded6..f4be6a6 100644
+--- a/pat.c
++++ b/pat.c
+@@ -341,6 +341,8 @@ void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length
+ char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" };
+ char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" };
+ int Tpid = 0;
++ tTeletextSubtitlePage TeletextSubtitlePages[MAXTXTPAGES];
++ int NumTPages = 0;
+ int NumApids = 0;
+ int NumDpids = 0;
+ int NumSpids = 0;
+@@ -426,8 +428,21 @@ void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length
+ NumSpids++;
+ }
+ break;
+- case SI::TeletextDescriptorTag:
++ case SI::TeletextDescriptorTag: {
+ Tpid = esPid;
++ SI::TeletextDescriptor *sd = (SI::TeletextDescriptor *)d;
++ SI::TeletextDescriptor::Teletext ttxt;
++ for (SI::Loop::Iterator it; sd->teletextLoop.getNext(ttxt, it); ) {
++ bool isSubtitlePage = (ttxt.getTeletextType() == 0x02) || (ttxt.getTeletextType() == 0x05);
++ if ((NumTPages < MAXTXTPAGES) && ttxt.languageCode[0] && isSubtitlePage) {
++ strn0cpy(TeletextSubtitlePages[NumTPages].ttxtLanguage, I18nNormalizeLanguageCode(ttxt.languageCode), MAXLANGCODE1);
++ TeletextSubtitlePages[NumTPages].ttxtPage = ttxt.getTeletextPageNumber();
++ TeletextSubtitlePages[NumTPages].ttxtMagazine = ttxt.getTeletextMagazineNumber();
++ TeletextSubtitlePages[NumTPages].ttxtType = ttxt.getTeletextType();
++ NumTPages++;
++ }
++ }
++ }
+ break;
+ case SI::ISO639LanguageDescriptorTag: {
+ SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d;
+@@ -458,6 +473,7 @@ void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length
+ }
+ if (Setup.UpdateChannels >= 2) {
+ Channel->SetPids(Vpid, Ppid, Vtype, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
++ Channel->SetTeletextSubtitlePages(TeletextSubtitlePages);
+ Channel->SetCaIds(CaDescriptors->CaIds());
+ Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds);
+ }
+diff --git a/receiver.c b/receiver.c
+index f922e98..dab95b3 100644
+--- a/receiver.c
++++ b/receiver.c
+@@ -82,7 +82,7 @@ bool cReceiver::SetPids(const cChannel *Channel)
+ (Channel->Ppid() == Channel->Vpid() || AddPid(Channel->Ppid())) &&
+ AddPids(Channel->Apids()) &&
+ (!Setup.UseDolbyDigital || AddPids(Channel->Dpids())) &&
+- AddPids(Channel->Spids());
++ AddPids(Channel->Spids()) && AddPid(Channel->Tpid());
+ }
+ return true;
+ }
+diff --git a/remux.c b/remux.c
+index 070a06a..869b6e4 100644
+--- a/remux.c
++++ b/remux.c
+@@ -215,6 +215,29 @@ int cPatPmtGenerator::MakeSubtitlingDescriptor(uchar *Target, const char *Langua
+ return i;
+ }
+
++int cPatPmtGenerator::MakeTeletextDescriptor(uchar *Target, const cChannel *Channel)
++{
++ int i = 0, j = 0;
++ Target[i++] = SI::TeletextDescriptorTag;
++ int l = i;
++ Target[i++] = 0x00; // length
++ for (int n = 0; Channel->TeletextSubtitlePage(n).ttxtType; n++) {
++ const char* Language = Channel->TeletextSubtitlePage(n).ttxtLanguage;
++ Target[i++] = *Language++;
++ Target[i++] = *Language++;
++ Target[i++] = *Language++;
++ Target[i++] = (Channel->TeletextSubtitlePage(n).ttxtType << 3) + Channel->TeletextSubtitlePage(n).ttxtMagazine;
++ Target[i++] = Channel->TeletextSubtitlePage(n).ttxtPage;
++ j++;
++ }
++ if (j > 0) {
++ Target[l] = j * 5; // update length
++ IncEsInfoLength(i);
++ return i;
++ }
++ return 0;
++}
++
+ int cPatPmtGenerator::MakeLanguageDescriptor(uchar *Target, const char *Language)
+ {
+ int i = 0;
+@@ -296,6 +319,7 @@ void cPatPmtGenerator::GeneratePmt(const cChannel *Channel)
+ if (Channel) {
+ int Vpid = Channel->Vpid();
+ int Ppid = Channel->Ppid();
++ int Tpid = Channel->Tpid();
+ uchar *p = buf;
+ int i = 0;
+ p[i++] = 0x02; // table id
+@@ -330,6 +354,10 @@ void cPatPmtGenerator::GeneratePmt(const cChannel *Channel)
+ i += MakeStream(buf + i, 0x06, Channel->Spid(n));
+ i += MakeSubtitlingDescriptor(buf + i, Channel->Slang(n), Channel->SubtitlingType(n), Channel->CompositionPageId(n), Channel->AncillaryPageId(n));
+ }
++ if (Tpid) {
++ i += MakeStream(buf + i, 0x06, Tpid);
++ i += MakeTeletextDescriptor(buf + i, Channel);
++ }
+
+ int sl = i - SectionLength - 2 + 4; // -2 = SectionLength storage, +4 = length of CRC
+ buf[SectionLength] |= (sl >> 8) & 0x0F;
+diff --git a/remux.h b/remux.h
+index 1115c4a..cef50d7 100644
+--- a/remux.h
++++ b/remux.h
+@@ -170,6 +170,7 @@ protected:
+ int MakeStream(uchar *Target, uchar Type, int Pid);
+ int MakeAC3Descriptor(uchar *Target);
+ int MakeSubtitlingDescriptor(uchar *Target, const char *Language, uchar SubtitlingType, uint16_t CompositionPageId, uint16_t AncillaryPageId);
++ int MakeTeletextDescriptor(uchar *Target, const cChannel *Channel);
+ int MakeLanguageDescriptor(uchar *Target, const char *Language);
+ int MakeCRC(uchar *Target, const uchar *Data, int Length);
+ void GeneratePmtPid(const cChannel *Channel);
+--
+1.6.5
+