CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
private.h
Go to the documentation of this file.
1// -------------------------------------------------------------------------------------------
2// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3// This file is part of the AWS CDI-SDK, licensed under the BSD 2-Clause "Simplified" License.
4// License details at: https://github.com/aws/aws-cdi-sdk/blob/mainline/LICENSE
5// -------------------------------------------------------------------------------------------
6
14#ifndef CDI_PRIVATE_H__
15#define CDI_PRIVATE_H__
16
17#include <stdbool.h>
18
19// The configuration.h file must be included first since it can have defines which affect subsequent files.
20#include "configuration.h"
21
22#include "cdi_avm_api.h"
23#include "cdi_logger_api.h"
24#include "cdi_os_api.h"
25#include "cdi_pool_api.h"
26#include "cdi_queue_api.h"
28#include "fifo_api.h"
29#include "list_api.h"
30#include "payload.h"
32
33//*********************************************************************************************************************
34//***************************************** START OF DEFINITIONS AND TYPES ********************************************
35//*********************************************************************************************************************
36
38typedef struct EndpointManagerGlobalState* EndpointManagerGlobalHandle;
39
59
64
86typedef struct CdiStatsCallbackState* CdiStatsCallbackHandle;
91
97typedef enum {
101
135
158
164typedef void (*CdiCallback)(const void* param_ptr);
165
193
197typedef struct SdkLogState* SdkLogHandle;
198
213
227
239
262
295
304
325
357
366
433
435enum {
436 kMagicAdapter = 0xacd95f67,
437 kMagicConnection = 0xf98b0b0d,
438 kMagicEndpoint = 0x725c4e3a,
439 kMagicMemory = 0xdcf693e4,
440};
441
445typedef struct {
448 uint32_t byte_size;
450
471
472//*********************************************************************************************************************
473//******************************************* START OF PUBLIC FUNCTIONS ***********************************************
474//*********************************************************************************************************************
475
476#endif // CDI_PRIVATE_H__
This file declares the public API data types, structures and functions that comprise the CDI audio,...
CdiReturnStatus
Values used for API function return codes.
Definition cdi_core_api.h:189
#define CDI_MAX_CONNECTION_NAME_STRING_LENGTH
Maximum connection name string length.
Definition cdi_core_api.h:129
void * CdiUserCbParameter
Type used as user defined data that is passed to the registered user RX/TX callback functions.
Definition cdi_core_api.h:182
#define CDI_MAX_STREAM_NAME_STRING_LENGTH
Maximum stream name string length.
Definition cdi_core_api.h:132
CdiBufferType
Values used to determine type of receive buffer to configure for a receiver connection....
Definition cdi_core_api.h:748
#define CDI_MAX_RX_PAYLOAD_OUT_OF_ORDER_BUFFER
Define the size of the Rx payload buffer used to hold out of order payloads. Value must be a power of...
Definition cdi_core_api.h:122
The declarations in this header file correspond to the definitions in logger.c.
This file contains the declarations for OS functions for creating/managing/freeing threads,...
struct CdiSignalType_t * CdiSignalType
Define portable signal type. Don't use void* here, which prevents the compiler from type checking.
Definition cdi_os_api.h:189
pthread_mutex_t * CdiCsID
Define portable critical section.
Definition cdi_os_api.h:192
struct CdiThreadID_t * CdiThreadID
Define portable thread type. Separate name from type, otherwise the typedef that follows it will gene...
Definition cdi_os_api.h:312
This file declares the public API data types, structures and functions that comprise the CDI Pool Uti...
The declarations in this header file correspond to the definitions in queue.c.
struct CdiQueueState * CdiQueueHandle
Type used as the handle (pointer to an opaque structure) for a queue. Each handle represents a instan...
Definition cdi_queue_api.h:32
CdiConnectionProtocolType
This enumeration is used in the CdiConnectionState structure to indicate what connection layer is bei...
Definition cdi_utility_api.h:71
The declarations in this header file correspond to the definitions in cloudwatch_sdk_metrics....
struct CloudWatchSdkMetrics * CloudWatchSdkMetricsHandle
Type used as the handle (pointer to an opaque structure) for managing statistics for a connection....
Definition cloudwatch_sdk_metrics.h:29
This header file contains definitions used to define the build configuration of the CDI SDK's impleme...
#define MAX_IP_STRING_LENGTH
Maximum IP string length.
Definition configuration.h:86
The declarations in this header file correspond to the definitions in fifo.c.
The declarations in this header file correspond to the definitions in list.c. Many of the functions h...
The declarations in this header file correspond to the definitions in payload.c.
CdiPayloadType
Enumeration used to identify packet type.
Definition payload.h:30
CdiPayloadState
Enumeration used to maintain payload state.
Definition private.h:231
@ kPayloadError
Payload received an error and has not yet been sent; transition to Ignore when sent.
Definition private.h:235
@ kPayloadPacketZeroPending
Payload is waiting for packet 0.
Definition private.h:233
@ kPayloadInProgress
Payload is in progress.
Definition private.h:234
@ kPayloadIdle
Payload state is not in use yet.
Definition private.h:232
@ kPayloadIgnore
Error payload has been sent and we now ignore packets for it.
Definition private.h:236
@ kPayloadComplete
Payload has completed but has not been sent; transition to Idle when sent.
Definition private.h:237
void(* CdiCallback)(const void *param_ptr)
Generic type used to pass Tx/Rx callbacks to internal functions.
Definition private.h:164
ConnectionHandleType
This enumeration is used in the CdiConnectionState and CdiEndpointState structures to indicate which ...
Definition private.h:97
@ kHandleTypeTx
Transmitter type handle.
Definition private.h:98
@ kHandleTypeRx
Receiver type handle.
Definition private.h:99
struct ReceiveBufferState * ReceiveBufferHandle
Forward reference of structure to create pointers later.
Definition private.h:90
struct EndpointManagerState * EndpointManagerHandle
Forward reference of structure to create pointers later.
Definition private.h:80
struct EndpointManagerGlobalState * EndpointManagerGlobalHandle
Forward reference of structure to create pointers later.
Definition private.h:38
struct SdkLogState * SdkLogHandle
Forward reference of structure to create pointers later.
Definition private.h:197
CdiBackPressureState
This enumeration is used to indicate the current backpressure state of a connection.
Definition private.h:361
@ kCdiBackPressureNone
Definition private.h:362
@ kCdiBackPressureActive
Back pressure is currently active due to unable to allocate resources, so throwing away payloads.
Definition private.h:364
struct AdapterEndpointState * AdapterEndpointHandle
Forward reference of structure to create pointers later.
Definition private.h:72
struct StatisticsState * StatisticsHandle
Forward reference of structure to create pointers later.
Definition private.h:84
CdiGlobalContext cdi_global_context
The one global variable defined by the SDK containing all of its state information.
Definition internal.c:44
struct CdiStatsCallbackState * CdiStatsCallbackHandle
Forward reference of structure to create pointers later.
Definition private.h:86
#define MAX_CDI_PACKET_EXTRA_DATA
Maximum number of bytes for CDI packet #0 extra data.
Definition private_avm.h:79
This file defines all the methods required for a singly linked list. A tail pointer is provided in or...
Structure used to hold adapter connection state.
Definition adapter_api.h:254
Structure used to hold adapter endpoint state.
Definition adapter_api.h:110
This defines a structure that contains all of the data required to use the application registered pay...
Definition private.h:106
CdiCoreExtraData core_extra_data
Core extra data.
Definition private.h:111
CdiSgList tx_source_sgl
For Tx connection, Tx payload source SGL that needs to be freed.
Definition private.h:122
CdiReturnStatus payload_status_code
Status of the payload.
Definition private.h:109
char * error_message_str
Pointer to error message string. It uses a pool, so must be freed after the user-registered callback ...
Definition private.h:126
CdiSgList payload_sgl
Scatter-Gather List for the payload.
Definition private.h:116
uint64_t tx_start_time_microseconds
Payload Tx start time in microseconds since epoch. NOTE: Only valid for protocols 2 and later.
Definition private.h:129
CdiListEntry list_entry
Allows this structure to be used as part of a list.
Definition private.h:107
uint64_t receive_buffer_send_time
The time in microsends according to the value returned by CdiOsGetMicroseconds() at which this payloa...
Definition private.h:133
CdiUserCbParameter tx_payload_user_cb_param
For Tx connection, the payload user callback parameter that was provided in CdiCoreTxPayloadConfig.
Definition private.h:119
uint16_t extra_data_size
Size of extra data.
Definition private.h:113
Structure definition behind the handles shared with the user's application program....
Definition adapter_api.h:384
Structure definition behind the connection handles shared with the user's application program....
Definition private.h:371
CdiSignalType shutdown_signal
Signal used to shutdown connection threads.
Definition private.h:380
CdiQueueHandle app_payload_message_queue_handle
Queue of payload AppPayloadCallbackData structures.
Definition private.h:399
RxConState rx_state
The internal state of the structure if ConnectionHandleType is kHandleTypeRx.
Definition private.h:410
CdiPoolHandle error_message_pool
Pool used to hold error message strings.
Definition private.h:429
EndpointManagerHandle endpoint_manager_handle
Handle of Endpoint Manager for this connection. Manages the list of endpoints associated with this co...
Definition private.h:384
CdiBackPressureState back_pressure_state
Back pressure state.
Definition private.h:431
char saved_connection_name_str[CDI_MAX_CONNECTION_NAME_STRING_LENGTH]
Name of the connection.
Definition private.h:425
CdiAdapterState * adapter_state_ptr
The instance of the adapter this Tx/Rx object is associated with.
Definition private.h:390
CdiSignalType start_signal
Definition private.h:379
CdiEndpointState * default_tx_endpoint_ptr
The instance of the default Tx endpoint object underlying this connection.
Definition private.h:387
ConnectionHandleType handle_type
Indicates which structure of the union is valid.
Definition private.h:405
StatisticsState * stats_state_ptr
Pointer to statistics state data.
Definition private.h:414
AdapterConnectionState * adapter_connection_ptr
The instance of the adapter connection object underlying this connection.
Definition private.h:393
TxConState tx_state
The internal state of the structure if ConnectionHandleType is kHandleTypeTx.
Definition private.h:408
CdiThreadID payload_thread_id
Data for payload worker thread. Either used for TxPayloadThread().
Definition private.h:423
CdiConnectionProtocolType protocol_type
Connection protocol type.
Definition private.h:420
CdiThreadID app_payload_message_thread_id
The ID of the thread that services payload messages from the related adapter.
Definition private.h:396
uint32_t magic
Set to kMagicConnection when allocated, checked at every API function to help ensure validity.
Definition private.h:375
CdiPoolHandle linear_buffer_pool
Pool of linear buffers in which to store incoming payloads if the connection was created with kCdiLin...
Definition private.h:402
CdiListEntry list_entry
Used to store an instance of this object in a list using this element as the list item.
Definition private.h:373
CdiLogHandle log_handle
Logger handle used for this connection. If NULL, the global logger is used.
Definition private.h:427
CdiStatsCallbackHandle stats_cb_handle
Handle of currently user-registered statistics callback.
Definition private.h:417
Extra data that is sent along with payloads to the receiver. It will be provided to the receiver thro...
Definition cdi_core_api.h:340
Structure definition behind the connection handles shared with the user's application program....
Definition private.h:330
CdiConnectionState * connection_state_ptr
The instance of the connection this Tx/Rx object is associated with.
Definition private.h:335
char remote_ip_str[MAX_IP_STRING_LENGTH]
Remote IP address as a string.
Definition private.h:340
TxEndpointState tx_state
The internal state of the structure if ConnectionHandleType is kHandleTypeTx.
Definition private.h:349
char stream_name_str[CDI_MAX_STREAM_NAME_STRING_LENGTH]
Name of the stream. It is used as an identifier when generating log messages, connection callbacks an...
Definition private.h:345
AdapterEndpointState * adapter_endpoint_ptr
The instance of the adapter endpoint object underlying this endpoint.
Definition private.h:338
RxEndpointState rx_state
The internal state of the structure if ConnectionHandleType is kHandleTypeRx.
Definition private.h:351
uint32_t magic
Set to kMagicEndpoint when allocated, checked at every API function to help ensure validity.
Definition private.h:332
CdiTransferStats transfer_stats
The accumulated statistics for this endpoint.
Definition private.h:355
struct sockaddr_in remote_sockaddr_in
Remote socket address structure.
Definition private.h:341
Structure to hold variables that would otherwise be global in order to keep them contained in one man...
Definition private.h:44
CdiThreadID system_monitor_thread_id
The ID of the global system monitor thread.
Definition private.h:54
CdiSglEntry empty_sgl_entry
Empty scatter-gather-list entry.
Definition private.h:52
CdiLoggerHandle logger_handle
Handle to logger.
Definition private.h:48
CdiLogHandle global_log_handle
Handle to global log.
Definition private.h:49
CdiCsID adapter_handle_list_lock
Lock used to protect access to the adapter handle list.
Definition private.h:46
CdiList adapter_handle_list
List of network adapter CdiAdapterHandle objects.
Definition private.h:47
bool sdk_initialized
True if SDK has been initialized.
Definition private.h:45
CloudWatchSdkMetricsHandle metrics_gathering_sdk_handle
Handle of metrics gathering SDK metrics component.
Definition private.h:51
CdiSignalType shutdown_signal
Signal used to shutdown global threads.
Definition private.h:53
CloudWatchSdkMetricsHandle cw_sdk_handle
Handle of CloudWatch SDK metrics component.
Definition private.h:50
This structure represents a single list entry.
Definition list_api.h:34
This structure represents a list.
Definition list_api.h:42
Structure used to hold state data for a single log of any type (stdout, callback or file).
Definition logger.c:79
Structure used to hold state data for a single logger.
Definition logger.c:43
Structure definition behind the Scatter-Gather List internal data handles shared with the user's appl...
Definition private.h:456
CdiSgList endpoint_packet_buffer_sgl
The SGL and entries to be returned to the endpoint's free lists.
Definition private.h:469
MemoryLinearState linear_state
The internal state of the structure if handleType is HandleTypeLinear.
Definition private.h:467
CdiBufferType buffer_type
Indicates which structure of the union is valid.
Definition private.h:466
uint32_t magic
Set to kMagicMem when allocated, checked at every API function to help ensure validity.
Definition private.h:458
CdiEndpointHandle cdi_endpoint_handle
Which endpoint this belongs to. NOTE: May not be valid if endpoint has been destroyed....
Definition private.h:464
CdiConnectionHandle cdi_connection_handle
Which connection this memory state belongs to.
Definition private.h:460
Structure used to hold state data for a single payload.
Definition payload.h:41
This structure represents the current state of a memory pool.
Definition pool.c:46
Structure containing top, bottom pointers and sequence numbers of sgls that comprise payload....
Definition private.h:220
uint16_t top_sequence_num
Sequence number of the packet sitting at the top of this sgl.
Definition private.h:223
CdiReorderList * prev_ptr
Previous pointer to neighboring lists for this sgl.
Definition private.h:221
uint16_t bot_sequence_num
Sequence number of the packet sitting at the bottom of this sgl.
Definition private.h:224
CdiReorderList * next_ptr
Next pointer to neighboring lists for this sgl.
Definition private.h:222
CdiSgList sglist
Sgl in this reorder list.
Definition private.h:225
Configuration data used by one of the Cdi...RxCreate() API functions.
Definition cdi_core_api.h:760
This structure defines a scatter-gather list (SGL) which is used to represent an array of data compri...
Definition cdi_core_api.h:728
This structure represents a single, contiguous region of memory as part of a scatter-gather list.
Definition cdi_core_api.h:709
This structure represents a list.
Definition singly_linked_list_api.h:56
Transfer statistics data. Used as a parameter of the user-registered CdiCoreStatsCallback() API funct...
Definition cdi_core_api.h:572
Configuration data used by one of the Cdi...TxCreate() API functions.
Definition cdi_core_api.h:624
This defines a structure that contains all the state information for endpoint state changes.
Definition endpoint_manager.c:88
This defines a structure used to contain all of the state information for a linear buffer.
Definition private.h:445
void * virtual_address
Pointer to structure to free buffer(s).
Definition private.h:446
uint64_t physical_address
Physical address.
Definition private.h:447
uint32_t byte_size
Size of buffer in bytes.
Definition private.h:448
Definition receive_buffer.c:29
This defines a structure that contains all of the state information for an rx connection....
Definition private.h:267
CdiPoolHandle payload_memory_state_pool_handle
Memory pool for payload memory state entries (CdiMemoryState).
Definition private.h:272
CdiCallback cb_ptr
Callback function address.
Definition private.h:270
CdiPoolHandle rx_payload_state_pool_handle
Pool used to hold state data while receiving payloads.
Definition private.h:279
bool received_first_payload
This is true if the first payload has been received after a connection has been established....
Definition private.h:284
ReceiveBufferHandle receive_buffer_handle
Handle to the receive buffer object if the receive delay buffer is enabled. If the receive delay buff...
Definition private.h:293
CdiRxConfigData config_data
Copy of the configuration data. Copies of strings are made and are then referenced in this structure.
Definition private.h:269
CdiPoolHandle payload_sgl_entry_pool_handle
Memory pool for payload SGL entries (CdiSglEntry).
Definition private.h:273
CdiPoolHandle reorder_entries_pool_handle
Memory pool for payload SGL entries that arrive out of order (CdiReorderList).
Definition private.h:276
CdiQueueHandle active_payload_complete_queue_handle
Handle to the queue into which completely and ordered received paylaods are to be placed to be sent t...
Definition private.h:289
This defines a structure that contains the state information for an Rx endpoint. The data is only req...
Definition private.h:309
int rxreorder_buffered_packet_count
The number of packets that are currently buffered in the Rx payload reorder process.
Definition private.h:323
uint32_t total_packet_count
The total number of packets received since the connection was established. Value wraps to zero,...
Definition private.h:312
int rxreorder_current_index
The current payload_state_array_ptr index that is pending completion or an error state,...
Definition private.h:321
CdiQueueHandle free_buffer_queue_handle
Circular queue of CdiSgList structures.
Definition private.h:314
This defines a structure that contains all of the state information for the receiving side of a paylo...
Definition private.h:244
RxPayloadWorkRequestState work_request_state
Rx work request state.
Definition private.h:249
int expected_payload_data_size
Expected total payload size in bytes obtained from CDI packet #0 header.
Definition private.h:256
CdiListEntry list_entry
Allows this structure to be used as part of a list.
Definition private.h:245
int payload_num
Payload number obtained from CDI packet #0 header.
Definition private.h:251
uint32_t last_total_packet_count
Value of total_packet_count when most recent packet of the payload was received.
Definition private.h:259
int data_bytes_received
Number of payload bytes received.
Definition private.h:257
CdiPayloadState payload_state
Current processing state of this payload (ie. idle, in progress, etc).
Definition private.h:247
CdiReorderList * reorder_list_ptr
Pointer to what will end up being the single SGL that comprises the payload.
Definition private.h:258
bool suspend_warnings
Use this flag to suspend packet warnings for a payload.
Definition private.h:255
int packet_count
Number of Rx packets in this payload.
Definition private.h:252
int ignore_packet_count
Number of Rx packets received since payload was set to ignore state.
Definition private.h:253
uint8_t * linear_buffer_ptr
Address to be used if assembling into a linear buffer.
Definition private.h:260
This defines a structure that contains all of the state information for the receiving side of a paylo...
Definition private.h:204
uint64_t start_time
Time payload Rx started.
Definition private.h:210
AppPayloadCallbackData app_payload_cb_data
Used to hold data for application payload callback.
Definition private.h:208
CdiMemoryState * payload_memory_state_ptr
Pointer to memory state of the Rx payload.
Definition private.h:206
uint32_t max_latency_microsecs
Maximum latency in microseconds of time to transmit the payload.
Definition private.h:211
CdiPayloadType payload_type
Payload type from CDI packet #0 header (app or keep alive).
Definition private.h:205
Structure used to hold state data for statistics.
Definition statistics.c:70
This defines a structure that contains all of the state information for the sending side of a single ...
Definition private.h:169
CdiCallback cb_ptr
Callback function address.
Definition private.h:174
CdiPoolHandle payload_state_pool_handle
Memory pool for payload state (TxPayloadState).
Definition private.h:179
CdiQueueHandle payload_queue_handle
Queue of TxPayloadState structures.
Definition private.h:176
CdiTxConfigData config_data
Copy of the configuration data. Copies of strings are made and are then referenced in this structure.
Definition private.h:173
CdiPoolHandle payload_sgl_entry_pool_handle
Memory pool for payload SGL entries (CdiSglEntry). Not thread-safe.
Definition private.h:182
CdiPoolHandle packet_sgl_entry_pool_handle
Memory pool for packet SGL entries (CdiSglEntry). Not thread-safe.
Definition private.h:188
CdiPoolHandle work_request_pool_handle
Memory pool for work requests (TxPacketWorkRequest). Not thread-safe.
Definition private.h:185
CdiQueueHandle work_req_comp_queue_handle
Queue of completed work requests that need their resources freed (TxPacketWorkRequest*).
Definition private.h:191
This defines a structure that contains the state information for the sending side's endpoint of a sin...
Definition private.h:299
uint32_t packet_id
Packet ID. Increments by 1 for each packet sent (wraps at 0).
Definition private.h:302
uint16_t payload_num
Payload number. Increments by 1 for each payload sent.
Definition private.h:301
CdiCsID payload_num_lock
Lock used to protect incrementing the payload number.
Definition private.h:300
This defines a structure that contains all of the state information for sending a single payload.
Definition private.h:141
CdiSgList source_sgl
Scatter-Gather List of payload entries to free.
Definition private.h:142
uint32_t max_latency_microsecs
Definition private.h:144
uint64_t start_time
Time payload Tx started.
Definition private.h:143
int data_bytes_transferred
Number of application payload data bytes transferred.
Definition private.h:153
int group_size_bytes
The size of the units (pixels, audio samples, etc.) in bytes making up the payload....
Definition private.h:147
CdiPayloadPacketState payload_packet_state
CDI packet state data.
Definition private.h:151
AppPayloadCallbackData app_payload_cb_data
Used to hold data for application payload callback.
Definition private.h:149
CdiSinglyLinkedList completed_packets_list
List of packets for current payload that have been acknowledged.
Definition private.h:154
CdiEndpointHandle cdi_endpoint_handle
CDI endpoint to use to send this payload.
Definition private.h:156