diff options
| author | etobi <git@e-tobi.net> | 2009-10-25 20:26:04 +0100 |
|---|---|---|
| committer | etobi <git@e-tobi.net> | 2009-10-25 20:26:04 +0100 |
| commit | 6bf565287bd718a72b8d862cae4d41797ca82fdc (patch) | |
| tree | 4a511b3cfe291b4e7e52f5480bec04919d8665c0 | |
| parent | bd012765a88067d3806e208923674750fffa0542 (diff) | |
| download | vdr-plugin-osdteletext-6bf565287bd718a72b8d862cae4d41797ca82fdc.tar.gz vdr-plugin-osdteletext-6bf565287bd718a72b8d862cae4d41797ca82fdc.tar.bz2 | |
Added command line option to enable storing TopText pages, which is
now disabled by default (References #177)
Patch provided by Andreas Brachold
| -rw-r--r-- | HISTORY | 2 | ||||
| -rw-r--r-- | README | 2 | ||||
| -rw-r--r-- | README.DE | 1 | ||||
| -rw-r--r-- | osdteletext.c | 14 | ||||
| -rw-r--r-- | txtrecv.c | 38 | ||||
| -rw-r--r-- | txtrecv.h | 8 |
6 files changed, 43 insertions, 22 deletions
@@ -7,6 +7,8 @@ VDR Plugin 'osdteletext' Revision History - Fixed possible segfault (Closes #179) - (Thx to Manuel Reimer) - Added setup option to disable maine menu entry (Closes #149) (Thx to Manuel Reimer!) +- Added command line option to enable storing TopText pages, which is + now disabled by default (References #177) (Thx to Andreas Brachold!) 2009-06-02: version 0.8.3 - Updated Ukrainian translation provided by Yarema P. aka Knedlyk (Closes #133) @@ -97,6 +97,8 @@ Command line options: one-file-per-page system. Default is "packed" for the one-file-for-a-few-pages system. + -t --toptext Store top text pages at cache. + (unviewable pages) Colors: On all sorts of output devices which are not limited as to color depth @@ -74,6 +74,7 @@ Kommandozeilen-Optionen: System "Eine Datei - eine Seite". Voreinstellung ist "packed" für ein System, das in eine Datei mehrere Seiten speichert. + -t --toptext Speichere TopText Seiten (nich anzeigbar) Farben: Auf allen Ausgabegeräten, die nicht in der Farbtiefe des OSD beschränkt sind, diff --git a/osdteletext.c b/osdteletext.c index 34c9184..ec6e65a 100644 --- a/osdteletext.c +++ b/osdteletext.c @@ -34,6 +34,7 @@ private: // Add any member variables or functions you may need here. cTxtStatus *txtStatus; bool startReceiver; + bool storeTopText; void initTexts(); public: cPluginTeletextosd(void); @@ -96,7 +97,6 @@ protected: };*/ - cPluginTeletextosd::cPluginTeletextosd(void) { // Initialize any member variables here. @@ -128,7 +128,8 @@ const char *cPluginTeletextosd::CommandLineHelp(void) " Choose \"legacy\" for the traditional\n" " one-file-per-page system.\n" " Default is \"packed\" for the \n" - " one-file-for-a-few-pages system.\n"; + " one-file-for-a-few-pages system.\n" + " -t, --toptext Store top text pages at cache. (unviewable pages)\n"; } bool cPluginTeletextosd::ProcessArgs(int argc, char *argv[]) @@ -137,13 +138,14 @@ bool cPluginTeletextosd::ProcessArgs(int argc, char *argv[]) static struct option long_options[] = { { "directory", required_argument, NULL, 'd' }, { "max-cache", required_argument, NULL, 'n' }, - { "cache-system", required_argument, NULL, 's' }, + { "cache-system", required_argument, NULL, 's' }, + { "toptext", no_argument, NULL, 't' }, { NULL } }; int c; int maxStorage=-1; - while ((c = getopt_long(argc, argv, "s:d:n:", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "s:d:n:t", long_options, NULL)) != -1) { switch (c) { case 's': if (!optarg) @@ -160,6 +162,8 @@ bool cPluginTeletextosd::ProcessArgs(int argc, char *argv[]) maxStorage=n; } break; + case 't': storeTopText=true; + break; } } //do this here because the option -s to change the storage system might be given @@ -177,7 +181,7 @@ bool cPluginTeletextosd::Start(void) Storage::instance()->init(); initTexts(); if (startReceiver) - txtStatus=new cTxtStatus(); + txtStatus=new cTxtStatus(storeTopText); if (ttSetup.OSDheight<=100) ttSetup.OSDheight=Setup.OSDHeight; if (ttSetup.OSDwidth<=100) ttSetup.OSDwidth=Setup.OSDWidth; @@ -487,11 +487,16 @@ void cTelePage::save() buf=0x00; s->write(&buf,1,fd); s->write(pagebuf,24*40,fd); s->close(fd); - } + } } +bool cTelePage::IsTopTextPage() +{ + return (page.page & 0xFF) <= 0x99 && (page.page & 0x0F) <= 0x9; +} -cTxtStatus::cTxtStatus(void) +cTxtStatus::cTxtStatus(bool storeTopText) + :storeTopText(storeTopText) { receiver = NULL; currentLiveChannel = tChannelID::InvalidID; @@ -531,7 +536,7 @@ void cTxtStatus::ChannelSwitch(const cDevice *Device, int ChannelNumber) int TPid = newLiveChannel->Tpid(); if (TPid) { - receiver = new cTxtReceiver(TPid, currentLiveChannel); + receiver = new cTxtReceiver(TPid, currentLiveChannel, storeTopText); cDevice::ActualDevice()->AttachReceiver(receiver); } @@ -539,9 +544,9 @@ void cTxtStatus::ChannelSwitch(const cDevice *Device, int ChannelNumber) } -cTxtReceiver::cTxtReceiver(int TPid, tChannelID chan) +cTxtReceiver::cTxtReceiver(int TPid, tChannelID chan, bool storeTopText) : cReceiver(chan, -1, TPid), cThread("osdteletext-receiver"), - TxtPage(0), buffer((188+60)*75) + TxtPage(0), storeTopText(storeTopText), buffer((188+60)*75) { Storage::instance()->prepareDirectory(ChannelID()); // 10 ms timeout on getting TS frames @@ -616,6 +621,17 @@ uchar cTxtReceiver::unham16 (uchar *p) return (c1 & 0x0F) | (c2 & 0x0F) *16; } +void cTxtReceiver::SaveAndDeleteTxtPage() +{ + if (storeTopText || !TxtPage->IsTopTextPage()) { + if (TxtPage) { + TxtPage->save(); + delete TxtPage; + TxtPage=NULL; + } + } +} + void cTxtReceiver::DecodeTXT(uchar* TXT_buf) { // Format of buffer: @@ -666,11 +682,7 @@ void cTxtReceiver::DecodeTXT(uchar* TXT_buf) // Page no, 10- and 1-digit if (b1 == 0xff) break; - if (TxtPage) { - TxtPage->save(); - delete TxtPage; - TxtPage=NULL; - } + SaveAndDeleteTxtPage(); b2 = unham16 (ptr+2); // Sub-code 0..6 + C4 b3 = unham16 (ptr+4); // Sub-code 8..13 + C5,C6 @@ -704,11 +716,7 @@ void cTxtReceiver::DecodeTXT(uchar* TXT_buf) } /*case 23: { - if (TxtPage) { - TxtPage->save(); - delete TxtPage; - TxtPage=NULL; - } + SaveAndDeleteTxtPage(); break; }*/ default: @@ -148,6 +148,7 @@ class cTelePage { ~cTelePage(); void SetLine(int, uchar*); void save(); + bool IsTopTextPage(); }; class cRingTxtFrames : public cRingBufferFrame { @@ -163,13 +164,15 @@ private: void DecodeTXT(uchar*); uchar unham16 (uchar*); cTelePage *TxtPage; + void SaveAndDeleteTxtPage(); + bool storeTopText; protected: virtual void Activate(bool On); virtual void Receive(uchar *Data, int Length); virtual void Action(); cRingTxtFrames buffer; public: - cTxtReceiver(int TPid, tChannelID chan); + cTxtReceiver(int TPid, tChannelID chan, bool storeTopText); virtual ~cTxtReceiver(); virtual void Stop(); }; @@ -178,10 +181,11 @@ class cTxtStatus : public cStatus { private: cTxtReceiver *receiver; tChannelID currentLiveChannel; + bool storeTopText; protected: virtual void ChannelSwitch(const cDevice *Device, int ChannelNumber); public: - cTxtStatus(void); + cTxtStatus(bool storeTopText); ~cTxtStatus(); }; |
