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

This file contains definitions and functions for the receive-side CDI test application logic. More...

#include "test_receiver.h"
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include "cdi_avm_api.h"
#include "cdi_avm_payloads_api.h"
#include "cdi_core_api.h"
#include "cdi_logger_api.h"
#include "cdi_test.h"
#include "fifo_api.h"
#include "riff.h"
#include "test_common.h"
#include "test_control.h"
#include "utilities_api.h"

Data Structures

struct  TestRxPayloadState
 A structure for storing data to be sent to the FIFO used in TestRxVerify(). More...
 
struct  UnpacketizeAncControl
 Control structure for Anc unpacketize callback. More...
 

Enumerations

enum  TestCheckStatus { kTestStatusOk , kTestStatusNonFatalFailure , kTestStatusFatalFailure }
 

Functions

static void UnpacketizeAncCallback (void *user_data_ptr, CdiFieldKind field_kind, const CdiAvmAncillaryDataPacket *packet_ptr, bool has_parity_error, bool has_checksum_error)
 
static bool UnpacketizeAncPayload (TestConnectionInfo *connection_info_ptr, CdiSgList *sgl_ptr)
 
static TestCheckStatus WritePayloadToFile (CdiSgList *sgl_ptr, TestConnectionInfo *connection_info_ptr, int stream_index)
 
static TestCheckStatus TestRxBufferCheck (CdiSgList *sgl_ptr, TestConnectionInfo *connection_info_ptr, int stream_index)
 Check a received data buffer (in scatter gather list form) against expected received data based on provided test parameters.
 
static bool TestRxVerify (TestConnectionInfo *connection_info_ptr)
 
static void TestRxProcessCoreCallbackData (const CdiCoreCbData *core_cb_data_ptr, int stream_index, int payload_size)
 
static void RxCoreCallbackCleanup (const CdiCoreCbData *core_cb_data_ptr, const CdiSgList *sgl_ptr, int stream_index)
 
static void TestRawRxCallback (const CdiRawRxCbData *cb_data_ptr)
 
static void VerifyAvmAudioConfiguration (TestConnectionInfo *connection_info_ptr, const CdiAvmAudioConfig *audio_config_ptr, const StreamSettings *stream_settings_ptr)
 
static void VerifyAvmAncillaryDataConfiguration (TestConnectionInfo *connection_info_ptr, const CdiAvmAncillaryDataConfig *anc_config_ptr, const StreamSettings *stream_settings_ptr)
 
static void VerifyAvmVideoConfiguration (TestConnectionInfo *connection_info_ptr, const CdiAvmVideoConfig *video_config_ptr, const StreamSettings *stream_settings_ptr, int stream_index)
 
static void VerifyAvmConfiguration (const CdiAvmRxCbData *cb_data_ptr, CdiAvmBaselineConfig *baseline_config_ptr, int stream_index)
 
static int GetStreamSettingsIndexFromStreamId (const TestConnectionInfo *connection_info_ptr, int stream_identifier)
 
static void TestAvmRxCallback (const CdiAvmRxCbData *cb_data_ptr)
 
CDI_THREAD TestRxCreateThread (void *arg_ptr)
 

Detailed Description

This file contains definitions and functions for the receive-side CDI test application logic.

See CDI Test Application Architecture Receive Logic for diagrams and detailed description of the receive-side program flow.

Enumeration Type Documentation

◆ TestCheckStatus

Enum indicating severity of check failures. For fatal failures the test should be aborted.

Enumerator
kTestStatusOk 

No check failed.

kTestStatusNonFatalFailure 

A check failed.

kTestStatusFatalFailure 

A check failed and it does not make sense to continue testing.

Function Documentation

◆ GetStreamSettingsIndexFromStreamId()

static int GetStreamSettingsIndexFromStreamId ( const TestConnectionInfo * connection_info_ptr,
int stream_identifier )
static

This function finds the index of the stream in the stream_settings array using the specified endpoint handle.

Parameters
connection_info_ptrPointer to test connection information.
stream_identifierThe stream identifier to search for.
Returns
The index of the selected stream_settings array. If an index is not found, return -1.

◆ RxCoreCallbackCleanup()

static void RxCoreCallbackCleanup ( const CdiCoreCbData * core_cb_data_ptr,
const CdiSgList * sgl_ptr,
int stream_index )
static

Perform any cleanup operation for the Rx callback. Currently, this function increments the payload count and writes the SGL to its thread-specific FIFO.

Parameters
core_cb_data_ptrPointer to a CdiCoreCbData callback structure.
sgl_ptrPointer to the received SGL.
stream_indexThe stream identifier.

◆ TestAvmRxCallback()

static void TestAvmRxCallback ( const CdiAvmRxCbData * cb_data_ptr)
static

Handle the RX callback for AVM data payloads. This callback will check AVM specific configuration data before calling TestRxProcessCoreCallbackData().

Parameters
cb_data_ptrPointer to rx callback data for AVM payloads.

◆ TestRawRxCallback()

static void TestRawRxCallback ( const CdiRawRxCbData * cb_data_ptr)
static

Handle the Rx callback for RAW data payloads. This immediately calls TestRxProcessCoreCallbackData().

Parameters
cb_data_ptrPointer to rx callback data for raw payloads.

◆ TestRxBufferCheck()

static TestCheckStatus TestRxBufferCheck ( CdiSgList * sgl_ptr,
TestConnectionInfo * connection_info_ptr,
int stream_index )
static

Check a received data buffer (in scatter gather list form) against expected received data based on provided test parameters.

Parameters
sgl_ptrPointer to scatter-gather list of received payload data.
connection_info_ptrPointer to data structure representing the connection parameters and associated test parameters.
stream_indexIndex of stream.
Returns
Return code indicating check failures.

◆ TestRxCreateThread()

CDI_THREAD TestRxCreateThread ( void * arg_ptr)
Parameters
arg_ptrVoid pointer to the connection_info data structure for this connection.
Returns
True if no errors; false if errors;

◆ TestRxProcessCoreCallbackData()

static void TestRxProcessCoreCallbackData ( const CdiCoreCbData * core_cb_data_ptr,
int stream_index,
int payload_size )
static

This function is called when a payload is received in the callback function. This function does some validation of the payload by checking things like payload number and SGL payload size. Then the SGL is placed in a FIFO for additional verification by TestRxVerify(). This function is used in both the RAW and AVM receive payload flow.

Parameters
core_cb_data_ptrPointer to a CdiCoreCbData callback structure.
stream_indexThe stream index.
payload_sizePayload size in bytes.

◆ TestRxVerify()

static bool TestRxVerify ( TestConnectionInfo * connection_info_ptr)
static

Wait for receive data from receive data FIFO. If error, print error message and mark the connection as fail. If no error, then check the received payload against expected test parameters.

Parameters
connection_info_ptrPointer to the connection info for this thread's associated connection.
Returns
True if success; false if failure.

◆ UnpacketizeAncCallback()

static void UnpacketizeAncCallback ( void * user_data_ptr,
CdiFieldKind field_kind,
const CdiAvmAncillaryDataPacket * packet_ptr,
bool has_parity_error,
bool has_checksum_error )
static

Callback used by UnpacketizeAncPayload. Writes user data into results buffer.

See also
CdiAvmUnpacketizeAncCallback.

◆ UnpacketizeAncPayload()

static bool UnpacketizeAncPayload ( TestConnectionInfo * connection_info_ptr,
CdiSgList * sgl_ptr )
static

Check that the data can be unpacketized successfully.

Parameters
connection_info_ptrPointer to connection info data. For TEST_LOG_CONNECTION macro.
sgl_ptrPointer to user data buffer.
Returns
Success or failure.

◆ VerifyAvmAncillaryDataConfiguration()

static void VerifyAvmAncillaryDataConfiguration ( TestConnectionInfo * connection_info_ptr,
const CdiAvmAncillaryDataConfig * anc_config_ptr,
const StreamSettings * stream_settings_ptr )
static

This function validates an audio AVM ancillary data payload. The pass_status of the TestConnectionInfo will be set to 'false' if there is an error in the payload.

Parameters
connection_info_ptrPointer to the test connection info structure.
anc_config_ptrPointer to the ancillary data configuration structure received through the SDK.
stream_settings_ptrPointer to the selected stream's StreamSettings structure.

◆ VerifyAvmAudioConfiguration()

static void VerifyAvmAudioConfiguration ( TestConnectionInfo * connection_info_ptr,
const CdiAvmAudioConfig * audio_config_ptr,
const StreamSettings * stream_settings_ptr )
static

This function validates an audio AVM payload. The pass_status of the TestConnectionInfo will be set to 'false' if there is an error in the payload.

Parameters
connection_info_ptrPointer to the test connection info structure.
audio_config_ptrPointer to the audio configuration structure received through the SDK.
stream_settings_ptrPointer to the selected stream's StreamSettings structure.

◆ VerifyAvmConfiguration()

static void VerifyAvmConfiguration ( const CdiAvmRxCbData * cb_data_ptr,
CdiAvmBaselineConfig * baseline_config_ptr,
int stream_index )
static

This function validates an AVM baseline configuration. The pass_status of the TestConnectionInfo will be set to false if there is an error in the configuration.

Parameters
cb_data_ptrPointer to the CdiAvmRxCbData.
baseline_config_ptrPointer to the baseline configuration structure.
stream_indexIndex of the streams settings array for this particular stream.

◆ VerifyAvmVideoConfiguration()

static void VerifyAvmVideoConfiguration ( TestConnectionInfo * connection_info_ptr,
const CdiAvmVideoConfig * video_config_ptr,
const StreamSettings * stream_settings_ptr,
int stream_index )
static

This function validates a video AVM payload. The pass_status of the TestConnectionInfo will be set to 'false' if there is an error in the payload.

Parameters
connection_info_ptrPointer to the test connection info structure.
video_config_ptrPointer to the video configuration structure received through the SDK.
stream_settings_ptrPointer to the selected stream's StreamSettings structure.
stream_indexIndex of the stream_settings array for this particular stream.

◆ WritePayloadToFile()

static TestCheckStatus WritePayloadToFile ( CdiSgList * sgl_ptr,
TestConnectionInfo * connection_info_ptr,
int stream_index )
static

Check that the data can be unpacketized successfully.

Parameters
sgl_ptrPointer to user data buffer.
connection_info_ptrPointer to connection info data. For TEST_LOG_CONNECTION macro.
stream_indexIndex of stream.
Returns
Return code indicating check failures.