2011-04-07 15:38:27 +02:00
|
|
|
#ifndef ICESESSION_H
|
|
|
|
#define ICESESSION_H
|
|
|
|
|
2011-05-18 15:54:26 +02:00
|
|
|
#include <pj/addr_resolv.h>
|
2011-04-07 15:38:27 +02:00
|
|
|
#include <pjlib.h>
|
|
|
|
#include <pjlib-util.h>
|
|
|
|
#include <pjnath.h>
|
|
|
|
|
|
|
|
#include <QHostAddress>
|
|
|
|
#include <QList>
|
2011-05-19 16:29:25 +02:00
|
|
|
#include <QIODevice>
|
2011-04-07 15:38:27 +02:00
|
|
|
#include <QtDebug>
|
|
|
|
|
|
|
|
#include <xrme/connection.h>
|
|
|
|
|
|
|
|
|
2011-05-19 16:29:25 +02:00
|
|
|
class ICESession : public QIODevice {
|
2011-04-07 15:38:27 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2011-05-18 15:54:26 +02:00
|
|
|
enum Direction {
|
|
|
|
DirectionControlling = 0,
|
|
|
|
DirectionControlled,
|
|
|
|
};
|
|
|
|
|
2011-04-07 15:38:27 +02:00
|
|
|
explicit ICESession(QObject* parent = 0);
|
|
|
|
|
|
|
|
static void StaticInit();
|
2011-05-18 15:54:26 +02:00
|
|
|
bool Init(Direction direction);
|
2011-04-07 15:38:27 +02:00
|
|
|
|
|
|
|
const xrme::SIPInfo& candidates() const { return candidates_; }
|
|
|
|
|
|
|
|
void StartNegotiation(const xrme::SIPInfo& session);
|
|
|
|
|
2011-05-19 16:29:25 +02:00
|
|
|
protected:
|
|
|
|
virtual qint64 readData(char* data, qint64 max_size);
|
|
|
|
virtual qint64 writeData(const char* data, qint64 max_size);
|
|
|
|
|
2011-04-07 15:38:27 +02:00
|
|
|
signals:
|
|
|
|
void CandidatesAvailable(const xrme::SIPInfo& candidates);
|
|
|
|
|
|
|
|
private:
|
|
|
|
pj_ice_strans* ice_instance_;
|
|
|
|
int component_id_;
|
|
|
|
|
|
|
|
xrme::SIPInfo candidates_;
|
|
|
|
|
2011-05-19 16:29:25 +02:00
|
|
|
QByteArray receive_buffer_;
|
|
|
|
|
2011-04-07 15:38:27 +02:00
|
|
|
void InitialisationComplete(pj_status_t status);
|
|
|
|
|
2011-05-18 15:54:26 +02:00
|
|
|
static void PJLog(int level, const char* data, int len);
|
2011-04-07 15:38:27 +02:00
|
|
|
|
|
|
|
static int HandleEvents(unsigned max_msec, unsigned* p_count);
|
|
|
|
static int WorkerThread(void*);
|
|
|
|
|
|
|
|
static void OnReceiveData(pj_ice_strans* ice_st,
|
|
|
|
unsigned comp_id,
|
|
|
|
void* pkt,
|
|
|
|
pj_size_t size,
|
|
|
|
const pj_sockaddr_t* src_addr,
|
|
|
|
unsigned src_addr_len);
|
|
|
|
static void OnICEComplete(pj_ice_strans* ice_st,
|
|
|
|
pj_ice_strans_op op,
|
|
|
|
pj_status_t status);
|
|
|
|
|
|
|
|
static pj_pool_t* sPool;
|
|
|
|
static pj_caching_pool sCachingPool;
|
|
|
|
static pj_ice_strans_cfg sIceConfig;
|
|
|
|
static pj_thread_t* sThread;
|
|
|
|
|
|
|
|
static int sComponentId;
|
|
|
|
|
|
|
|
static const char* kStunServer;
|
|
|
|
};
|
|
|
|
|
|
|
|
QDebug operator<< (QDebug dbg, const xrme::SIPInfo& session);
|
|
|
|
|
|
|
|
#endif // ICESESSION_H
|