1 / 37

Google T 1 alk API - Libjingle

Google T 1 alk API - Libjingle. Speaker : C hungyi Wang Adviser : Quincy Wu Date : 2006/11/20 1. outline. Google Talk API – Libjingle Compile Example : login Example : call Reference. Google Talk API – Libjingle. Google Talk API – Libjingle Google Talk(1/2). Google Talk

shanta
Télécharger la présentation

Google T 1 alk API - Libjingle

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Google T1alk API - Libjingle Speaker:Chungyi WangAdviser : Quincy Wu Date : 2006/11/201

  2. outline • Google Talk API – Libjingle • Compile • Example : login • Example : call • Reference

  3. Google Talk API – Libjingle

  4. Google Talk API – Libjingle Google Talk(1/2) • Google Talk • http://www.google.com/talk/

  5. Google Talk API – Libjingle Google Talk(2/2) • Gmail • http://mail.google.com/mail/

  6. Google Talk API – Libjingle(1/2) • Software : libjingle-0.3.0 • http://code.google.com/apis/talk/index.html • OS : Linux Fedora Core 4

  7. Google Talk API – Libjingle(2/2) • Google Talk Voice and P2P Interoperability Library • 使用XMPP • traverse many types of NATs • establish peer-to-peer connections

  8. Google Talk API – Libjingle Libjingle-XMPP(1/2) • Why? • Google Talk在即時通訊部分使用開放的XMPP協定,鼓勵其他用戶端的使用,用戶連接Google Talk服務時不一定要使用官方客戶端。 • What? • Extensible Messaging and Presence Protocol (XMPP) ,核心定義在 RFC 3920和 RFC 3921 • 是一種開放的XML於real-time溝通的技術

  9. Libjingle Jingle XMPP Google Talk API – Libjingle Libjingle-XMPP(2/2)

  10. Google Talk API - Libjingle 元件(1/3) • talk/base • Low-level portable utility functions • Libjingle 需要的 Socket & Thread • p2p 和 session 都使用此元件 • talk/p2p • The p2p stack, including base p2p functionality and client hooks into XMPP • 溝通,設置還有維持peer-to-peer 連線

  11. Google Talk API - Libjingle 元件(2/3) • talk/session • Phone call signaling and reliable peer-to-peer streams • 了解 Jingle-Audio格式並且可以藉由XMPP和其他Client協商通話 (negotiate) • talk/third_party • Non-Google components required for some functionality • Mediastreamer2 & RTP (from linphone)

  12. Google Talk API - Libjingle 元件(3/3) • XMPP server • talk/xmllite • XML parser • talk/xmpp • XMPP engine

  13. Compile

  14. Compile(1/4) • Linux Command • ./configure • 找尋系統內,程式需要的函式庫以及資源 • make • 編譯程式 • make install • 安裝套件(如果是必須安裝的套件)

  15. Compile(2/4) • ortp-0.7.1 • http://download.savannah.nongnu.org/releases/linphone/ortp/sources/ortp-0.7.1.tar.gz • ./configure之後,修改Makefile的prefix=/usr • make; make install • alsa-lib-1.0.9rc4(ALSA-lib:Advanced Linux Sound Architecture) • http://www.alsa-project.org/alsa/ftp/driver/alsa-driver-0.5.2.tar.gz • ./configure & make install • 如果無法安裝可以考慮安裝 rpm 檔案 • http://www.alsa-project.org/alsa/ftp/lib/stable/alsa-lib-1.0.9rc4.tar.bz2 • ./configure & make install

  16. Compile(3/4) • Libjingle-0.3.0 • ./configure • 完成之後會看到:libjingle 0.3.0Supported Codecs:Speex : noiLBC : noMULAW : yes • make

  17. Compile(4/4) • talk/examples/ • login • 簡單的登入程式範例 • login_main.cc • call • 登入,搜尋線上好友,建立通話,結束通話 • call_main.cc

  18. Example : login

  19. Example : login #include …(1/3) • talk/examples/login/login_main.cc • #include “talk/base/thread.h” • 處理使用者指令,並且設定相對應的訊息(Message)到訊息佇列(MessageQueue)內執行 • 定義類別thread • void Loop( int cms ) • cms 定義迴圈監聽的秒數

  20. Example : login #include …(2/3) • #include “talk/xmpp/xmppclientsettings.h” • 儲存設定的資料;設定項目好比 user,host,server,use_tls (TLS),auth_cookie or password • 定義類別 thread • set_user(const std::string & user) • set_host(const std::string & host) • set_server(const cricket:SocketAddress &server) • set_auth_cookie(const std:string & auth_cookie) • set_password(const XmppPassword & pass)

  21. Example : login #include …(3/3) • #include “talk/examples/login/xmppthread.h” • 定義指令輸入所需的XmppThread,其功能就是類別thread的工作(Loop),另外再加上Login( xcs )的函式 • 指定Loop監聽伺服器(talk.google.com)的工作。 • 定義類別 XmppThread • void Loop(int cms) • Thread::Loop(cms) • void Login(const buzz::XmppClientSettings &xcs)

  22. Example : login Flowchart(1/2) • 使用者輸入 帳號,認證碼 • scanf(“%s”, username) • scanf(“%s”, auth_cookie) • 使用者必須登入GMail,並且拷貝瀏覽器上auth之後的字串 • 每次的auth都不相同,並且GMail登出之後XmppThread會因為中斷連線而發生 程式記憶體區段錯誤 • 啟動 XmppThread • XmppThread threadthread.Start( );

  23. Example : login Flowchart(2/2) • 設定 XmppClientSettings • buzz:: XmppClientSettings xcsxcs.set_user(username)xcs.set_host(“gmail.com”)xcs.set_use_tls(false)xcs.set_user(auth_cookie)xcs.set_user(cricket::SocketAddress(“talk.google.com”, 52222)) • 進行登入的動作 • thread.Login(xcs)

  24. Example : login Demo • 示範:talk/examples/login/login_main.cc

  25. Example : login Problems • Auth_Cookie? • 必須登入GMail才能取得auth_cookie • 每次的auth碼都不相同,如果錯誤會直接產生 程式記憶體區段錯誤,由迴圈跳出 • 無法使用password形式 • 會產生 程式記憶體區段錯誤 • 登入狀態? • 由於已經使用瀏覽器登入GMail,所以無法確認登入成功與否 • 但是還是一個最簡單的登入示範範例

  26. Example : call

  27. Example : call #include …(1/4) • talk/examples/login/call_main.cc • 擁有3個Thread • XMPP Client • Input • PhoneSessionClient • #include "talk/base/physicalsocketserver.h“ • cricket::PhysicalSocketServer • 三個Thread都會使用到

  28. Example : call #include …(2/4) • #include "talk/base/ssladapter.h“ • InitializeSSL( ); • Libjingle 啟動 SSL 必須執行的 Initialize • #include "talk/xmpp/xmppclientsettings.h“ • 儲存設定的資訊 • #include "talk/examples/login/xmppthread.h“ • XMPP Client Thread

  29. Example : call #include …(3/4) • #include "talk/examples/login/xmppauth.h“ • 認證:登入以及離線 • XmppPump pump • DoLogin( … ) • DoDisconnect( )

  30. Example : call #include …(4/4) • #include "talk/examples/call/callclient.h“ • 處理使用者的指令

  31. Example : call Flowchart(1/3) • 使用者輸入 帳號,認證碼 當輸入密碼時必須SetConsoleEcho(false) • 填滿XmppClientSetting的資料 • Username,host,pass,server • 建立使用者指令處理執行緒 (T1) • CallClient

  32. Example : call Flowchart(2/3) • 主迴圈建立 • 建立主要執行緒(T2),並且將處理實體Socket的物件傳入 • cricket::PhysicalSocketServer ss;…cricket::Thread main_thread(&ss); • 建立處理使用者輸入執行緒(T3) • Console *console = new Console(&main_thread, client); • client->SetConsole(console); //設定CallClient的Consolr來源 • cricket::Thread *console_thread = new cricket::Thread(&ss); • console_thread->Start(); • console_thread->Post(console, MSG_START);

  33. Example : call Flowchart(3/3) • 執行登入的動作 • pump.DoLogin(xcs, new XmppSocket(true), 0); • 開始主執行緒的迴圈 • main_thread.Loop();

  34. Example : call Demo • 示範:talk/examples/login/call_main.cc

  35. Example : login Problems • 如果要進行修改,好比說GUI? • 最簡單可以下手的部分在 • CallClient.cc

  36. Reference

  37. Reference • Google Talk • http://www.google.com/talk/ • Gmail • http://mail.google.com/mail/ • libjingle-0.3.0 • http://code.google.com/apis/talk/index.html • XMPP • RFC 3920 • RFC 3921 • Jingle • http://www.xmpp.org/extensions/xep-0166.html • This document defines a framework for initiating and managing peer-to-peer sessions (e.g., voice and video exchanges) between Jabber/XMPP clients in a way that is interoperable with existing Internet standards • http://www.xmpp.org/extensions/xep-0167.html • This document defines a content description format for Jingle audio sessions

More Related