Decoding KLV encoded MISB 601 packets

klvdecode plugin accepts meta/x-klv buffers containing MISB KLV encoded metadata and decodes them to JSON strings (application/x-json), preserving the nested data hierarchy. The resulting JSON tag / value structure follows MISB 601.X standard.

Input data

The input data (which can be, demultiplexed from a STANAG 4609 stream) contains a KLV encoded MISB 601.X metadata.
For example, the binary data buffer may look like this:

Encoded buffer
The above buffer contains the following parts:

  • The UAS Local Set 16-Byte UL “Key”-0x06 0x0E 0x2B 0x34 0x02 0x0B 0x01 0x01 0x0E 0x01 0x03 0x01 0x01 0x00 0x00 0x00
  • Packet length - 0x30
  • Packet data payload - Klv triplets: tag, length and value
  • Checksum (last klv triplet, last 4 bytes)

Output data

The result of the decoding is a JSON string.

{
  "2": "2008-10-24T00:13:29.913Z",
  "3": "MISSION01",
  "13": 60.176822967,
  "14": 128.426759042,
  "15": 14190.72,
  "16": 144.5713,
  "65": 13,
  "1": 53482
}

The "keys" in the above json correspond to MISB 0601.X specification.

Usage

klvdecode plugin configuration

gstreamer-klv-plugins use the MisbCore library. You MUST set the library path, so the plugins could find it.

Here are instructions for plugin configuration.

GStreamer 1.0 Pipelines examples

Basic plugin usage.
Get the file ~/packet.bin that contains binary data (like the one shown above), decode it, and output the resulting JSON to the stdout.

gst-launch-1.0 filesrc location=~/packet.bin ! klvdecode ! fakesink dump=TRUE

or do the same in loop:

gst-launch-1.0 multifilesrc location=~/packet.bin loop=true ! klvdecode ! fakesink dump=TRUE

A pipeline that plays STANAG 4609 file and decodes its KLV metadata:

gst-launch-1.0 filesrc location=~/Movies/stanagfile.ts ! tsdemux name=demux demux. ! \
queue ! decodebin ! videoconvert ! autovideosink  \ 
demux. ! 'meta/x-klv' ! klvdecode ! queue ! fakesink dump=TRUE

or

gst-launch-1.0 filesrc location=~/Movies/stanagfile.ts ! tsdemux name=demux demux. ! \
queue ! h264parse ! 'video/x-h264, stream-format=byte-stream' ! avdec_h264 ! videoconvert ! autovideosink \ 
demux. ! 'meta/x-klv' ! klvdecode ! queue ! fakesink dump=TRUE

Inspect klvdecode

~$ gst-inspect-1.0 klvdecode

Factory Details:
  Rank                     none (0)
  Long-name                KlvDecode
  Klass                    MISB KLV Decoder
  Description              MISB KLV Decoder Element
  Author                   info@impleotv.com

Plugin Details:
  Name                     klvdecode
  Description              MISB Klv decoder
  Filename                 /home/myuser/gstreamer-klv-plugins/libgstklvdecode.so
  Version                  1.0.0
  License                  Proprietary
  Source module            gst-misb-klv
  Binary package           GStreamer MISB KLV
  Origin URL               https://www.impleotv.com

GObject
 +----GInitiallyUnowned
       +----GstObject
             +----GstElement
                   +----GstKlvDecode

Pad Templates:
  SINK template: 'sink'
    Availability: Always
    Capabilities:
      meta/x-klv
         parsed: true

  SRC template: 'src'
    Availability: Always
    Capabilities:
      application/x-json

Element has no clocking capabilities.
Element has no URI handling capabilities.

Pads:
  SINK: 'sink'
    Pad Template: 'sink'
  SRC: 'src'
    Pad Template: 'src'

Element Properties:
  silent              : Produce verbose output ?
                        flags: readable, writable
                        Boolean. Default: true

Application development

Impleo's gstreamer-klv-plugins come with a sample code that shows the basics of GStreamer application programming for STANAG4609 processing.

klv-decode-dynamic is a C++ app sample that demonstrates video playback of a STANAG4609 file and MISB 601 metadata demultiplexing and decoding.
The sample builds the pipeline "on the fly", as information on video and metadata becomes available.

Code Walkthrough

Klvdecode plugin debug output

klvdecode plugin prints out to console some helpful debug information.
The debug output is controlled with the GST_DEBUG environment variable. For example:

export GST_DEBUG=2,klvdecode:6

When set to level 6 (LOG), the klvdecode will print out the info on the incoming meta/x-klv buffer size and the decoded application/x-json output.

Supported tags

Supported MISB 601 tags