summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Grimm <tobias@e-tobi.loc>2009-04-23 22:05:35 +0200
committerTobias Grimm <tobias@e-tobi.loc>2009-06-20 18:17:42 +0200
commit4de3caa67369af756d2ef008ad26453c9c4065ad (patch)
treebcb6573d7cb90b1a63303205b3c3a898c6c62a9d
parent656e4190a147f97978bf324107a4008c79a18fe0 (diff)
downloadvdr-patches-4de3caa67369af756d2ef008ad26453c9c4065ad.tar.gz
vdr-patches-4de3caa67369af756d2ef008ad26453c9c4065ad.tar.bz2
ttxtsubs: Added (subtitle) teletext pids to cPatPmtGenerator
(provided by Rolf Ahrenberg)
-rw-r--r--remux.c35
-rw-r--r--remux.h3
2 files changed, 38 insertions, 0 deletions
diff --git a/remux.c b/remux.c
index 97c139c..84fe17b 100644
--- a/remux.c
+++ b/remux.c
@@ -215,6 +215,30 @@ int cPatPmtGenerator::MakeSubtitlingDescriptor(uchar *Target, const char *Langua
return i;
}
+int cPatPmtGenerator::MakeTeletextDescriptor(uchar *Target, 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;
@@ -295,6 +319,7 @@ void cPatPmtGenerator::GeneratePmt(cChannel *Channel)
numPmtPackets = 0;
if (Channel) {
int Vpid = Channel->Vpid();
+ int Tpid = Channel->Tpid();
uchar *p = buf;
int i = 0;
p[i++] = 0x02; // table id
@@ -329,6 +354,10 @@ void cPatPmtGenerator::GeneratePmt(cChannel *Channel)
i += MakeStream(buf + i, 0x06, Channel->Spid(n));
i += MakeSubtitlingDescriptor(buf + i, Channel->Slang(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;
@@ -401,6 +430,7 @@ void cPatPmtParser::Reset(void)
patVersion = pmtVersion = -1;
pmtPid = -1;
vpid = vtype = 0;
+ tpid = 0;
}
void cPatPmtParser::ParsePat(const uchar *Data, int Length)
@@ -485,6 +515,7 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length)
int NumDpids = 0;
int NumSpids = 0;
vpid = vtype = 0;
+ tpid = 0;
SI::PMT::Stream stream;
for (SI::Loop::Iterator it; Pmt.streamLoop.getNext(stream, it); ) {
dbgpatpmt(" stream type = %02X, pid = %d", stream.getStreamType(), stream.getPid());
@@ -565,6 +596,10 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length)
NumSpids++;
}
break;
+ case SI::TeletextDescriptorTag:
+ dbgpatpmt(" teletext");
+ tpid = stream.getPid();
+ break;
case SI::ISO639LanguageDescriptorTag: {
SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d;
dbgpatpmt(" '%s'", ld->languageCode);
diff --git a/remux.h b/remux.h
index 0dd1a9a..c3c1d0a 100644
--- a/remux.h
+++ b/remux.h
@@ -169,6 +169,7 @@ protected:
int MakeStream(uchar *Target, uchar Type, int Pid);
int MakeAC3Descriptor(uchar *Target);
int MakeSubtitlingDescriptor(uchar *Target, const char *Language);
+ int MakeTeletextDescriptor(uchar *Target, cChannel *Channel);
int MakeLanguageDescriptor(uchar *Target, const char *Language);
int MakeCRC(uchar *Target, const uchar *Data, int Length);
void GeneratePmtPid(cChannel *Channel);
@@ -214,6 +215,7 @@ private:
int vpid;
int vtype;
bool updatePrimaryDevice;
+ int tpid;
protected:
int SectionLength(const uchar *Data, int Length) { return (Length >= 3) ? ((int(Data[1]) & 0x0F) << 8)| Data[2] : 0; }
public:
@@ -240,6 +242,7 @@ public:
int Vpid(void) { return vpid; }
///< Returns the video pid as defined by the current PMT.
int Vtype(void) { return vtype; }
+ int Tpid(void) { return tpid; }
};
// TS to PES converter: