From 9b61b20f9a6159150f31c93d65668d6945c21b7a Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 16 Aug 2009 15:32:39 +0200 Subject: Implemented full handling of subtitling descriptors --- CONTRIBUTORS | 3 +++ HISTORY | 1 + channels.c | 18 +++++++++++++++++- channels.h | 9 ++++++++- pat.c | 9 ++++++++- remux.c | 16 ++++++++-------- remux.h | 4 ++-- 7 files changed, 47 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 2bc9dd75..f80bce2f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2486,3 +2486,6 @@ G Martin Neuditschko for reporting a problem with error messages from cDvbDevice::GetVideoSize() on systems with no real primary replay device + +Mikko Tuumanen + for implementing full handling of subtitling descriptors diff --git a/HISTORY b/HISTORY index fd9e3407..f80c3127 100644 --- a/HISTORY +++ b/HISTORY @@ -6155,3 +6155,4 @@ Video Disk Recorder Revision History (thanks to Matthias Schwarzott). - Increased the value of MAXFRAMESIZE to better suit HD recordings (thanks to Reinhard Nissl). +- Implemented full handling of subtitling descriptors (thanks to Mikko Tuumanen). diff --git a/channels.c b/channels.c index 1e857009..590271d6 100644 --- a/channels.c +++ b/channels.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: channels.c 2.6 2009/04/25 13:57:32 kls Exp $ + * $Id: channels.c 2.7 2009/08/16 15:08:49 kls Exp $ */ #include "channels.h" @@ -533,6 +533,22 @@ void cChannel::SetPids(int Vpid, int Ppid, int Vtype, int *Apids, char ALangs[][ } } +void cChannel::SetSubtitlingDescriptors(uchar *SubtitlingTypes, uint16_t *CompositionPageIds, uint16_t *AncillaryPageIds) +{ + if (SubtitlingTypes) { + for (int i = 0; i < MAXSPIDS; i++) + subtitlingTypes[i] = SubtitlingTypes[i]; + } + if (CompositionPageIds) { + for (int i = 0; i < MAXSPIDS; i++) + compositionPageIds[i] = CompositionPageIds[i]; + } + if (AncillaryPageIds) { + for (int i = 0; i < MAXSPIDS; i++) + ancillaryPageIds[i] = AncillaryPageIds[i]; + } +} + void cChannel::SetCaIds(const int *CaIds) { if (caids[0] && caids[0] <= CA_USER_MAX) diff --git a/channels.h b/channels.h index a3c1d433..c012a7d4 100644 --- a/channels.h +++ b/channels.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: channels.h 2.4 2008/11/22 13:35:52 kls Exp $ + * $Id: channels.h 2.5 2009/08/16 14:58:26 kls Exp $ */ #ifndef __CHANNELS_H @@ -129,6 +129,9 @@ private: char dlangs[MAXDPIDS][MAXLANGCODE2]; int spids[MAXSPIDS + 1]; // list is zero-terminated char slangs[MAXSPIDS][MAXLANGCODE2]; + uchar subtitlingTypes[MAXSPIDS]; + uint16_t compositionPageIds[MAXSPIDS]; + uint16_t ancillaryPageIds[MAXSPIDS]; int tpid; int caids[MAXCAIDS + 1]; // list is zero-terminated int nid; @@ -185,6 +188,9 @@ public: const char *Alang(int i) const { return (0 <= i && i < MAXAPIDS) ? alangs[i] : ""; } const char *Dlang(int i) const { return (0 <= i && i < MAXDPIDS) ? dlangs[i] : ""; } const char *Slang(int i) const { return (0 <= i && i < MAXSPIDS) ? slangs[i] : ""; } + uchar SubtitlingType(int i) const { return (0 <= i && i < MAXSPIDS ? subtitlingTypes[i] : 0); } + uint16_t CompositionPageId(int i) const { return (0 <= i && i < MAXSPIDS ? compositionPageIds[i] : 0); } + uint16_t AncillaryPageId(int i) const { return (0 <= i && i < MAXSPIDS ? ancillaryPageIds[i] : 0); } int Tpid(void) const { return tpid; } const int *Caids(void) const { return caids; } int Ca(int Index = 0) const { return Index < MAXCAIDS ? caids[Index] : 0; } @@ -226,6 +232,7 @@ public: void SetCaDescriptors(int Level); void SetLinkChannels(cLinkChannels *LinkChannels); void SetRefChannel(cChannel *RefChannel); + void SetSubtitlingDescriptors(uchar *SubtitlingTypes, uint16_t *CompositionPageIds, uint16_t *AncillaryPageIds); }; class cChannels : public cRwLock, public cConfig { diff --git a/pat.c b/pat.c index 8136ef07..cc96cd9d 100644 --- a/pat.c +++ b/pat.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: pat.c 2.3 2009/08/15 22:16:02 kls Exp $ + * $Id: pat.c 2.4 2009/08/16 15:01:03 kls Exp $ */ #include "pat.h" @@ -334,6 +334,9 @@ void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated int Dpids[MAXDPIDS + 1] = { 0 }; int Spids[MAXSPIDS + 1] = { 0 }; + uchar SubtitlingTypes[MAXSPIDS + 1] = { 0 }; + uint16_t CompositionPageIds[MAXSPIDS + 1] = { 0 }; + uint16_t AncillaryPageIds[MAXSPIDS + 1] = { 0 }; char ALangs[MAXAPIDS][MAXLANGCODE2] = { "" }; char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" }; char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" }; @@ -405,6 +408,9 @@ void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length int n = 0; for (SI::Loop::Iterator it; sd->subtitlingLoop.getNext(sub, it); ) { if (sub.languageCode[0]) { + SubtitlingTypes[NumSpids] = sub.getSubtitlingType(); + CompositionPageIds[NumSpids] = sub.getCompositionPageId(); + AncillaryPageIds[NumSpids] = sub.getAncillaryPageId(); if (n > 0) *s++ = '+'; strn0cpy(s, I18nNormalizeLanguageCode(sub.languageCode), MAXLANGCODE1); @@ -447,6 +453,7 @@ 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); Channel->SetCaIds(CaDescriptors->CaIds()); + Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds); } Channel->SetCaDescriptors(CaDescriptorHandler.AddCaDescriptors(CaDescriptors)); } diff --git a/remux.c b/remux.c index 20664d7b..d9731435 100644 --- a/remux.c +++ b/remux.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: remux.c 2.25 2009/06/21 13:30:03 kls Exp $ + * $Id: remux.c 2.26 2009/08/16 15:13:42 kls Exp $ */ #include "remux.h" @@ -198,7 +198,7 @@ int cPatPmtGenerator::MakeAC3Descriptor(uchar *Target) return i; } -int cPatPmtGenerator::MakeSubtitlingDescriptor(uchar *Target, const char *Language) +int cPatPmtGenerator::MakeSubtitlingDescriptor(uchar *Target, const char *Language, uchar SubtitlingType, uint16_t CompositionPageId, uint16_t AncillaryPageId) { int i = 0; Target[i++] = SI::SubtitlingDescriptorTag; @@ -206,11 +206,11 @@ int cPatPmtGenerator::MakeSubtitlingDescriptor(uchar *Target, const char *Langua Target[i++] = *Language++; Target[i++] = *Language++; Target[i++] = *Language++; - Target[i++] = 0x00; // subtitling type - Target[i++] = 0x00; // composition page id hi - Target[i++] = 0x01; // composition page id lo - Target[i++] = 0x00; // ancillary page id hi - Target[i++] = 0x01; // ancillary page id lo + Target[i++] = SubtitlingType; + Target[i++] = CompositionPageId >> 8; + Target[i++] = CompositionPageId & 0xFF; + Target[i++] = AncillaryPageId >> 8; + Target[i++] = AncillaryPageId & 0xFF; IncEsInfoLength(i); return i; } @@ -327,7 +327,7 @@ void cPatPmtGenerator::GeneratePmt(cChannel *Channel) } for (int n = 0; Channel->Spid(n); n++) { i += MakeStream(buf + i, 0x06, Channel->Spid(n)); - i += MakeSubtitlingDescriptor(buf + i, Channel->Slang(n)); + i += MakeSubtitlingDescriptor(buf + i, Channel->Slang(n), Channel->SubtitlingType(n), Channel->CompositionPageId(n), Channel->AncillaryPageId(n)); } int sl = i - SectionLength - 2 + 4; // -2 = SectionLength storage, +4 = length of CRC diff --git a/remux.h b/remux.h index 84b35f06..e6025fa5 100644 --- a/remux.h +++ b/remux.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: remux.h 2.18 2009/06/21 13:01:30 kls Exp $ + * $Id: remux.h 2.19 2009/08/16 15:15:33 kls Exp $ */ #ifndef __REMUX_H @@ -168,7 +168,7 @@ private: protected: int MakeStream(uchar *Target, uchar Type, int Pid); int MakeAC3Descriptor(uchar *Target); - int MakeSubtitlingDescriptor(uchar *Target, const char *Language); + int MakeSubtitlingDescriptor(uchar *Target, const char *Language, uchar SubtitlingType, uint16_t CompositionPageId, uint16_t AncillaryPageId); int MakeLanguageDescriptor(uchar *Target, const char *Language); int MakeCRC(uchar *Target, const uchar *Data, int Length); void GeneratePmtPid(cChannel *Channel); -- cgit v1.2.3