Hi,
I have a configuration which work with sound and video but I need also early media.
This my architecture:
Asterisk 11.7.0 is in front of Internet with a public address (example of ip: 87.98.130.1) (installed on a public server OVH)
A first station is in a lan in a society 1 (example private ip 192.168.48.132 / public ip 80.74.74.3)
A second station is a sip application a on smartphone (example public ip 80.74.74.4)
This is how i configure my sip.conf to be able to run with audio and video :
[general]
context = mysociety ; Default context for incoming calls
useragent = Sip Server On Host; Allows you to change the user agent string
; The default user agent string also contains the Asterisk version.
realm = sip.myserver.fr ; Realm for digest authentication defaults to "asterisk".
; If you set a system name in asterisk.conf, it defaults to that system name
; Realms MUST be globally unique according to RFC 3261
; Set this to your host name or domain name
srvlookup = yes ; Enable DNS SRV lookups on outbound calls
; Note: Asterisk only uses the first host in SRV records
; Disabling DNS SRV lookups disables the ability to place SIP calls
; based on domain names to some other SIP users on the Internet
; Specifying a port in a SIP peer definition or when dialing outbound calls
; will supress SRV lookups for that peer or call.
allowoverlap = no ; Disable overlap dialing support. (Default is yes)
nat = yes ; Force rport to always be on and perform comedia RTP handling. (Default is no)
tcpenable = yes ; Enable server for incoming TCP connections (default is no)
tcpbindaddr = 0.0.0.0 ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
; Optionally add a port number, 192.168.1.1:5062 (default is port 5060)
udpbindaddr = 0.0.0.0 ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
; Optionally add a port number, 192.168.1.1:5062 (default is port 5060)
;transport = udp,tcp,tls ;
transport = udp,tcp ; TLS is disable because need a root certificate with agrement
directmedia = no ; Asterisk by default tries to redirect the
; RTP media stream (audio) to go directly from
; the caller to the callee. Some devices do not
; support this (especially if one of them is
; behind a NAT). (Default is yes)
canreinvite = no ; The "canreinvite" option has changed. canreinvite=yes used to disable re-invites if you had NAT=yes.
; In 1.4, you need to set canreinvite=nonat to disable re-invites when NAT=yes.
; This is propably what you want. The settings are now: "yes", "no", "nonat", "update".
; canreinvite= was renamed to directmedia= in Asterisk 1.6.2 to more accurately describe what this setting does.
directrtpsetup = no ; Enable the new experimental direct RTP setup. This sets up
; the call directly with media peer-2-peer without re-invites.
; Will not work for video and cases where the callee sends
; RTP payloads and fmtp headers in the 200 OK that does not match the
; callers INVITE. This will also fail if directmedia is enabled when
; the device is actually behind NAT. (Default is yes)
ignoresdpversion = yes ; By default, Asterisk will honor the session version
; number in SDP packets and will only modify the SDP
; session if the version number changes. This option will
; force asterisk to ignore the SDP session version number
; and treat all SDP data as new data. This is required
; for devices that send us non standard SDP packets
; (observed with Microsoft OCS). By default this option is
; off.
videosupport = yes ; Turn on support for SIP video. You need to turn this
; on in this section to get any video support at all.
; You can turn it off on a per peer basis if the general
; video support is enabled, but you can't enable it for
; one peer only without enabling in the general section.
; If you set videosupport to "always", then RTP ports will
; always be set up for video, even on clients that don't
; support it. This assists callfile-derived calls and
; certain transferred calls to use always use video when
; available. [yes|NO|always]
language = fr ; Default language setting for all users/peers - This may also be set for individual users/peers
disallow = all ; First disallow all codecs then allow codecs in order of preference
allow = alaw
allow = ulaw
allow = gsm
allow = h264
allow = h263p
[a-aaa]
context = mysociety
callerid = a
defaultuser = a
secret = aaa
dtmfmode = rfc2833
type = friend
insecure = invite
host = dynamic
qualify = yes
[b_bbb]
context = mysociety
callerid = b
defaultuser = b
secret = bbb
dtmfmode = rfc2833
type = friend
insecure = invite
host = dynamic
qualify = yes
And in extension.conf :
...
[macro--single-dial]
;ARG1: Call timeout
;ARG2: Communication timeout
;ARG3: Extension for the voicemail
;ARG4: sip number
exten => s,1,Noop(VERSION=1.0.0)
exten => s,n,Set(cn=${CALLERID(name)})
exten => s,n,Set(CHANNEL(hangup_handler_push)=handler,s,1)
exten => s,n,Ringing
;Dial the peer, if no response => voicemail
exten => s,n,Progress()
exten => s,n,Dial(${ARG4},${ARG1},S(${ARG2}))
exten => s,n,Gosub(treat-dial-status,s,1(${ARG3}))
[treat-dial-status]
;ARG1: Extension for the voicemail
exten => s,1,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,MailboxExists(${ARG1}) ;deprecated in v11.2 : should use ${VM_INFO(${ARG3},exists)} instead
;exten => s-NOANSWER,1,${VM_INFO(${ARG1},exists)}
exten => s-NOANSWER,n,Goto(vm${VMBOXEXISTSSTATUS})
exten => s-NOANSWER,n(vmFAILED),Goto(hangup)
exten => s-NOANSWER,n(vmSUCCESS),Voicemail(${ARG1},u)
exten => s-NOANSWER,n(hangup),Hangup()
exten => s-BUSY,1,MailboxExists(${ARG1}) ;deprecated in v11.2 : should use ${VM_INFO(${ARG3},exists)} instead
;exten => s-BUSY,1,${VM_INFO(${ARG1},exists)}
exten => s-BUSY,n,Goto(vm${VMBOXEXISTSSTATUS})
exten => s-BUSY,n(vmFAILED),Goto(hangup)
exten => s-BUSY,n(vmSUCCESS),Voicemail(${ARG1},b)
exten => s-BUSY,n(hangup),Hangup()
exten => s-CONGESTION,1,Goto(s-BUSY,1)
exten => s-CHANUNAVAIL,1,Hangup()
exten => _s-.,1,Goto(s-BUSY,1)
exten => a,1,VoicemailMain(${ARG1})
exten => s,n,Return()
[mysociety]
exten => a-aaa,1,Macro(single-dial,60,300,a-aaa,SIP/a-aaa)
exten => b_bbb,1,Macro(single-dial,60,300,b_bbb,SIP/b_bbb)
If I disable nat, enable directmedia and directrtpsetup when the first and second station are in the same lan, I can have the early media (audio and video)
How must I do to be able to have early media when peers are not in the same network ?
In my configuration nat is it necessary or should I use a STUN server to get the public IP of the peers ?
Thanks to give me your opinion about my config and how you i should do to get early media available.