libklvanc
Classes | Macros | Functions
vanc.h File Reference

Parse VANC lines, interpret data, call user callbacks with populated structures.
Callers allocate a usage context, assign callbacks to this context and then feed
VANC data into the library. VANC messages that are understood are parse, converted
into structs and if the user has registered a callback for that specific message type
then the structure is passed via the callback.

Callbacks should not attempt to modify or release the callback structs, releasing of
memory allocats is automatically taken care of by this library. More...

#include <stdint.h>
#include <stdarg.h>
#include <sys/errno.h>
#include <libklvanc/klrestricted_code_path.h>
#include <libklvanc/vanc-afd.h>
#include <libklvanc/vanc-eia_708b.h>
#include <libklvanc/vanc-eia_608.h>
#include <libklvanc/vanc-scte_104.h>
#include <libklvanc/vanc-smpte_12_2.h>
#include <libklvanc/did.h>
#include <libklvanc/pixels.h>
#include <libklvanc/vanc-checksum.h>
#include <libklvanc/smpte2038.h>
#include <libklvanc/cache.h>
#include <libklvanc/vanc-kl_u64le_counter.h>
#include <libklvanc/vanc-sdp.h>

Go to the source code of this file.

Classes

struct  klvanc_callbacks_s
 TODO - Brief description goes here. More...
 
struct  klvanc_context_s
 Application specific context, the library allocates and stores user specific instance information. More...
 

Macros

#define LIBKLVANC_SCTE104_MAX_FRAGMENTS   (10)
 
#define LIBKLVANC_LOGLEVEL_ERR   0
 
#define LIBKLVANC_LOGLEVEL_WARN   1
 
#define LIBKLVANC_LOGLEVEL_INFO   2
 
#define LIBKLVANC_LOGLEVEL_DEBUG   3
 

Functions

int klvanc_context_create (struct klvanc_context_s **ctx)
 Create or destroy some basic application/library context.
The context is considered private and is likely to change. More...
 
int klvanc_context_destroy (struct klvanc_context_s *ctx)
 Deallocate and destroy a context. See klvanc_context_create() More...
 
int klvanc_context_dump (struct klvanc_context_s *ctx)
 Generate user visible context details to the console. More...
 
int klvanc_packet_parse (struct klvanc_context_s *ctx, unsigned int lineNr, const unsigned short *words, unsigned int wordCount)
 Parse a line of payload, trigger callbacks as necessary. lineNr is passed around and only
used for reporting purposes, so we can figure out which line this came from in different
callbacks and various parts of the reporting stack. More...
 
void klvanc_dump_words_console (struct klvanc_context_s *ctx, uint16_t *vanc, int maxlen, unsigned int linenr, int onlyvalid)
 TODO - Brief description goes here. More...
 
int klvanc_sdi_create_payload (uint8_t sdid, uint8_t did, const uint8_t *src, uint16_t srcByteCount, uint16_t **dst, uint16_t *dstWordCount, uint32_t bitDepth)
 Take an array of payload, create a fully formed VANC message. bitDepth of 10 is the only valid input value. did: 0x41, sdid: 0x07 = SCTE104 generateParity = 1/0. More...
 
const char * klvanc_lookupDescriptionByType (enum klvanc_packet_type_e type)
 TODO - Brief description goes here. More...
 
const char * klvanc_lookupSpecificationByType (enum klvanc_packet_type_e type)
 TODO - Brief description goes here. More...
 
int klvanc_packet_copy (struct klvanc_packet_header_s **dst, struct klvanc_packet_header_s *src)
 Create a copy of a packet header. More...
 
int klvanc_packet_save (const char *dir, const struct klvanc_packet_header_s *pkt, int lineNr, int did)
 Write the packet to disk, in a debug friendly format that can be used by other offline tools. The output filename is library generated while the directory prefix may be user specified. The output filename is: uniqueid–klvanc-packet–line-%04d–did-%02x–sdid-%02x–name-s.bin %08d–klvanc-packet–line-%04d–did-%02x–sdid-%02x–name-s.bin The contents of the file are the original caller supplied 16bit raw payload words which includes original parity, checksum, payload. More...
 
void klvanc_packet_free (struct klvanc_packet_header_s *src)
 TODO - Brief description goes here. More...
 
int klvanc_packet_payload_append (struct klvanc_packet_header_s *dst, struct klvanc_packet_header_s *src, int srcOffset)
 Append the payload words from srd to dst. Start copying from srcOffset position. More...
 

Detailed Description

Parse VANC lines, interpret data, call user callbacks with populated structures.
Callers allocate a usage context, assign callbacks to this context and then feed
VANC data into the library. VANC messages that are understood are parse, converted
into structs and if the user has registered a callback for that specific message type
then the structure is passed via the callback.

Callbacks should not attempt to modify or release the callback structs, releasing of
memory allocats is automatically taken care of by this library.

Author
Steven Toth stoth.nosp@m.@ker.nosp@m.nella.nosp@m.bs.c.nosp@m.om

Function Documentation

int klvanc_context_create ( struct klvanc_context_s **  ctx)

Create or destroy some basic application/library context.
The context is considered private and is likely to change.

Parameters
[out]structklvanc_context_s **ctx - Context.
Returns
0 - Success
< 0 - Error
int klvanc_context_destroy ( struct klvanc_context_s ctx)

Deallocate and destroy a context. See klvanc_context_create()

Parameters
[in]structklvanc_context_s *ctx - Context.
Returns
0 - Success
< 0 - Error
int klvanc_context_dump ( struct klvanc_context_s ctx)

Generate user visible context details to the console.

Parameters
[in]structklvanc_context_s *ctx - Context.
Returns
0 - Success
< 0 - Error
void klvanc_dump_words_console ( struct klvanc_context_s ctx,
uint16_t *  vanc,
int  maxlen,
unsigned int  linenr,
int  onlyvalid 
)

TODO - Brief description goes here.

Parameters
[in]uint16_t*array - Array of SDI words (10bit) that the caller wants parsed.
[in]intlen - Number of words in array.
[in]unsignedint linenr - SDI line number the array data came from. Used for information / tracking purposes only.
[in]intonlyvalid - Brief description goes here.
const char* klvanc_lookupDescriptionByType ( enum klvanc_packet_type_e  type)

TODO - Brief description goes here.

Parameters
[in]enumpacket_type_e type
Returns
TODO.
const char* klvanc_lookupSpecificationByType ( enum klvanc_packet_type_e  type)

TODO - Brief description goes here.

Parameters
[in]enumpacket_type_e type
Returns
TODO.
int klvanc_packet_copy ( struct klvanc_packet_header_s **  dst,
struct klvanc_packet_header_s src 
)

Create a copy of a packet header.

Parameters
[in]structpacket_header_s **dst
[in]structpacket_header_s *src
Returns
0 - Success
< 0 - Error
void klvanc_packet_free ( struct klvanc_packet_header_s src)

TODO - Brief description goes here.

Parameters
[in]structpacket_header_s *src
int klvanc_packet_parse ( struct klvanc_context_s ctx,
unsigned int  lineNr,
const unsigned short *  words,
unsigned int  wordCount 
)

Parse a line of payload, trigger callbacks as necessary. lineNr is passed around and only
used for reporting purposes, so we can figure out which line this came from in different
callbacks and various parts of the reporting stack.

Parameters
[in]structklvanc_context_s *ctx - Context.
[in]unsignedint lineNr - SDI line number the array data came from. Used for information / tracking purposes only.
[in]unsignedshort *words - Array of SDI words (10bit) that the caller wants parsed.
[in]unsignedint wordCount - Number of words in array.
Returns
The number of VANC frames found and parsing was attempted.
< 0 - Error
int klvanc_packet_payload_append ( struct klvanc_packet_header_s dst,
struct klvanc_packet_header_s src,
int  srcOffset 
)

Append the payload words from srd to dst. Start copying from srcOffset position.

Returns
0 on success, else < 0.
int klvanc_packet_save ( const char *  dir,
const struct klvanc_packet_header_s pkt,
int  lineNr,
int  did 
)

Write the packet to disk, in a debug friendly format that can be used by other offline tools. The output filename is library generated while the directory prefix may be user specified. The output filename is: uniqueid–klvanc-packet–line-%04d–did-%02x–sdid-%02x–name-s.bin %08d–klvanc-packet–line-%04d–did-%02x–sdid-%02x–name-s.bin The contents of the file are the original caller supplied 16bit raw payload words which includes original parity, checksum, payload.

Parameters
[in]constchar *dir
[in]conststruct packet_header_s *pkt
[in]intlineNr - Only save pkt if the line number matches this filter, caller should pass -1 if all packets are to be saved.
[in]intdid - Only save pkt if the did number in the packet matches this filter, caller should pass -1 if all packets are to be saved.
Returns
0 - Success
< 0 - Error
int klvanc_sdi_create_payload ( uint8_t  sdid,
uint8_t  did,
const uint8_t *  src,
uint16_t  srcByteCount,
uint16_t **  dst,
uint16_t *  dstWordCount,
uint32_t  bitDepth 
)

Take an array of payload, create a fully formed VANC message. bitDepth of 10 is the only valid input value. did: 0x41, sdid: 0x07 = SCTE104 generateParity = 1/0.

Parameters
[in]uint8_tsdid, uint8_t did - Brief description goes here.
[in]constuint8_t *src - Brief description goes here.
[in]uint16_tsrcByteCount - Brief description goes here.
[in]uint16_t**dst - Brief description goes here.
[in]uint16_t*dstWordCount - Brief description goes here.
[in]uint32_tbitDepth - Brief description goes here.
Returns
0 - Success
< 0 - Error