From 5bff1274f6578f82c7cbe60e3b6de9c67727f26d Mon Sep 17 00:00:00 2001 From: Tobias Grimm Date: Sun, 14 Feb 2010 01:34:57 +0100 Subject: Decrypt encrypted teletext stream (Closes #241) --- .../patch-set/0001-Record-teletext-subtitles.patch | 2 +- ...-option-to-enable-teletext-subtitle-recor.patch | 2 +- ...l-configuration-of-teletetxt-subtitle-pag.patch | 2 +- ...-Capture-teletext-subtitle-pages-from-PMT.patch | 104 --------- .../patch-set/0004-Decrypt-teletext-stream.patch | 26 +++ ...-Capture-teletext-subtitle-pages-from-PMT.patch | 104 +++++++++ patches/patch-set/0005-Ttxtsubs-plugin-hook.patch | 244 --------------------- patches/patch-set/0006-Ttxtsubs-plugin-hook.patch | 244 +++++++++++++++++++++ patches/vdr-1.7.12-ttxtsubs.patch | 14 ++ 9 files changed, 391 insertions(+), 351 deletions(-) delete mode 100644 patches/patch-set/0004-Capture-teletext-subtitle-pages-from-PMT.patch create mode 100644 patches/patch-set/0004-Decrypt-teletext-stream.patch create mode 100644 patches/patch-set/0005-Capture-teletext-subtitle-pages-from-PMT.patch delete mode 100644 patches/patch-set/0005-Ttxtsubs-plugin-hook.patch create mode 100644 patches/patch-set/0006-Ttxtsubs-plugin-hook.patch (limited to 'patches') diff --git a/patches/patch-set/0001-Record-teletext-subtitles.patch b/patches/patch-set/0001-Record-teletext-subtitles.patch index 05122c6..4272381 100644 --- a/patches/patch-set/0001-Record-teletext-subtitles.patch +++ b/patches/patch-set/0001-Record-teletext-subtitles.patch @@ -1,7 +1,7 @@ From 43914f1e49c368fbcc4d97e63e0e878de1238594 Mon Sep 17 00:00:00 2001 From: etobi Date: Fri, 12 Feb 2010 21:55:04 +0100 -Subject: [PATCH 1/5] Record teletext subtitles +Subject: [PATCH 1/6] Record teletext subtitles --- channels.c | 7 +++++++ diff --git a/patches/patch-set/0002-Added-setup-option-to-enable-teletext-subtitle-recor.patch b/patches/patch-set/0002-Added-setup-option-to-enable-teletext-subtitle-recor.patch index 80cfac5..2c49115 100644 --- a/patches/patch-set/0002-Added-setup-option-to-enable-teletext-subtitle-recor.patch +++ b/patches/patch-set/0002-Added-setup-option-to-enable-teletext-subtitle-recor.patch @@ -1,7 +1,7 @@ From 53a2a588490c058bb2a907d00dad88927bec4618 Mon Sep 17 00:00:00 2001 From: etobi Date: Sat, 13 Feb 2010 14:42:30 +0100 -Subject: [PATCH 2/5] Added setup option to enable teletext subtitle recording +Subject: [PATCH 2/6] Added setup option to enable teletext subtitle recording --- MANUAL | 3 +++ diff --git a/patches/patch-set/0003-Allow-manual-configuration-of-teletetxt-subtitle-pag.patch b/patches/patch-set/0003-Allow-manual-configuration-of-teletetxt-subtitle-pag.patch index 249185a..300282b 100644 --- a/patches/patch-set/0003-Allow-manual-configuration-of-teletetxt-subtitle-pag.patch +++ b/patches/patch-set/0003-Allow-manual-configuration-of-teletetxt-subtitle-pag.patch @@ -1,7 +1,7 @@ From f33ffd78393792ba23c4ee48b3543e182663dc97 Mon Sep 17 00:00:00 2001 From: etobi Date: Fri, 12 Feb 2010 21:56:41 +0100 -Subject: [PATCH 3/5] Allow manual configuration of teletetxt subtitle pages in channels.conf +Subject: [PATCH 3/6] Allow manual configuration of teletetxt subtitle pages in channels.conf --- channels.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- diff --git a/patches/patch-set/0004-Capture-teletext-subtitle-pages-from-PMT.patch b/patches/patch-set/0004-Capture-teletext-subtitle-pages-from-PMT.patch deleted file mode 100644 index 4424838..0000000 --- a/patches/patch-set/0004-Capture-teletext-subtitle-pages-from-PMT.patch +++ /dev/null @@ -1,104 +0,0 @@ -From a0823f9a5d13174c8942a4c7dff52e0270ad483e Mon Sep 17 00:00:00 2001 -From: etobi -Date: Fri, 12 Feb 2010 22:06:19 +0100 -Subject: [PATCH 4/5] Capture teletext subtitle pages from PMT - ---- - remux.c | 26 ++++++++++++++++++++++++++ - remux.h | 6 ++++++ - 2 files changed, 32 insertions(+), 0 deletions(-) - -diff --git a/remux.c b/remux.c -index 869b6e4..24fcbd3 100644 ---- a/remux.c -+++ b/remux.c -@@ -431,6 +431,7 @@ void cPatPmtParser::Reset(void) - pmtPid = -1; - vpid = vtype = 0; - ppid = 0; -+ tpid = 0; - } - - void cPatPmtParser::ParsePat(const uchar *Data, int Length) -@@ -514,8 +515,10 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length) - int NumApids = 0; - int NumDpids = 0; - int NumSpids = 0; -+ int NumTPages = 0; - vpid = vtype = 0; - ppid = 0; -+ tpid = 0; - apids[0] = 0; - dpids[0] = 0; - spids[0] = 0; -@@ -614,6 +617,29 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length) - spids[NumSpids]= 0; - } - break; -+ case SI::TeletextDescriptorTag: { -+ dbgpatpmt(" teletext"); -+ tpid = stream.getPid(); -+ SI::TeletextDescriptor *sd = (SI::TeletextDescriptor *)d; -+ SI::TeletextDescriptor::Teletext ttxt; -+ if (NumTPages < MAXTXTPAGES) { -+ for (SI::Loop::Iterator it; sd->teletextLoop.getNext(ttxt, it); ) { -+ bool isSubtitlePage = (ttxt.getTeletextType() == 0x02) || (ttxt.getTeletextType() == 0x05); -+ if (isSubtitlePage && ttxt.languageCode[0]) { -+ dbgpatpmt(" '%s:%x.%x'", ttxt.languageCode, ttxt.getTeletextMagazineNumber(), ttxt.getTeletextPageNumber()); -+ strn0cpy(teletextSubtitlePages[NumTPages].ttxtLanguage, I18nNormalizeLanguageCode(ttxt.languageCode), MAXLANGCODE1); -+ teletextSubtitlePages[NumTPages].ttxtPage = ttxt.getTeletextPageNumber(); -+ teletextSubtitlePages[NumTPages].ttxtMagazine = ttxt.getTeletextMagazineNumber(); -+ teletextSubtitlePages[NumTPages].ttxtType = ttxt.getTeletextType(); -+ NumTPages++; -+ if (NumTPages >= MAXTXTPAGES) -+ break; -+ } -+ } -+ teletextSubtitlePages[NumTPages].ttxtType = 0; // indicates end of list -+ } -+ } -+ break; - case SI::ISO639LanguageDescriptorTag: { - SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d; - dbgpatpmt(" '%s'", ld->languageCode); -diff --git a/remux.h b/remux.h -index cef50d7..43809fc 100644 ---- a/remux.h -+++ b/remux.h -@@ -216,6 +216,7 @@ private: - int vpid; - int ppid; - int vtype; -+ int tpid; - int apids[MAXAPIDS + 1]; // list is zero-terminated - int atypes[MAXAPIDS + 1]; // list is zero-terminated - char alangs[MAXAPIDS][MAXLANGCODE2]; -@@ -228,6 +229,7 @@ private: - uint16_t compositionPageIds[MAXSPIDS]; - uint16_t ancillaryPageIds[MAXSPIDS]; - bool updatePrimaryDevice; -+ tTeletextSubtitlePage teletextSubtitlePages[MAXTXTPAGES + 1]; // list is zero-terminated - protected: - int SectionLength(const uchar *Data, int Length) { return (Length >= 3) ? ((int(Data[1]) & 0x0F) << 8)| Data[2] : 0; } - public: -@@ -260,6 +262,9 @@ public: - int Vtype(void) const { return vtype; } - ///< Returns the video stream type as defined by the current PMT, or 0 if no video - ///< stream type has been detected, yet. -+ int Tpid(void) { return tpid; } -+ ///< Returns the teletext pid as defined by the current PMT, or 0 if no teletext -+ ///< pid has been detected, yet. - const int *Apids(void) const { return apids; } - const int *Dpids(void) const { return dpids; } - const int *Spids(void) const { return spids; } -@@ -274,6 +279,7 @@ public: - uchar SubtitlingType(int i) const { return (0 <= i && i < MAXSPIDS) ? subtitlingTypes[i] : uchar(0); } - 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); } -+ const tTeletextSubtitlePage* TeletextSubtitlePages() const { return teletextSubtitlePages; } - }; - - // TS to PES converter: --- -1.6.5 - diff --git a/patches/patch-set/0004-Decrypt-teletext-stream.patch b/patches/patch-set/0004-Decrypt-teletext-stream.patch new file mode 100644 index 0000000..7eb732f --- /dev/null +++ b/patches/patch-set/0004-Decrypt-teletext-stream.patch @@ -0,0 +1,26 @@ +From 047e1fc5c4e7f6b4b987f3d19dba963d60126d55 Mon Sep 17 00:00:00 2001 +From: etobi +Date: Sun, 14 Feb 2010 01:30:34 +0100 +Subject: [PATCH 4/6] Decrypt teletext stream + +--- + ci.c | 3 +++ + 1 files changed, 3 insertions(+), 0 deletions(-) + +diff --git a/ci.c b/ci.c +index 6c7b031..f158a18 100644 +--- a/ci.c ++++ b/ci.c +@@ -1932,6 +1932,9 @@ bool cCamSlot::CanDecrypt(const cChannel *Channel) + CaPmt.AddPid(*Apid, STREAM_TYPE_AUDIO); + for (const int *Dpid = Channel->Dpids(); *Dpid; Dpid++) + CaPmt.AddPid(*Dpid, STREAM_TYPE_DOLBY); ++ if (Channel->Tpid() && Setup.RecordTtxtSubtitles) { ++ CaPmt.AddPid(Channel->Tpid(), STREAM_TYPE_DOLBY); // FIXME: STREAM_TYPE_DOLBY should probably be renamed STREAM_TYPE_PRIVATE ++ } + cas->SendPMT(&CaPmt); + cTimeMs Timeout(QUERY_REPLY_TIMEOUT); + do { +-- +1.6.5 + diff --git a/patches/patch-set/0005-Capture-teletext-subtitle-pages-from-PMT.patch b/patches/patch-set/0005-Capture-teletext-subtitle-pages-from-PMT.patch new file mode 100644 index 0000000..91b57c3 --- /dev/null +++ b/patches/patch-set/0005-Capture-teletext-subtitle-pages-from-PMT.patch @@ -0,0 +1,104 @@ +From cd69cfb12c691834710beb346527920b8802552e Mon Sep 17 00:00:00 2001 +From: etobi +Date: Fri, 12 Feb 2010 22:06:19 +0100 +Subject: [PATCH 5/6] Capture teletext subtitle pages from PMT + +--- + remux.c | 26 ++++++++++++++++++++++++++ + remux.h | 6 ++++++ + 2 files changed, 32 insertions(+), 0 deletions(-) + +diff --git a/remux.c b/remux.c +index 869b6e4..24fcbd3 100644 +--- a/remux.c ++++ b/remux.c +@@ -431,6 +431,7 @@ void cPatPmtParser::Reset(void) + pmtPid = -1; + vpid = vtype = 0; + ppid = 0; ++ tpid = 0; + } + + void cPatPmtParser::ParsePat(const uchar *Data, int Length) +@@ -514,8 +515,10 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length) + int NumApids = 0; + int NumDpids = 0; + int NumSpids = 0; ++ int NumTPages = 0; + vpid = vtype = 0; + ppid = 0; ++ tpid = 0; + apids[0] = 0; + dpids[0] = 0; + spids[0] = 0; +@@ -614,6 +617,29 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length) + spids[NumSpids]= 0; + } + break; ++ case SI::TeletextDescriptorTag: { ++ dbgpatpmt(" teletext"); ++ tpid = stream.getPid(); ++ SI::TeletextDescriptor *sd = (SI::TeletextDescriptor *)d; ++ SI::TeletextDescriptor::Teletext ttxt; ++ if (NumTPages < MAXTXTPAGES) { ++ for (SI::Loop::Iterator it; sd->teletextLoop.getNext(ttxt, it); ) { ++ bool isSubtitlePage = (ttxt.getTeletextType() == 0x02) || (ttxt.getTeletextType() == 0x05); ++ if (isSubtitlePage && ttxt.languageCode[0]) { ++ dbgpatpmt(" '%s:%x.%x'", ttxt.languageCode, ttxt.getTeletextMagazineNumber(), ttxt.getTeletextPageNumber()); ++ strn0cpy(teletextSubtitlePages[NumTPages].ttxtLanguage, I18nNormalizeLanguageCode(ttxt.languageCode), MAXLANGCODE1); ++ teletextSubtitlePages[NumTPages].ttxtPage = ttxt.getTeletextPageNumber(); ++ teletextSubtitlePages[NumTPages].ttxtMagazine = ttxt.getTeletextMagazineNumber(); ++ teletextSubtitlePages[NumTPages].ttxtType = ttxt.getTeletextType(); ++ NumTPages++; ++ if (NumTPages >= MAXTXTPAGES) ++ break; ++ } ++ } ++ teletextSubtitlePages[NumTPages].ttxtType = 0; // indicates end of list ++ } ++ } ++ break; + case SI::ISO639LanguageDescriptorTag: { + SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d; + dbgpatpmt(" '%s'", ld->languageCode); +diff --git a/remux.h b/remux.h +index cef50d7..43809fc 100644 +--- a/remux.h ++++ b/remux.h +@@ -216,6 +216,7 @@ private: + int vpid; + int ppid; + int vtype; ++ int tpid; + int apids[MAXAPIDS + 1]; // list is zero-terminated + int atypes[MAXAPIDS + 1]; // list is zero-terminated + char alangs[MAXAPIDS][MAXLANGCODE2]; +@@ -228,6 +229,7 @@ private: + uint16_t compositionPageIds[MAXSPIDS]; + uint16_t ancillaryPageIds[MAXSPIDS]; + bool updatePrimaryDevice; ++ tTeletextSubtitlePage teletextSubtitlePages[MAXTXTPAGES + 1]; // list is zero-terminated + protected: + int SectionLength(const uchar *Data, int Length) { return (Length >= 3) ? ((int(Data[1]) & 0x0F) << 8)| Data[2] : 0; } + public: +@@ -260,6 +262,9 @@ public: + int Vtype(void) const { return vtype; } + ///< Returns the video stream type as defined by the current PMT, or 0 if no video + ///< stream type has been detected, yet. ++ int Tpid(void) { return tpid; } ++ ///< Returns the teletext pid as defined by the current PMT, or 0 if no teletext ++ ///< pid has been detected, yet. + const int *Apids(void) const { return apids; } + const int *Dpids(void) const { return dpids; } + const int *Spids(void) const { return spids; } +@@ -274,6 +279,7 @@ public: + uchar SubtitlingType(int i) const { return (0 <= i && i < MAXSPIDS) ? subtitlingTypes[i] : uchar(0); } + 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); } ++ const tTeletextSubtitlePage* TeletextSubtitlePages() const { return teletextSubtitlePages; } + }; + + // TS to PES converter: +-- +1.6.5 + diff --git a/patches/patch-set/0005-Ttxtsubs-plugin-hook.patch b/patches/patch-set/0005-Ttxtsubs-plugin-hook.patch deleted file mode 100644 index b338345..0000000 --- a/patches/patch-set/0005-Ttxtsubs-plugin-hook.patch +++ /dev/null @@ -1,244 +0,0 @@ -From 122be8fa91973f031586fdd2026585cb0510e19f Mon Sep 17 00:00:00 2001 -From: etobi -Date: Sat, 13 Feb 2010 00:28:21 +0100 -Subject: [PATCH 5/5] Ttxtsubs plugin hook - ---- - Makefile | 2 + - device.c | 20 ++++++++++++++++ - device.h | 1 + - pat.c | 9 +++++++ - vdrttxtsubshooks.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - vdrttxtsubshooks.h | 46 ++++++++++++++++++++++++++++++++++++++ - 6 files changed, 141 insertions(+), 0 deletions(-) - create mode 100644 vdrttxtsubshooks.c - create mode 100644 vdrttxtsubshooks.h - -diff --git a/Makefile b/Makefile -index 01408cb..b280030 100644 ---- a/Makefile -+++ b/Makefile -@@ -43,6 +43,8 @@ OBJS = audio.o channels.o ci.o config.o cutter.o device.o diseqc.o dvbdevice.o d - skinclassic.o skins.o skinsttng.o sources.o spu.o status.o svdrp.o themes.o thread.o\ - timers.o tools.o transfer.o vdr.o videodir.o - -+OBJS += vdrttxtsubshooks.o -+ - ifndef NO_KBD - DEFINES += -DREMOTE_KBD - endif -diff --git a/device.c b/device.c -index cb31b83..86b6b2c 100644 ---- a/device.c -+++ b/device.c -@@ -18,6 +18,7 @@ - #include "receiver.h" - #include "status.h" - #include "transfer.h" -+#include "vdrttxtsubshooks.h" - - // --- cLiveSubtitle --------------------------------------------------------- - -@@ -1190,6 +1191,13 @@ int cDevice::PlayPesPacket(const uchar *Data, int Length, bool VideoOnly) - } - break; - case 0xBD: { // private stream 1 -+ // EBU Teletext data, ETSI EN 300 472 -+ // if PES data header length = 24 and data_identifier = 0x10..0x1F (EBU Data) -+ if (Data[8] == 0x24 && Data[45] >= 0x10 && Data[45] < 0x20) { -+ cVDRTtxtsubsHookListener::Hook()->PlayerTeletextData((uint8_t*)Data, Length); -+ break; -+ } -+ - int PayloadOffset = Data[8] + 9; - - // Compatibility mode for old subtitles plugin: -@@ -1349,6 +1357,7 @@ int cDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly) - tsToPesVideo.Reset(); - tsToPesAudio.Reset(); - tsToPesSubtitle.Reset(); -+ tsToPesTeletext.Reset(); - } - else if (Length < TS_SIZE) { - esyslog("ERROR: skipped %d bytes of TS fragment", Length); -@@ -1394,6 +1403,17 @@ int cDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly) - if (!VideoOnly || HasIBPTrickSpeed()) - PlayTsSubtitle(Data, TS_SIZE); - } -+ else if (Pid == patPmtParser.Tpid()) { -+ if (!VideoOnly || HasIBPTrickSpeed()) { -+ int l; -+ tsToPesTeletext.PutTs(Data, Length); -+ if (const uchar *p = tsToPesTeletext.GetPes(l)) { -+ if ((l > 45) && (p[0] == 0x00) && (p[1] == 0x00) && (p[2] == 0x01) && (p[3] == 0xbd) && (p[8] == 0x24) && (p[45] >= 0x10) && (p[45] < 0x20)) -+ cVDRTtxtsubsHookListener::Hook()->PlayerTeletextData((uchar *)p, l, false, patPmtParser.TeletextSubtitlePages()); -+ tsToPesTeletext.Reset(); -+ } -+ } -+ } - } - } - else if (Pid == patPmtParser.Ppid()) { -diff --git a/device.h b/device.h -index 897de2a..2e36351 100644 ---- a/device.h -+++ b/device.h -@@ -499,6 +499,7 @@ private: - cTsToPes tsToPesVideo; - cTsToPes tsToPesAudio; - cTsToPes tsToPesSubtitle; -+ cTsToPes tsToPesTeletext; - bool isPlayingVideo; - protected: - const cPatPmtParser *PatPmtParser(void) const { return &patPmtParser; } -diff --git a/pat.c b/pat.c -index f4be6a6..444be21 100644 ---- a/pat.c -+++ b/pat.c -@@ -13,6 +13,7 @@ - #include "libsi/section.h" - #include "libsi/descriptor.h" - #include "thread.h" -+#include "vdrttxtsubshooks.h" - - #define PMT_SCAN_TIMEOUT 10 // seconds - -@@ -473,6 +474,14 @@ 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); -+ if (NumTPages < MAXTXTPAGES) { -+ int manualPageNumber = cVDRTtxtsubsHookListener::Hook()->ManualPageNumber(Channel); -+ if (manualPageNumber) { -+ TeletextSubtitlePages[NumTPages] = tTeletextSubtitlePage(manualPageNumber); -+ strn0cpy(TeletextSubtitlePages[NumTPages].ttxtLanguage, "und", MAXLANGCODE1); -+ NumTPages++; -+ } -+ } - Channel->SetTeletextSubtitlePages(TeletextSubtitlePages); - Channel->SetCaIds(CaDescriptors->CaIds()); - Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds); -diff --git a/vdrttxtsubshooks.c b/vdrttxtsubshooks.c -new file mode 100644 -index 0000000..865596e ---- /dev/null -+++ b/vdrttxtsubshooks.c -@@ -0,0 +1,63 @@ -+/* -+ * vdr-ttxtsubs - A plugin for the Linux Video Disk Recorder -+ * Copyright (c) 2003 - 2008 Ragnar Sundblad -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2 of the License, or (at your option) -+ * any later version. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -+ * details. -+ * -+ * You should have received a copy of the GNU General Public License along with -+ * this program; if not, write to the Free Software Foundation, Inc., -+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ * -+ */ -+ -+#include -+#include -+#include -+ -+#include "vdrttxtsubshooks.h" -+ -+// XXX Really should be a list... -+static cVDRTtxtsubsHookListener *gListener; -+ -+// ------ class cVDRTtxtsubsHookProxy ------ -+ -+class cVDRTtxtsubsHookProxy : public cVDRTtxtsubsHookListener -+{ -+ public: -+ virtual void HideOSD(void) { if(gListener) gListener->HideOSD(); }; -+ virtual void ShowOSD(void) { if(gListener) gListener->ShowOSD(); }; -+ virtual void PlayerTeletextData(uint8_t *p, int length, bool IsPesRecording, const struct tTeletextSubtitlePage teletextSubtitlePages[] = NULL) -+ { if(gListener) gListener->PlayerTeletextData(p, length, IsPesRecording, teletextSubtitlePages); }; -+ virtual int ManualPageNumber(const cChannel *channel) -+ { if(gListener) return gListener->ManualPageNumber(channel); else return 0; }; -+}; -+ -+ -+// ------ class cVDRTtxtsubsHookListener ------ -+ -+cVDRTtxtsubsHookListener::~cVDRTtxtsubsHookListener() -+{ -+ gListener = 0; -+} -+ -+void cVDRTtxtsubsHookListener::HookAttach(void) -+{ -+ gListener = this; -+ //printf("cVDRTtxtsubsHookListener::HookAttach\n"); -+} -+ -+static cVDRTtxtsubsHookProxy gProxy; -+ -+cVDRTtxtsubsHookListener *cVDRTtxtsubsHookListener::Hook(void) -+{ -+ return &gProxy; -+} -+ -diff --git a/vdrttxtsubshooks.h b/vdrttxtsubshooks.h -new file mode 100644 -index 0000000..2e8e9ba ---- /dev/null -+++ b/vdrttxtsubshooks.h -@@ -0,0 +1,46 @@ -+/* -+ * vdr-ttxtsubs - A plugin for the Linux Video Disk Recorder -+ * Copyright (c) 2003 - 2008 Ragnar Sundblad -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2 of the License, or (at your option) -+ * any later version. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -+ * details. -+ * -+ * You should have received a copy of the GNU General Public License along with -+ * this program; if not, write to the Free Software Foundation, Inc., -+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ * -+ */ -+ -+#ifndef __VDRTTXTSUBSHOOKS_H -+#define __VDRTTXTSUBSHOOKS_H -+ -+#define TTXTSUBSVERSNUM 2 -+ -+class cDevice; -+class cChannel; -+struct tTeletextSubtitlePage; -+ -+class cVDRTtxtsubsHookListener { -+ public: -+ cVDRTtxtsubsHookListener(void) {}; -+ virtual ~cVDRTtxtsubsHookListener(); -+ -+ void HookAttach(void); -+ -+ virtual void HideOSD(void) {}; -+ virtual void ShowOSD(void) {}; -+ virtual void PlayerTeletextData(uint8_t *p, int length, bool IsPesRecording = true, const struct tTeletextSubtitlePage teletextSubtitlePages[] = NULL) {}; -+ virtual int ManualPageNumber(const cChannel *channel) { return 0; }; -+ -+ // used by VDR to call hook listeners -+ static cVDRTtxtsubsHookListener *Hook(void); -+}; -+ -+#endif --- -1.6.5 - diff --git a/patches/patch-set/0006-Ttxtsubs-plugin-hook.patch b/patches/patch-set/0006-Ttxtsubs-plugin-hook.patch new file mode 100644 index 0000000..59fb8c8 --- /dev/null +++ b/patches/patch-set/0006-Ttxtsubs-plugin-hook.patch @@ -0,0 +1,244 @@ +From 2432eec2b93648cf2b75155b6237293de91da1b6 Mon Sep 17 00:00:00 2001 +From: etobi +Date: Sat, 13 Feb 2010 00:28:21 +0100 +Subject: [PATCH 6/6] Ttxtsubs plugin hook + +--- + Makefile | 2 + + device.c | 20 ++++++++++++++++ + device.h | 1 + + pat.c | 9 +++++++ + vdrttxtsubshooks.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + vdrttxtsubshooks.h | 46 ++++++++++++++++++++++++++++++++++++++ + 6 files changed, 141 insertions(+), 0 deletions(-) + create mode 100644 vdrttxtsubshooks.c + create mode 100644 vdrttxtsubshooks.h + +diff --git a/Makefile b/Makefile +index 01408cb..b280030 100644 +--- a/Makefile ++++ b/Makefile +@@ -43,6 +43,8 @@ OBJS = audio.o channels.o ci.o config.o cutter.o device.o diseqc.o dvbdevice.o d + skinclassic.o skins.o skinsttng.o sources.o spu.o status.o svdrp.o themes.o thread.o\ + timers.o tools.o transfer.o vdr.o videodir.o + ++OBJS += vdrttxtsubshooks.o ++ + ifndef NO_KBD + DEFINES += -DREMOTE_KBD + endif +diff --git a/device.c b/device.c +index cb31b83..86b6b2c 100644 +--- a/device.c ++++ b/device.c +@@ -18,6 +18,7 @@ + #include "receiver.h" + #include "status.h" + #include "transfer.h" ++#include "vdrttxtsubshooks.h" + + // --- cLiveSubtitle --------------------------------------------------------- + +@@ -1190,6 +1191,13 @@ int cDevice::PlayPesPacket(const uchar *Data, int Length, bool VideoOnly) + } + break; + case 0xBD: { // private stream 1 ++ // EBU Teletext data, ETSI EN 300 472 ++ // if PES data header length = 24 and data_identifier = 0x10..0x1F (EBU Data) ++ if (Data[8] == 0x24 && Data[45] >= 0x10 && Data[45] < 0x20) { ++ cVDRTtxtsubsHookListener::Hook()->PlayerTeletextData((uint8_t*)Data, Length); ++ break; ++ } ++ + int PayloadOffset = Data[8] + 9; + + // Compatibility mode for old subtitles plugin: +@@ -1349,6 +1357,7 @@ int cDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly) + tsToPesVideo.Reset(); + tsToPesAudio.Reset(); + tsToPesSubtitle.Reset(); ++ tsToPesTeletext.Reset(); + } + else if (Length < TS_SIZE) { + esyslog("ERROR: skipped %d bytes of TS fragment", Length); +@@ -1394,6 +1403,17 @@ int cDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly) + if (!VideoOnly || HasIBPTrickSpeed()) + PlayTsSubtitle(Data, TS_SIZE); + } ++ else if (Pid == patPmtParser.Tpid()) { ++ if (!VideoOnly || HasIBPTrickSpeed()) { ++ int l; ++ tsToPesTeletext.PutTs(Data, Length); ++ if (const uchar *p = tsToPesTeletext.GetPes(l)) { ++ if ((l > 45) && (p[0] == 0x00) && (p[1] == 0x00) && (p[2] == 0x01) && (p[3] == 0xbd) && (p[8] == 0x24) && (p[45] >= 0x10) && (p[45] < 0x20)) ++ cVDRTtxtsubsHookListener::Hook()->PlayerTeletextData((uchar *)p, l, false, patPmtParser.TeletextSubtitlePages()); ++ tsToPesTeletext.Reset(); ++ } ++ } ++ } + } + } + else if (Pid == patPmtParser.Ppid()) { +diff --git a/device.h b/device.h +index 897de2a..2e36351 100644 +--- a/device.h ++++ b/device.h +@@ -499,6 +499,7 @@ private: + cTsToPes tsToPesVideo; + cTsToPes tsToPesAudio; + cTsToPes tsToPesSubtitle; ++ cTsToPes tsToPesTeletext; + bool isPlayingVideo; + protected: + const cPatPmtParser *PatPmtParser(void) const { return &patPmtParser; } +diff --git a/pat.c b/pat.c +index f4be6a6..444be21 100644 +--- a/pat.c ++++ b/pat.c +@@ -13,6 +13,7 @@ + #include "libsi/section.h" + #include "libsi/descriptor.h" + #include "thread.h" ++#include "vdrttxtsubshooks.h" + + #define PMT_SCAN_TIMEOUT 10 // seconds + +@@ -473,6 +474,14 @@ 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); ++ if (NumTPages < MAXTXTPAGES) { ++ int manualPageNumber = cVDRTtxtsubsHookListener::Hook()->ManualPageNumber(Channel); ++ if (manualPageNumber) { ++ TeletextSubtitlePages[NumTPages] = tTeletextSubtitlePage(manualPageNumber); ++ strn0cpy(TeletextSubtitlePages[NumTPages].ttxtLanguage, "und", MAXLANGCODE1); ++ NumTPages++; ++ } ++ } + Channel->SetTeletextSubtitlePages(TeletextSubtitlePages); + Channel->SetCaIds(CaDescriptors->CaIds()); + Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds); +diff --git a/vdrttxtsubshooks.c b/vdrttxtsubshooks.c +new file mode 100644 +index 0000000..865596e +--- /dev/null ++++ b/vdrttxtsubshooks.c +@@ -0,0 +1,63 @@ ++/* ++ * vdr-ttxtsubs - A plugin for the Linux Video Disk Recorder ++ * Copyright (c) 2003 - 2008 Ragnar Sundblad ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License as published by the ++ * Free Software Foundation; either version 2 of the License, or (at your option) ++ * any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ++ * details. ++ * ++ * You should have received a copy of the GNU General Public License along with ++ * this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ * ++ */ ++ ++#include ++#include ++#include ++ ++#include "vdrttxtsubshooks.h" ++ ++// XXX Really should be a list... ++static cVDRTtxtsubsHookListener *gListener; ++ ++// ------ class cVDRTtxtsubsHookProxy ------ ++ ++class cVDRTtxtsubsHookProxy : public cVDRTtxtsubsHookListener ++{ ++ public: ++ virtual void HideOSD(void) { if(gListener) gListener->HideOSD(); }; ++ virtual void ShowOSD(void) { if(gListener) gListener->ShowOSD(); }; ++ virtual void PlayerTeletextData(uint8_t *p, int length, bool IsPesRecording, const struct tTeletextSubtitlePage teletextSubtitlePages[] = NULL) ++ { if(gListener) gListener->PlayerTeletextData(p, length, IsPesRecording, teletextSubtitlePages); }; ++ virtual int ManualPageNumber(const cChannel *channel) ++ { if(gListener) return gListener->ManualPageNumber(channel); else return 0; }; ++}; ++ ++ ++// ------ class cVDRTtxtsubsHookListener ------ ++ ++cVDRTtxtsubsHookListener::~cVDRTtxtsubsHookListener() ++{ ++ gListener = 0; ++} ++ ++void cVDRTtxtsubsHookListener::HookAttach(void) ++{ ++ gListener = this; ++ //printf("cVDRTtxtsubsHookListener::HookAttach\n"); ++} ++ ++static cVDRTtxtsubsHookProxy gProxy; ++ ++cVDRTtxtsubsHookListener *cVDRTtxtsubsHookListener::Hook(void) ++{ ++ return &gProxy; ++} ++ +diff --git a/vdrttxtsubshooks.h b/vdrttxtsubshooks.h +new file mode 100644 +index 0000000..2e8e9ba +--- /dev/null ++++ b/vdrttxtsubshooks.h +@@ -0,0 +1,46 @@ ++/* ++ * vdr-ttxtsubs - A plugin for the Linux Video Disk Recorder ++ * Copyright (c) 2003 - 2008 Ragnar Sundblad ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License as published by the ++ * Free Software Foundation; either version 2 of the License, or (at your option) ++ * any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ++ * details. ++ * ++ * You should have received a copy of the GNU General Public License along with ++ * this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ * ++ */ ++ ++#ifndef __VDRTTXTSUBSHOOKS_H ++#define __VDRTTXTSUBSHOOKS_H ++ ++#define TTXTSUBSVERSNUM 2 ++ ++class cDevice; ++class cChannel; ++struct tTeletextSubtitlePage; ++ ++class cVDRTtxtsubsHookListener { ++ public: ++ cVDRTtxtsubsHookListener(void) {}; ++ virtual ~cVDRTtxtsubsHookListener(); ++ ++ void HookAttach(void); ++ ++ virtual void HideOSD(void) {}; ++ virtual void ShowOSD(void) {}; ++ virtual void PlayerTeletextData(uint8_t *p, int length, bool IsPesRecording = true, const struct tTeletextSubtitlePage teletextSubtitlePages[] = NULL) {}; ++ virtual int ManualPageNumber(const cChannel *channel) { return 0; }; ++ ++ // used by VDR to call hook listeners ++ static cVDRTtxtsubsHookListener *Hook(void); ++}; ++ ++#endif +-- +1.6.5 + diff --git a/patches/vdr-1.7.12-ttxtsubs.patch b/patches/vdr-1.7.12-ttxtsubs.patch index fb85ffb..113e14a 100644 --- a/patches/vdr-1.7.12-ttxtsubs.patch +++ b/patches/vdr-1.7.12-ttxtsubs.patch @@ -177,6 +177,20 @@ index b465f6a..1ddef40 100644 void SetCaIds(const int *CaIds); // list must be zero-terminated void SetCaDescriptors(int Level); void SetLinkChannels(cLinkChannels *LinkChannels); +diff --git a/ci.c b/ci.c +index 6c7b031..f158a18 100644 +--- a/ci.c ++++ b/ci.c +@@ -1932,6 +1932,9 @@ bool cCamSlot::CanDecrypt(const cChannel *Channel) + CaPmt.AddPid(*Apid, STREAM_TYPE_AUDIO); + for (const int *Dpid = Channel->Dpids(); *Dpid; Dpid++) + CaPmt.AddPid(*Dpid, STREAM_TYPE_DOLBY); ++ if (Channel->Tpid() && Setup.RecordTtxtSubtitles) { ++ CaPmt.AddPid(Channel->Tpid(), STREAM_TYPE_DOLBY); // FIXME: STREAM_TYPE_DOLBY should probably be renamed STREAM_TYPE_PRIVATE ++ } + cas->SendPMT(&CaPmt); + cTimeMs Timeout(QUERY_REPLY_TIMEOUT); + do { diff --git a/config.c b/config.c index acdf4c4..4aaf720 100644 --- a/config.c -- cgit v1.2.3