#include "../Include_i.h"
Macros | |
| #define | LOG_CLASS "IceAgent" |
| #define | MARK_STUNS_SRFLX_CANDIDATE_INVALID(logFn, candidate, ...) |
Functions | |
| STATUS | createIceAgent (PCHAR username, PCHAR password, PIceAgentCallbacks pIceAgentCallbacks, PRtcConfiguration pRtcConfiguration, TIMER_QUEUE_HANDLE timerQueueHandle, PConnectionListener pConnectionListener, PIceAgent *ppIceAgent) |
| STATUS | iceAgentStopConnectionListener (PIceAgent pIceAgent) |
| STATUS | freeIceAgent (PIceAgent *ppIceAgent) |
| STATUS | iceAgentAddIceServers (PIceAgent pIceAgent, PRtcIceServer pIceServers, UINT32 iceServersCount) |
| STATUS | iceAgentValidateKvsRtcConfig (PKvsRtcConfiguration pKvsRtcConfiguration) |
| STATUS | iceAgentReportNewLocalCandidate (PIceAgent pIceAgent, PIceCandidate pIceCandidate) |
| STATUS | iceAgentAddRemoteCandidate (PIceAgent pIceAgent, PCHAR pIceCandidateString) |
| STATUS | iceAgentInitHostCandidate (PIceAgent pIceAgent) |
| STATUS | iceAgentStartAgent (PIceAgent pIceAgent, PCHAR remoteUsername, PCHAR remotePassword, BOOL isControlling) |
| STATUS | iceAgentStartGathering (PIceAgent pIceAgent) |
| STATUS | iceAgentSendPacket (PIceAgent pIceAgent, PBYTE pBuffer, UINT32 bufferLen) |
| STATUS | iceAgentPopulateSdpMediaDescriptionCandidates (PIceAgent pIceAgent, PSdpMediaDescription pSdpMediaDescription, UINT32 attrBufferLen, PUINT32 pIndex) |
| STATUS | iceAgentShutdown (PIceAgent pIceAgent) |
| STATUS | iceAgentRestart (PIceAgent pIceAgent, PCHAR localIceUfrag, PCHAR localIcePwd) |
| STATUS | findCandidateWithIp (PKvsIpAddress pIpAddress, PDoubleList pCandidateList, PIceCandidate *ppIceCandidate) |
| STATUS | findCandidateWithSocketConnection (PSocketConnection pSocketConnection, PDoubleList pCandidateList, PIceCandidate *ppIceCandidate) |
| STATUS | createIceCandidatePairs (PIceAgent pIceAgent, PIceCandidate pIceCandidate, BOOL isRemoteCandidate) |
| STATUS | freeIceCandidatePair (PIceCandidatePair *ppIceCandidatePair) |
| STATUS | insertIceCandidatePair (PDoubleList iceCandidatePairs, PIceCandidatePair pIceCandidatePair) |
| STATUS | findIceCandidatePairWithLocalSocketConnectionAndRemoteAddr (PIceAgent pIceAgent, PSocketConnection pSocketConnection, PKvsIpAddress pRemoteAddr, BOOL checkPort, PIceCandidatePair *ppIceCandidatePair) |
| STATUS | pruneUnconnectedIceCandidatePair (PIceAgent pIceAgent) |
| STATUS | iceCandidatePairCheckConnection (PStunPacket pStunBindingRequest, PIceAgent pIceAgent, PIceCandidatePair pIceCandidatePair) |
| STATUS | iceAgentSendStunPacket (PStunPacket pStunPacket, PBYTE password, UINT32 passwordLen, PIceAgent pIceAgent, PIceCandidate pLocalCandidate, PKvsIpAddress pDestAddr) |
| STATUS | iceAgentStateTransitionTimerCallback (UINT32 timerId, UINT64 currentTime, UINT64 customData) |
| STATUS | iceAgentSendSrflxCandidateRequest (PIceAgent pIceAgent) |
| STATUS | iceAgentCheckCandidatePairConnection (PIceAgent pIceAgent) |
| STATUS | iceAgentSendKeepAliveTimerCallback (UINT32 timerId, UINT64 currentTime, UINT64 customData) |
| STATUS | iceAgentGatherCandidateTimerCallback (UINT32 timerId, UINT64 currentTime, UINT64 customData) |
| STATUS | iceAgentSendCandidateNomination (PIceAgent pIceAgent) |
| STATUS | iceAgentInitSrflxCandidate (PIceAgent pIceAgent) |
| STATUS | iceAgentInitRelayCandidates (PIceAgent pIceAgent) |
| STATUS | turnStateFailedFn (PSocketConnection pSocketConnection, UINT64 data) |
| STATUS | iceAgentInitRelayCandidate (PIceAgent pIceAgent, UINT32 iceServerIndex, KVS_SOCKET_PROTOCOL protocol, KVS_IP_FAMILY_TYPE turnServerIpFamily) |
| STATUS | iceAgentCheckConnectionStateSetup (PIceAgent pIceAgent) |
| STATUS | updateCandidateStats (PIceAgent pIceAgent, BOOL isRemote) |
| STATUS | updateSelectedLocalRemoteCandidateStats (PIceAgent pIceAgent) |
| STATUS | iceAgentConnectedStateSetup (PIceAgent pIceAgent) |
| STATUS | iceAgentNominatingStateSetup (PIceAgent pIceAgent) |
| STATUS | iceAgentReadyStateSetup (PIceAgent pIceAgent) |
| STATUS | iceAgentNominateCandidatePair (PIceAgent pIceAgent) |
| STATUS | iceAgentInvalidateCandidatePair (PIceAgent pIceAgent) |
| STATUS | incomingRelayedDataHandler (UINT64 customData, PSocketConnection pSocketConnection, PBYTE pBuffer, UINT32 bufferLen, PKvsIpAddress pSrc, PKvsIpAddress pDest) |
| STATUS | incomingDataHandler (UINT64 customData, PSocketConnection pSocketConnection, PBYTE pBuffer, UINT32 bufferLen, PKvsIpAddress pSrc, PKvsIpAddress pDest) |
| STATUS | iceCandidateSerialize (PIceCandidate pIceCandidate, PCHAR pOutputData, PUINT32 pOutputLength) |
| STATUS | iceAgentDeserializeBindingRequest (PBYTE pBuffer, UINT32 bufferLen, PCHAR localUsername, PCHAR localPassword, PStunPacket *ppStunPacket) |
| UINT16 | iceAgentGetBindingErrorCode (STATUS status) |
| STATUS | iceAgentCreateBindingErrorResponse (PBYTE transactionId, UINT16 errorCode, PStunPacket *ppStunResponse) |
| STATUS | iceAgentSendBindingErrorResponse (PIceAgent pIceAgent, PBYTE transactionId, UINT16 errorCode, PSocketConnection pSocketConnection, PKvsIpAddress pDestAddr) |
| STATUS | handleStunPacket (PIceAgent pIceAgent, PBYTE pBuffer, UINT32 bufferLen, PSocketConnection pSocketConnection, PKvsIpAddress pSrcAddr, PKvsIpAddress pDestAddr, PSocketConnection *ppSocketConnectionToShutdown) |
| STATUS | iceAgentCheckPeerReflexiveCandidate (PIceAgent pIceAgent, PKvsIpAddress pIpAddress, UINT32 priority, BOOL isRemote, PSocketConnection pSocketConnection) |
| STATUS | iceAgentFatalError (PIceAgent pIceAgent, STATUS errorStatus) |
| VOID | iceAgentLogNewCandidate (PIceCandidate pIceCandidate) |
| STATUS | updateCandidateAddress (PIceCandidate pIceCandidate, PKvsIpAddress pIpAddr) |
| UINT32 | computeCandidatePriority (PIceCandidate pIceCandidate) |
| UINT64 | computeCandidatePairPriority (PIceCandidatePair pIceCandidatePair, BOOL isLocalControlling) |
| PCHAR | iceAgentGetCandidateTypeStr (ICE_CANDIDATE_TYPE candidateType) |
| UINT64 | iceAgentGetCurrentTime (UINT64 customData) |
| STATUS | getIceAgentStats (PIceAgent pIceAgent, PKvsIceAgentMetrics pKvsIceAgentMetrics) |
Variables | |
| StateMachineState | ICE_AGENT_STATE_MACHINE_STATES [] |
| UINT32 | ICE_AGENT_STATE_MACHINE_STATE_COUNT |
| #define LOG_CLASS "IceAgent" |
Ice Agent APIs
| #define MARK_STUNS_SRFLX_CANDIDATE_INVALID | ( | logFn, | |
| candidate, | |||
| ... ) |
| UINT64 computeCandidatePairPriority | ( | PIceCandidatePair | pIceCandidatePair, |
| BOOL | isLocalControlling ) |

| UINT32 computeCandidatePriority | ( | PIceCandidate | pIceCandidate | ) |

| STATUS createIceAgent | ( | PCHAR | username, |
| PCHAR | password, | ||
| PIceAgentCallbacks | pIceAgentCallbacks, | ||
| PRtcConfiguration | pRtcConfiguration, | ||
| TIMER_QUEUE_HANDLE | timerQueueHandle, | ||
| PConnectionListener | pConnectionListener, | ||
| PIceAgent * | ppIceAgent ) |
allocate the IceAgent struct and store username and password
| - | PCHAR - IN - username |
| - | PCHAR - IN - password |
| - | PIceAgentCallbacks - IN - callback for inbound packets |
| - | PRtcConfiguration - IN - RtcConfig |
| - | PIceAgent* - OUT - the created IceAgent struct |


| STATUS createIceCandidatePairs | ( | PIceAgent | pIceAgent, |
| PIceCandidate | pIceCandidate, | ||
| BOOL | isRemoteCandidate ) |


| STATUS findCandidateWithIp | ( | PKvsIpAddress | pIpAddress, |
| PDoubleList | pCandidateList, | ||
| PIceCandidate * | ppIceCandidate ) |

| STATUS findCandidateWithSocketConnection | ( | PSocketConnection | pSocketConnection, |
| PDoubleList | pCandidateList, | ||
| PIceCandidate * | ppIceCandidate ) |

| STATUS findIceCandidatePairWithLocalSocketConnectionAndRemoteAddr | ( | PIceAgent | pIceAgent, |
| PSocketConnection | pSocketConnection, | ||
| PKvsIpAddress | pRemoteAddr, | ||
| BOOL | checkPort, | ||
| PIceCandidatePair * | ppIceCandidatePair ) |

| STATUS freeIceAgent | ( | PIceAgent * | ppIceAgent | ) |
Not thread-safe
| ppIceAgent |


| STATUS freeIceCandidatePair | ( | PIceCandidatePair * | ppIceCandidatePair | ) |


| STATUS getIceAgentStats | ( | PIceAgent | pIceAgent, |
| PKvsIceAgentMetrics | pKvsIceAgentMetrics ) |

| STATUS handleStunPacket | ( | PIceAgent | pIceAgent, |
| PBYTE | pBuffer, | ||
| UINT32 | bufferLen, | ||
| PSocketConnection | pSocketConnection, | ||
| PKvsIpAddress | pSrcAddr, | ||
| PKvsIpAddress | pDestAddr, | ||
| PSocketConnection * | ppSocketConnectionToShutdown ) |


| STATUS iceAgentAddIceServers | ( | PIceAgent | pIceAgent, |
| PRtcIceServer | pIceServers, | ||
| UINT32 | iceServersCount ) |
Add new ICE servers to an existing ICE agent and initialize relay candidates for TURN servers
| - | PIceAgent - IN - IceAgent object |
| - | PRtcIceServer - IN - Array of new ICE servers to add |
| - | UINT32 - IN - Number of ICE servers in the array |


| STATUS iceAgentAddRemoteCandidate | ( | PIceAgent | pIceAgent, |
| PCHAR | pIceCandidateString ) |
if PIceCandidate doesnt exist already in remoteCandidates, create a copy and add to remoteCandidates
| - | PIceAgent - IN - IceAgent object |
| - | PIceCandidate - IN - new remote candidate to add |


| STATUS iceAgentCheckCandidatePairConnection | ( | PIceAgent | pIceAgent | ) |


| STATUS iceAgentCheckConnectionStateSetup | ( | PIceAgent | pIceAgent | ) |


| STATUS iceAgentCheckPeerReflexiveCandidate | ( | PIceAgent | pIceAgent, |
| PKvsIpAddress | pIpAddress, | ||
| UINT32 | priority, | ||
| BOOL | isRemote, | ||
| PSocketConnection | pSocketConnection ) |


| STATUS iceAgentConnectedStateSetup | ( | PIceAgent | pIceAgent | ) |


| STATUS iceAgentCreateBindingErrorResponse | ( | PBYTE | transactionId, |
| UINT16 | errorCode, | ||
| PStunPacket * | ppStunResponse ) |
Creates the error response to an unauthenticated Binding request: ERROR-CODE, and no MESSAGE-INTEGRITY or USERNAME (RFC 8489 section 9.1.3)
| - | PBYTE - IN - the request's transaction ID |
| - | UINT16 - IN - STUN error code, 400 or 401 |
| - | PStunPacket* - OUT - the error response |


| STATUS iceAgentDeserializeBindingRequest | ( | PBYTE | pBuffer, |
| UINT32 | bufferLen, | ||
| PCHAR | localUsername, | ||
| PCHAR | localPassword, | ||
| PStunPacket * | ppStunPacket ) |
Authenticates and deserializes a Binding request, with the checks of RFC 8489 section 9.1.3 in their order: MESSAGE-INTEGRITY and USERNAME present, USERNAME valid, MESSAGE-INTEGRITY verified. A valid USERNAME's value before the colon is the local ufrag (RFC 8445 section 7.3); the part after it is not compared, as a check can arrive before the remote description.
| - | PBYTE - IN - Binding request |
| - | UINT32 - IN - its size |
| - | PCHAR - IN - local ufrag |
| - | PCHAR - IN - local password |
| - | PStunPacket* - OUT - the deserialized request |


| STATUS iceAgentFatalError | ( | PIceAgent | pIceAgent, |
| STATUS | errorStatus ) |

| STATUS iceAgentGatherCandidateTimerCallback | ( | UINT32 | timerId, |
| UINT64 | currentTime, | ||
| UINT64 | customData ) |


| UINT16 iceAgentGetBindingErrorCode | ( | STATUS | status | ) |
The error code RFC 8489 section 9.1.3 answers a Binding request with when iceAgentDeserializeBindingRequest() failed: 400 without MESSAGE-INTEGRITY or USERNAME, 401 for another USERNAME or a wrong MESSAGE-INTEGRITY
| - | STATUS - IN - what iceAgentDeserializeBindingRequest() returned |

| PCHAR iceAgentGetCandidateTypeStr | ( | ICE_CANDIDATE_TYPE | candidateType | ) |

| UINT64 iceAgentGetCurrentTime | ( | UINT64 | customData | ) |

| STATUS iceAgentInitHostCandidate | ( | PIceAgent | pIceAgent | ) |
gather local IP addresses and create a udp port. If port creation succeeded then create a new candidate and store it in localCandidates. Ips that are already a local candidate will not be added again.


| STATUS iceAgentInitRelayCandidate | ( | PIceAgent | pIceAgent, |
| UINT32 | iceServerIndex, | ||
| KVS_SOCKET_PROTOCOL | protocol, | ||
| KVS_IP_FAMILY_TYPE | turnServerIpFamily ) |


| STATUS iceAgentInitRelayCandidates | ( | PIceAgent | pIceAgent | ) |


| STATUS iceAgentInitSrflxCandidate | ( | PIceAgent | pIceAgent | ) |


| STATUS iceAgentInvalidateCandidatePair | ( | PIceAgent | pIceAgent | ) |

| VOID iceAgentLogNewCandidate | ( | PIceCandidate | pIceCandidate | ) |


| STATUS iceAgentNominateCandidatePair | ( | PIceAgent | pIceAgent | ) |


| STATUS iceAgentNominatingStateSetup | ( | PIceAgent | pIceAgent | ) |


| STATUS iceAgentPopulateSdpMediaDescriptionCandidates | ( | PIceAgent | pIceAgent, |
| PSdpMediaDescription | pSdpMediaDescription, | ||
| UINT32 | attrBufferLen, | ||
| PUINT32 | pIndex ) |
Starting from given index, fillout PSdpMediaDescription->sdpAttributes with serialize local candidate strings.
| - | PIceAgent - IN - IceAgent object |
| - | PSdpMediaDescription - IN - PSdpMediaDescription object whose sdpAttributes will be filled with local candidate strings |
| - | UINT32 - IN - buffer length of pSdpMediaDescription->sdpAttributes[index].attributeValue |
| - | PUINT32 - IN - starting index in sdpAttributes |


| STATUS iceAgentReadyStateSetup | ( | PIceAgent | pIceAgent | ) |


| STATUS iceAgentReportNewLocalCandidate | ( | PIceAgent | pIceAgent, |
| PIceCandidate | pIceCandidate ) |


| STATUS iceAgentRestart | ( | PIceAgent | pIceAgent, |
| PCHAR | localIceUfrag, | ||
| PCHAR | localIcePwd ) |
Restart IceAgent. IceAgent is reset back to the same state when it was first created. Once iceAgentRestart() return, call iceAgentStartGathering() to start gathering and call iceAgentStartAgent() to give iceAgent the new remote uFrag and uPwd. While Ice is restarting, iceAgentSendPacket can still be called to send data if a connected pair exists.
| - | PIceAgent - IN - IceAgent object |
| - | PCHAR - IN - new local uFrag |
| - | PCHAR - IN - new local uPwd |


| STATUS iceAgentSendBindingErrorResponse | ( | PIceAgent | pIceAgent, |
| PBYTE | transactionId, | ||
| UINT16 | errorCode, | ||
| PSocketConnection | pSocketConnection, | ||
| PKvsIpAddress | pDestAddr ) |
Sends the error response to an unauthenticated Binding request, from the local candidate it reached
| - | PIceAgent - IN - IceAgent object |
| - | PBYTE - IN - the request's transaction ID |
| - | UINT16 - IN - STUN error code, 400 or 401 |
| - | PSocketConnection - IN - socket the request came in on |
| - | PKvsIpAddress - IN - where the request came from |


| STATUS iceAgentSendCandidateNomination | ( | PIceAgent | pIceAgent | ) |


| STATUS iceAgentSendKeepAliveTimerCallback | ( | UINT32 | timerId, |
| UINT64 | currentTime, | ||
| UINT64 | customData ) |


| STATUS iceAgentSendPacket | ( | PIceAgent | pIceAgent, |
| PBYTE | pBuffer, | ||
| UINT32 | bufferLen ) |
Send data through selected connection. PIceAgent has to be in ICE_AGENT_CONNECTION_STATE_CONNECTED state.
| - | PIceAgent - IN - IceAgent object |
| - | PBYTE - IN - buffer storing the data to be sent |
| - | UINT32 - IN - length of data |


| STATUS iceAgentSendSrflxCandidateRequest | ( | PIceAgent | pIceAgent | ) |


| STATUS iceAgentSendStunPacket | ( | PStunPacket | pStunPacket, |
| PBYTE | password, | ||
| UINT32 | passwordLen, | ||
| PIceAgent | pIceAgent, | ||
| PIceCandidate | pLocalCandidate, | ||
| PKvsIpAddress | pDestAddr ) |


| STATUS iceAgentShutdown | ( | PIceAgent | pIceAgent | ) |
Start shutdown sequence for IceAgent. Once the function returns the sockets are marked closed, but the connection listener thread keeps delivering packets (the one in progress and any already queued on a socket) until iceAgentStopConnectionListener() returns. Call iceAgentStopConnectionListener() before freeing anything the receive path uses. User should stop calling iceAgentSendPacket after iceAgentShutdown returns. iceAgentShutdown is idempotent.


| STATUS iceAgentStartAgent | ( | PIceAgent | pIceAgent, |
| PCHAR | remoteUsername, | ||
| PCHAR | remotePassword, | ||
| BOOL | isControlling ) |
Initiates stun communication with remote candidates.
| - | PIceAgent - IN - IceAgent object |
| - | PCHAR - IN - remote username |
| - | PCHAR - IN - remote password |
| - | BOOL - IN - is controlling agent |


| STATUS iceAgentStartGathering | ( | PIceAgent | pIceAgent | ) |
| STATUS iceAgentStateTransitionTimerCallback | ( | UINT32 | timerId, |
| UINT64 | currentTime, | ||
| UINT64 | customData ) |
timer queue callbacks are interlocked by time queue lock.
| timerId | - timer queue task id |
| currentTime | |
| customData | - custom data passed to timer queue when task was added |


| STATUS iceAgentStopConnectionListener | ( | PIceAgent | pIceAgent | ) |
Not thread-safe. Must not be called from the connection listener thread (for example from a frame, RTCP or connection state callback), since it joins that thread.


| STATUS iceAgentValidateKvsRtcConfig | ( | PKvsRtcConfiguration | pKvsRtcConfiguration | ) |

| STATUS iceCandidatePairCheckConnection | ( | PStunPacket | pStunBindingRequest, |
| PIceAgent | pIceAgent, | ||
| PIceCandidatePair | pIceCandidatePair ) |


| STATUS iceCandidateSerialize | ( | PIceCandidate | pIceCandidate, |
| PCHAR | pOutputData, | ||
| PUINT32 | pOutputLength ) |
Serialize a candidate for Trickle ICE or exchange via SDP
| - | PIceAgent - IN - IceAgent object |
| - | PCHAR - OUT - Destination buffer |
| - | UINT32 - OUT - Size of destination buffer |


| STATUS incomingDataHandler | ( | UINT64 | customData, |
| PSocketConnection | pSocketConnection, | ||
| PBYTE | pBuffer, | ||
| UINT32 | bufferLen, | ||
| PKvsIpAddress | pSrc, | ||
| PKvsIpAddress | pDest ) |


| STATUS incomingRelayedDataHandler | ( | UINT64 | customData, |
| PSocketConnection | pSocketConnection, | ||
| PBYTE | pBuffer, | ||
| UINT32 | bufferLen, | ||
| PKvsIpAddress | pSrc, | ||
| PKvsIpAddress | pDest ) |


| STATUS insertIceCandidatePair | ( | PDoubleList | iceCandidatePairs, |
| PIceCandidatePair | pIceCandidatePair ) |

| STATUS pruneUnconnectedIceCandidatePair | ( | PIceAgent | pIceAgent | ) |

| STATUS turnStateFailedFn | ( | PSocketConnection | pSocketConnection, |
| UINT64 | data ) |

| STATUS updateCandidateAddress | ( | PIceCandidate | pIceCandidate, |
| PKvsIpAddress | pIpAddr ) |

| STATUS updateCandidateStats | ( | PIceAgent | pIceAgent, |
| BOOL | isRemote ) |


| STATUS updateSelectedLocalRemoteCandidateStats | ( | PIceAgent | pIceAgent | ) |


|
extern |
|
extern |
Static definitions of the states