diff options
author | Tobias Grimm <git@e-tobi.net> | 2010-04-19 01:58:36 +0200 |
---|---|---|
committer | Tobias Grimm <git@e-tobi.net> | 2010-04-19 02:01:09 +0200 |
commit | 79829f7f63e9008e4ef38cba3805f86cb4b4e28d (patch) | |
tree | 944a517a68ee2e8b8f317bacfea9574edc6228f7 | |
parent | 5bdbed2e4f7b26a42261ff3640daf792d40fd1c9 (diff) | |
download | vdr-plugin-ttxtsubs-79829f7f63e9008e4ef38cba3805f86cb4b4e28d.tar.gz vdr-plugin-ttxtsubs-79829f7f63e9008e4ef38cba3805f86cb4b4e28d.tar.bz2 |
For live tv in non-transfer mode use a cReceiver
With a FF card, when the card is not in transfer mode, in order to get the
Tpid data, a cReceiver mus be used.
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | ttxtsubs.c | 28 | ||||
-rw-r--r-- | ttxtsubslivereceiver.c | 77 | ||||
-rw-r--r-- | ttxtsubslivereceiver.h | 41 |
5 files changed, 136 insertions, 13 deletions
@@ -5,6 +5,7 @@ VDR Plugin 'ttxtsubs' Revision History - Fixed channel retune triggering in VDR patch and updated patch to 1.7.14 (Dropped 1.7.12 and 1.7.13 patch) - Got rid of the backround thread +- Fixed live TV subtitles on FF cards, where there is no transfer mode 2010-03-06: Version 0.2.1 - Added Estonian translation by Arthur Konovalov (Closes #271) @@ -52,7 +52,7 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): OBJS = $(PLUGIN).o ttxtsubsdisplayer.o ttxtsubsdisplay.o teletext.o \ - ttxtsubspagemenu.o ttxtsubschannelsettings.o + ttxtsubspagemenu.o ttxtsubschannelsettings.o ttxtsubslivereceiver.o ### Implicit rules: .PHONY: all all-redirect @@ -42,6 +42,7 @@ #include "utils.h" #include "ttxtsubspagemenu.h" #include "ttxtsubschannelsettings.h" +#include "ttxtsubslivereceiver.h" #if defined(APIVERSNUM) && APIVERSNUM < 10706 #error "This version of ttxtsubs only works with vdr version >= 1.7.6!" @@ -166,13 +167,7 @@ private: char mOldLanguage[4]; // language chosen from previous version int mOldHearingImpaired; // HI setting chosen from previous version - bool mReplay; - tChannelID mReplayChannelId; - - // wait for channel switch - int switchChannel; - int lastc; - const cDevice *switchDevice; + cTtxtSubsLiveReceiver* mLiveReceiver; }; class cMenuSetupTtxtsubs : public cMenuSetupPage { @@ -195,7 +190,7 @@ cPluginTtxtsubs::cPluginTtxtsubs(void) : mDispl(NULL), mOldHearingImpaired(0), - mReplay(false) + mLiveReceiver(0) { // Initialize any member variables here. // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL @@ -203,12 +198,12 @@ cPluginTtxtsubs::cPluginTtxtsubs(void) memset(mOldLanguage, 0, 4); strncpy(globals.mLanguages[0][0], "unk", 4); - lastc=0; } cPluginTtxtsubs::~cPluginTtxtsubs() { // Clean up after yourself! + DELETENULL(mLiveReceiver); } const char *cPluginTtxtsubs::CommandLineHelp(void) @@ -340,11 +335,20 @@ bool cPluginTtxtsubs::SetupParse(const char *Name, const char *Value) void cPluginTtxtsubs::ChannelSwitch(const cDevice *Device, int ChannelNumber) { //dprint("cPluginTtxtsubs::ChannelSwitch(devicenr: %d, channelnr: %d) - mDispl: %x\n", Device->DeviceNumber(), ChannelNumber, mDispl); // XXX - if (Device->IsPrimaryDevice() && !Device->Replaying() && ChannelNumber && ChannelNumber != lastc) + if (Device->IsPrimaryDevice() && !Device->Replaying() && ChannelNumber) { StopTtxt(); + DELETENULL(mLiveReceiver); + if (!Device->Replaying() && !Device->Transferring()) + { + cChannel* channel = Channels.GetByNumber(ChannelNumber); + if (channel && channel->Tpid()) + { + mLiveReceiver = new cTtxtSubsLiveReceiver(channel, this); + cDevice::PrimaryDevice()->AttachReceiver(mLiveReceiver); + } + } StartTtxtPlay(0x000); - lastc=ChannelNumber; } } @@ -354,9 +358,9 @@ void cPluginTtxtsubs::Replaying(const cControl *Control, const char *Name, const StopTtxt(); if (On) { + DELETENULL(mLiveReceiver); StartTtxtPlay(0x000); } - lastc=-1; } void cPluginTtxtsubs::PlayerTeletextData(uint8_t *p, int length, bool IsPesRecording, const struct tTeletextSubtitlePage teletextSubtitlePages[], int pageCount) diff --git a/ttxtsubslivereceiver.c b/ttxtsubslivereceiver.c new file mode 100644 index 0000000..cfe3288 --- /dev/null +++ b/ttxtsubslivereceiver.c @@ -0,0 +1,77 @@ +/* + * 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 <vdr/device.h> +#include <vdr/remux.h> +#include "ttxtsubslivereceiver.h" + +cTtxtSubsLiveReceiver::cTtxtSubsLiveReceiver(cChannel* channel, cVDRTtxtsubsHookListener* hook) +{ + _channel = channel; + _hook = hook; + AddPid(channel->Tpid()); +} + +cTtxtSubsLiveReceiver::~cTtxtSubsLiveReceiver() +{ + cReceiver::Detach(); +} + +void cTtxtSubsLiveReceiver::Receive(uchar *Data, int Length) +{ + if (Data == NULL) + { + tsToPesTeletext.Reset(); + return; + } + + if (Length < TS_SIZE) + { + esyslog("ERROR: skipped %d bytes of TS fragment", Length); + return; + } + + while (Length >= TS_SIZE) + { + if (Data[0] != TS_SYNC_BYTE) + { + return; + } + if (TsHasPayload(Data)) // silently ignore TS packets w/o payload + { + int PayloadOffset = TsPayloadOffset(Data); + if (PayloadOffset < TS_SIZE) + { + 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)) + { + _hook->PlayerTeletextData((uchar *)p, l, false, _channel->TeletextSubtitlePages(), _channel->TotalTeletextSubtitlePages()); + } + tsToPesTeletext.Reset(); + } + } + } + Length -= TS_SIZE; + Data += TS_SIZE; + } +} diff --git a/ttxtsubslivereceiver.h b/ttxtsubslivereceiver.h new file mode 100644 index 0000000..9752be6 --- /dev/null +++ b/ttxtsubslivereceiver.h @@ -0,0 +1,41 @@ +/* + * 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 <vdr/receiver.h> +#include <vdr/remux.h> +#include <vdr/vdrttxtsubshooks.h> + +#ifndef ___TTXTSUBSLIVERECEIVER_H +#define ___TTXTSUBSLIVERECEIVER_H + +class cTtxtSubsLiveReceiver : public cReceiver +{ + private: + cTsToPes tsToPesTeletext; + cChannel* _channel; + cVDRTtxtsubsHookListener* _hook; + protected: + virtual void Receive(uchar *Data, int Length); + public: + cTtxtSubsLiveReceiver(cChannel* channel, cVDRTtxtsubsHookListener* hook); + virtual ~cTtxtSubsLiveReceiver(); +}; + +#endif |