]> git.sesse.net Git - decode_sdt/commitdiff
Deduplication was too aggressive; fix to make it on channel instead. master
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 20 Sep 2014 15:34:51 +0000 (17:34 +0200)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 20 Sep 2014 15:34:51 +0000 (17:34 +0200)
decode_sdt.cc

index 916505a3e49fc7aab91f06f3274b709dd953df2f..3709ad5fad995010db2a95bfcb94ef3b02aab06c 100644 (file)
 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<std::pair<uint8_t, bool> > 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<channel_id> 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);