| 96 | |
| 97 | == Measuring Overall/End-to-end Latency == |
| 98 | |
| 99 | The objective of this test is to measure the overall latency of: |
| 100 | * microphone and speaker device buffering (both in application layer, driver layer, and hardware itself) |
| 101 | * conference bridge buffering |
| 102 | * jitter buffering |
| 103 | * codec buffering |
| 104 | * and everything else |
| 105 | |
| 106 | Note that in order to measure the latency, we use loopback call for this test (meaning, the pjsua application is making call to itself), so this test method cannot be used to measure end-to-end latency of two pjsua instances. |
| 107 | |
| 108 | Test method: |
| 109 | * make loopback call (i.e. pjsua is calling itself, so we have both caller and callee in the same pjsua instance) |
| 110 | * arrange the conference bridge connection so that audio flow is one way (i.e. microphone -> call1 --> local network/OS --> call2 --> speaker) |
| 111 | * play a special WAV file to caller, and simultaneously record WAV file |
| 112 | * audio/RTP is received by callee, which will play the received the audio to speaker |
| 113 | * as the audio is played in the speaker, capture the signal in the microphone (i.e. similar to how sound echo is captured) |
| 114 | * record the microphone capture to WAV file. |
| 115 | |
| 116 | By looking in the recorded WAV file we should be able to know the sound device latency by measuring the interval between the recording of original signal and recording of the echo signal. |
| 117 | |
| 118 | === Running the Test === |
| 119 | |
| 120 | Run pjsua with the following command line arguments: |
| 121 | |
| 122 | {{{ |
| 123 | pjsua --no-tones --ec-tail 0 --no-vad --clock-rate 8000 --snd-clock-rate 8000 --rec-file rec2.wav --play-file tock8.wav --add-codec pcmu |
| 124 | }}} |
| 125 | |
| 126 | Then copy/paste the script below to pjsua: |
| 127 | |
| 128 | {{{ |
| 129 | m |
| 130 | sip:localhost |
| 131 | sleep 100 |
| 132 | ] |
| 133 | a |
| 134 | 200 |
| 135 | sleep 1000 |
| 136 | cd 0 4 |
| 137 | cd 3 0 |
| 138 | cd 0 3 |
| 139 | cc 1 3 |
| 140 | cc 1 2 |
| 141 | cc 0 2 |
| 142 | sleep 10000 |
| 143 | cd 0 2 |
| 144 | cd 1 2 |
| 145 | q |
| 146 | }}} |
| 147 | |
| 148 | The command above will make pjsua calls itself, answer the call, setup the conference bridge interconnection to record the WAV file, and do recording to 10 seconds. Once it's done, the recorded WAV file is in {{{rec2.wav}}} file. |
| 149 | |
| 150 | === Analyzing the result with WAV analyzer === |
| 151 | |
| 152 | Measuring the latency in the recorded WAV file is the same as in the previous test. Here's my {{{rec2.wav}}} looks like in the WAV analyzer: |
| 153 | |
| 154 | [[Image(rec2.png, 50%)]]] |
| 155 | |
| 156 | And in my measurement, I measured the delay is about 200 milliseconds. |
| 157 | |
| 158 | |
| 159 | === Analyzing the result with latency analyzer === |
| 160 | |
| 161 | Again, similar like previous test, and here's my result: |
| 162 | |
| 163 | {{{ |
| 164 | C:\> latency.exe rec2.wav |
| 165 | Latency average = 213 |
| 166 | Latency minimum = 183 |
| 167 | Latency maximum = 227 |
| 168 | Number of data = 9 |
| 169 | }}} |
| 170 | |