summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
authorTobias Grimm <git@e-tobi.net>2010-02-03 20:49:24 +0100
committerTobias Grimm <git@e-tobi.net>2010-02-04 23:25:49 +0100
commit3fe4cb0b34fbdd810777b14800f937eaf4cebc09 (patch)
treec4ded34886439315964a6249ddccacc64d0b31de /patches
parent1fc8dd6fd7b29a49d64eabc05e10b9926ee7a5f6 (diff)
downloadvdr-plugin-ttxtsubs-3fe4cb0b34fbdd810777b14800f937eaf4cebc09.tar.gz
vdr-plugin-ttxtsubs-3fe4cb0b34fbdd810777b14800f937eaf4cebc09.tar.bz2
Update for VDR 1.7.12 (Closes #236)
Plugin code and VDR patch updated for 1.7.12 - Thx to Rolf Ahrenberg
Diffstat (limited to 'patches')
-rw-r--r--patches/vdr-1.7.12-ttxtsubs.patch424
1 files changed, 424 insertions, 0 deletions
diff --git a/patches/vdr-1.7.12-ttxtsubs.patch b/patches/vdr-1.7.12-ttxtsubs.patch
new file mode 100644
index 0000000..870c92e
--- /dev/null
+++ b/patches/vdr-1.7.12-ttxtsubs.patch
@@ -0,0 +1,424 @@
+diff -Nru vdr-1.7.12-vanilla/channels.c vdr-1.7.12-ttxtsubs/channels.c
+--- vdr-1.7.12-vanilla/channels.c 2010-01-31 16:56:52.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/channels.c 2010-02-03 09:21:21.000000000 +0200
+@@ -551,6 +551,15 @@
+ }
+ }
+
++void cChannel::SetTPidData(char TLangs[][MAXLANGCODE2], int TPages[])
++{
++ for (int i = 0; i < MAXTPAGES; i++) {
++ tpages[i] = TPages[i];
++ strn0cpy(tlangs[i], TLangs[i], MAXLANGCODE2);
++ }
++ tpages[MAXTPAGES] = 0;
++}
++
+ void cChannel::SetCaIds(const int *CaIds)
+ {
+ if (caids[0] && caids[0] <= CA_USER_MAX)
+diff -Nru vdr-1.7.12-vanilla/channels.h vdr-1.7.12-ttxtsubs/channels.h
+--- vdr-1.7.12-vanilla/channels.h 2010-01-31 16:56:52.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/channels.h 2010-02-03 09:21:21.000000000 +0200
+@@ -35,6 +35,7 @@
+ #define MAXDPIDS 16 // dolby (AC3 + DTS)
+ #define MAXSPIDS 32 // subtitles
+ #define MAXCAIDS 8 // conditional access
++#define MAXTPAGES 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
+@@ -133,6 +134,8 @@
+ uint16_t compositionPageIds[MAXSPIDS];
+ uint16_t ancillaryPageIds[MAXSPIDS];
+ int tpid;
++ char tlangs[MAXTPAGES][MAXLANGCODE2];
++ int tpages[MAXTPAGES + 1]; // list is zero-terminated
+ int caids[MAXCAIDS + 1]; // list is zero-terminated
+ int nid;
+ int tid;
+@@ -192,6 +195,8 @@
+ 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 char *Tlang(int i) const { return (0 <= i && i < MAXTPAGES) ? tlangs[i] : ""; }
++ const int TPages(int i) const { return (0 <= i && i < MAXTPAGES) ? tpages[i] : 0; }
+ 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 +233,7 @@
+ 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 SetTPidData(char TLangs[][MAXLANGCODE2], int TPages[]);
+ void SetCaIds(const int *CaIds); // list must be zero-terminated
+ void SetCaDescriptors(int Level);
+ void SetLinkChannels(cLinkChannels *LinkChannels);
+diff -Nru vdr-1.7.12-vanilla/device.c vdr-1.7.12-ttxtsubs/device.c
+--- vdr-1.7.12-vanilla/device.c 2010-01-31 16:56:52.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/device.c 2010-02-03 09:21:21.000000000 +0200
+@@ -18,6 +18,7 @@
+ #include "receiver.h"
+ #include "status.h"
+ #include "transfer.h"
++#include "vdrttxtsubshooks.h"
+
+ // --- cLiveSubtitle ---------------------------------------------------------
+
+@@ -1190,6 +1191,13 @@
+ }
+ 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 @@
+ 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 @@
+ 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);
++ tsToPesTeletext.Reset();
++ }
++ }
++ }
+ }
+ }
+ else if (Pid == patPmtParser.Ppid()) {
+diff -Nru vdr-1.7.12-vanilla/device.h vdr-1.7.12-ttxtsubs/device.h
+--- vdr-1.7.12-vanilla/device.h 2010-01-31 16:56:52.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/device.h 2010-02-03 09:21:21.000000000 +0200
+@@ -499,6 +499,7 @@
+ cTsToPes tsToPesVideo;
+ cTsToPes tsToPesAudio;
+ cTsToPes tsToPesSubtitle;
++ cTsToPes tsToPesTeletext;
+ bool isPlayingVideo;
+ protected:
+ const cPatPmtParser *PatPmtParser(void) const { return &patPmtParser; }
+diff -Nru vdr-1.7.12-vanilla/Makefile vdr-1.7.12-ttxtsubs/Makefile
+--- vdr-1.7.12-vanilla/Makefile 2010-01-31 16:56:52.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/Makefile 2010-02-03 09:21:21.000000000 +0200
+@@ -43,6 +43,8 @@
+ 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 -Nru vdr-1.7.12-vanilla/pat.c vdr-1.7.12-ttxtsubs/pat.c
+--- vdr-1.7.12-vanilla/pat.c 2010-01-31 16:56:52.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/pat.c 2010-02-03 09:30:12.000000000 +0200
+@@ -13,6 +13,7 @@
+ #include "libsi/section.h"
+ #include "libsi/descriptor.h"
+ #include "thread.h"
++#include "vdrttxtsubshooks.h"
+
+ #define PMT_SCAN_TIMEOUT 10 // seconds
+
+@@ -341,6 +342,9 @@
+ char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" };
+ char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" };
+ int Tpid = 0;
++ char TLangs[MAXTPAGES][MAXLANGCODE2] = { "" };
++ int TPages[MAXTPAGES + 1] = { 0 };
++ int NumTPages = 0;
+ int NumApids = 0;
+ int NumDpids = 0;
+ int NumSpids = 0;
+@@ -426,8 +430,19 @@
+ 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); ) {
++ if ((NumTPages < MAXTPAGES) && ttxt.languageCode[0] && ((ttxt.getTeletextType() == 0x02) || (ttxt.getTeletextType() == 0x05))) {
++ char *s = TLangs[NumTPages];
++ strn0cpy(s, I18nNormalizeLanguageCode(ttxt.languageCode), MAXLANGCODE1);
++ TPages[NumTPages] = (ttxt.getTeletextPageNumber() & 0xff) | ((ttxt.getTeletextMagazineNumber() & 0xff) << 8) | ((ttxt.getTeletextType() & 0xff) << 16);
++ NumTPages++;
++ }
++ }
++ }
+ break;
+ case SI::ISO639LanguageDescriptorTag: {
+ SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d;
+@@ -458,6 +473,16 @@
+ }
+ if (Setup.UpdateChannels >= 2) {
+ Channel->SetPids(Vpid, Ppid, Vtype, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
++ if (NumTPages < MAXTPAGES) {
++ int manualPageNumber = cVDRTtxtsubsHookListener::Hook()->ManualPageNumber(Channel);
++ if (manualPageNumber) {
++ char *s = TLangs[NumTPages];
++ strn0cpy(s, "man", MAXLANGCODE1);
++ TPages[NumTPages] = manualPageNumber;
++ NumTPages++;
++ }
++ }
++ Channel->SetTPidData(TLangs, TPages);
+ Channel->SetCaIds(CaDescriptors->CaIds());
+ Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds);
+ }
+diff -Nru vdr-1.7.12-vanilla/receiver.c vdr-1.7.12-ttxtsubs/receiver.c
+--- vdr-1.7.12-vanilla/receiver.c 2010-01-31 16:56:52.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/receiver.c 2010-02-03 09:27:31.000000000 +0200
+@@ -82,7 +82,7 @@
+ (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 -Nru vdr-1.7.12-vanilla/remux.c vdr-1.7.12-ttxtsubs/remux.c
+--- vdr-1.7.12-vanilla/remux.c 2010-01-31 16:56:52.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/remux.c 2010-02-03 09:28:25.000000000 +0200
+@@ -215,6 +215,30 @@
+ 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->TPages(n); n++) {
++ const char *Language = Channel->Tlang(n);
++ int Pages = Channel->TPages(n);
++ Target[i++] = *Language++;
++ Target[i++] = *Language++;
++ Target[i++] = *Language++;
++ Target[i++] = ((Pages >> 13) & 0xf8) | ((Pages >> 8) & 0x7); // teletext type & magazine number
++ Target[i++] = Pages & 0xff; // teletext page number
++ 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 +320,7 @@
+ 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 +355,10 @@
+ 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;
+@@ -403,6 +432,7 @@
+ pmtPid = -1;
+ vpid = vtype = 0;
+ ppid = 0;
++ tpid = 0;
+ }
+
+ void cPatPmtParser::ParsePat(const uchar *Data, int Length)
+@@ -488,6 +518,7 @@
+ int NumSpids = 0;
+ vpid = vtype = 0;
+ ppid = 0;
++ tpid = 0;
+ apids[0] = 0;
+ dpids[0] = 0;
+ spids[0] = 0;
+@@ -586,6 +617,10 @@
+ spids[NumSpids]= 0;
+ }
+ break;
++ case SI::TeletextDescriptorTag:
++ dbgpatpmt(" teletext");
++ tpid = stream.getPid();
++ break;
+ case SI::ISO639LanguageDescriptorTag: {
+ SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d;
+ dbgpatpmt(" '%s'", ld->languageCode);
+diff -Nru vdr-1.7.12-vanilla/remux.h vdr-1.7.12-ttxtsubs/remux.h
+--- vdr-1.7.12-vanilla/remux.h 2010-01-31 16:56:52.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/remux.h 2010-02-03 09:29:15.000000000 +0200
+@@ -170,6 +170,7 @@
+ 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);
+@@ -215,6 +216,7 @@
+ 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];
+@@ -259,6 +261,7 @@
+ 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; }
+ const int *Apids(void) const { return apids; }
+ const int *Dpids(void) const { return dpids; }
+ const int *Spids(void) const { return spids; }
+diff -Nru vdr-1.7.12-vanilla/vdrttxtsubshooks.c vdr-1.7.12-ttxtsubs/vdrttxtsubshooks.c
+--- vdr-1.7.12-vanilla/vdrttxtsubshooks.c 1970-01-01 02:00:00.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/vdrttxtsubshooks.c 2010-02-03 09:21:22.000000000 +0200
+@@ -0,0 +1,63 @@
++/*
++ * vdr-ttxtsubs - A plugin for the Linux Video Disk Recorder
++ * Copyright (c) 2003 - 2008 Ragnar Sundblad <ragge@nada.kth.se>
++ *
++ * 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 <stdlib.h>
++#include <stdio.h>
++#include <stdint.h>
++
++#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)
++ { if(gListener) gListener->PlayerTeletextData(p, length, IsPesRecording); };
++ 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 -Nru vdr-1.7.12-vanilla/vdrttxtsubshooks.h vdr-1.7.12-ttxtsubs/vdrttxtsubshooks.h
+--- vdr-1.7.12-vanilla/vdrttxtsubshooks.h 1970-01-01 02:00:00.000000000 +0200
++++ vdr-1.7.12-ttxtsubs/vdrttxtsubshooks.h 2010-02-03 09:33:22.000000000 +0200
+@@ -0,0 +1,45 @@
++/*
++ * vdr-ttxtsubs - A plugin for the Linux Video Disk Recorder
++ * Copyright (c) 2003 - 2008 Ragnar Sundblad <ragge@nada.kth.se>
++ *
++ * 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 1
++
++class cDevice;
++class cChannel;
++
++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) {};
++ virtual int ManualPageNumber(const cChannel *channel) { return 0; };
++
++ // used by VDR to call hook listeners
++ static cVDRTtxtsubsHookListener *Hook(void);
++};
++
++#endif