Showcase 2 – QT Simple VoIP Program

This software is a DEMO, intended to demonstrates MY SKILLS in this subjects:

Programming LanguajeC++
IDEQt Creator 4.3.0
OSWindows, Ubuntu
QT version5.9 (WIndows) 5.5.1 (Ubuntu)
QT Technologies InvolvedAudio (low level), Network UDP communication, Dialog, threading
QT classes usedQDialog, QMainWindow, QHostAddress, QUdpSocket, QThread, QMutex, QIODevice, QAudioFormat, QAudioOutput, QAudioInput, QByteArray, QMessageBox, QString, QTableWidgetItem, QTableWidget.

And Other Widgets and general classes

Abstract

Showcase2 is a simple VoIP program completely developed using QT libraries, and C++, intended to be used inside your private network (does not implements any NAT traversal algorithm). Download this demo and prepare yourself with microphone and earphones.

Instructions

Windows:

  1. download & install VS 2015 redist using this link (or search from google).
  2. download software using this link
  3. unpack contents in a empty folder
  4. Double click and run simple_voip_program.exe
  5. You must see first about dialog, just click OK and continue next screen.

Ubuntu 16.04:

  1. download software using this link
  2. unpack contentes in a empty folder
  3. Double click and run deploy/simple_voip_linux_qt
  4. You must see first about dialog, just click OK and continue next screen.

Then you see VoIP program screen:

Just follow steps in order is showed.

NOTE: maybe you guess, but this program needs a partner or peer program running in other pc machine, both connected to the same private network (same router for example).

NOTE: i suggest you download and run Wireshark software, in order to sniff UDP packets traveling through UDP ports 20000 (control channel) & 20001 (voice channel).

Code Snippet

qint64 AudioInput::readData(char *data, qint64 maxlen)
{
    qint64 total = 0;
    QByteArray datagram;
    QHostAddress src_addr;
    int s, count;

    count = 0;
    do
    {
        audioUdpSocket->waitForReadyRead(100);
        while(total < maxlen && audioUdpSocket->hasPendingDatagrams())
        {
            datagram.resize(audioUdpSocket->pendingDatagramSize());
            if(audioUdpSocket->readDatagram(datagram.data(), datagram.size(), &src_addr) <= 0) continue;
            QByteArray decompress = qUncompress(datagram);
            s = decompress.size() - sizeof(int);
            if(s + total > maxlen) s = maxlen - total;
            if(s <= 0) return total;
            memcpy(data + total, decompress.data() + sizeof(int), s);
            total += s;
        }
    } while(total == 0 && count++ < 5);
    return total;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *