directmedia/ directrtpsetup

网上找到的总结,当设置directmedia  =  yes时,不会发出reinvite:

If one of the clients is configured withcanreinvite=NO, Asterisk will not issue a re-invite at all.

If the clients use different codecs,Asterisk will not issue a re-invite.

If the Dial() command contains ''t'', ''T","h", "H", "w", "W" or "L"(with multiple arguments) Asterisk will not issue a re-invite.

When dtmfmode=rfc2833, asterisk will sendthe RTP stream through asterisk(经测试,这个没有生效).With dtmfmode=info canreinvite works properly.

 

 

 

canreinvite在 asrerisk1.6改名为directmedia。

 

directmedia  =  no        ;不会发出reinvite,rtp通过asterisk中转

directmedia =  yes      ;会发出reinvite,如果client在nat后面,rtp会不通,没有声音

directmedia     =       nonat        ;clientasterisk都在私网时,asterisk会发出reinviteclient在私网(nat后面)asterisk在公网,不会发出reinvite(如果发出reinvite让媒体点对点,会因为nat而无法穿越,原因在下面)

directmedia     =       update     ;会发出update消息,让媒体点对点。

 

client都在nat后面,asterisk在公网时(在公司,主被叫使用voipwangpeng.vicp.cc注册),如果这时候通过reinvite或者其他方式实现点对点,rtp会不通,没有声音,原因:

当呼叫时,在asterisk发出reinvite的时候会收到主被叫发来的rtp(见下图),主被叫软电话使用的ip1:port1(nat映射后的)ip2:port2(nat映射后的)都先是分别跟asterisk的临时端口ip3:port3ip3port4互通过,这样如果使用了对称型的natip1:port1只能和ip3:port3互发消息,ip2:port2只能跟ip3port4互发消息(因为这是软电话和asterisk之间已经分别通过这些端口互发rtp消息,已经在nat中建立了映射),这样当asterisk在发invite消息让终端p2p call(也就是让ip1:port1ip2:port2互发消息,类似UDP打洞,应该是可以穿越nat的,但是遇到的是对称nat),会被nat丢掉。所以接通后没有声音。

上面的解释也可能不对,因为所有端口都映射到了ip3ip1 ip2发出的rtp都发到了ip3,所以没有声音。

但是使用tplink就可以通(在家里,主被叫使用voipwangpeng.vicp.cc注册),抓包跟上面一样的。tplinknat是端口受限型,NAT(3)

 

 

 

directrtpsetup=yes is similar to directmedia=,except the audio is redirected in the initial INVITEs rather than reinvitingthe media a
few RTP packets in. 

 

The canonical way is to enable"canreinvite=yes" on both SIP peers (incoming and outgoing legs),which will cause Asterisk to send a new INVITE within the dialog that hasupdated SDP information corresponding to both endpoints.
The more interesting option is newer —"directrtpsetup=yes" in sip.conf. This will cause Asterisk to behavemore like a proxy does with respect to media and simply pass the SDP payloadsas received to both endpoints without pivoting the media stream toward itselfat any time, unless explicitly forced to do so (i.e. generating music on holdor IVR messages).
Both approaches come with the caveat that theendpoints must be able to address each other directly, so it can't be that oneendpoint is behind NAT on a private network that only Asterisk can see and theother endpoint cannot. But if that's taken care of, or you have a far-end NATtraversal solution in place to go with it, then you can do media release onAsterisk.

 

asteriskRTP透传相关参数整理

1 directmedia/canreinvite

The "canreinvite" option haschanged. canreinvite=yesused to disable re-invites if you had NAT=yes(原因可能是上面的解释). In 1.4, you need to set canreinvite=nonat to disable re-inviteswhen NAT=yes. This is propably what you want. The settings are now:"yes", "no", "nonat", "update".Pleaseconsult sip.conf.sample for detailed information.

canreinvite= was renamed to directmedia= inAsterisk 1.6.2 to more accurately describe what this setting does.See also theclosely related setting directrtpsetup.

canreinvite = yes "allow RTP mediadirect"

canreinvite = no "denyre-invites"

canreinvite = nonat "allow reinvite when local, deny reinvitewhen NAT"

canreinvite = update "use UPDATEinstead of INVITE"

canreinvite = update,nonat "use UPDATEwhen local, deny when NAT"

2 directmediapermit/directmediadeny

Asterisk 1.8 added directmediapermit anddirectmediadeny to limit which peers can send direct media to each other.

3 directrtpsetup=yes

directrtpsetup=yes is similar todirectmedia=, except the audio is redirected in the initial INVITEs rather thanreinviting the media a few RTP packets in. Note: canreinvite= was renamed todirectmedia= in Asterisk 1.6.2 to more accurately describe what this settingdoes

4 media_address

configuration option which can be used toexplicitly specify the IP address to use in the SDP for media (audio, video,and text) streams.

5 NOTICE

If one of the clientsis configured with canreinvite=NO, Asterisk will not issue a re-invite at all.

If the clients usedifferent codecs, Asterisk will not issue a re-invite.

If the Dial() commandcontains ''t'', ''T", "h", "H", "w","W" or "L" (with multiple arguments)

Asterisk will notissue a re-invite.

6 DIAL()

T: Allow thecalling user to transfer the call by hitting the blind xfer keys(features.conf). Does not affect transfers initiated through other methods.

    If you have set thevariable GOTO_ON_BLINDXFR then the transferrer will be sent to thecontext|exten|pri (you can use ^ to represent | to avoid escapes), example: SetVar(GOTO_ON_BLINDXFR=woohoo^s^1);works with both t and T

t: Allow thecalled user to transfer the call by hitting the blind xfer keys (features.conf)Does not affect transfers initiated through other methods.

    If you have set thevariable GOTO_ON_BLINDXFR then the transferrer will be sent to thecontext|exten|pri (you can use ^ to represent | to avoid escapes), example:SetVar(GOTO_ON_BLINDXFR=woohoo^s^1); works with both t and T

H: Allow thecaller to hang up by dialing * ( * is defined in features.conf -> featuremap-> disconnect )

h: Allow thecallee to hang up by dialing * ( * is defined in features.conf -> featuremap-> disconnect )

W: Allow thecalling user to start recording after pressing *1 or what defined infeatures.conf (Asterisk v1.2.x); requires Set(DYNAMIC_FEATURES=automon)

w: Allow thecalled user to start recording after pressing *1 or what defined infeatures.conf (Asterisk v1.2.x); requires Set(DYNAMIC_FEATURES=automon)

L(x[:y][:z]):Limit the call to 'x' ms, warning when 'y' ms are left, repeated every 'z' ms)Only 'x' is required, 'y' and 'z' are optional. Numbers must be integers-beware of AGI scripts that may return long integers in scientific notation (espPHP 5.2.5&6) The following special variables are optional for limit calls:(pasted from app_dial.c)

    LIMIT_PLAYAUDIO_CALLER -yes|no (default yes) - Play sounds to the caller.

    LIMIT_PLAYAUDIO_CALLEE -yes|no - Play sounds to the callee.

    LIMIT_TIMEOUT_FILE -File to play when time is up.

    LIMIT_CONNECT_FILE -File to play when call begins.

    LIMIT_WARNING_FILE -File to play as warning if 'y' is defined. If LIMIT_WARNING_FILE is notdefined, then the default behaviour is to announce ("You have [XX minutes]YY seconds").

 

 

asterisk位于公网 linphone都在nat后面nat = auto_force_rport,auto_comedia
linphone ice=no ast ice=no directmedia=no directrtpsetup=yes 会修改sdp 中转媒体没有reinvite 有声音
linphone ice=no ast ice=no directmedia=yes directrtpsetup=yes 不会修改sdp 不中转媒体没有reinvite 没声音
linphone ice=yes ast ice=no directmedia=yes directrtpsetup=yes 会修改sdp,去掉ice 不中转媒体没有reinvite 没声音
linphone ice=yes ast ice1=yes directmedia=yes directrtpsetup=yes 会修改sdp,去掉ice 不中转媒体没有reinvite 没声音
linphone ice=yes ast ice2=yes directmedia=yes directrtpsetup=yes 会修改sdp,去掉ice 不中转媒体没有reinvite 没声音
linphone ice=yes ast ice12=yes directmedia=yes directrtpsetup=yes 会修改sdp,去掉ice 不中转媒体没有reinvite 没声音

 

 

linphone都在nat后面nat =auto_force_rport,auto_comedia icesupport = no

directmedia=yes directrtpsetup=yes tplinkp2pok

directmedia=yes directrtpsetup=no  tplink p2pok

之所以p2p OK,是因为linphone使用了stun,可以在sdp中填入自己的公网IP。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值