Skip to content

Commit 8f088ee

Browse files
Add answer call timestamp
1 parent a55cced commit 8f088ee

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

MatrixSDK/VoIP/MXCall.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ @interface MXCall ()
6767
The date when the communication has been established.
6868
*/
6969
NSDate *callConnectedDate;
70+
71+
/**
72+
The date for gk.call.answer timestamp event
73+
*/
74+
NSDate *answerConnectedDate;
7075

7176
/**
7277
The total duration of the call. It is computed when the call ends.
@@ -968,7 +973,11 @@ - (NSUInteger)duration
968973

969974
if (MXCallStateConnected == _state)
970975
{
971-
duration = [[NSDate date] timeIntervalSinceDate:callConnectedDate] * 1000;
976+
if (answerConnectedDate) {
977+
duration = [[NSDate date] timeIntervalSinceDate: answerConnectedDate] * 1000;
978+
} else {
979+
duration = [[NSDate date] timeIntervalSinceDate: callConnectedDate] * 1000;
980+
}
972981
}
973982
else if (MXCallStateEnded == _state)
974983
{
@@ -1217,6 +1226,11 @@ - (void)handleCallAnswer:(MXEvent *)event
12171226
{
12181227
MXLogDebug(@"[MXCall][%@] handleCallAnswer", _callId)
12191228

1229+
if (_isGkCall) {
1230+
// reset call connected date
1231+
answerConnectedDate = [NSDate dateWithTimeIntervalSince1970: (event.originServerTs / 1000)];
1232+
}
1233+
12201234
if ([self isMyEvent:event])
12211235
{
12221236
return;

0 commit comments

Comments
 (0)