CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
anc_payloads.h File Reference

Declarations of utilities for creating and parsing payloads formatted according to the CDI Ancillary Data Format Specification (https://cdi.elemental.com/specs/baseline-ancillary-data). More...

#include "cdi_avm_payloads_api.h"
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  AncillaryDataPacket
 The ANC data packet. See https://datatracker.ietf.org/doc/html/rfc8331#section-2.1 for details. More...
 
struct  AncillaryDataPayloadErrors
 Counters for keeping track of errors observed when parsing ANC payloads. More...
 
struct  AncillaryDataPayloadHeader
 The ANC payload header. More...
 

Functions

static bool Parity8 (uint8_t value)
 
static uint16_t WithParityBits (uint8_t value)
 
static uint8_t CheckParityBits (uint16_t raw_word, int *parity_errors_ptr)
 
void ParseAncillaryDataPayloadHeader (const uint32_t *payload_net_data_ptr, uint16_t *packet_count_ptr, CdiFieldKind *field_kind_ptr)
 
void ParseAncillaryDataPacketHeader (const uint32_t *packet_net_data_ptr, struct AncillaryDataPacket *packet_ptr, struct AncillaryDataPayloadErrors *payload_errors)
 
int ParseAncillaryDataPacket (const uint32_t *packet_net_data_ptr, struct AncillaryDataPacket *packet_ptr, struct AncillaryDataPayloadErrors *payload_errors_ptr)
 
int GetAncillaryDataPacketSize (int data_count)
 
void WriteAncillaryDataPayloadHeader (uint32_t *payload_net_data_ptr, uint16_t packet_count, CdiFieldKind field_kind)
 
void WriteAncillaryDataPacketHeader (uint32_t *packet_net_data_ptr, const struct AncillaryDataPacket *packet_ptr, uint32_t *checksum_ptr)
 
int WriteAncillaryDataPacket (uint32_t *packet_net_data_ptr, const struct AncillaryDataPacket *packet_ptr)
 

Detailed Description

Declarations of utilities for creating and parsing payloads formatted according to the CDI Ancillary Data Format Specification (https://cdi.elemental.com/specs/baseline-ancillary-data).

Ancillary data payloads contain one or more ancillarry data packets (ANC packets). Each ANC packet compactly contains user data in 10-bit words. An ANC packet may contain up to 255 user data words. The meaning of these words is determined by the DID and SDID fields in an ANC packet header. See https://smpte-ra.org/smpte-ancillary-data-smpte-st-291 for current assignments.

Function Documentation

◆ CheckParityBits()

static uint8_t CheckParityBits ( uint16_t raw_word,
int * parity_errors_ptr )
inlinestatic

Check the parity bits of an 8-bit value in the 10-bit input data.

Parameters
raw_word10-bit raw word
parity_errors_ptrPointer to payload error counts.
Returns
8-bit value (bits b7-b0 of raw_word).

◆ GetAncillaryDataPacketSize()

int GetAncillaryDataPacketSize ( int data_count)

Calculate number of 32-bit words needed to write an ancillary data packet.

Parameters
data_countThe number of user data words in the ANC packet.
Returns
The number of 32-bit words required to store an ANC packet with data_count user data words.

◆ Parity8()

static bool Parity8 ( uint8_t value)
inlinestatic

Return parity bit of a byte.

Parameters
valueThe value for which to calculate the parity bit.
Returns
The parity bit of value.

◆ ParseAncillaryDataPacket()

int ParseAncillaryDataPacket ( const uint32_t * packet_net_data_ptr,
struct AncillaryDataPacket * packet_ptr,
struct AncillaryDataPayloadErrors * payload_errors_ptr )

Parse and ancillary data packet.

Parameters
packet_net_data_ptrPointer to a received ANC packet contained in an ANC payload. In network byte order. Input.
packet_ptrPointer to an ANC packet. Output.
payload_errors_ptrPointer to error counters.
Returns
Offset from packet_net_data_ptr to the beginning of the next ANC packet.

◆ ParseAncillaryDataPacketHeader()

void ParseAncillaryDataPacketHeader ( const uint32_t * packet_net_data_ptr,
struct AncillaryDataPacket * packet_ptr,
struct AncillaryDataPayloadErrors * payload_errors )

Parse the header of an ancillary data packet.

Parameters
packet_net_data_ptrPointer to a received ANC packet contained in an ANC payload. In network byte order. Input.
packet_ptrPointer to an ANC packet structure. Output.
payload_errorsPointer to error counters.
Returns
Part of the packet's first user data word or zero when the packet is empty.

◆ ParseAncillaryDataPayloadHeader()

void ParseAncillaryDataPayloadHeader ( const uint32_t * payload_net_data_ptr,
uint16_t * packet_count_ptr,
CdiFieldKind * field_kind_ptr )

Parse the header of a received ancillary data payload.

Parameters
payload_net_data_ptrPointer to received ancillary data. In network byte order. Input.
packet_count_ptrPointer to number of ancillary data packets in payload. Output.
field_kind_ptrPointer to field kind associated with payload. Output.

◆ WithParityBits()

static uint16_t WithParityBits ( uint8_t value)
inlinestatic

Return 8-bit value with two parity bits.

Parameters
valueThe value to augment with parity bits.
Returns
10-bit word: 8-bit value and two parity bits.

◆ WriteAncillaryDataPacket()

int WriteAncillaryDataPacket ( uint32_t * packet_net_data_ptr,
const struct AncillaryDataPacket * packet_ptr )

Write an ancillary data packet for transmission in network byte order.

Parameters
packet_net_data_ptrPointer into transmit buffer to start of an ANC packet. In network byte order. Output.
packet_ptrPointer to ANC packet. Input.
Returns
Offset from packet_net_data_ptr to the start of the next ancillary data packet to write.

◆ WriteAncillaryDataPacketHeader()

void WriteAncillaryDataPacketHeader ( uint32_t * packet_net_data_ptr,
const struct AncillaryDataPacket * packet_ptr,
uint32_t * checksum_ptr )

Write an ancillary data packet header for transmission in network byte order.

Parameters
packet_net_data_ptrPointer into transmit buffer to start of an ANC packet. In network byte order. Output.
packet_ptrPointer to an ANC packet. Input.
checksum_ptrPointer to running checksum. Output.

◆ WriteAncillaryDataPayloadHeader()

void WriteAncillaryDataPayloadHeader ( uint32_t * payload_net_data_ptr,
uint16_t packet_count,
CdiFieldKind field_kind )

Write an ancillary data payload header for transmission in network byte order.

Parameters
payload_net_data_ptrPointer to transmit buffer for an ANC payload. In network byte order. Output.
packet_countNumber of ancillary data packets in payload. Input.
field_kindField kind associated with payload. Input.