Skip to content

Commit

Permalink
Profile create peer connection
Browse files Browse the repository at this point in the history
  • Loading branch information
disa6302 committed Jul 27, 2023
1 parent e9729b1 commit 35dbe0e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/include/com/amazonaws/kinesis/video/webrtcclient/Stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ typedef struct {
*/
typedef struct {
UINT64 localCandidateGatheringTime;
UINT64 hostCandidateSetUpTime;
UINT64 srflxCandidateSetUpTime;
UINT64 relayCandidateSetUpTime;
UINT64 iceServerParsingTime;
UINT64 iceCandidatePairNominationTime;
UINT64 candidateGatheringTime;
Expand Down Expand Up @@ -604,10 +607,11 @@ typedef struct {
} SignalingClientStats, *PSignalingClientStats;

typedef struct {
UINT64 dtlsSessionSetupTime; //!< Time taken (ms) for DTLS handshake to complete
UINT64 iceHolePunchingTime; //!< Time taken (ms) for ICE agent set up to complete
UINT64 closePeerConnectionTime; //!< Time taken (ms) to close the peer connection
UINT64 freePeerConnectionTime; //!< Time taken (ms) to free the peer connection object
UINT64 peerConnectionCreationTime; //!< Time taken (ms) for peer connection object creation time
UINT64 dtlsSessionSetupTime; //!< Time taken (ms) for DTLS handshake to complete
UINT64 iceHolePunchingTime; //!< Time taken (ms) for ICE agent set up to complete
UINT64 closePeerConnectionTime; //!< Time taken (ms) to close the peer connection
UINT64 freePeerConnectionTime; //!< Time taken (ms) to free the peer connection object
} PeerConnectionStats, *PPeerConnectionStats;

/**
Expand Down
12 changes: 9 additions & 3 deletions src/source/Ice/IceAgent.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,14 @@ STATUS iceAgentStartGathering(PIceAgent pIceAgent)
pIceAgent->kvsRtcConfiguration.iceSetInterfaceFilterFunc,
pIceAgent->kvsRtcConfiguration.filterCustomData)),
pIceAgent->iceAgentProfileDiagnostics.localCandidateGatheringTime, "Host candidate gathering from local interfaces");
CHK_STATUS(iceAgentInitHostCandidate(pIceAgent));
CHK_STATUS(iceAgentInitSrflxCandidate(pIceAgent));
PROFILE_CALL_WITH_T_OBJ(CHK_STATUS(iceAgentInitHostCandidate(pIceAgent)), pIceAgent->iceAgentProfileDiagnostics.hostCandidateSetUpTime,
"Host candidates setup time");
PROFILE_CALL_WITH_T_OBJ(CHK_STATUS(iceAgentInitSrflxCandidate(pIceAgent)), pIceAgent->iceAgentProfileDiagnostics.srflxCandidateSetUpTime,
"Srflx candidates setup time");
}

CHK_STATUS(iceAgentInitRelayCandidates(pIceAgent));
PROFILE_CALL_WITH_T_OBJ(CHK_STATUS(iceAgentInitRelayCandidates(pIceAgent)), pIceAgent->iceAgentProfileDiagnostics.relayCandidateSetUpTime,
"Relay candidates setup time");

// start listening for incoming data
CHK_STATUS(connectionListenerStart(pIceAgent->pConnectionListener));
Expand Down Expand Up @@ -2812,6 +2815,9 @@ STATUS getIceAgentStats(PIceAgent pIceAgent, PKvsIceAgentMetrics pKvsIceAgentMet
UINT32 i = 0;
CHK(pIceAgent != NULL && pKvsIceAgentMetrics != NULL, STATUS_NULL_ARG);
pKvsIceAgentMetrics->kvsIceAgentStats.localCandidateGatheringTime = pIceAgent->iceAgentProfileDiagnostics.localCandidateGatheringTime;
pKvsIceAgentMetrics->kvsIceAgentStats.hostCandidateSetUpTime = pIceAgent->iceAgentProfileDiagnostics.hostCandidateSetUpTime;
pKvsIceAgentMetrics->kvsIceAgentStats.srflxCandidateSetUpTime = pIceAgent->iceAgentProfileDiagnostics.srflxCandidateSetUpTime;
pKvsIceAgentMetrics->kvsIceAgentStats.relayCandidateSetUpTime = pIceAgent->iceAgentProfileDiagnostics.relayCandidateSetUpTime;
for (i = 0; i < MAX_ICE_SERVERS_COUNT; i++) {
pKvsIceAgentMetrics->kvsIceAgentStats.iceServerParsingTime += pIceAgent->iceAgentProfileDiagnostics.iceServerParsingTime[i];
}
Expand Down
3 changes: 3 additions & 0 deletions src/source/Ice/IceAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ typedef struct {

typedef struct {
UINT64 localCandidateGatheringTime;
UINT64 hostCandidateSetUpTime;
UINT64 srflxCandidateSetUpTime;
UINT64 relayCandidateSetUpTime;
UINT64 iceServerParsingTime[MAX_ICE_SERVERS_COUNT];
UINT64 iceCandidatePairNominationTime;
UINT64 candidateGatheringTime;
Expand Down
6 changes: 6 additions & 0 deletions src/source/PeerConnection/PeerConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,11 @@ STATUS createPeerConnection(PRtcConfiguration pConfiguration, PRtcPeerConnection
IceAgentCallbacks iceAgentCallbacks;
DtlsSessionCallbacks dtlsSessionCallbacks;
PConnectionListener pConnectionListener = NULL;
UINT64 startTime = 0;

CHK(pConfiguration != NULL && ppPeerConnection != NULL, STATUS_NULL_ARG);

startTime = GETTIME();
MEMSET(&iceAgentCallbacks, 0, SIZEOF(IceAgentCallbacks));
MEMSET(&dtlsSessionCallbacks, 0, SIZEOF(DtlsSessionCallbacks));

Expand Down Expand Up @@ -756,6 +758,9 @@ STATUS createPeerConnection(PRtcConfiguration pConfiguration, PRtcPeerConnection

if (STATUS_FAILED(retStatus)) {
freePeerConnection((PRtcPeerConnection*) &pKvsPeerConnection);
} else {
PROFILE_WITH_START_TIME_OBJ(startTime, pKvsPeerConnection->peerConnectionDiagnostics.peerConnectionCreationTime,
"Peer connection object creation time");
}

LEAVES();
Expand Down Expand Up @@ -1508,6 +1513,7 @@ STATUS peerConnectionGetMetrics(PRtcPeerConnection pPeerConnection, PPeerConnect
DLOGW("Peer connection metrics object version invalid..setting to highest default version %d", PEER_CONNECTION_METRICS_CURRENT_VERSION);
pPeerConnectionMetrics->version = PEER_CONNECTION_METRICS_CURRENT_VERSION;
}
pPeerConnectionMetrics->peerConnectionStats.peerConnectionCreationTime = pKvsPeerConnection->peerConnectionDiagnostics.peerConnectionCreationTime;
pPeerConnectionMetrics->peerConnectionStats.dtlsSessionSetupTime = pKvsPeerConnection->peerConnectionDiagnostics.dtlsSessionSetupTime;
pPeerConnectionMetrics->peerConnectionStats.iceHolePunchingTime = pKvsPeerConnection->peerConnectionDiagnostics.iceHolePunchingTime;
// Cannot record these 2 in here because peer connection object would become NULL after clearing. Need another strategy
Expand Down
1 change: 1 addition & 0 deletions src/source/PeerConnection/PeerConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef struct {
} TwccManager, *PTwccManager;

typedef struct {
UINT64 peerConnectionCreationTime;
UINT64 dtlsSessionSetupTime;
UINT64 iceHolePunchingTime;
UINT64 closePeerConnectionTime;
Expand Down

0 comments on commit 35dbe0e

Please sign in to comment.