KLV.java is a public domain class for working with Key-Length-Value (KLV) byte-packing and unpacking. Supports 1-, 2-, 4-byte, and BER-encoded
length fields and 1-, 2-, 4-, and 16-byte key fields. Provides
auto-mapping of KLV elements within a payload to the
KLV has been used for years as a repeatable, no-guesswork technique for byte-packing data, that is, sending data in a binary format with two bytes for this integer, four bytes for that float, and so forth. KLV is used in broadcast television and is defined in SMPTE 336M-2001, but it also greatly eases the burden of non-TV-related applications for an easy, interchangeable binary format (always Big Endian). It is also enjoying success as a standard way to embed telemetry on Unmanned Aerial Vehicles (UAV) and other remote vehicles.
This code is released into the Public Domain. Enjoy.
- v0.3 - Made significant changes to how the data is stored within. If you create a KLV object from an existing byte array, the array is parsed and copied, and the KLV object is no longer dependent on that array.
- v0.2 - Made Key Length and Length Field encodings enums instead of ints. Use generics internally.
- v0.1 - Initial release.
A Note About Public Domain
I have released this software into the Public Domain. That means you can do whatever you want with it. Really. You don't have to match it up with any other open source license &em; just use it. You can rename the files, move the Java packages, whatever you want. If your lawyers say you have to have a license, contact me, and I'll make a special release to you under whatever reasonable license you desire: MIT, BSD, GPL, whatever.
blog comments powered by Disqus