CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
|
This file contains definitions and functions for the NDI-CDI Converter application. More...
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "cdi_baseline_profile_02_00_api.h"
#include "test_common.h"
#include "ndi_test.h"
#include "ndi_wrapper.h"
Functions | |
static int64_t | CDITimestampToNdi (const CdiPtpTimestamp *cdi_timestamp_ptr) |
Convert a CDI timestamp to NDI. | |
static double | MAX (float num1, float num2) |
Find maximum between two numbers. | |
static double | MIN (float num1, float num2) |
Find minimum between two numbers. | |
static bool | NdiToCdiAudioConversion (float *original_audio_ptr, int num_channels, int num_samples, int channel_stride_in_bytes, int *audio_size_byte_ret_ptr) |
Convert audio from 32-bit float Little-Endian to 24-bit int Big-Endian PCM. NDI audio frame appear in stacked channels in 32-bit float Little Endian format and CDI audio frame is requested to be in interleaved channels in 24-bit int Big-Endian PCM. Function goes through each NDI channel, reads audio segment in 4 byte segments, converts segment from 32-bit float Little-Endian to 24-bit int Big-Endian PCM, and places 24-bit int segment in jumps, that match interleaved spacing with corresponding number of channels, in temporary buffer. Temporary buffer replaces original NDI audio buffer and the size of the audio in bytes is updated to its new size. | |
static bool | CdiToNdiAudioConversion (const uint8_t *cdi_audio_ptr, int cdi_audio_size, int num_channels, int num_samples_per_channel, int ndi_channel_stride_in_bytes, float *ndi_audio_ptr, int *ndi_size_ptr) |
Convert CDI audio 24-bit Big-Endian interleaved PCM to NDI 32-bit float Little Endian non-interleaved. | |
static CdiReturnStatus | NdiToCdiVideo (const FrameData *frame_data_ptr, int *buffer_size_ptr, void **payload_buffer_ptr, int64_t *timestamp_ptr, CdiAvmBaselineConfig *avm_config_ptr) |
Convert a NDI video frame to CDI. | |
static CdiReturnStatus | CdiToNdiVideo (const CdiPtpTimestamp *cdi_timestamp_ptr, const CdiAvmBaselineConfig *avm_config_ptr, int payload_size, const CdiSgList *sgl_ptr, FrameData *frame_data_ptr) |
Convert a CDI video frame to NDI. | |
static CdiReturnStatus | NdiToCdiAudio (FrameData *frame_data_ptr, int *buffer_size_ptr, void **payload_buffer_ptr, int64_t *timestamp_ptr, CdiAvmBaselineConfig *avm_config_ptr) |
Convert a NDI audio frame to CDI. | |
static CdiReturnStatus | CdiToNdiAudio (const CdiPtpTimestamp *cdi_timestamp_ptr, const CdiAvmBaselineConfig *avm_config_ptr, int payload_size, const CdiSgList *sgl_ptr, FrameData *frame_data_ptr) |
Convert CDI audio to NDI audio. | |
static CdiReturnStatus | CdiToNdiMetadata (const CdiPtpTimestamp *cdi_timestamp_ptr, const CdiAvmBaselineConfig *avm_config_ptr, int payload_size, const CdiSgList *sgl_ptr, FrameData *frame_data_ptr) |
Convert CDI metadata to NDI metadata. | |
static CdiReturnStatus | NdiToCdiMeta (FrameData *frame_data_ptr, int *buffer_size_ptr, void **payload_buffer_ptr, int64_t *timestamp_ptr, CdiAvmBaselineConfig *avm_config_ptr) |
Convert a NDI metadata frame to CDI. | |
NdiTime | NdiTimeBreakdown (int64_t ndi_timestamp) |
A function that breaks down the NDI Timestamp, in 100ns format, into seconds, milliseconds, and nanoseconds. | |
bool | NdiInitialize (void) |
A function which initializes the NDI SDK. | |
NDIlib_send_instance_t | NdiCreateSender (const TestSettings *test_settings_ptr) |
A function which creates a NDI sender. | |
void | NdiShowSources (void) |
Show available NDI sources and exit. | |
NDIlib_recv_instance_t | NdiCreateReceiver (const TestSettings *test_settings_ptr) |
A function which creates a NDI finder, looks for NDI sources, creates a NDI receiver, and connects to a NDI source to receive stream information. | |
void | NdiReleasePayload (FrameData *frame_data_ptr) |
A function that releases the memory of a NDI video, audio, or metadata frame, and puts back memory pool allocation. | |
CdiReturnStatus | NdiConvertNdiToCdi (FrameData *frame_data_ptr, int *buffer_size_ptr, void **payload_buffer_ptr, int64_t *timestamp_ptr, CdiAvmBaselineConfig *avm_config_ptr) |
A function that maps information of NDI frame to an AVM structure that is compatible with CDI. | |
CdiReturnStatus | NdiConvertCdiToNdi (const CdiPtpTimestamp *cdi_timestamp_ptr, const CdiAvmBaselineConfig *avm_config_ptr, int payload_size, const CdiSgList *sgl_ptr, FrameData *frame_data_ptr) |
Convert CDI payload to NDI frame. | |
CDI_THREAD | NdiReceivePayloadThread (void *ptr) |
A function that captures NDI frames that is to be written to the memory pool and put in the Payload FIFO. Function also reads from Callback FIFO to determine if NDI frame memory should be released or resent. Function uses a receding time clock element to determine if video frames are being sent consistently at the expected time. If video frame is not seen in expected time, function resends last seen video frame, else it keeps sending new video frames. | |
CDI_THREAD | NdiTransmitPayloadThread (void *ptr) |
Thread used to transmit NDI frames. | |
This file contains definitions and functions for the NDI-CDI Converter application.
|
static |
Convert a CDI timestamp to NDI.
|
static |
Convert CDI audio to NDI audio.
cdi_timestamp_ptr | Pointer to CDI timestamp. |
avm_config_ptr | Pointer to CDI AVM configuration data. |
payload_size | Size of CDI payload in bytes. |
sgl_ptr | Pointer to CDI payload data in Scatter-Gather-List format. |
frame_data_ptr | Pointer where to write NDI frame data. |
|
static |
Convert CDI audio 24-bit Big-Endian interleaved PCM to NDI 32-bit float Little Endian non-interleaved.
cdi_audio_ptr | Pointer to CDI audio sample data. |
cdi_audio_size | Size in bytes of CDI audio data. |
num_channels | Number of audio channels. |
num_samples_per_channel | Number of audio samples per channel. |
ndi_channel_stride_in_bytes | Stride in bytes of each NDI channel. |
ndi_audio_ptr | Pointer where to write the NDI audio data. |
ndi_size_ptr | Size of the NDI audio data buffer. |
|
static |
Convert CDI metadata to NDI metadata.
cdi_timestamp_ptr | Pointer to CDI timestamp. |
avm_config_ptr | Pointer to CDI AVM configuration data. |
payload_size | Size of CDI payload in bytes. |
sgl_ptr | Pointer to CDI payload data in Scatter-Gather-List format. |
frame_data_ptr | Pointer where to write NDI frame data. |
|
static |
Convert a CDI video frame to NDI.
|
static |
Find maximum between two numbers.
num1 | Float number. |
num2 | Float number. |
|
static |
Find minimum between two numbers.
num1 | Float number. |
num2 | Float number. |
CdiReturnStatus NdiConvertCdiToNdi | ( | const CdiPtpTimestamp * | cdi_timestamp_ptr, |
const CdiAvmBaselineConfig * | avm_config_ptr, | ||
int | payload_size, | ||
const CdiSgList * | sgl_ptr, | ||
FrameData * | frame_data_ptr ) |
Convert CDI payload to NDI frame.
CdiReturnStatus NdiConvertNdiToCdi | ( | FrameData * | arg_ptr, |
int * | data_size_ptr, | ||
void ** | data_ptr, | ||
int64_t * | timestamp_ptr, | ||
CdiAvmBaselineConfig * | avm_baseline_config_ptr ) |
A function that maps information of NDI frame to an AVM structure that is compatible with CDI.
arg_ptr | Frame Data pointer which stores NDI frame. |
data_size_ptr | Argument passed in to CDI send containing size of data. |
data_ptr | Argument passed in to CDI send containing data. |
timestamp_ptr | Argument passed in to CDI send containing timestamp of data. |
avm_baseline_config_ptr | Argument passed in to CDI send containing configuration of data. |
NDIlib_recv_instance_t NdiCreateReceiver | ( | const TestSettings * | test_settings_ptr | ) |
A function which creates a NDI finder, looks for NDI sources, creates a NDI receiver, and connects to a NDI source to receive stream information.
test_settings_ptr | Pointer to Test Settings argument to find NDI source based from the command line, if given. |
NDIlib_send_instance_t NdiCreateSender | ( | const TestSettings * | test_settings_ptr | ) |
A function which creates a NDI sender.
test_settings_ptr | Pointer to Test Settings argument to create NDI source based from the command line, if given. |
bool NdiInitialize | ( | void | ) |
A function which initializes the NDI SDK.
CDI_THREAD NdiReceivePayloadThread | ( | void * | ndi_thread_data_ptr | ) |
A function that captures NDI frames that is to be written to the memory pool and put in the Payload FIFO. Function also reads from Callback FIFO to determine if NDI frame memory should be released or resent. Function uses a receding time clock element to determine if video frames are being sent consistently at the expected time. If video frame is not seen in expected time, function resends last seen video frame, else it keeps sending new video frames.
ndi_thread_data_ptr | Contains necessary and unchanged data like Test Connections Information. |
void NdiReleasePayload | ( | FrameData * | arg_ptr | ) |
A function that releases the memory of a NDI video, audio, or metadata frame, and puts back memory pool allocation.
arg_ptr | A pointer to an Frame Data structure that is to be released. |
NdiTime NdiTimeBreakdown | ( | int64_t | ndi_timestamp | ) |
A function that breaks down the NDI Timestamp, in 100ns format, into seconds, milliseconds, and nanoseconds.
ndi_timestamp | NDI timestamp. |
|
static |
Convert a NDI audio frame to CDI.
frame_data_ptr | Frame Data pointer which stores NDI frame. |
buffer_size_ptr | Argument passed in to CDI send containing size of data. |
payload_buffer_ptr | Argument passed in to CDI send containing data. |
timestamp_ptr | Argument passed in to CDI send containing timestamp of data. |
avm_config_ptr | Argument passed in to CDI send containing configuration of data. |
|
static |
Convert audio from 32-bit float Little-Endian to 24-bit int Big-Endian PCM. NDI audio frame appear in stacked channels in 32-bit float Little Endian format and CDI audio frame is requested to be in interleaved channels in 24-bit int Big-Endian PCM. Function goes through each NDI channel, reads audio segment in 4 byte segments, converts segment from 32-bit float Little-Endian to 24-bit int Big-Endian PCM, and places 24-bit int segment in jumps, that match interleaved spacing with corresponding number of channels, in temporary buffer. Temporary buffer replaces original NDI audio buffer and the size of the audio in bytes is updated to its new size.
original_audio_ptr | 32-bit float audio given from NDI audio frame. |
num_channels | Number of audio channels given from NDI audio frame. |
num_samples | Number of audio samples given from NDI audio frame. |
channel_stride_in_bytes | Length of channel stride in bytes given from NDI audio frame. |
audio_size_byte_ret_ptr | New total length of audio size in bytes for CDI. |
|
static |
Convert a NDI metadata frame to CDI.
frame_data_ptr | Frame Data pointer which stores NDI frame. |
buffer_size_ptr | Argument passed in to CDI send containing size of data. |
payload_buffer_ptr | Argument passed in to CDI send containing data. |
timestamp_ptr | Argument passed in to CDI send containing timestamp of data. |
avm_config_ptr | Argument passed in to CDI send containing configuration of data. |
|
static |
Convert a NDI video frame to CDI.
frame_data_ptr | Pointer to NDI frame data. |
buffer_size_ptr | Pointer where to write the returned size of the CDI payload. |
payload_buffer_ptr | Pointer where to write the returned pointer to the CDI payload data. |
timestamp_ptr | Pointer where to write the returned CDI timestamp. |
avm_config_ptr | Pointer where to write the return CDI AVM data. |
CDI_THREAD NdiTransmitPayloadThread | ( | void * | ndi_thread_data_ptr | ) |
Thread used to transmit NDI frames.
ndi_thread_data_ptr | Pointer to NDI thread data. |