return desc->descriptor_length + 2;
}
+int parseComponentDesc(unsigned char *data, ComponentDesc *desc) {
+ int boff = 0;
+
+ memset(desc, 0, sizeof(ComponentDesc));
+
+ desc->descriptor_tag = getBit(data, &boff, 8);
+ if((desc->descriptor_tag & 0xFF) != 0x50) {
+ return -1;
+ }
+ desc->descriptor_length = getBit(data, &boff, 8);
+ desc->reserved_future_use = getBit(data, &boff, 4);
+ desc->stream_content = getBit(data, &boff, 4);
+ desc->component_type = getBit(data, &boff, 8);
+ desc->component_tag = getBit(data, &boff, 8);
+ memcpy(desc->ISO_639_language_code, data + boff / 8, 3);
+ boff += 24;
+ getStr(desc->text_char, data, &boff, desc->descriptor_length - 6);
+ return desc->descriptor_length + 2;
+}
+
+int parseAudioComponentDesc(unsigned char *data, AudioComponentDesc *desc) {
+ int boff = 0;
+
+ memset(desc, 0, sizeof(AudioComponentDesc));
+
+ desc->descriptor_tag = getBit(data, &boff, 8);
+ if((desc->descriptor_tag & 0xFF) != 0xC4) {
+ return -1;
+ }
+ desc->descriptor_length = getBit(data, &boff, 8);
+ desc->reserved_future_use_1 = getBit(data, &boff, 4);
+ desc->stream_content = getBit(data, &boff, 4);
+ desc->component_type = getBit(data, &boff, 8);
+ desc->component_tag = getBit(data, &boff, 8);
+ desc->stream_type = getBit(data, &boff, 8);
+ desc->simulcast_group_tag = getBit(data, &boff, 8);
+ desc->ES_multi_lingual_flag = getBit(data, &boff, 1);
+ desc->main_component_flag = getBit(data, &boff, 1);
+ desc->quality_indicator = getBit(data, &boff, 2);
+ desc->sampling_rate = getBit(data, &boff, 3);
+ desc->reserved_future_use_2 = getBit(data, &boff, 1);
+ memcpy(desc->ISO_639_language_code_1, data + boff / 8, 3);
+ boff += 24;
+ memcpy(desc->ISO_639_language_code_2, data + boff / 8, 3);
+ boff += 24;
+ getStr(desc->text_char, data, &boff, desc->descriptor_length - desc->ES_multi_lingual_flag ? 12 : 9);
+ return desc->descriptor_length + 2;
+}
+
+char* parseComponentDescType(int componentDescType) {
+ static char str[MAXSECLEN];
+ memset(str, '\0', sizeof(str));
+ char *strpart;
+
+ switch (componentDescType & 0xF0) {
+ case 0x00 :
+ strpart = "映像480i ";
+ break;
+ case 0x90 :
+ strpart = "映像2160p ";
+ break;
+ case 0xA0 :
+ strpart = "映像480p ";
+ break;
+ case 0xB0 :
+ strpart = "映像1080i ";
+ break;
+ case 0xC0 :
+ strpart = "映像720p ";
+ break;
+ case 0xD0 :
+ strpart = "映像240p ";
+ break;
+ case 0xE0 :
+ strpart = "映像1080p ";
+ break;
+ default :
+ strpart = "映像不明 ";
+ break;
+ }
+ strcat(str, strpart);
+
+ switch (componentDescType & 0x0F) {
+ case 0x01 :
+ strpart = "アスペクト比4:3";
+ break;
+ case 0x02 :
+ strpart = "アスペクト比16:9 パンベクトルあり";
+ break;
+ case 0x03 :
+ strpart = "アスペクト比16:9 パンベクトルなし";
+ break;
+ case 0x04 :
+ strpart = "アスペクト比 > 16:9";
+ break;
+ default :
+ strpart = "アスペクト比不明";
+ break;
+ }
+ strcat(str, strpart);
+
+ return str;
+}
+
+char* parseAudioComponentDescType(int AudiocomponentDescType) {
+ static char str[MAXSECLEN];
+ memset(str, '\0', sizeof(str));
+ char *strpart;
+
+ switch (AudiocomponentDescType) {
+ case 0x01 :
+ strpart = "音声1/0モード(シングルモノ)";
+ break;
+ case 0x02 :
+ strpart = "音声1/0+1/0モード(デュアルモノ)";
+ break;
+ case 0x03 :
+ strpart = "音声2/0モード(ステレオ)";
+ break;
+ case 0x04 :
+ strpart = "音声2/1モード";
+ break;
+ case 0x05 :
+ strpart = "音声3/0モード";
+ break;
+ case 0x06 :
+ strpart = "音声2/2モード";
+ break;
+ case 0x07 :
+ strpart = "音声3/1モード";
+ break;
+ case 0x08 :
+ strpart = "音声3/2モード";
+ break;
+ case 0x09 :
+ strpart = "音声3/2+LFEモード(3/2.1モード)";
+ break;
+ case 0x0A :
+ strpart = "音声3/3.1モード";
+ break;
+ case 0x0B :
+ strpart = "音声2/0/0-2/0/2-0.1モード";
+ break;
+ case 0x0C :
+ strpart = "音声5/2.1モード";
+ break;
+ case 0x0D :
+ strpart = "音声3/2/2.1モード";
+ break;
+ case 0x0E :
+ strpart = "音声2/0/0-3/0/2-0.1モード";
+ break;
+ case 0x0F :
+ strpart = "音声0/2/0-3/0/2-0.1モード";
+ break;
+ case 0x10 :
+ strpart = "音声2/0/0-3/2/3-0.2モード";
+ break;
+ case 0x11 :
+ strpart = "音声3/3/3-5/2/3-3/0/0.2モード";
+ break;
+ case 0x40 :
+ strpart = "音声視覚障害者用解説";
+ break;
+ case 0x41 :
+ strpart = "音声聴覚障害者用";
+ break;
+ default :
+ strpart = "音声不明";
+ break;
+ }
+ strcat(str, strpart);
+
+ return str;
+}
+
int parseEEVTDhead(unsigned char *data, EEVTDhead *desc) {
int boff = 0;
}
#endif
} else {
- ContentDesc contentDesc;
- len = parseContentDesc(ptr, &contentDesc);
- if (len > 0) {
- //int header_printed = 0;
- for (int i = 0; i < contentDesc.descriptor_length - 1; i+=2) {
- /*
- if (0xff == (unsigned char)contentDesc.content[i])
- continue;
- */
-#if 0
- if (!header_printed) {
- fprintf(out, "Content,%d,%d\n",
- eith.service_id,
- eitb.event_id);
- header_printed = 1;
- }
-#endif
+ ContentDesc contentDesc;
+ SeriesDesc seriesDesc;
+ ComponentDesc componentDesc;
+ AudioComponentDesc audioComponentDesc;
- //fprintf(out, ",%02x%02x", (unsigned char)contentDesc.content[i], (unsigned char)contentDesc.content[i+1]);
+ if((eith.original_network_id == original_network_id) && (eith.transport_stream_id == transport_stream_id)){
+ cur = searcheit(eittop, eith.service_id, eitb.event_id);
+ }
+ else {
+ cur = NULL;
+ }
- }
- if((eith.original_network_id == original_network_id) && (eith.transport_stream_id == transport_stream_id)){
- cur = searcheit(eittop, eith.service_id, eitb.event_id);
+ switch (*ptr) {
+ case 0x54 :
+ len = parseContentDesc(ptr, &contentDesc);
+ if (len > 0) {
if(cur != NULL){
cur->content_type = (unsigned char)contentDesc.content_nibble_level_1;
-#if 0
- fprintf(stdout, "%s:", cur->title);
- fprintf(stdout, ",%02x%02x", (unsigned char)contentDesc.content[0], (unsigned char)contentDesc.content[1]);
- fprintf(stdout, ",%02x%02x\n", (unsigned char)contentDesc.content[2], (unsigned char)contentDesc.content[3]);
-#endif
- }
-
-#if 0
- if (header_printed) {
- fprintf(out, "\n");
}
-#endif
}
- } else {
- SeriesDesc seriesDesc;
+ break;
+ case 0xD5 :
len = parseSeriesDesc(ptr, &seriesDesc);
if (len > 0) {
-#if 0
- printf("Series,%d,%d,series=%d,repeat=%01x,pattern=%d,expire_valid=%d,expire=%04x,epinum=%d,lastepinum=%d,%s\n",
- eith.service_id,
- eitb.event_id,
- seriesDesc.series_id,
- seriesDesc.repeat_label,
- seriesDesc.program_pattern,
- seriesDesc.expire_date_valid_flag,
- seriesDesc.expire_date,
- seriesDesc.episode_number,
- seriesDesc.last_episode_number,
- seriesDesc.series_name_char);
-#endif
- } else {
- len = parseOTHERdesc(ptr);
+ #if 0
+ printf("Series,%d,%d,series=%d,repeat=%01x,pattern=%d,expire_valid=%d,expire=%04x,epinum=%d,lastepinum=%d,%s\n",
+ eith.service_id,
+ eitb.event_id,
+ seriesDesc.series_id,
+ seriesDesc.repeat_label,
+ seriesDesc.program_pattern,
+ seriesDesc.expire_date_valid_flag,
+ seriesDesc.expire_date,
+ seriesDesc.episode_number,
+ seriesDesc.last_episode_number,
+ seriesDesc.series_name_char);
+ #endif
+ }
+ break;
+ case 0x50 :
+ len = parseComponentDesc(ptr, &componentDesc);
+ if (len > 0) {
+ if(cur != NULL){
+ cur->video_type = componentDesc.component_type;
+ }
+ #if 0
+ printf("Component,%d %d %s\n",
+ componentDesc.stream_content,
+ componentDesc.component_type,
+ parseComponentDescType(componentDesc.component_type));
+ #endif
+ }
+ break;
+ case 0xC4 :
+ len = parseAudioComponentDesc(ptr, &audioComponentDesc);
+ if (len > 0) {
+ if(cur != NULL){
+ cur->audio_type = audioComponentDesc.component_type;
+ cur->multi_type = audioComponentDesc.ES_multi_lingual_flag;
+ }
+ #if 0
+ printf("AudioComponent,%d %d %d %s\n",
+ audioComponentDesc.component_type,
+ audioComponentDesc.ES_multi_lingual_flag,
+ audioComponentDesc.sampling_rate,
+ parseAudioComponentDescType(audioComponentDesc.component_type)
+ );
+ #endif
}
+ break;
+ default :
+ len = parseOTHERdesc(ptr);
}
}
}