Currently I'm making application which sends faxes, and I need to detect call duration.
My current approach is to detect call state changes, but unfortunately result is ~2 seconds less than actual call duration from fax board.
public override void OnCallProgress(DSAPI.CallState NewState)
if (NewState == DSAPI.CallState.Connected)
this.CallStart = DateTime.Now;
if (NewState == DSAPI.CallState.Disconnected)
this.CallEnd = DateTime.Now;
CallDuration = (CallEnd - CallStart).TotalSeconds;
If I'm using Proceeding state result is ~10 seconds bigger then actual.
Has anyone encountered similar problem, and/or do you have any suggestions?
Hi,I would save call start time when calling Dial and call end time in OnCallDisconnected event.Given up-to-date drivers and SDK are being used, this should result in correct duration results.Regards,Alex.
I've updated my sdk and drivers and tried your method, so now my application's call time is equal to call time from Call History in Diva Management (60 seconds).
But the strange thing is that fax device which is recipient, telling that call was 42 seconds. Also I've made approximate measurement of call time with stopwatch: 42-47 seconds.
What could it be? It looks like fax device telling truth but what about call duration from Diva board?
Is it possible that diva board adding dialing time or ringing time to actual call duration?
Good to hear that the application now lines up with the call history.
It depends on what you want to measure and why. The duration of the actual fax transmission or the duration of the call. These are 2 different things. The call duration from Dial to Disconnected includes the call establishment process (dialing, getting connected, establishment of transmission channels), the fax transmission (negotiating speed, training, image data transmission, receiving confirmation) and the call termination process (disconnect, disconnect confirmation, clearing resources). Especially on long distance calls the call establishment phase may take several seconds.One purpose of measuring call duration is to estimate costs, call costs are based on the call duration.
Using the stopwatch - when did you start and stop measurements? If you start when the receiving fax machine starts playing the fax beeps (i.e. a desktop fax with loudspeakers on) or at the time your app returns the Connected event, then you are missing the time it takes to get connected.If you want to have control over the stages you could return the current time whenever the API returns an call state change (Dial, Proceeding, Alerting, Connected, Disconnect, Disconnected).
Hope it helps.Alex.