From: Steinar H. Gunderson Date: Sat, 20 Sep 2014 15:34:51 +0000 (+0200) Subject: Deduplication was too aggressive; fix to make it on channel instead. X-Git-Url: https://git.sesse.net/?p=decode_sdt;a=commitdiff_plain;h=41a7f1cb96284512c2faf4d977bfe7c80b8643ae Deduplication was too aggressive; fix to make it on channel instead. --- diff --git a/decode_sdt.cc b/decode_sdt.cc index 916505a..3709ad5 100644 --- a/decode_sdt.cc +++ b/decode_sdt.cc @@ -49,6 +49,20 @@ static int packet_num = 0; static int last_used_packet_num = 0; +struct channel_id { + int i_network_id; + int i_service_id; + int i_extension; + + bool operator< (const channel_id &other) const { + if (i_network_id != other.i_network_id) + return (i_network_id < other.i_network_id); + if (i_service_id != other.i_service_id) + return (i_service_id < other.i_service_id); + return (i_extension < other.i_extension); + } +}; + /** @brief The different encodings that can be used Cf EN 300 468 Annex A (I used v1.9.1) @@ -183,14 +197,6 @@ has_stuff: static void ParseSDT(void *p_zero, dvbpsi_sdt_t * p_sdt) { - // Do our own deduplication, since libdvbpsi only deduplicates against - // the last version seen, not the entire history. - static std::set > seen_sdt_tables; - if (!seen_sdt_tables.insert(std::make_pair(p_sdt->i_version, p_sdt->b_current_next)).second) { - return; - } - - last_used_packet_num = packet_num; dvbpsi_sdt_service_t *p_service = p_sdt->p_first_service; for (dvbpsi_sdt_service_t * p_service = p_sdt->p_first_service; p_service != NULL; @@ -229,10 +235,17 @@ static void ParseSDT(void *p_zero, dvbpsi_sdt_t * p_sdt) // Show television types only. if (service_type == 0x01 || service_type == 0x11 || service_type == 0x16 || service_type == 0x19 || service_type == 0x1c) { - printf("sid %d/%d: ts_id=%d, provider_name=\"%s\", channel_name=\"%s\"\n", - p_sdt->i_network_id, p_service->i_service_id, - p_sdt->i_extension, provider_name, - channel_name); + // Do our own deduplication, since libdvbpsi only deduplicates against + // the last version seen, not the entire history. + static std::set seen_channels; + channel_id id = { p_sdt->i_network_id, p_service->i_service_id, p_sdt->i_extension }; + if (seen_channels.insert(id).second) { + last_used_packet_num = packet_num; + printf("sid %d/%d: ts_id=%d, provider_name=\"%s\", channel_name=\"%s\"\n", + p_sdt->i_network_id, p_service->i_service_id, + p_sdt->i_extension, provider_name, + channel_name); + } } } dvbpsi_sdt_delete(p_sdt);