Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dvb_support: start implementing ATSC multiple string structure
  • Loading branch information
laurimyllari authored and perexg committed Oct 22, 2015
1 parent 3bdcfb8 commit d1653f6
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/input/mpegts/dvb.h
Expand Up @@ -200,6 +200,10 @@ int dvb_get_string_with_len
(char *dst, size_t dstlen, const uint8_t *buf, size_t buflen,
const char *dvb_charset, dvb_string_conv_t *conv);

int atsc_get_string
(char *dst, size_t dstlen, const uint8_t *src, size_t srclen,
const char *lang);

/* Conversion */

#define bcdtoint(i) ((((i & 0xf0) >> 4) * 10) + (i & 0x0f))
Expand Down
54 changes: 54 additions & 0 deletions src/input/mpegts/dvb_support.c
Expand Up @@ -392,6 +392,60 @@ atsc_utf16_to_utf8(const uint8_t *src, int len, char *buf, int buflen)
*buf = 0;
}

int
atsc_get_string
(char *dst, size_t dstlen, const uint8_t *src, size_t srclen,
const char *lang)
{
int stringcount;
int i, j;

stringcount = src[0];
tvhdebug("mss", "%d strings", stringcount);

src++;
srclen--;

for (i = 0; i < stringcount && srclen >= 4; i++) {
char langcode[3];
int segmentcount;

langcode[0] = src[0];
langcode[1] = src[1];
langcode[2] = src[2];
segmentcount = src[3];

tvhdebug("mss", " %d: lang '%c%c%c', segments %d",
i, langcode[0], langcode[1], langcode[2], segmentcount);

src += 4;
srclen -= 4;

for (j = 0; j < segmentcount && srclen >= 3; j++) {
int compressiontype, mode, bytecount;

compressiontype = src[0];
mode = src[1];
bytecount = src[2];

src += 3;
srclen -= 3;

if (mode == 0 && compressiontype == 0) {
tvhdebug("mss", " %d: comptype 0x%02x, mode 0x%02x, %d bytes: '%.*s'",
j, compressiontype, mode, bytecount, bytecount, src);
} else {
tvhdebug("mss", " %d: comptype 0x%02x, mode 0x%02x, %d bytes",
j, compressiontype, mode, bytecount);
}

/* FIXME: read compressed bytes */
src += bytecount; srclen -= bytecount; // skip for now
}
}
return 0;
}

/*
* DVB time and date functions
*/
Expand Down

0 comments on commit d1653f6

Please sign in to comment.