XMPPでP2Pの音声チャットセッションを確立する方法1
Posted on 9月 20, 2008
Filed Under jingle, xmpp, libjingle, nat, P2P |
頭を整理するためのMemo
GoogleTalkで使われているというjingle
XEP-0166: Jingle
XMPP protocol extension for initiating and managing peer-to-peer media sessions between two XMPP entities in a way that is interoperable with existing Internet standards
既存のInternet標準と共存できる方法で、2つのXMPPentities間でP2Pメディアセッションを確立、管理するためのXMPPプロトコルの拡張。
In essence, Jingle enables two XMPP entities (e.g., romeo@montague.lit and juliet@capulet.lit) to set up, manage, and tear down a multimedia session. The negotiation takes place over XMPP, and the media transfer takes place outside of XMPP. The simplest session flow is as follows:
セッションのnegotiationはXMPPで、メディアはXMPP外で。
-
Initiator Responder
-
| |
-
| session-initiate |
-
|---------------------------->|
-
| ack |
-
|<----------------------------|
-
| [transport negotiation] |
-
|<--------------------------->|
-
| session-accept |
-
|<----------------------------|
-
| ack |
-
|---------------------------->|
-
| AUDIO (RTP) |
-
|<===========================>|
-
| |
Example 1. Initiator sends session-initiate
-
<iq from='romeo@montague.net/orchard'
-
id='jingle1'
-
to='juliet@capulet.com/balcony'
-
type='set'>
-
<jingle xmlns='urn:xmpp:tmp:jingle'>
-
action='session-initiate'
-
initiator='romeo@montague.net/orchard'
-
sid='a73sjjvkla37jfea'>
-
<content creator='initiator' name='voice'>
-
<description xmlns='urn:xmpp:tmp:jingle:apps:rtp' media='audio'>
-
<payload -type id='96' name='speex' clockrate='16000'/>
-
<payload -type id='97' name='speex' clockrate='8000'/>
-
<payload -type id='18' name='G729'/>
-
<payload -type id='0' name='PCMU' />
-
<payload -type id='103' name='L16' clockrate='16000' channels='2'/>
-
<payload -type id='98' name='x-ISAC' clockrate='8000'/>
-
</description>
-
<transport xmlns='urn:xmpp:tmp:jingle:transports:ice-udp'/>
-
</content>
-
</jingle>
-
</iq>
Example 2. Responder acknowledges session-initiate
-
<iq from='juliet@capulet.com/balcony'
-
id='jingle1'
-
to='romeo@montague.net/orchard'
-
type='result'/>
After successful transport negotiation (not shown here), the responder accepts the session by sending a session-accept action to the initiator.
Example 3. Responder definitively accepts the session
-
<iq from='juliet@capulet.com/balcony'
-
id='accept1'
-
to='romeo@montague.net/orchard'
-
type='set'>
-
<jingle xmlns='urn:xmpp:tmp:jingle'
-
action='session-accept'
-
initiator='romeo@montague.net/orchard'
-
responder='juliet@capulet.com/balcony'
-
sid='a73sjjvkla37jfea'>
-
<content creator='initiator' name='voice'>
-
<description xmlns='urn:xmpp:tmp:jingle:apps:rtp' media='audio'>
-
<payload -type id='97' name='speex' clockrate='8000'/>
-
<payload -type id='18' name='G729'/>
-
</description>
-
<transport xmlns='urn:xmpp:tmp:jingle:transports:ice-udp'>
-
<candidate component='1'
-
foundation='1'
-
generation='0'
-
ip='192.0.2.3'
-
network='1'
-
port='45664'
-
priority='1678246398'
-
protocol='udp'
-
pwd='asd88fgpdd777uzjYhagZg'
-
type='srflx'
-
ufrag='8hhy'/>
-
</transport>
-
</content>
-
</jingle>
-
</iq>
ここで
・受信側が使えるpayload-typeに絞り込まれて(?)レスポンス
・IPアドレスとポートが受信側のjulietから送信側のromeoへ行ってる。
IPアドレスとポートはどうやって取得してるんだろ。
この例では192..ってローカルのIPだけどNAT超えの時は、NATの外側のグローバルIPとポートが必要でしょう。
XEP-0166: Jingleでは省略されてる transport negotiation について調べる。
Comments
Leave a Reply