]> git.sesse.net Git - nageru/blobdiff - metacube2.cpp
Support audio-only FFmpeg inputs. Somewhat wonky, though.
[nageru] / metacube2.cpp
index 1bf9efb8a1cb7bfa941c1f386ab93be5a6b06f27..6b68132237af229745ea032d3e0411e2b5eced04 100644 (file)
@@ -7,6 +7,9 @@
 
 #include "metacube2.h"
 
+#include <byteswap.h>
+#include <netinet/in.h>
+
 /*
  * https://www.ece.cmu.edu/~koopman/pubs/KoopmanCRCWebinar9May2012.pdf
  * recommends this for messages as short as ours (see table at page 34).
@@ -44,5 +47,14 @@ uint16_t metacube2_compute_crc(const struct metacube2_block_header *hdr)
                }
        }
 
+       /*
+        * Invert the checksum for metadata packets, so that clients that
+        * don't understand metadata will ignore it as broken. There will
+        * probably be logging, but apart from that, it's harmless.
+        */
+       if (ntohs(hdr->flags) & METACUBE_FLAGS_METADATA) {
+               crc ^= 0xffff;
+       }
+
        return crc;
 }