Skip to content

Commit

Permalink
Add functions that returns remaining time in ZRTP discovery phase.
Browse files Browse the repository at this point in the history
Patch from Damian Minkov.
  • Loading branch information
wernerd committed Apr 8, 2012
1 parent 4aef0c0 commit d4c7c66
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/gnu/java/zrtp/ZRtp.java
Expand Up @@ -971,6 +971,22 @@ public byte[] getPeerZid() {
return ret;
}

/**
* Get remaining time before a "ZRTP not supported by other party" is reported.
*
* This function calls the protocol state engine to determine how many time is left
* in ZRTP's discovery phase (Hello phase).
*
* @return Time left in milliseconds.
*/
public long getTimeoutValue() {
if(stateEngine != null) {
return stateEngine.getTimeoutValue();
}

return -1;
}

/*
* The following methods are helper functions for ZrtpStateClass.
* ZrtpStateClass calls them to prepare packets, send data, report problems,
Expand Down
16 changes: 16 additions & 0 deletions src/gnu/java/zrtp/ZrtpStateClass.java
Expand Up @@ -208,6 +208,22 @@ protected ZrtpStateClass(ZRtp p) {

}

public long getTimeoutValue() {
long res = 0;
int counter = 0;
int time = t1.start;

do {
res += time;
time += time;
time = (time > t1.capping)? t1.capping : time;
counter++;
}
while(counter < t1.maxResend);

return res;
}

protected synchronized void processEvent(Event ev) {

char first, middle, last;
Expand Down

0 comments on commit d4c7c66

Please sign in to comment.