From cfba1a11c54eba936a954d5bc5cf19d6dc14fc85 Mon Sep 17 00:00:00 2001 From: Anshul Date: Sat, 10 May 2014 06:06:13 +0530 Subject: [PATCH] fix teletext detection by parsing all desc tag Fix #20 --- src/constants.h | 14 ++++++++++++++ src/ts_tables.cpp | 16 ++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/constants.h b/src/constants.h index aebf36dd..39133b2d 100644 --- a/src/constants.h +++ b/src/constants.h @@ -126,6 +126,7 @@ enum ccx_mpeg_descriptor CCX_MPEG_DSC_DVB_SUBTITLE = 0x59, }; + enum { CCX_MESSAGES_QUIET = 0, @@ -218,7 +219,20 @@ enum cxx_code_type CCX_CODEC_DVB, CCX_CODEC_NONE, }; +/* + * This Macro check whether descriptor tag is valid for teletext + * codec or not. + * + * @param desc descriptor tag given for each stream + * + * @return if descriptor tag is valid then it return 1 otherwise 0 + * + */ +#define IS_VALID_TELETEXT_DESC(desc) ( ((desc) == CCX_MPEG_DSC_VBI_DATA_DESCRIPTOR )|| \ + ( (desc) == CCX_MPEG_DSC_VBI_TELETEXT_DESCRIPTOR ) || \ + ( (desc) == CCX_MPEG_DSC_TELETEXT_DESCRIPTOR ) ) + /* * This macro to be used when you want to find out whether you * should parse f_sel subtitle codec type or not diff --git a/src/ts_tables.cpp b/src/ts_tables.cpp index b58f8018..3e4259ae 100644 --- a/src/ts_tables.cpp +++ b/src/ts_tables.cpp @@ -233,15 +233,18 @@ int parse_PMT (int pos) } } - if (IS_FEASIBLE(ccx_options.codec,ccx_options.nocodec,CCX_CODEC_TELETEXT) && (ccx_options.teletext_mode==CCX_TXT_AUTO_NOT_YET_FOUND || (ccx_options.teletext_mode==CCX_TXT_IN_USE && !ccx_options.ts_cappid)) // Want teletext but don't know the PID yet + && ES_info_length && ccx_stream_type == CCX_STREAM_TYPE_PRIVATE_MPEG2) // MPEG-2 Packetized Elementary Stream packets containing private data { - // descriptor_tag: 0x45 = VBI_data_descriptor, 0x46 = VBI_teletext_descriptor, 0x56 = teletext_descriptor - unsigned descriptor_tag = payload_start[i + 5]; - if ((descriptor_tag == 0x45) || (descriptor_tag == 0x46) || (descriptor_tag == 0x56)) - { + unsigned char *es_info = payload_start + i + 5; + for (desc_len = 0;(payload_start + i + 5 + ES_info_length) - es_info ;es_info += desc_len) + { + enum ccx_mpeg_descriptor descriptor_tag = (enum ccx_mpeg_descriptor)(*es_info++); + desc_len = (*es_info++); + if(!IS_VALID_TELETEXT_DESC(descriptor_tag)) + continue; telxcc_init(); if (!ccx_options.ts_forced_cappid) { @@ -251,7 +254,8 @@ int parse_PMT (int pos) ccx_options.teletext_mode =CCX_TXT_IN_USE; mprint ("VBI/teletext stream ID %u (0x%x) for SID %u (0x%x)\n", elementary_PID, elementary_PID, program_number, program_number); - } + } + } if (ccx_options.teletext_mode==CCX_TXT_FORBIDDEN && ccx_stream_type == CCX_STREAM_TYPE_PRIVATE_MPEG2) // MPEG-2 Packetized Elementary Stream packets containing private data