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.c File Reference

This file contains the definitions of the functions that comprise the CDI Utility Functions API. More...

#include "cdi_utility_api.h"
#include <assert.h>
#include <stddef.h>
#include "cdi_baseline_profile_api.h"
#include "cdi_core_api.h"
#include "cdi_test_unit_api.h"
#include "cdi_os_api.h"
#include "utilities_api.h"

Macros

#define RTP_ROLLOVER_COUNT   0x100000000ULL
 How many times an RTP counter increments before rolling over. An RTP timestamp is specified in IETF RFC 3550 as a 32 bit value.
 

Functions

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

Variables

static const CdiEnumStringKey adapter_type_key_array []
 Enum/string keys for CdiAdapterTypeSelection.
 
static const CdiEnumStringKey buffer_type_key_array []
 Enum/string keys for CdiBufferType.
 
static const CdiEnumStringKey protocols_key_array []
 Enum/String keys for ConnectionProtocolType.
 
static const CdiEnumStringKey log_method_key_array []
 Enum/string keys for CdiLogMethod.
 
static const CdiEnumStringKey log_component_key_array []
 Enum/string keys for CdiLogComponent.
 
static const CdiEnumStringKey log_level_key_array []
 Enum/string keys for CdiLogLevel.
 
static const CdiEnumStringKey connection_status_key_array []
 Enum/string keys for CdiConnectionStatus.
 

Detailed Description

This file contains the definitions of the functions that comprise the CDI Utility Functions API.

Function Documentation

◆ CdiUtilityEnumValueToString()

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()

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()

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()

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()

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()

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()

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.

Variable Documentation

◆ adapter_type_key_array

const CdiEnumStringKey adapter_type_key_array[]
static
Initial value:
= {
{ kCdiAdapterTypeEfa, "EFA" },
{ kCdiAdapterTypeSocket, "SOCKET" },
{ kCdiAdapterTypeSocketLibfabric, "SOCKET_LIBFABRIC" },
}
@ kCdiAdapterTypeEfa
This adapter type is the typical choice for high throughput, reliable delivery of data....
Definition cdi_core_api.h:451
@ kCdiAdapterTypeSocketLibfabric
This adapter type is mainly useful for testing. This is similar to kCdiAdapterTypeSocket except that ...
Definition cdi_core_api.h:474
@ kCdiAdapterTypeSocket
This adapter type has significant performance limitations and is mainly useful for testing since ther...
Definition cdi_core_api.h:470
#define CDI_INVALID_ENUM_VALUE
Used to define an invalid enum found.
Definition cdi_utility_api.h:38

Enum/string keys for CdiAdapterTypeSelection.

◆ buffer_type_key_array

const CdiEnumStringKey buffer_type_key_array[]
static
Initial value:
= {
{ kCdiLinearBuffer, "LINEAR" },
{ kCdiSgl, "SGL" },
}
@ kCdiLinearBuffer
Use a linear buffer to store received payload data. Depending on hardware capabilities,...
Definition cdi_core_api.h:751
@ kCdiSgl
Use scatter-gather buffers to store received payload data.
Definition cdi_core_api.h:754

Enum/string keys for CdiBufferType.

◆ connection_status_key_array

const CdiEnumStringKey connection_status_key_array[]
static
Initial value:
= {
{ kCdiConnectionStatusDisconnected, "Disconnected" },
}
@ kCdiConnectionStatusDisconnected
Disconnected. The SDK is trying to establish the connection.
Definition cdi_core_api.h:369
@ kCdiConnectionStatusConnected
Connected and ready for use.
Definition cdi_core_api.h:370

Enum/string keys for CdiConnectionStatus.

◆ log_component_key_array

const CdiEnumStringKey log_component_key_array[]
static
Initial value:
= {
{ kLogComponentGeneric, "GENERIC" },
{ kLogComponentPayloadConfig, "PAYLOAD_CONFIG" },
{ kLogComponentPerformanceMetrics, "PERFORMANCE_METRICS" },
{ kLogComponentProbe, "PROBE" },
{ kLogComponentEndpointManager, "ENDPOINT_MANAGER" },
}
@ kLogComponentGeneric
Generic component.
Definition cdi_log_enums.h:36
@ kLogComponentPayloadConfig
Payload configuration data component.
Definition cdi_log_enums.h:37
@ kLogComponentPerformanceMetrics
Performance metrics component.
Definition cdi_log_enums.h:38
@ kLogComponentEndpointManager
Endpoint Manager component.
Definition cdi_log_enums.h:40
@ kLogComponentProbe
Probe component.
Definition cdi_log_enums.h:39

Enum/string keys for CdiLogComponent.

◆ log_level_key_array

const CdiEnumStringKey log_level_key_array[]
static
Initial value:
= {
{ kLogFatal, "FATAL" },
{ kLogCritical, "CRITICAL" },
{ kLogError, "ERROR" },
{ kLogWarning, "WARNING" },
{ kLogInfo, "INFO" },
{ kLogVerbose, "VERBOSE" },
{ kLogDebug, "DEBUG" },
}
@ kLogWarning
Warnings to the user.
Definition cdi_log_enums.h:54
@ kLogFatal
Fatal errors are not recoverable. Software needs to exit.
Definition cdi_log_enums.h:51
@ kLogError
Errors to the user.
Definition cdi_log_enums.h:53
@ kLogVerbose
Additional verbose information to the user.
Definition cdi_log_enums.h:56
@ kLogInfo
General information to the user.
Definition cdi_log_enums.h:55
@ kLogCritical
Critical errors are logged. Software may continue but something is very wrong.
Definition cdi_log_enums.h:52
@ kLogDebug
Debug information to the user.
Definition cdi_log_enums.h:57

Enum/string keys for CdiLogLevel.

◆ log_method_key_array

const CdiEnumStringKey log_method_key_array[]
static
Initial value:
= {
{ kLogMethodStdout, "LogMethodStdout" },
{ kLogMethodCallback, "LogMethodCallback" },
{ kLogMethodFile, "LogMethodFile" },
}
@ kLogMethodFile
Write log messages directly to a file.
Definition cdi_log_enums.h:27
@ kLogMethodCallback
Send log messages to a user-registered callback function.
Definition cdi_log_enums.h:26
@ kLogMethodStdout
Send log messages directly to stdout.
Definition cdi_log_enums.h:25

Enum/string keys for CdiLogMethod.

◆ protocols_key_array

const CdiEnumStringKey protocols_key_array[]
static
Initial value:
= {
{ kProtocolTypeRaw, "RAW" },
{ kProtocolTypeAvm, "AVM" },
}
@ kProtocolTypeRaw
Raw connection.
Definition cdi_utility_api.h:72
@ kProtocolTypeAvm
Audio, Video and Metadata (AVM) connection.
Definition cdi_utility_api.h:73

Enum/String keys for ConnectionProtocolType.