diff options
author | etobi <git@e-tobi.net> | 2010-02-13 00:28:21 +0100 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2010-04-18 02:42:59 +0200 |
commit | 2f325a640f1d71222d3d7082776b7e1c55489bbd (patch) | |
tree | 0676a050d791487964c6601da7fa39fa9f45a044 | |
parent | 62912232e2b38a1857c0ff279bd61579b1ab85ae (diff) | |
download | vdr-patches-patches/ttxtsubs-vdr-1.7.14.tar.gz vdr-patches-patches/ttxtsubs-vdr-1.7.14.tar.bz2 |
Ttxtsubs plugin hookpatches/ttxtsubs-vdr-1.7.14
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | device.c | 20 | ||||
-rw-r--r-- | device.h | 1 | ||||
-rw-r--r-- | pat.c | 6 | ||||
-rw-r--r-- | remux.h | 3 | ||||
-rw-r--r-- | vdrttxtsubshooks.c | 63 | ||||
-rw-r--r-- | vdrttxtsubshooks.h | 46 |
7 files changed, 140 insertions, 1 deletions
@@ -44,6 +44,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 sourceparams.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 @@ -18,6 +18,7 @@ #include "receiver.h" #include "status.h" #include "transfer.h" +#include "vdrttxtsubshooks.h" // --- cLiveSubtitle --------------------------------------------------------- @@ -1223,6 +1224,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: @@ -1382,6 +1390,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); @@ -1427,6 +1436,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(), patPmtParser.TotalTeletextSubtitlePages()); + tsToPesTeletext.Reset(); + } + } + } } } else if (Pid == patPmtParser.Ppid()) { @@ -519,6 +519,7 @@ private: cTsToPes tsToPesVideo; cTsToPes tsToPesAudio; cTsToPes tsToPesSubtitle; + cTsToPes tsToPesTeletext; bool isPlayingVideo; protected: const cPatPmtParser *PatPmtParser(void) const { return &patPmtParser; } @@ -13,6 +13,7 @@ #include "libsi/section.h" #include "libsi/descriptor.h" #include "thread.h" +#include "vdrttxtsubshooks.h" #define PMT_SCAN_TIMEOUT 10 // seconds @@ -496,6 +497,11 @@ 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); + } Channel->SetTeletextSubtitlePages(TeletextSubtitlePages, NumTPages); Channel->SetCaIds(CaDescriptors->CaIds()); Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds); @@ -280,7 +280,8 @@ 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; } + const tTeletextSubtitlePage *TeletextSubtitlePages() const { return teletextSubtitlePages; } + int TotalTeletextSubtitlePages() const { return totalTtxtSubtitlePages; } }; // TS to PES converter: diff --git a/vdrttxtsubshooks.c b/vdrttxtsubshooks.c new file mode 100644 index 0000000..2471788 --- /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 <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, const struct tTeletextSubtitlePage teletextSubtitlePages[] = NULL, int pageCount = 0) + { if(gListener) gListener->PlayerTeletextData(p, length, IsPesRecording, teletextSubtitlePages, pageCount); }; + 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..2f97969 --- /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 <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 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, int pageCount = 0) {}; + virtual int ManualPageNumber(const cChannel *channel) { return 0; }; + + // used by VDR to call hook listeners + static cVDRTtxtsubsHookListener *Hook(void); +}; + +#endif |