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

The declarations in this header file correspond to the definitions in cdi_utility_api.c and are meant to provide access to helpful SDK data structures and functions that are not part of the core API functionality. More...

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

Go to the source code of this file.

Data Structures

struct  CdiEnumStringKey
 Type used for holding arrays of enums and related string representations. More...
 

Macros

#define CDI_INTERFACE
 Specify C linkage when compiling as C++ and define API interface export for Windows.
 
#define CDI_INVALID_ENUM_VALUE   (-1)
 Used to define an invalid enum found.
 

Typedefs

typedef struct CdiPtpTimestamp CdiPtpTimestamp
 Forward structure declaration to create pointer to PTP timestamp.
 

Enumerations

enum  CdiEnumStringKeyType {
  kKeyAdapterType , kKeyBufferType , kKeyConnectionProtocolType , kKeyLogMethod ,
  kKeyLogComponent , kKeyLogLevel , kKeyConnectionStatus , kKeyTestUnit
}
 Enums used to indicate which key-value array a function is to access. More...
 
enum  CdiConnectionProtocolType { kProtocolTypeRaw , kProtocolTypeAvm }
 This enumeration is used in the CdiConnectionState structure to indicate what connection layer is being used. More...
 

Functions

CDI_INTERFACE const CdiEnumStringKeyCdiUtilityKeyGetArray (CdiEnumStringKeyType key_type)
 
CDI_INTERFACE const char * CdiUtilityEnumValueToString (const CdiEnumStringKey *key_array, int enum_value)
 
CDI_INTERFACE int CdiUtilityStringToEnumValue (const CdiEnumStringKey *key_array, const char *name_str)
 
CDI_INTERFACE const char * CdiUtilityKeyEnumToString (CdiEnumStringKeyType key_type, int enum_value)
 
CDI_INTERFACE int CdiUtilityKeyStringToEnum (CdiEnumStringKeyType key_type, const char *name_str)
 
CDI_INTERFACE uint32_t CdiUtilityPtpToRtp (const CdiPtpTimestamp *ptp_timestamp_ptr, uint32_t sample_rate)
 Function used to convert a PTP timestamp into an RTP timestamp.
 
CDI_INTERFACE uint64_t CdiUtilityPtpTimestampToMicroseconds (const CdiPtpTimestamp *timestamp_ptr)
 
static const char * CdiUtilityBoolToString (bool b)
 

Detailed Description

The declarations in this header file correspond to the definitions in cdi_utility_api.c and are meant to provide access to helpful SDK data structures and functions that are not part of the core API functionality.

Enumeration Type Documentation

◆ CdiConnectionProtocolType

This enumeration is used in the CdiConnectionState structure to indicate what connection layer is being used.

Enumerator
kProtocolTypeRaw 

Raw connection.

kProtocolTypeAvm 

Audio, Video and Metadata (AVM) connection.

◆ CdiEnumStringKeyType

Enums used to indicate which key-value array a function is to access.

NOTE: Update CdiUtilityKeyGetArray in cdi_utility_api.c whenever an entry is added to this table.

Enumerator
kKeyAdapterType 

Key for CdiAdapterTypeSelection.

kKeyBufferType 

Key for CdiBufferType.

kKeyConnectionProtocolType 

Key for CdiConnectionProtocolType.

kKeyLogMethod 

Key for CdiLogMethod.

kKeyLogComponent 

Key for CdiLogComponent.

kKeyLogLevel 

Key for CdiLogLevel.

kKeyConnectionStatus 

Key for CdiConnectionStatus.

kKeyTestUnit 

Key for CdiTestUnitName.

Function Documentation

◆ CdiUtilityBoolToString()

static const char * CdiUtilityBoolToString ( bool b)
inlinestatic

Convenience function to return the human readable string associated with the given boolean value.

Parameters
bThe value to convert.
Returns
The address of a human readable character string.

◆ CdiUtilityEnumValueToString()

CDI_INTERFACE const char * CdiUtilityEnumValueToString ( const CdiEnumStringKey * key_array,
int enum_value )

Convert an enum value to a string.

Parameters
key_arrayPointer to array enum/string key pairs to use for the conversion.
enum_valueValue to convert to a string.
Returns
Pointer to returned string. If no match was found, NULL is returned.

◆ CdiUtilityKeyEnumToString()

CDI_INTERFACE const char * CdiUtilityKeyEnumToString ( CdiEnumStringKeyType key_type,
int enum_value )

Function used to convert an enum value to a string.

Parameters
key_typeEnum from CdiEnumStringKeyType which indicates which key-value array to search for enum_value.
enum_valueValue to convert to a string.
Returns
Pointer to returned string. If no match was found, NULL is returned.

◆ CdiUtilityKeyGetArray()

CDI_INTERFACE const CdiEnumStringKey * CdiUtilityKeyGetArray ( CdiEnumStringKeyType key_type)

Function used to get a pointer to a key-value array of a type specified by key_type.

Parameters
key_typeEnum from CdiEnumStringKeyType which indicates which key-value array to return.
Returns
Pointer to returned string. If no match was found, NULL is returned.

◆ CdiUtilityKeyStringToEnum()

CDI_INTERFACE int CdiUtilityKeyStringToEnum ( CdiEnumStringKeyType key_type,
const char * name_str )

Function used to convert a string to a matching enum value.

Parameters
key_typeEnum from CdiEnumStringKeyType which indicates which key-value array to search for name_str.
name_strPointer to string name of enumerated value.
Returns
Returned enumerated value. If no match was found, CDI_INVALID_ENUM_VALUE is returned.

◆ CdiUtilityPtpTimestampToMicroseconds()

CDI_INTERFACE uint64_t CdiUtilityPtpTimestampToMicroseconds ( const CdiPtpTimestamp * timestamp_ptr)

Convert the specified PTP timestamp into microseconds.

Parameters
timestamp_ptrPointer to PTP timestamp to convert.
Returns
PTP timestamp in microseconds.

◆ CdiUtilityPtpToRtp()

CDI_INTERFACE uint32_t CdiUtilityPtpToRtp ( const CdiPtpTimestamp * ptp_timestamp_ptr,
uint32_t sample_rate )

Function used to convert a PTP timestamp into an RTP timestamp.

Parameters
ptp_timestamp_ptrA pointer to a PTP timestamp consisting of seconds and nanoseconds;
sample_rateA sample rate value in Hz for the number of samples per second used for the RTP units.
Returns
An RTP timestamp in sample_rate units. If sample_rate is 0 or ptp_timestamp_ptr is NULL 0 is returned.

◆ CdiUtilityStringToEnumValue()

CDI_INTERFACE int CdiUtilityStringToEnumValue ( const CdiEnumStringKey * key_array,
const char * name_str )

Convert a string to a matching enum value.

Parameters
key_arrayPointer to array enum/string key pairs to use for the conversion.
name_strPointer to string name of enumerated value.
Returns
Returned enumerated value. If no match was found, CDI_INVALID_ENUM_VALUE is returned.