add content type
This commit is contained in:
parent
6a2e15e712
commit
d3e30600bb
67
descriptor.c
67
descriptor.c
|
@ -105,6 +105,23 @@ read_descriptor(struct epg *epg, struct descriptor *d)
|
|||
&d->content.d137.warninglen);
|
||||
break;
|
||||
|
||||
case DS_CONTENT:
|
||||
{
|
||||
unsigned int end = epg->offset + d->len;
|
||||
int cnt = 0;
|
||||
/* A content descriptor can contain multiple types. Only
|
||||
* save the first one at the moment. */
|
||||
while (epg->offset < end)
|
||||
{
|
||||
if (!cnt++)
|
||||
memcpy(&d->content.d84, epg->bin + epg->offset,
|
||||
sizeof(d->content.d84));
|
||||
epg->offset += sizeof(d->content.d84);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case DS_CONTENT_IDENTIFIER:
|
||||
{
|
||||
unsigned int end = epg->offset + d->len;
|
||||
|
@ -149,7 +166,6 @@ read_descriptor(struct epg *epg, struct descriptor *d)
|
|||
default:
|
||||
printf("Default descriptor: %d\n", d->tag);
|
||||
case DS_LINKAGE:
|
||||
case DS_CONTENT:
|
||||
case DS_PRIVATE_DATA_SPECIFIER:
|
||||
case DS_FTA_CONTENT_MGMT:
|
||||
d->content.unknown.text = string_to_end(epg, d, 0,
|
||||
|
@ -177,16 +193,19 @@ free_descriptor(struct descriptor *d)
|
|||
if (d->content.d77.text)
|
||||
free(d->content.d77.text);
|
||||
break;
|
||||
|
||||
case DS_COMPONENT:
|
||||
if (d->content.d80.text)
|
||||
free(d->content.d80.text);
|
||||
break;
|
||||
|
||||
case DS_USER_DEFINED:
|
||||
if (d->content.d137.text)
|
||||
free(d->content.d137.text);
|
||||
if (d->content.d137.warning)
|
||||
free(d->content.d137.warning);
|
||||
break;
|
||||
|
||||
case DS_CONTENT_IDENTIFIER:
|
||||
{
|
||||
int i;
|
||||
|
@ -199,6 +218,10 @@ free_descriptor(struct descriptor *d)
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case DS_CONTENT:
|
||||
break;
|
||||
|
||||
default:
|
||||
if (d->content.unknown.text)
|
||||
free(d->content.unknown.text);
|
||||
|
@ -208,7 +231,7 @@ free_descriptor(struct descriptor *d)
|
|||
free(d);
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
descriptor_name(struct descriptor *d)
|
||||
{
|
||||
switch (d->tag)
|
||||
|
@ -226,6 +249,37 @@ descriptor_name(struct descriptor *d)
|
|||
return "Unknown";
|
||||
}
|
||||
|
||||
const char *
|
||||
content_type(struct descriptor *d)
|
||||
{
|
||||
switch (d->content.d84.level1)
|
||||
{
|
||||
case 0x1:
|
||||
return "Film/Drama";
|
||||
case 0x2:
|
||||
return "News/Current affairs";
|
||||
case 0x3:
|
||||
return "Show/Game show";
|
||||
case 0x4:
|
||||
return "Sport";
|
||||
case 0x5:
|
||||
return "Children's";
|
||||
case 0x6:
|
||||
return "Music/Ballet/Dance";
|
||||
case 0x7:
|
||||
return "Arts/Culture";
|
||||
case 0x8:
|
||||
return "Social/Political/Economic";
|
||||
case 0x9:
|
||||
return "Education/Science/Factual";
|
||||
case 0xa:
|
||||
return "Leisure";
|
||||
default:
|
||||
return "Undefined";
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
void
|
||||
dump_descriptor(struct descriptor *d, int content)
|
||||
{
|
||||
|
@ -283,6 +337,15 @@ dump_descriptor(struct descriptor *d, int content)
|
|||
break;
|
||||
}
|
||||
|
||||
case DS_CONTENT:
|
||||
{
|
||||
DUMPINT(d, content.d84.level1);
|
||||
DUMPINT(d, content.d84.level2);
|
||||
DUMPINT(d, content.d84.user);
|
||||
printf("%30s: %s\n", "Type", content_type(d));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if (d->content.unknown.textlen)
|
||||
DUMPHEX(d, content.unknown.text,
|
||||
|
|
13
descriptor.h
13
descriptor.h
|
@ -14,9 +14,11 @@
|
|||
|
||||
#define PARSER_SHORT_EVENT 0
|
||||
#define PARSER_USER_DEFINED 1
|
||||
#define PARSER_CRID_EVENT 2
|
||||
#define PARSER_CRID_SERIES 3
|
||||
#define PARSER_CRID_REC 4
|
||||
#define PARSER_CONTENT 2
|
||||
#define PARSER_CRID_EVENT 3
|
||||
#define PARSER_CRID_SERIES 4
|
||||
#define PARSER_CRID_REC 5
|
||||
#define PARSER_MAX 6
|
||||
|
||||
#define CRIDT_EVENT '1'
|
||||
#define CRIDT_SERIES '2'
|
||||
|
@ -51,6 +53,11 @@ struct descriptor {
|
|||
char *text;
|
||||
unsigned int textlen;
|
||||
} d80; /* COMPONENT */
|
||||
struct {
|
||||
unsigned int level2:4;
|
||||
unsigned int level1:4;
|
||||
unsigned int user:8;
|
||||
} d84; /* CONTENT */
|
||||
struct {
|
||||
unsigned int textlen;
|
||||
char *text;
|
||||
|
|
12
epg.c
12
epg.c
|
@ -154,8 +154,7 @@ parse(char *epgpath,
|
|||
void (*callback)(struct epg *, struct section *, struct data *,
|
||||
struct descriptor **, void *), void *val, struct epgfilter *filter)
|
||||
{
|
||||
#define DSLIST_SIZE 5
|
||||
struct descriptor *dslist[DSLIST_SIZE];
|
||||
struct descriptor *dslist[PARSER_MAX];
|
||||
struct epg *epg;
|
||||
int i;
|
||||
|
||||
|
@ -226,7 +225,7 @@ parse(char *epgpath,
|
|||
hexdump(epg->bin + dstart, dend - dstart,
|
||||
dstart);
|
||||
|
||||
for (i = 0; i < DSLIST_SIZE; i++)
|
||||
for (i = 0; i < PARSER_MAX; i++)
|
||||
dslist[i] = NULL;
|
||||
|
||||
while (epg->offset < dend)
|
||||
|
@ -272,6 +271,11 @@ parse(char *epgpath,
|
|||
dslist[PARSER_USER_DEFINED] = ds;
|
||||
break;
|
||||
|
||||
case DS_CONTENT:
|
||||
read_descriptor(epg, ds);
|
||||
dslist[PARSER_CONTENT] = ds;
|
||||
break;
|
||||
|
||||
default:
|
||||
skip_descriptor(epg, ds);
|
||||
free_descriptor(ds);
|
||||
|
@ -286,7 +290,7 @@ parse(char *epgpath,
|
|||
crids[0].crid)))
|
||||
callback(epg, s, d, dslist, val);
|
||||
|
||||
for (i = 0; i < DSLIST_SIZE; i++)
|
||||
for (i = 0; i < PARSER_MAX; i++)
|
||||
if (dslist[i])
|
||||
free_descriptor(dslist[i]);
|
||||
}
|
||||
|
|
1
lint.h
1
lint.h
|
@ -45,6 +45,7 @@ void read_descriptor(struct epg *, struct descriptor *);
|
|||
void skip_descriptor(struct epg *, struct descriptor *);
|
||||
void dump_descriptor(struct descriptor *, int);
|
||||
void free_descriptor(struct descriptor *);
|
||||
const char *content_type(struct descriptor *);
|
||||
|
||||
unsigned char *freeview_huffman_to_string(const unsigned char *, uint,
|
||||
unsigned int *);
|
||||
|
|
32
main.c
32
main.c
|
@ -47,7 +47,9 @@ syntax()
|
|||
fprintf(stderr,
|
||||
" Commands:\n"
|
||||
" dump Show a parsed summary of the EPG.\n"
|
||||
" dumpraw Show raw data from the EPG.\n"
|
||||
" now Show what is currently on.\n"
|
||||
" parse Parse the EPG, no output.\n"
|
||||
" search <text> Search programme names for text.\n"
|
||||
" searchall <text> "
|
||||
"Search programme names/descriptions for text.\n"
|
||||
|
@ -59,6 +61,16 @@ syntax()
|
|||
#define DECOMPRESS(str, len) \
|
||||
if (*(str) == 0x1f) uncompress_epg(&(str), &(len))
|
||||
|
||||
void
|
||||
pass(struct epg *epg __attribute__((unused)),
|
||||
struct section *s __attribute__((unused)),
|
||||
struct data *d __attribute__((unused)),
|
||||
struct descriptor **ds __attribute__((unused)),
|
||||
void *var __attribute__((unused)))
|
||||
{
|
||||
/* Do nothing. */
|
||||
}
|
||||
|
||||
void
|
||||
dumpraw(struct epg *epg __attribute__((unused)),
|
||||
struct section *s, struct data *d, struct descriptor **ds,
|
||||
|
@ -71,6 +83,8 @@ dumpraw(struct epg *epg __attribute__((unused)),
|
|||
dump_descriptor(ds[PARSER_SHORT_EVENT], 1);
|
||||
if (ds[PARSER_USER_DEFINED])
|
||||
dump_descriptor(ds[PARSER_USER_DEFINED], 1);
|
||||
if (ds[PARSER_CONTENT])
|
||||
dump_descriptor(ds[PARSER_CONTENT], 1);
|
||||
if (ds[PARSER_CRID_EVENT])
|
||||
dump_descriptor(ds[PARSER_CRID_EVENT], 1);
|
||||
if (ds[PARSER_CRID_SERIES])
|
||||
|
@ -98,7 +112,8 @@ dump(struct epg *epg __attribute__((unused)),
|
|||
if (sysopts & SYSOPT_PARSABLE)
|
||||
{
|
||||
/* service_id, event_id, start, duration, encrypted, name, text
|
||||
* warning, num_crids, crid_type, crid, ...
|
||||
* warning, content code, content type,
|
||||
* event CRID, series CRID, rec CRID
|
||||
*/
|
||||
printf("%d\t%d\t%ld\t%d\t%d\t",
|
||||
s->service_id, d->event_id, tm,
|
||||
|
@ -126,6 +141,14 @@ dump(struct epg *epg __attribute__((unused)),
|
|||
else
|
||||
printf("\t");
|
||||
|
||||
if (ds[PARSER_CONTENT])
|
||||
{
|
||||
printf("%d\t", ds[PARSER_CONTENT]->content.d84.level1);
|
||||
printf("%s\t", content_type(ds[PARSER_CONTENT]));
|
||||
}
|
||||
else
|
||||
printf("\t\t");
|
||||
|
||||
if (ds[PARSER_CRID_EVENT])
|
||||
{
|
||||
struct descriptor *d = ds[PARSER_CRID_EVENT];
|
||||
|
@ -207,6 +230,11 @@ dump(struct epg *epg __attribute__((unused)),
|
|||
d137->content.d137.warninglen, d137->content.d137.warning);
|
||||
}
|
||||
|
||||
if (ds[PARSER_CONTENT])
|
||||
printf("%30s: %s (%d)\n", "Content Type",
|
||||
content_type(ds[PARSER_CONTENT]),
|
||||
ds[PARSER_CONTENT]->content.d84.level1);
|
||||
|
||||
if (ds[PARSER_CRID_EVENT])
|
||||
printf("%30s: %.*s\n", "Event CRID",
|
||||
ds[PARSER_CRID_EVENT]->content.d118.crids[0].cridlen,
|
||||
|
@ -398,6 +426,8 @@ nextopt:
|
|||
|
||||
if (!strcmp(argv[0], "dump"))
|
||||
parse(epgpath, dump, NULL, filter);
|
||||
else if (!strcmp(argv[0], "parse"))
|
||||
parse(epgpath, pass, NULL, filter);
|
||||
else if (!strcmp(argv[0], "dumpraw"))
|
||||
parse(epgpath, dumpraw, NULL, filter);
|
||||
else if (!strcmp(argv[0], "now"))
|
||||
|
|
Loading…
Reference in New Issue