--- /dev/null
+// -*- tab-width:4 -*-
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "bit.h"
+
+// 2-STD-B10v4_6.pdf p89 (101/399)
+int parseBIThead(unsigned char *data, BIThead *head) {
+ int boff = 0;
+
+ memset(head, 0, sizeof(BIThead));
+
+ head->table_id = getBit(data, &boff, 8);
+ head->section_syntax_indicator = getBit(data, &boff, 1);
+ head->reserved_future_use1 = getBit(data, &boff, 1);
+ head->reserved1 = getBit(data, &boff, 2);
+ head->section_length = getBit(data, &boff, 12);
+ head->original_network_id = getBit(data, &boff, 16);
+ head->reserved2 = getBit(data, &boff, 2);
+ head->version_number = getBit(data, &boff, 5);
+ head->current_next_indicator = getBit(data, &boff, 1);
+ head->section_number = getBit(data, &boff, 8);
+ head->last_section_number = getBit(data, &boff, 8);
+ head->reserved_future_use2 = getBit(data, &boff, 3);
+ head->broadcast_view_propriety = getBit(data, &boff, 1);
+ head->first_descriptors_length = getBit(data, &boff, 12);
+ return 10 + head->first_descriptors_length;
+}
+
+// 4-TR-B14v4_3-2p3.pdf p4-254 (276/543)
+int parseBITloop(unsigned char *data, BITloop *loop) {
+ int boff = 0;
+
+ memset(loop, 0, sizeof(BITloop));
+
+ loop->broadcaster_id = getBit(data, &boff, 8);
+ loop->reserved_future_use = getBit(data, &boff, 4);
+ loop->broadcaster_descriptors_length = getBit(data, &boff, 12);
+
+ return 3;
+}
+
+// SI伝送パラメータ記述子
+int parseBITdesc(unsigned char *data, BITdesc *desc) {
+ int boff = 0;
+
+ memset(desc, 0, sizeof(BITdesc));
+
+ desc->descriptor_tag = getBit(data, &boff, 8);
+ desc->descriptor_length = getBit(data, &boff, 8);
+ desc->parameter_version = getBit(data, &boff, 8);
+ desc->update_time = getBit(data, &boff,16);
+
+ return 5;
+}
+
+int parseBITtable(unsigned char *data, BITtable *table) {
+ int boff = 0;
+
+ memset(table, 0, sizeof(BITtable));
+
+ table->table_id = getBit(data, &boff, 8);
+ table->table_description_length = getBit(data, &boff, 8);
+ table->table_cycle = getBit(data, &boff, 16);
+
+ return table->table_description_length + 2;
+}
+
+void dumpBIT(unsigned char *ptr)
+{
+ BIThead bith;
+ BITloop bitl;
+ BITdesc bitd;
+ BITtable bitt;
+
+ int len = 0;
+ int loop_len = 0;
+ int desc_len = 0;
+ int table_len = 0;
+
+ /* BIT */
+ len = parseBIThead(ptr, &bith);
+ ptr += len;
+ loop_len = bith.section_length - (len - 3 + 4); // 3は共通ヘッダ長 4はCRC
+
+ while(loop_len > 0) {
+ len = parseBITloop(ptr, &bitl);
+ ptr += len;
+ loop_len -= len;
+
+ desc_len = bitl.broadcaster_descriptors_length;
+ loop_len -= desc_len;
+
+ while(desc_len > 0) {
+ len = parseBITdesc(ptr, &bitd);
+ ptr += len;
+ desc_len -= len;
+
+ table_len = bitd.descriptor_length - 3;
+ desc_len -= table_len;
+
+ if ( bitd.descriptor_tag != 0xD7 ) {
+ ptr += table_len;
+ continue;
+ }
+
+ while(table_len > 0) {
+ len = parseBITtable(ptr, &bitt);
+ ptr += len;
+ table_len -= len;
+
+ /*
+ 0x4E (M-EIT,L-EIT)
+ 0x50(各局伝送パラメータ運用部分の H-EIT[schedule basic])
+ 0x58 (各局伝送パラメータ運用部分の H-EIT[schedule extended])
+ 0xC3(SDTT)
+ 0xC8(CDT)
+ */
+
+ if (0) printf("BIT=(%d)%d:%d:%d:%d|0x%x:%d:%d=BCD(%d)\n",
+ bitl.broadcaster_id, bitd.descriptor_tag, bitd.descriptor_length,
+ bitd.parameter_version, bitd.update_time,
+ bitt.table_id, bitt.table_description_length,
+ bitt.table_cycle, BCD(bitt.table_cycle));
+ }
+ }
+ }
+
+ return;
+}
+
--- /dev/null
+#ifndef BIT_H
+#define BIT_H 1
+
+#include "util.h"
+#include "ts_ctl.h"
+
+typedef struct _BIThead {
+ unsigned char table_id;
+ int section_syntax_indicator;
+ int reserved_future_use1;
+ int reserved1;
+ int section_length;
+ int original_network_id;
+ int reserved2;
+ int version_number;
+ int current_next_indicator;
+ int section_number;
+ int last_section_number;
+ int reserved_future_use2;
+ int broadcast_view_propriety;
+ int first_descriptors_length;
+ // first_descriptors skipped
+} BIThead;
+
+typedef struct _BITloop {
+ int broadcaster_id;
+ int reserved_future_use;
+ int broadcaster_descriptors_length;
+} BITloop;
+
+typedef struct _BITdesc {
+ int descriptor_tag;
+ int descriptor_length;
+ int parameter_version;
+ int update_time;
+} BITdesc;
+
+typedef struct _BITtable {
+ int table_id;
+ int table_description_length;
+ int table_cycle;
+} BITtable;
+
+#ifdef __cplusplus
+extern "C"{
+#endif /* __cplusplus */
+
+ int parseBIThead(unsigned char *data, BIThead *head);
+ int parseBITdesc(unsigned char *data, BITdesc *desc);
+ void dumpBIT(unsigned char *ptr);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+
{ "ドキュメンタリー・教養", "documentary" },
{ "演劇", "stage" },
{ "趣味・実用", "hobby" },
- { "福祉", "etc" }, //福祉
- { "予備", "etc" }, //予備
- { "予備", "etc" }, //予備
- { "予備", "etc" }, //予備
- { "その他", "etc" } //その他
+ { "福祉", "welfare" },
+ { "予備", "etc" },
+ { "予備", "etc" },
+ { "予備", "etc" },
+ { "その他", "etc" }
};
//else if((bsecs->pid & 0xFF) == 0x23) {
// dumpSDTT(bsecs->buf, *station, *station_count);
//}
+ /* BIT */
+ else if((bsecs->pid & 0xFF) == 0x24) {
+ dumpBIT(bsecs->buf);
+ }
/* CDT */
else if((bsecs->pid & 0xFF) == 0x29) {
dumpCDT(bsecs->buf, *station, *station_count);
fprintf(stdout, "Usage : %s (/LOGO) {/BS|/CS|<id>} <tsFile> <outfile>\n", argv[0]);
fprintf(stdout, "\n");
fprintf(stdout, "/LOGO ロゴ取得モード。独立して指定し、番組表の出力を行ないません。\n");
+ fprintf(stdout, " 必要なTSの長さ 地上波は10分 BS/CSは20分です。\n");
fprintf(stdout, "id チャンネル識別子。地上波の物理チャンネルを与えます。\n");
fprintf(stdout, "/BS BSモード。一つのTSからBS全局のデータを読み込みます。\n");
fprintf(stdout, "/CS CSモード。一つのTSから複数局のデータを読み込みます。\n");
char *head = "CS";
GetSDT(infile, svttop, secs, SECCOUNT, &pStas, &staCount, head, is_logo);
}else if(strcmp(arg_onTV, "/TEST") == 0){
+ memset(secs, 0, sizeof(SECcache) * SECCOUNT);
+ secs[0].pid = 0x24; /* BIT */
+
char *head = "TEST";
GetSDT(infile, svttop, secs, SECCOUNT, &pStas, &staCount, head, 0);
//if (sta_count)
if ( logd.logo_transmission_type != 0x01 ) continue;
for (i=0; i<stationi; i++) {
- if ( pStation[i].svId == sdtb.service_id ) {
+ if ( pStation[i].svId == sdtb.service_id && pStation[i].logo_version < logd.logo_version ) {
pStation[i].logo_download_data_id = logd.download_data_id;
+ pStation[i].logo_version = logd.logo_version;
}
}
}
pStation = realloc(pStation, (stationi + 1) * sizeof(STATION));
+ memset(&pStation[stationi], 0, sizeof(STATION));
+
pStation[stationi].name = malloc( strlen(desc.service_name) + 1 );
pStation[stationi].ontv = malloc( strlen(sid) + 1 );
pStation[stationi].tsId = sdth.transport_stream_id;
pStation[stationi].onId = sdth.original_network_id;
pStation[stationi].svId = sdtb.service_id;
- memset(pStation[stationi].logo_array, 0, sizeof(pStation[stationi].logo_array));
strcpy(pStation[stationi].name, desc.service_name);
strcpy(pStation[stationi].ontv, sid);