| 1 | = Audio Problems: Getting Around NAT = |
| 2 | |
| 3 | If [wiki:audio-check-rx-rtp no RTP packet is received] (or [wiki:audio-problem-local-no-audio you can't any hear audio]), perhaps it's because of the NAT device is blocking the incoming RTP packets. |
| 4 | |
| 5 | == Use STUN == |
| 6 | One of the obvious reason why no incoming packet is received is because the application sends private IP address as its RTP address. This can be verified by looking at the SDP {{{c=}}} line that is sent by the application. |
| 7 | |
| 8 | If the SDP {{{c=}}} line contains private address, then probably you need to use STUN. You can enable STUN support in ''pjsua'' by using '''{{{--stun-srv}}}''' option from the command line. For example: |
| 9 | {{{ |
| 10 | $ ./pjsua --use-stun stun.pjsip.org |
| 11 | }}} |
| 12 | |
| 13 | |
| 14 | |
| 15 | == Disabling VAD == |
| 16 | Normally NAT router only forwards incoming packets to internal network after the internal host has sent some packets to remote destination. But this may not happen if Voice Activity Detector (VAD)/Silence Detector is enabled, because then no RTP packet will be transmitted when there is no voice activity on the microphone. |
| 17 | |
| 18 | So as workaround solution, try to disable VAD to see if this is the case. You can disable VAD in ''pjsua'' by using '''{{{--no-vad}}}''' option from the command line. |
| 19 | |
| 20 | == Using Port Forwarding == |
| 21 | ''pjsua'' can also be configured in port forwarding environment, for both SIP UDP/TCP and media (RTP) transports. To do this, you have to configure your router to forward UDP/TCP port 5060 to the application, and also UDP ports for RTP. By default, ''pjsua'' (and ''PJSUA-API'') allocates UDP ports for RTP/RTCP from port 4000 for RTP and 4001 for RTCP, and upwards up to the maximum number of calls configured in pjsua (for example, if ''max-calls'' is 10, then the port range allocated for RTP/RTCP will be UDP ports 4000 - 4019, since each call will need two UDP sockets). |
| 22 | |
| 23 | ''(Note: the default port 5060 for SIP can be changed with --local-port option, while the default RTP start port of 4000 can be changed with --rtp-port option)'' |
| 24 | |
| 25 | After port forwarding has been configured in the router, you just need to specify the router's public IP address to pjsua, with '''{{{--ip-addr}}}''' command line option. With this option, all addresses advertised by ''pjsua'' will use this address rather than the internal IP address. |
| 26 | |