[PR-153] Generalise the PL specific portions of PR-153
The original patch provided a very PL specific patch, this has now
been expanded to be more general and work better with the previous
charset PR.
(cherry picked from commit 495247bd67
)
This commit is contained in:
parent
8a7db81088
commit
3e3c54100a
8 changed files with 77 additions and 66 deletions
2
Makefile
2
Makefile
|
@ -116,7 +116,6 @@ SRCS += src/epggrab/module.c\
|
|||
src/epggrab/module/xmltv.c\
|
||||
src/epggrab/module/eit.c \
|
||||
src/epggrab/module/opentv.c \
|
||||
src/epggrab/module/encoding.c \
|
||||
src/epggrab/support/freesat_huffman.c \
|
||||
|
||||
SRCS += src/plumbing/tsfix.c \
|
||||
|
@ -147,6 +146,7 @@ SRCS += src/muxer.c \
|
|||
SRCS-${CONFIG_LINUXDVB} += \
|
||||
src/dvb/dvb.c \
|
||||
src/dvb/dvb_support.c \
|
||||
src/dvb/dvb_charset.c \
|
||||
src/dvb/dvb_fe.c \
|
||||
src/dvb/dvb_tables.c \
|
||||
src/dvb/diseqc.c \
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
#include "tvheadend.h"
|
||||
#include "dvb.h"
|
||||
#include "dvb_support.h"
|
||||
#include "dvb_charset.h"
|
||||
|
||||
void
|
||||
dvb_init(uint32_t adapter_mask)
|
||||
{
|
||||
dvb_charset_init();
|
||||
dvb_adapter_init(adapter_mask);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* tvheadend, encoding list
|
||||
* tvheadend, charset list
|
||||
* Copyright (C) 2012 Mariusz Białończyk
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -18,39 +18,44 @@
|
|||
|
||||
#include <string.h>
|
||||
#include "tvheadend.h"
|
||||
#include "encoding.h"
|
||||
#include "../../settings.h"
|
||||
#include "settings.h"
|
||||
#include "dvb/dvb_charset.h"
|
||||
|
||||
/*
|
||||
* Process a file
|
||||
*/
|
||||
static void _encoding_load_file()
|
||||
static void _charset_load_file()
|
||||
{
|
||||
htsmsg_t *l, *e;
|
||||
htsmsg_field_t *f;
|
||||
|
||||
encoding_t *enc;
|
||||
unsigned int tsid, onid;
|
||||
dvb_charset_t *enc;
|
||||
const char *charset;
|
||||
uint32_t tsid, onid, sid;
|
||||
int i = 0;
|
||||
|
||||
l = hts_settings_load("encoding");
|
||||
l = hts_settings_load("charset");
|
||||
if (l)
|
||||
{
|
||||
HTSMSG_FOREACH(f, l) {
|
||||
if ((e = htsmsg_get_map_by_field(f))) {
|
||||
tsid = onid = 0;
|
||||
htsmsg_get_u32(e, "tsid", &tsid);
|
||||
tsid = onid = sid = 0;
|
||||
htsmsg_get_u32(e, "onid", &onid);
|
||||
htsmsg_get_u32(e, "tsid", &tsid);
|
||||
htsmsg_get_u32(e, "sid", &sid);
|
||||
charset = htsmsg_get_str(e, "charset");
|
||||
|
||||
if (tsid == 0 || onid == 0)
|
||||
if (tsid == 0 || onid == 0 || !charset)
|
||||
continue;
|
||||
|
||||
enc = calloc(1, sizeof(encoding_t));
|
||||
enc = calloc(1, sizeof(dvb_charset_t));
|
||||
if (enc)
|
||||
{
|
||||
enc->tsid = tsid;
|
||||
enc->onid = onid;
|
||||
LIST_INSERT_HEAD(&encoding_list, enc, link);
|
||||
enc->onid = onid;
|
||||
enc->tsid = tsid;
|
||||
enc->sid = sid;
|
||||
enc->charset = strdup(charset);
|
||||
LIST_INSERT_HEAD(&dvb_charset_list, enc, link);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -59,13 +64,33 @@ static void _encoding_load_file()
|
|||
};
|
||||
|
||||
if (i > 0)
|
||||
tvhlog(LOG_INFO, "encoding", "%d entries loaded", i);
|
||||
tvhlog(LOG_INFO, "charset", "%d entries loaded", i);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise the encoding list
|
||||
* Initialise the charset list
|
||||
*/
|
||||
void encoding_init ( void )
|
||||
void dvb_charset_init ( void )
|
||||
{
|
||||
_encoding_load_file();
|
||||
_charset_load_file();
|
||||
}
|
||||
|
||||
/*
|
||||
* Find default charset
|
||||
*/
|
||||
const char *dvb_charset_find
|
||||
( uint16_t tsid, uint16_t sid )
|
||||
{
|
||||
dvb_charset_t *ret = NULL, *enc;
|
||||
LIST_FOREACH(enc, &dvb_charset_list, link) {
|
||||
if (tsid == enc->tsid) {
|
||||
if (sid == enc->sid) {
|
||||
ret = enc;
|
||||
break;
|
||||
} else if (!enc->sid) {
|
||||
ret = enc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret ? ret->charset : NULL;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* tvheadend, encoding list
|
||||
* tvheadend, dvb charset config
|
||||
* Copyright (C) 2012 Mariusz Białończyk
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -16,17 +16,22 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __TVH_ENCODING_H__
|
||||
#define __TVH_ENCODING_H__
|
||||
#ifndef __TVH_DVB_CHARSET_H__
|
||||
#define __TVH_DVB_CHARSET_H__
|
||||
|
||||
typedef struct encoding {
|
||||
LIST_ENTRY(encoding) link;
|
||||
unsigned int tsid;
|
||||
unsigned int onid;
|
||||
} encoding_t;
|
||||
typedef struct dvb_charset {
|
||||
LIST_ENTRY(dvb_charset) link;
|
||||
uint16_t onid;
|
||||
uint16_t tsid;
|
||||
uint16_t sid;
|
||||
const char *charset;
|
||||
} dvb_charset_t;
|
||||
|
||||
LIST_HEAD(,encoding) encoding_list;
|
||||
LIST_HEAD(,dvb_charset) dvb_charset_list;
|
||||
|
||||
void encoding_init ( void );
|
||||
void dvb_charset_init ( void );
|
||||
|
||||
#endif /* __TVH_ENCODING_H__ */
|
||||
const char *dvb_charset_find
|
||||
(uint16_t tsid, uint16_t sid);
|
||||
|
||||
#endif /* __TVH_DVB_CHARSET_H__ */
|
|
@ -202,9 +202,9 @@ static inline size_t dvb_convert(int conv,
|
|||
*/
|
||||
|
||||
int
|
||||
dvb_get_string(char *dst, size_t dstlen, const uint8_t *src, size_t srclen, char *dvb_charset, dvb_string_conv_t *conv)
|
||||
dvb_get_string(char *dst, size_t dstlen, const uint8_t *src, size_t srclen, const char *dvb_charset, dvb_string_conv_t *conv)
|
||||
{
|
||||
int ic, pl_workaround = 0;
|
||||
int ic;
|
||||
size_t len, outlen;
|
||||
int i;
|
||||
|
||||
|
@ -220,22 +220,13 @@ dvb_get_string(char *dst, size_t dstlen, const uint8_t *src, size_t srclen, char
|
|||
conv++;
|
||||
}
|
||||
|
||||
// check for polish channels encoding workaround
|
||||
if (dvb_charset && (strcmp(dvb_charset, "pl_workaround") == 0)) {
|
||||
pl_workaround = 1;
|
||||
dvb_charset = NULL;
|
||||
}
|
||||
|
||||
// automatic charset detection
|
||||
switch(src[0]) {
|
||||
case 0:
|
||||
return -1;
|
||||
|
||||
case 0x01 ... 0x0b:
|
||||
if (pl_workaround && (src[0] + 4) == 5)
|
||||
ic = convert_iso6937;
|
||||
else
|
||||
ic = convert_iso_8859[src[0] + 4];
|
||||
ic = convert_iso_8859[src[0] + 4];
|
||||
src++; srclen--;
|
||||
break;
|
||||
|
||||
|
@ -260,10 +251,7 @@ dvb_get_string(char *dst, size_t dstlen, const uint8_t *src, size_t srclen, char
|
|||
return -1;
|
||||
|
||||
default:
|
||||
if (pl_workaround)
|
||||
ic = convert_iso_8859[2];
|
||||
else
|
||||
ic = convert_iso6937;
|
||||
ic = convert_iso6937;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -298,7 +286,7 @@ dvb_get_string(char *dst, size_t dstlen, const uint8_t *src, size_t srclen, char
|
|||
|
||||
int
|
||||
dvb_get_string_with_len(char *dst, size_t dstlen,
|
||||
const uint8_t *buf, size_t buflen, char *dvb_charset,
|
||||
const uint8_t *buf, size_t buflen, const char *dvb_charset,
|
||||
dvb_string_conv_t *conv)
|
||||
{
|
||||
int l = buf[0];
|
||||
|
|
|
@ -62,11 +62,11 @@ typedef struct dvb_string_conv
|
|||
} dvb_string_conv_t;
|
||||
|
||||
int dvb_get_string(char *dst, size_t dstlen, const uint8_t *src,
|
||||
const size_t srclen, char *dvb_charset,
|
||||
const size_t srclen, const char *dvb_charset,
|
||||
dvb_string_conv_t *conv);
|
||||
|
||||
int dvb_get_string_with_len(char *dst, size_t dstlen,
|
||||
const uint8_t *buf, size_t buflen, char *dvb_charset,
|
||||
const uint8_t *buf, size_t buflen, const char *dvb_charset,
|
||||
dvb_string_conv_t *conv);
|
||||
|
||||
#define bcdtoint(i) ((((i & 0xf0) >> 4) * 10) + (i & 0x0f))
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "epg.h"
|
||||
#include "epggrab.h"
|
||||
#include "epggrab/private.h"
|
||||
#include "encoding.h"
|
||||
#include "dvb/dvb_charset.h"
|
||||
|
||||
/* ************************************************************************
|
||||
* Status handling
|
||||
|
@ -154,7 +154,7 @@ typedef struct eit_event
|
|||
lang_str_t *summary;
|
||||
lang_str_t *desc;
|
||||
|
||||
char *default_charset;
|
||||
const char *default_charset;
|
||||
|
||||
htsmsg_t *extra;
|
||||
|
||||
|
@ -205,7 +205,7 @@ static dvb_string_conv_t _eit_freesat_conv[2] = {
|
|||
static int _eit_get_string_with_len
|
||||
( epggrab_module_t *m,
|
||||
char *dst, size_t dstlen,
|
||||
const uint8_t *src, size_t srclen, char *charset )
|
||||
const uint8_t *src, size_t srclen, const char *charset )
|
||||
{
|
||||
dvb_string_conv_t *cptr = NULL;
|
||||
|
||||
|
@ -509,7 +509,6 @@ static int _eit_process_event
|
|||
epg_episode_t *ee;
|
||||
epg_serieslink_t *es;
|
||||
eit_event_t ev;
|
||||
static char pl_workaround[] = "pl_workaround";
|
||||
|
||||
if ( len < 12 ) return -1;
|
||||
|
||||
|
@ -542,17 +541,11 @@ static int _eit_process_event
|
|||
memset(&ev, 0, sizeof(ev));
|
||||
ev.default_charset = svc->s_dvb_charset;
|
||||
|
||||
/* Test channels which needs polish workaround */
|
||||
encoding_t *enc;
|
||||
LIST_FOREACH(enc, &encoding_list, link) {
|
||||
// TODO: also check for original network id (onid)
|
||||
// currently onid is unavailable in tvh but there are additional cases which has
|
||||
// to be met, so I believe, that it should not harm Russian ISO-8859-5 channels
|
||||
// until we've got this information here
|
||||
if (!ev.default_charset && svc->s_dvb_mux_instance->tdmi_transport_stream_id == enc->tsid) {
|
||||
ev.default_charset = pl_workaround;
|
||||
break;
|
||||
}
|
||||
/* Override */
|
||||
if (!ev.default_charset) {
|
||||
ev.default_charset
|
||||
= dvb_charset_find(svc->s_dvb_mux_instance->tdmi_transport_stream_id,
|
||||
svc->s_dvb_service_id);
|
||||
}
|
||||
|
||||
while (dllen > 2) {
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
#include "ffdecsa/FFdecsa.h"
|
||||
#include "muxes.h"
|
||||
#include "config2.h"
|
||||
#include "epggrab/module/encoding.h"
|
||||
|
||||
int running;
|
||||
time_t dispatch_clock;
|
||||
|
@ -434,7 +433,6 @@ main(int argc, char **argv)
|
|||
|
||||
epggrab_init();
|
||||
epg_init();
|
||||
encoding_init();
|
||||
|
||||
dvr_init();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue