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

This file contains common cdi_test definitions and functions used by both receiver connections and transmitter connections. More...

#include "test_control.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "cdi_logger_api.h"
#include "cdi_avm_payloads_api.h"
#include "cdi_test.h"
#include "curses.h"
#include "riff.h"
#include "run_test.h"
#include "test_console.h"
#include "utilities_api.h"

Functions

static bool TestPayloadPatternSet (uint64_t seed_value, TestPatternType pattern_type, int payload_word_size, void *pattern_buffer_ptr)
 
bool TestWaitForConnection (TestConnectionInfo *connection_info_ptr, int timeout_seconds)
 
void TestConnectionCallback (const CdiCoreConnectionCbData *cb_data_ptr)
 
void TestStatisticsCallback (const CdiCoreStatsCbData *cb_data_ptr)
 
void TestIncPayloadCount (TestConnectionInfo *connection_info_ptr, int stream_index)
 
bool PreparePayloadData (StreamSettings *stream_settings_ptr, int payload_buffer_size, CdiFileID *read_file_handle_ptr, void *buffer_ptr)
 
bool GetNextPayloadDataSgl (const TestConnectionInfo *connection_info_ptr, const StreamSettings *stream_settings_ptr, int payload_id, CdiFileID read_file_handle, CdiSgList *sgl_ptr)
 
bool GetNextPayloadDataLinear (const TestConnectionInfo *connection_info_ptr, const StreamSettings *stream_settings_ptr, TestConnectionStreamInfo *stream_info_ptr)
 
bool TestCreateConnectionLogFiles (TestConnectionInfo *connection_info_ptr, CdiLogMethodData *log_method_data_ptr, char *sdk_log_filename_buffer_str)
 
bool IsPayloadNumLessThanTotal (int current_payload_num, int total_payloads)
 
CdiPtpTimestamp GetVideoPtpTimestamp (const TestConnectionInfo *connection_info_ptr, const TestConnectionStreamInfo *stream_info_ptr, int ptp_rate_count)
 Get the next video PTP timestamp to use in the payload origination_ptp_timestamp.
 
CdiPtpTimestamp GetAudioPtpTimestamp (const StreamSettings *stream_settings_ptr, TestConnectionStreamInfo *stream_info_ptr, int audio_data_size)
 Get the next audio PTP timestamp to use in the payload origination_ptp_timestamp.
 
void LogTimestamps (const StreamSettings *stream_settings_ptr, TestConnectionStreamInfo *stream_info_ptr, CdiPtpTimestamp current_ptp_timestamp)
 Log timestamp, if enabled.
 

Detailed Description

This file contains common cdi_test definitions and functions used by both receiver connections and transmitter connections.

Function Documentation

◆ GetAudioPtpTimestamp()

CdiPtpTimestamp GetAudioPtpTimestamp ( const StreamSettings * stream_settings_ptr,
TestConnectionStreamInfo * stream_info_ptr,
int audio_data_size )

Get the next audio PTP timestamp to use in the payload origination_ptp_timestamp.

Parameters
stream_settings_ptrPointer to stream settings info.
stream_info_ptrPointer to stream info.
audio_data_sizeSize of audio data in bytes.
Returns
A PTP timestamp for the next payload to send.

◆ GetNextPayloadDataLinear()

bool GetNextPayloadDataLinear ( const TestConnectionInfo * connection_info_ptr,
const StreamSettings * stream_settings_ptr,
TestConnectionStreamInfo * stream_info_ptr )

Prepare next set of payload data. This is either reading the next payload from the file or incrementing the payload identifier value when using patterns.

Parameters
connection_info_ptrPointer to test connection information.
stream_settings_ptrPointer to stream settings.
stream_info_ptrPointer to stream state.
Returns
if successful return true, otherwise returns false.

◆ GetNextPayloadDataSgl()

bool GetNextPayloadDataSgl ( const TestConnectionInfo * connection_info_ptr,
const StreamSettings * stream_settings_ptr,
int payload_id,
CdiFileID read_file_handle,
CdiSgList * sgl_ptr )

Prepare next set of payload data. This is either reading the next payload from the file or incrementing the payload identifier value when using patterns.

Parameters
connection_info_ptrPointer to test connection information.
stream_settings_ptrPointer to stream settings.
payload_idPayload identifier.
read_file_handleThe file handle for reading the next pattern from, if the pattern type is from file.
sgl_ptrPointer to an SGL describing the buffer to be filled with payload data.
Returns
if successful return true, otherwise returns false.

◆ GetVideoPtpTimestamp()

CdiPtpTimestamp GetVideoPtpTimestamp ( const TestConnectionInfo * connection_info_ptr,
const TestConnectionStreamInfo * stream_info_ptr,
int ptp_rate_count )

Get the next video PTP timestamp to use in the payload origination_ptp_timestamp.

Parameters
connection_info_ptrPointer to test connection information.
stream_info_ptrPointer to stream info.
ptp_rate_countCurrent PTP rate counter value.
Returns
A PTP timestamp for the next payload to send.

◆ IsPayloadNumLessThanTotal()

bool IsPayloadNumLessThanTotal ( int current_payload_num,
int total_payloads )

Check whether the current payload number is less that the total payloads allowed.

Parameters
current_payload_numNumber that represents the current payload number.
total_payloadsNumber that represents the total number of payloads for this connection (0 is infinite).
Returns
bool Indicates if the current payload number is less than the total number of payloads. This is always true if infinite payloads.

◆ LogTimestamps()

void LogTimestamps ( const StreamSettings * stream_settings_ptr,
TestConnectionStreamInfo * stream_info_ptr,
CdiPtpTimestamp current_ptp_timestamp )

Log timestamp, if enabled.

Parameters
stream_settings_ptrPointer to stream settings.
stream_info_ptrPointer to stream info.
current_ptp_timestampCurrent PTP timestamp value to log.

◆ PreparePayloadData()

bool PreparePayloadData ( StreamSettings * stream_settings_ptr,
int payload_buffer_size,
CdiFileID * read_file_handle_ptr,
void * buffer_ptr )

Prepare next set of payload data. This is either reading the next payload from the file or incrementing the payload identifier value when using patterns. This function is shared for managing both Tx and Rx buffer patterns.

Parameters
stream_settings_ptrPointer to stream settings.
payload_buffer_sizePayload buffer size, rounded up to multiple of 8 bytes.
read_file_handle_ptrPointer to the user read data file handle which this function will set.
buffer_ptrPointer to buffer of payload size to be filled with initial pattern words if using patterns.
Returns
if successful return true, otherwise returns false.

◆ TestConnectionCallback()

void TestConnectionCallback ( const CdiCoreConnectionCbData * cb_data_ptr)

Handle the connection callback.

Parameters
cb_data_ptrPointer to core connection callback data.

◆ TestCreateConnectionLogFiles()

bool TestCreateConnectionLogFiles ( TestConnectionInfo * connection_info_ptr,
CdiLogMethodData * log_method_data_ptr,
char * sdk_log_filename_buffer_str )

Create a unique log file name for this application's connection and associate it with the current thread. This allows use of the CDI_LOG_THREAD() macro to direct log messages to the logger.

Parameters
connection_info_ptrPointer to test connection information.
log_method_data_ptrPointer to log method data.
sdk_log_filename_buffer_strPointer to buffer for return SDK log filename.
Returns
bool Returns true if successful, otherwise false is returned.

◆ TestIncPayloadCount()

void TestIncPayloadCount ( TestConnectionInfo * connection_info_ptr,
int stream_index )

Increment the connection's payload counter and mark done if we hit the user-specified total_payloads.

Parameters
connection_info_ptrPointer to connection info data for which we want to increment the payload count.
stream_indexStream index.

◆ TestPayloadPatternSet()

static bool TestPayloadPatternSet ( uint64_t seed_value,
TestPatternType pattern_type,
int payload_word_size,
void * pattern_buffer_ptr )
static

Initializes a buffer the size of a single payload to use when using test patterns. This buffer is used to efficiently send the payload by the test_transmitter and is used for comparing the receive data buffer in test_receiver.

Parameters
seed_valueThe seed_value to start patterns with.
pattern_typeThe enum (TestPatternTypes) value for the pattern type.
payload_word_sizeSets how many 64 bit words fit in the buffer pointed to by pattern_buffer_ptr.
pattern_buffer_ptrThe pointer to a buffer of payload_word_size that will be filled with payload_word_size number of words of pattern pattern_type.
Returns
If successful returns true, otherwise returns false.

◆ TestStatisticsCallback()

void TestStatisticsCallback ( const CdiCoreStatsCbData * cb_data_ptr)

Handle the statistics callback.

Parameters
cb_data_ptrPointer to statistics callback data.

◆ TestWaitForConnection()

bool TestWaitForConnection ( TestConnectionInfo * connection_info_ptr,
int timeout_seconds )

Wait until the connection has been established.

Parameters
connection_info_ptrPointer to connection info data for which to wait for a connection.
timeout_secondsTimeout in seconds.
Returns
Returns true if successful, false if the timeout occurred while waiting.