Compare commits
No commits in common. 'master' and 'foxsat' have entirely different histories.
9 changed files with 633 additions and 1083 deletions
@ -1,161 +1,203 @@
|
||||
#include <stdio.h> |
||||
#include <stdint.h> |
||||
#include <string.h> |
||||
#include <stdlib.h> |
||||
#include <time.h> |
||||
#include "lint.h" |
||||
|
||||
const char * |
||||
genre(unsigned char b) |
||||
{ |
||||
switch (b) |
||||
{ |
||||
case 0: |
||||
return "Unclassified"; |
||||
case 0x10: |
||||
return "Film"; |
||||
case 0x20: |
||||
return "News & Factual"; |
||||
case 0x30: |
||||
return "Entertainment"; |
||||
case 0x40: |
||||
return "Sport"; |
||||
case 0x50: |
||||
return "Children"; |
||||
case 0x60: |
||||
return "Education"; |
||||
case 0xa0: |
||||
return "Lifestyle"; |
||||
case 0xf0: |
||||
return "Drama"; |
||||
default: |
||||
return "Unknown"; |
||||
} |
||||
} |
||||
|
||||
char * |
||||
ctimenl(time_t tm) |
||||
ctimenl(time_t *tm) |
||||
{ |
||||
static char buf[32]; |
||||
static char buf[25]; |
||||
char *p; |
||||
|
||||
p = ctime(&tm); |
||||
memset(buf, '\0', sizeof(buf)); |
||||
if (p) |
||||
{ |
||||
strncpy(buf, p, sizeof(buf) - 1); |
||||
if ((p = strpbrk(buf, "\r\n"))) |
||||
*p = '\0'; |
||||
} |
||||
strcpy(buf, ctime(tm)); |
||||
|
||||
if ((p = strpbrk(buf, "\r\n"))) |
||||
*p = '\0'; |
||||
|
||||
return buf; |
||||
} |
||||
|
||||
void |
||||
display_bookmarks(struct hmt *hmt) |
||||
uint8_t * |
||||
strip_string(uint8_t *str) |
||||
{ |
||||
int i; |
||||
|
||||
for (i = 0; i < hmt->num_bookmarks && i < 32; i++) |
||||
printf("%d ", hmt->bookmarks[i]); |
||||
printf("\n"); |
||||
if (str[0] == 0x10 && str[1] == 0x69 && str[2] == 0x37) |
||||
return str + 3; |
||||
if (*str == 0x15) |
||||
return str + 1; |
||||
/* non freesat recordings seems to have a 0x05 as the header string */ |
||||
if (*str == 0x05) |
||||
return str + 1; |
||||
return str; |
||||
} |
||||
|
||||
void |
||||
display_hmt(struct hmt *hmt) |
||||
{ |
||||
int g; |
||||
|
||||
g = guidance(hmt); |
||||
|
||||
uint16_t i; |
||||
uint16_t j; |
||||
time_t tm; |
||||
char time_buf[256]; |
||||
|
||||
char fullpath[512]={0}; |
||||
char filename[512]={0}; |
||||
int posslash = -1; |
||||
|
||||
/* title, epg, def, channel num, channel name, start, end, flags,
|
||||
* guidance |
||||
*/ |
||||
if (sysopts & SYSOPT_PARSABLE) |
||||
{ |
||||
printf("%s\t", hmt->mediatitle); |
||||
printf("%s\t", hmt->synopsis); |
||||
printf("%s\t", hmt->definition == DEF_HD ? "HD" : "SD"); |
||||
printf("%u\t%s\t", hmt->lcn, hmt->channel); |
||||
printf("%u\t", hmt->start); |
||||
printf("%u\t", hmt->end); |
||||
printf("%s\t", hmt_flags(hmt)); |
||||
if (g) |
||||
printf("%s\t", hmt->guidance); |
||||
printf("%s\t", strip_string(hmt->bin + (HMT_TITLE))); |
||||
if (hmt->epgstart != NULL) |
||||
printf("%s\t", strip_string(hmt->epgstart + HMT_EPG)); |
||||
else |
||||
printf("\t"); |
||||
printf("%s\t", hmt->bin[HMT_FLAGS2] & HMT_FLAGS2_HD ? "HD" : "SD"); |
||||
|
||||
i = read_uint16(hmt->bin + HMT_CHANNEL_NUM, 0); |
||||
printf("%i\t%s\t", i, |
||||
strip_string(hmt->bin + HMT_CHANNEL_NAME)); |
||||
|
||||
tm = read_uint32(hmt->bin + HMT_RECORDING_START, 0); |
||||
(void) strftime(time_buf, sizeof(time_buf), "%a %b %d %H:%M:%S %Y", gmtime(&tm)); |
||||
printf("%s\t", time_buf); |
||||
printf("%lu\t", tm); |
||||
|
||||
tm = read_uint32(hmt->bin + HMT_RECORDING_END, 0); |
||||
(void) strftime(time_buf, sizeof(time_buf), "%a %b %d %H:%M:%S %Y", gmtime(&tm)); |
||||
printf("%s\t", time_buf); |
||||
printf("%lu\t", tm); |
||||
|
||||
printf("%s%s%s%s%s", |
||||
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_LOCKED ? "Locked," : "", |
||||
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_NEW ? "" : "New,", |
||||
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_PROTECTED? "Protected," : "", |
||||
hmt->bin[HMT_FLAGS2] & HMT_FLAGS2_ENCRYPTED ? "Encrypted," : "", |
||||
hmt->epgguidance != NULL ? "Guidance," : "" |
||||
); |
||||
if (hmt->bin[HMT_CONVERT_FLAG] == 'P') |
||||
printf("Converting,\t"); |
||||
else |
||||
if (hmt->bin[HMT_CONVERT_FLAG] == 'F') |
||||
printf("Converted,\t"); |
||||
else |
||||
printf("Unconverted,\t"); |
||||
|
||||
printf("%d\t", hmt->num_bookmarks); |
||||
printf("%u\t", hmt->schedstart); |
||||
printf("%u\t", hmt->scheddur); |
||||
printf("%d\t", hmt->genre); |
||||
printf("%u\t", hmt->resume); |
||||
printf("%s/%s\t", recordingstatus(hmt), failurereason(hmt)); |
||||
printf("%u\t%u\t%u\t", hmt->series, hmt->episode, |
||||
hmt->episodetot); |
||||
if (hmt->epgguidance != NULL) |
||||
printf("%s\t", strip_string(hmt->epgguidance)); |
||||
|
||||
printf("\n"); |
||||
|
||||
return; |
||||
} |
||||
|
||||
printf("Format:%s\n", hmt->definition == DEF_HD ? "HD" : "SD"); |
||||
printf("Title:%s\n", hmt->mediatitle); |
||||
printf("ITitle:%s\n", hmt->title); |
||||
printf("Channel:%u (%s)\n", hmt->lcn, hmt->channel); |
||||
printf("Episode:%u,%u/%u\n", |
||||
hmt->series, hmt->episode, hmt->episodetot); |
||||
i = read_uint16(hmt->bin + HMT_CHANNEL_NUM, 0); |
||||
|
||||
printf("Folder:%s\n", hmt->directory); |
||||
if (*hmt->filename == '\0' && hmt->filename[1] != '\0') |
||||
printf("Filename:%s\n", hmt->filename + 1); |
||||
else |
||||
printf("Filename:%s\n", hmt->filename); |
||||
memcpy(fullpath, hmt->bin + HMT_FOLDER, sizeof(fullpath)); |
||||
posslash = (strrchr(fullpath, '/') - fullpath); |
||||
memcpy(filename, hmt->bin + HMT_FOLDER + posslash + 1, (sizeof(fullpath) - posslash)); |
||||
fullpath[posslash+1]=0; |
||||
|
||||
printf("Genre:%s (%d)\n", genredescr(hmt->genre), hmt->genre); |
||||
printf("EPG:%s\n", hmt->synopsis); |
||||
if (g) |
||||
printf("Guidance:%s\n", hmt->guidance); |
||||
printf("Format: %s\n", hmt->bin[HMT_FLAGS2] & HMT_FLAGS2_HD ? "HD" : "SD"); |
||||
printf("Title: %s\n", strip_string(hmt->bin + (HMT_TITLE))); |
||||
|
||||
if (hmt_is(hmt, HMTA_ENCRYPTED)) |
||||
printf("Raw file is encrypted on disk.\n"); |
||||
printf("Channel: %i (%s)\n", i, hmt->bin + HMT_CHANNEL_NAME); |
||||
|
||||
printf("\n"); |
||||
printf("Folder: %s\n", fullpath); |
||||
printf("Filename: %s.ts\n", filename); |
||||
if (hmt->epgstart != NULL) { |
||||
printf("EPG: %s\n", strip_string(hmt->epgstart + HMT_EPG)); |
||||
} else { |
||||
printf("EPG:\n"); |
||||
} |
||||
|
||||
printf("Recording Status: %s (%s)\n", |
||||
recordingstatus(hmt), failurereason(hmt)); |
||||
printf("Flags: %s\n", hmt_flags(hmt)); |
||||
printf("Copy count:%d\n", hmt->copycount); |
||||
if (hmt->epgguidance != NULL) |
||||
printf("Guidance: %s\n", strip_string(hmt->epgguidance)); |
||||
|
||||
printf("\n"); |
||||
|
||||
printf("Scheduled start:%u (%s)\n", hmt->schedstart, |
||||
ctimenl(hmt->schedstart)); |
||||
printf("Scheduled duration:%u\n", hmt->scheddur); |
||||
printf("Recording start:%u (%s)\n", hmt->start, |
||||
ctimenl(hmt->start)); |
||||
printf("Recording end:%u (%s)\n", hmt->end, ctimenl(hmt->end)); |
||||
printf("Duration:%u\n", hmt->end - hmt->start); |
||||
printf("Stored duration:%u\n", hmt->duration); |
||||
printf("Flags: %s%s%s%s%s%s", |
||||
hmt->bin[HMT_FLAGS2] & HMT_FLAGS2_HD ? "HD," : "SD,", |
||||
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_LOCKED ? "Locked," : "", |
||||
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_NEW ? "" : "New,", |
||||
hmt->bin[HMT_FLAGS1] & HMT_FLAGS1_PROTECTED? "Protected," : "", |
||||
hmt->bin[HMT_FLAGS2] & HMT_FLAGS2_ENCRYPTED ? "Encrypted," : "", |
||||
hmt->epgguidance != NULL ? "Guidance," : "" |
||||
); |
||||
if (hmt->bin[HMT_CONVERT_FLAG] == 'P') |
||||
printf("Converting,\n"); |
||||
else |
||||
if (hmt->bin[HMT_CONVERT_FLAG] == 'F') |
||||
printf("Converted,\n"); |
||||
else |
||||
printf("Unconverted,\n"); |
||||
|
||||
printf("Play resumes at:%u second%s in.\n", hmt->resume, |
||||
hmt->resume == 1 ? "" : "s"); |
||||
printf("Timezone offset:%d\n", hmt->tzoffset); |
||||
printf("Copy count: %d\n", hmt->bin[HMT_COPYCOUNT]); |
||||
|
||||
printf("\n"); |
||||
|
||||
printf("Service ID (SID):%u\n", hmt->service_id); |
||||
printf("Event ID:%u\n", hmt->event_id); |
||||
printf("Transport Stream ID (TSID):%u\n", hmt->tsid); |
||||
printf("Originating Network ID (ONID):%u\n", hmt->onid); |
||||
printf("Programme Map Table PID (PMTPID):%u\n", hmt->pmt_pid); |
||||
printf("Video PID:%u\n", hmt->video_pid); |
||||
printf("Audio PID:%u\n", hmt->audio_pid); |
||||
printf("Bookmarks:%d = ", hmt->num_bookmarks); |
||||
display_bookmarks(hmt); |
||||
|
||||
/* Display basic information EPG blocks... TBC */ |
||||
if (hmt->binsize > 0x1001) |
||||
{ |
||||
uint16_t j; |
||||
uint32_t k; |
||||
int n; |
||||
tm = read_uint32(hmt->epgstart + HMT_SCHEDULED_START, 0); |
||||
(void) strftime(time_buf, sizeof(time_buf), "%a %b %d %H:%M:%S %Y", gmtime(&tm)); |
||||
printf("Scheduled start: %s\n", time_buf); |
||||
/* printf("Scheduled start:%lu (%s)\n", tm, ctimenl(&tm)); */ |
||||
|
||||
printf("\n"); |
||||
j = read_uint16(hmt->bin + 0x1000, 1); |
||||
printf("EPG Blocks:%u\n", j); |
||||
for (n = 1; n <= j; n++) |
||||
{ |
||||
uint32_t off = 0x1004 + n * 32; |
||||
if (hmt->binsize < off) |
||||
break; |
||||
printf(" Block:%d", n); |
||||
k = read_uint32(hmt->bin + off + 4, 1); |
||||
printf(" Time:%u", k); |
||||
k = read_uint32(hmt->bin + off + 8, 1); |
||||
printf(" Offset:%#x\n", k); |
||||
|
||||
if (k < off) |
||||
continue; |
||||
|
||||
if (hmt->binsize >= k + 704) |
||||
{ |
||||
/* Offset to EPG block. */ |
||||
off = k; |
||||
printf(" Block%d_Title:%s\n", n, |
||||
strip_string(hmt->bin + off + HMT_EPG_TITLE)); |
||||
} |
||||
|
||||
/* Synopsis is off + 0x13e */ |
||||
} |
||||
} |
||||
} |
||||
tm = read_uint32(hmt->epgstart + HMT_SCHEDULED_DURATION, 0); |
||||
printf("Scheduled duration: %lu\n", tm); |
||||
|
||||
tm = read_uint32(hmt->bin + HMT_RECORDING_START, 0); |
||||
(void) strftime(time_buf, sizeof(time_buf), "%a %b %d %H:%M:%S %Y", gmtime(&tm)); |
||||
printf("Recording start: %s\n", time_buf); |
||||
/* printf("Recording start:%lu (%s)\n", tm, ctimenl(&tm)); */ |
||||
|
||||
tm = read_uint32(hmt->bin + HMT_RECORDING_END, 0); |
||||
(void) strftime(time_buf, sizeof(time_buf), "%a %b %d %H:%M:%S %Y", gmtime(&tm)); |
||||
printf("Recording end: %s\n", time_buf); |
||||
/* printf("Recording end:%lu (%s)\n", tm, ctimenl(&tm)); */ |
||||
|
||||
/* printf("Play resumes at: %i seconds in.\n", read_uint16(hmt->bin + HMT_PLAYED_TIME, 0)); */ |
||||
|
||||
printf("\n"); |
||||
|
||||
j = read_uint16(hmt->bin + HMT_SID, 0); |
||||
printf("Service ID (SID): %u\n", j); |
||||
j = read_uint16(hmt->bin + HMT_TSID, 0); |
||||
printf("Transport Stream ID (TSID): %u\n", j); |
||||
j = read_uint16(hmt->bin + HMT_ONID, 0); |
||||
printf("Originating Network ID (ONID): %u\n", j); |
||||
j = read_uint16(hmt->bin + HMT_PMTPID, 0); |
||||
printf("Programme Map Table PID (PMTPID): %u\n", j); |
||||
j = read_uint16(hmt->bin + HMT_VIDEOPID, 0); |
||||
printf("Video PID: %u\n", j); |
||||
j = read_uint16(hmt->bin + HMT_AUDIOPID, 0); |
||||
printf("Audio PID: %u\n", j); |
||||
} |
||||
|