1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
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
|