diff options
author | etobi <git@e-tobi.net> | 2010-02-12 21:56:41 +0100 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2011-08-19 22:41:07 +0200 |
commit | eb49859708903842aaf85b8cc0f91d45722907bb (patch) | |
tree | 6b8fc4bd42d1d73dbbed2c0f60722b5386a1cfce | |
parent | 73a69fc122dd744f48d1d51e1b5747c67b5822dc (diff) | |
download | vdr-patches-eb49859708903842aaf85b8cc0f91d45722907bb.tar.gz vdr-patches-eb49859708903842aaf85b8cc0f91d45722907bb.tar.bz2 |
Allow manual configuration of teletetxt subtitle pages in channels.conf
-rw-r--r-- | channels.c | 53 | ||||
-rw-r--r-- | channels.h | 1 | ||||
-rw-r--r-- | vdr.5 | 7 |
3 files changed, 56 insertions, 5 deletions
@@ -381,9 +381,9 @@ void cChannel::SetSubtitlingDescriptors(uchar *SubtitlingTypes, uint16_t *Compos void cChannel::SetTeletextSubtitlePages(tTeletextSubtitlePage pages[], int numberOfPages) { int mod = CHANNELMOD_NONE; - if (totalTtxtSubtitlePages != numberOfPages) + if (totalTtxtSubtitlePages != (fixedTtxtSubtitlePages + numberOfPages)) mod |= CHANNELMOD_PIDS; - totalTtxtSubtitlePages = 0; + totalTtxtSubtitlePages = fixedTtxtSubtitlePages; for (int i = 0; (i < numberOfPages) && (totalTtxtSubtitlePages < MAXTXTPAGES); i++) { if (teletextSubtitlePages[totalTtxtSubtitlePages].ttxtMagazine != pages[i].ttxtMagazine || teletextSubtitlePages[totalTtxtSubtitlePages].ttxtPage != pages[i].ttxtPage || @@ -526,11 +526,22 @@ cString cChannel::ToText(const cChannel *Channel) q += IntArrayToString(q, Channel->dpids, 10, Channel->dlangs, Channel->dtypes); } *q = 0; + const int TBufferSize = 5 + 1 + (MAXTXTPAGES * (3 + 1 + MAXLANGCODE1 + 1)) + 10; // '12345;150=deu,151=fin,...', +10: paranoia + char tpidbuf[TBufferSize]; + q = tpidbuf; + q += snprintf(q, sizeof(tpidbuf), "%d", Channel->tpid); + if (Channel->fixedTtxtSubtitlePages > 0) { + q += snprintf(q, sizeof(tpidbuf) - (q - tpidbuf), ";"); + for (int i = 0; i < Channel->fixedTtxtSubtitlePages; ++i) { + tTeletextSubtitlePage page = Channel->teletextSubtitlePages[i]; + q += snprintf(q, sizeof(tpidbuf) - (q - tpidbuf), "%d=%s", page.PageNumber(), page.ttxtLanguage); + } + } char caidbuf[MAXCAIDS * 5 + 10]; // 5: 4 digits plus delimiting ',', 10: paranoia q = caidbuf; q += IntArrayToString(q, Channel->caids, 16); *q = 0; - buffer = cString::sprintf("%s:%d:%s:%s:%d:%s:%s:%d:%s:%d:%d:%d:%d\n", FullName, Channel->frequency, *Channel->parameters, *cSource::ToString(Channel->source), Channel->srate, vpidbuf, apidbuf, Channel->tpid, caidbuf, Channel->sid, Channel->nid, Channel->tid, Channel->rid); + buffer = cString::sprintf("%s:%d:%s:%s:%d:%s:%s:%s:%s:%d:%d:%d:%d\n", FullName, Channel->frequency, *Channel->parameters, *cSource::ToString(Channel->source), Channel->srate, vpidbuf, apidbuf, tpidbuf, caidbuf, Channel->sid, Channel->nid, Channel->tid, Channel->rid); } return buffer; } @@ -564,8 +575,9 @@ bool cChannel::Parse(const char *s) char *parambuf = NULL; char *vpidbuf = NULL; char *apidbuf = NULL; + char *tpidbuf = NULL; char *caidbuf = NULL; - int fields = sscanf(s, "%a[^:]:%d :%a[^:]:%a[^:] :%d :%a[^:]:%a[^:]:%d :%a[^:]:%d :%d :%d :%d ", &namebuf, &frequency, ¶mbuf, &sourcebuf, &srate, &vpidbuf, &apidbuf, &tpid, &caidbuf, &sid, &nid, &tid, &rid); + int fields = sscanf(s, "%a[^:]:%d :%a[^:]:%a[^:] :%d :%a[^:]:%a[^:]:%a[^:]:%a[^:]:%d :%d :%d :%d ", &namebuf, &frequency, ¶mbuf, &sourcebuf, &srate, &vpidbuf, &apidbuf, &tpidbuf, &caidbuf, &sid, &nid, &tid, &rid); if (fields >= 9) { if (fields == 9) { // allow reading of old format @@ -664,7 +676,37 @@ bool cChannel::Parse(const char *s) dpids[NumDpids] = 0; dtypes[NumDpids] = 0; } - + if (tpidbuf) { + char *p; + fixedTtxtSubtitlePages = 0; + // 2001;150=deu,151=fin + if ((p = strchr(tpidbuf, ';')) != NULL) { + char *q, *strtok_next; + *p++ = 0; + while ((q = strtok_r(p, ",", &strtok_next)) != NULL) { + if (fixedTtxtSubtitlePages < MAXTXTPAGES) { + int page; + char *l = strchr(q, '='); + if (l) + *l++ = 0; + if (sscanf(q, "%d", &page) == 1) { + teletextSubtitlePages[fixedTtxtSubtitlePages] = tTeletextSubtitlePage(page); + if (l) + strn0cpy(teletextSubtitlePages[fixedTtxtSubtitlePages].ttxtLanguage, l, MAXLANGCODE1); + fixedTtxtSubtitlePages++; + } + else + esyslog("ERROR: invalid Teletext page!"); // no need to set ok to 'false' + } + else + esyslog("ERROR: too many Teletext pages!"); // no need to set ok to 'false' + p = NULL; + } + totalTtxtSubtitlePages = fixedTtxtSubtitlePages; + } + if (sscanf(tpidbuf, "%d", &tpid) != 1) + return false; + } if (caidbuf) { char *p = caidbuf; char *q; @@ -701,6 +743,7 @@ bool cChannel::Parse(const char *s) free(sourcebuf); free(vpidbuf); free(apidbuf); + free(tpidbuf); free(caidbuf); free(namebuf); if (!GetChannelID().Valid()) { @@ -126,6 +126,7 @@ private: uint16_t compositionPageIds[MAXSPIDS]; uint16_t ancillaryPageIds[MAXSPIDS]; int tpid; + int fixedTtxtSubtitlePages; int totalTtxtSubtitlePages; tTeletextSubtitlePage teletextSubtitlePages[MAXTXTPAGES]; int caids[MAXCAIDS + 1]; // list is zero-terminated @@ -214,6 +214,13 @@ if there is an audio type. .TP .B TPID The teletext PID. + +Fixed teletext subtitling pages can be defined separated by a semicolon. +The pages (separated by commas) can contain ISO 639 language codes, delimited +by a '=' sign, as in + +.B ...:2001;150=deu,151=fin:... + .TP .B Conditional access A hexadecimal integer defining how this channel can be accessed: |