How to modify/add a STANAG Klv metadata on the fly.

Let’s assume you have to modify some Klv fields in a live STANAG 4609 stream. Or add/delete an existing metadata.

In this article, we’ll show how to put together a simple app that extracts and decodes existing MISB Klv metadata, modifies it and re-inserts back into stream with the same (in case of SYNC Klv) timestamp. We’ll use KlvInjector SDK.

First things first, let’s create a VS project, add the references and make sure all the required dependencies are copied to the target directory (we can do it using the ‘post-build event’)
Next, we create an instance of the Klv Injector, initialize it and add events:
 
There are some additional parameters we can set up.
By default, KlvInjector will pass through all existing KLV data from the source to the output. This is not what we want. We need to instruct KvInjector to remove existing KlvPid from the multiplex, receive the data, modify it and re-insert.
Let’s setup the  NotifyPidDetection event, it should trigger shortly after the playback is started. That’s the place where we can receive the information on the existing elementary streams. Here we can configure what should be
included into our output stream.
 
The straightforward method – we simply get the decoded data, replace the required value and encode the whole packet back. A better option, which would eliminate a “generation loss” while decoding/encoding compressed data is to only reencode the specific klv item value and re-calculate the packet checksum.

That’s it! You can now start KlvInjector,  open your stream with any STANAG player and see the results.

No Comments

Post a Comment