Jun 23, 2012

Simple video call example program using QXmpp

In my previous post I had shown you how to compile QXmmp in ArchLinux, now I'll show you a minimal videoconference example using QXmpp.


First of all, I will explain why I did chose QXmpp as my VOIP library.

As (maybe) you are noticed, one of my latest movements for Carnival LiveCam was the inclusion of the Spaces. The idea of Spaces was intentionally thought to be used in a video conference environment.

Also, I was chose to use XMPP/Jingle/WebRTC from beginning. The reason? Simply because it's an open standard, and the most world wide popular companies adopted it:
It's a very easy decision, I don't need to care about using another non-popular VOIP protocol. Do you really need more reasons? I'm not.

Now, with the protocol chosen, we need a library that work with it. There are only four Free Software libraries that supports Jingle:
  • libjingle: The real one XMPP/Jingle library, developed by Google, multiplataform with BSD license. But it's really hard to compile (nearest to imposible), requires a large amount of patches to be applied before compile it.
  • libpurple: The library created by Pidgin proyect, multiplataform, multiprotocol, with GPL license. The problem is that it's absolutely undocumented. Also, even if Carnival LiveCam is licensed under the GPL, there could have a dangerous legal bottleneck by using it in my program.
  • telepathy: The library used for Empathy and KDE Telepathy, works only on GNU/Linux, multiprotocol, with GPL license. Again, idem to libpurple, using a GPL library is a bad idea. Also, documentation only explains how D-Bus works and that the user needs very advanced GStreamer knowledge, but doesn't explains how to make a fucking simple VOIP program.
  • QXmpp: An independent XMPP library that supports Jingle, multiplataform, with LGPL license. If you are making your program in Qt you are lucky because this library is fully writen in Qt/C++. It's API is clear and very easy to understand. There are only one against, QXmpp doesn't implements a Foward Error Correction (FEC) algorithm, this means that in case of packet loss, the video will suffer of a severe image corruption.
Obviously, QXmpp is the best option here. I don't know if the developers of QXmpp will add FEC or not, but in the worst case I will take the related code from libjingle and adapt it to QXmpp, the license of both allows that.

A few weeks ago, I had uploaded a simple videoconference example program.

Because the packages for Arch Linux are outdated and incomplete, I had uploaded also three PKGBUILD's to create a QXmpp package with Speex, Vp8 and Theora support from stable and Git version. You can test it using your Gmail (someuser@gmail.com) or Jabber (someuser@jabber.org) account for example.

13 comments:

  1. Hello, use VoipTest to call between networks: it fails, no video (cameta) init.

    If i call between one subnetwork's PCs - all OK enough - camera inits and stream displays..

    have tryed init with STUN/TURN defined:
    https://github.com/hipersayanX/VoipTest/blob/master/mainwindow.cpp
    ALTERED:
    MainWindow::MainWindow(QWidget *parent): QMainWindow(parent)
    {
    this->setupUi(this);
    this->m_call = NULL;

    this->m_callManager.setStunServer (QHostAddress ("66.228.45.110"));
    this->m_callManager.setTurnServer (QHostAddress ("66.228.45.110"));
    this->m_callManager.setTurnUser ("someuser");
    this->m_callManager.setTurnPassword ("somelogin");
    // Add the extention for Jingle (Voice/Video calls).
    this->m_client.addExtension(&this->m_callManager);

    this->m_timer.setInterval(1);


    Any ideas/suggestions?

    ReplyDelete
  2. Try using VoipTest in one side and Pidgin in the other, check Tools -> XMPP Console for the stanzas log, that could help debugging the app.

    ReplyDelete
  3. pidgin seems like not supprts video. What i've gor on console on incoming call over WAN anyway:







    Logged out
































    Logged out

    ReplyDelete
  4. sorry, log:
    http://sharetext.org/uvP7

    ReplyDelete
    Replies
    1. Look here:

      http://xmpp.org/extensions/xep-0166.html#howitworks
      http://xmpp.org/extensions/xep-0167.html#negotiation

      Your VoipTest client aren't sending the payloads for Speex, Theora and Vpx. You've not compiled QXmpp with codecs support. If you're using Windows see here. If you're using GNU/Linux compile QXmpp as:

      qmake-qt4 QXMPP_USE_SPEEX=1 QXMPP_USE_THEORA=1 QXMPP_USE_VPX=1
      make
      make install

      Delete
  5. This is the thing! QXmpp built with Speex, Theora. It does communicates OK during LAN connection. I have video transmitting both sides.
    But, when i try connect to voiptest instance on another network through internet - no video, no camera init.

    here logs of both situations (last message):
    https://groups.google.com/forum/#!topic/qxmpp/JQWDo78egkI

    and LAN situation have pauloads with theora. I'm confused a bit with payload = PCMU instead 'speex', but anyway video is OK in LAN situation.
    WAN whole another story. I've altered code a little to use STUN/TURN and again, LAN situation displays that they're in use, but WAN, over internet - still not connects.

    ReplyDelete
    Replies
    1. From the wan log, your VoipTest client keep sending the same binding request:

      Ср июл 23 12:46:54 2014 SENT Sent to 66.228.45.110 port 52009 (local 192.168.56.1 port 49153)
      type Binding Request (1)
      id d4aac6ad12ad9dc18023dd69
      * USERNAME N8vj:8K9z
      * PRIORITY 1862270974
      * ICE-CONTROLLING 0000000000000000
      ...

      But it never receives the binding response:

      Ср июл 23 13:02:59 2014 SENT Sent to 192.168.0.112 port 49152 (local 192.168.0.122 port 49152)
      type Binding Response (257)
      id cf9743e2865a61e3bb37e466
      * USERNAME MUOv:56in
      * XOR-MAPPED-ADDRESS 192.168.0.112 49152

      Instead, QXmpp decides not to create a transport layer for the video:

      Ср июл 23 12:46:54 2014 SENT
      <iq id="qxmpp53" to="voiceless@xmpp.ru.net/QXmpp" type="set">
      <jingle xmlns="urn:xmpp:jingle:1" action="session-terminate" sid="MkhKJTBKE8RJVZ1jVgNTWeiRvnf5p6Q5"/>
      </iq>

      I'm not sure but you can try checking:

      1) Your firewall config.
      2) May be a problem of the stun server.
      3) Or it may be a problem of QXmpp it self.

      Delete
    2. 1|2) - why could it be used runs in LAN situation than: STUN/TURN mentioned there well enough.

      Delete
    3. I've not tested so far, so is you continuing the work.

      Delete
    4. yes, i'm rebuilding qith extra debug in qxmpp and other servers as settings + qxmpp from git.

      Delete
    5. Are you connecting to your own server? May be you can try connecting with http://www.jabber.org/.

      Delete
  6. i am getting this error please help me
    error: LNK1104: cannot open file 'qxmpp_d.lib'

    ReplyDelete