XMPPでP2Pの音声チャットセッションを確立する方法4

Posted on 9月 21, 2008
Filed Under xmpp, libjingle, P2P |

XMPPでP2Pの音声チャットセッションを確立する方法3
の続き

libjingleでcallサンプル(P2Pの音声電話)を動かしてみて、
ログみてどういうxmpp stanza送りあってるのかなぁ、見てみる。

call.exe に -d オプションをつけて動かすとデバッグ情報がログに出てくる

libjingleではGIPSMediaEngineとlinphoneというのにデフォルト対応していますが
GIPSMediaEngine手に入らないし
linphoneはWindows上でうまくbuildできないので
とりあえず適当なpayload-typeを指定しています。
IPアドレスも適当にしています

XMPPのJIDはこんな感じ
caller: o.masakazu@gmail.com/callB3B38FB3
callee: o.masakazu@gmail.com/call7DA716D7

ところで悲しいことに、、
libjingle Developer Guide

libjingle was created at about the same time as the Jingle XMPP extension (XEP-0166). The libjingle team created their own protocol to handle session negotiation, and later worked with the XMPP Standards Foundation to standardize Jingle; thus, although the libjingle protocol and Jingle are very similar, they are not the same, and are not interoperable.

libjingleは前回までみてきたjingle specとは非互換だしjingleの方は実装してない、さらにlibjingleの独自実装は(たぶん探しても見つからないので)仕様非公開。
いちいち難所がありますな><
very similarに期待して進みます。

セッション開始
非同期にいろいろ送りあってるので、 のidのところを見ると、
req/resの組み合わせがわかる

SEND >>>>>>>>>>>>>>>>>>>>>>>>> : Sun Sep 21 17:30:02 2008

XML:
  1. </iq><iq to="o.masakazu@gmail.com/call7DA716D7" type="set" id="7">
  2.      <session xmlns="http://www.google.com/session" type="initiate" id="2398276180" initiator="o.masakazu@gmail.com/callB3B38FB3">
  3.        <description xmlns="http://www.google.com/session/phone">
  4.          <payload -type xmlns="http://www.google.com/session/phone" id="102" name="plain" clockrate="44100"/>
  5.        </description>
  6.        <transport xmlns="http://www.google.com/transport/p2p"/>
  7.      </session>
  8.    </iq>

続けて自分の候補を送る(emobileでグローバルIP持ってる)

SEND >>>>>>>>>>>>>>>>>>>>>>>>> : Sun Sep 21 17:30:03 2008

XML:
  1. <iq to="o.masakazu@gmail.com/call7DA716D7" type="set" id="8">
  2.      <session xmlns="http://www.google.com/session" type="transport-info" id="2398276180" initiator="o.masakazu@gmail.com/callB3B38FB3">
  3.        <transport xmlns="http://www.google.com/transport/p2p">
  4.          <candidate name="rtp" address="119.1.2.3" port="3773" preference="1" username="uloaCAVUNxLbDt4w" protocol="udp" generation="0" password="yewpj2tpBCTP9C5u" type="local" network="0"/>
  5.        </transport>
  6.      </session>
  7.    </iq>

最初のセッション開始に対してackが返ってくる

RECV < <<<<<<<<<<<<<<<<<<<<<<<< : Sun Sep 21 17:30:03 2008

XML:
  1. <iq to="o.masakazu@gmail.com/callB3B38FB3" id="7" type="result" from="o.masakazu@gmail.com/call7DA716D7"/>

もう1個候補を送る(こっちはhamachiのIP、オフライン)id="9"

SEND >>>>>>>>>>>>>>>>>>>>>>>>> : Sun Sep 21 17:30:03 2008

XML:
  1. <iq to="o.masakazu@gmail.com/call7DA716D7" type="set" id="9">
  2.      <session xmlns="http://www.google.com/session" type="transport-info" id="2398276180" initiator="o.masakazu@gmail.com/callB3B38FB3">
  3.        <transport xmlns="http://www.google.com/transport/p2p">
  4.          <candidate name="rtp" address="5.1.2.3" port="3775" preference="1" username="j7GgUkfbQnyM8npJ" protocol="udp" generation="0" password="lJeNoPmxQhOX/tkp" type="local" network="1"/>
  5.        </transport>
  6.      </session>
  7.    </iq>

id="8"の候補に対して、transport-acceptが返ってくる

RECV < <<<<<<<<<<<<<<<<<<<<<<<< : Sun Sep 21 17:30:03 2008

XML:
  1. <iq to="o.masakazu@gmail.com/callB3B38FB3" type="set" id="8" from="o.masakazu@gmail.com/call7DA716D7">
  2.      <session type="transport-accept" id="2398276180" initiator="o.masakazu@gmail.com/callB3B38FB3" xmlns="http://www.google.com/session">
  3.        <transport xmlns="http://www.google.com/transport/p2p"/>
  4.      </session>

id="8"に対してackを返す

SEND >>>>>>>>>>>>>>>>>>>>>>>>> : Sun Sep 21 17:30:03 2008

XML:
  1. <iq to="o.masakazu@gmail.com/call7DA716D7" id="8" type="result"/>

こんな感じで続く。。。。

finally...
STUNのところはlibjingleロギングしてくれないのでこれから見ますが、、
つながったら、こんな。

payload-type(カスタムのやつ)を受け入れますよ、ってところでしょうか

RECV < <<<<<<<<<<<<<<<<<<<<<<<< : Sun Sep 21 17:30:13 2008

XML:
  1. <iq to="o.masakazu@gmail.com/callB3B38FB3" type="set" id="17" from="o.masakazu@gmail.com/call7DA716D7">
  2.      <session type="accept" id="2398276180" initiator="o.masakazu@gmail.com/callB3B38FB3" xmlns="http://www.google.com/session">
  3.        <description xmlns="http://www.google.com/session/phone">
  4.          <payload -type id="102" name="plain" clockrate="44100"/>
  5.        </description>
  6.      </session>

SEND >>>>>>>>>>>>>>>>>>>>>>>>> : Sun Sep 21 17:30:13 2008

XML:
  1. <iq to="o.masakazu@gmail.com/call7DA716D7" id="17" type="result"/>

さて、次はSTUNのやり取りをみてみる

Comments

Leave a Reply