Clementine-audio-player-Mac.../src/remote/icesession.h

79 lines
1.8 KiB
C
Raw Normal View History

#ifndef ICESESSION_H
#define ICESESSION_H
#include <pj/addr_resolv.h>
#include <pjlib.h>
#include <pjlib-util.h>
#include <pjnath.h>
#include <QHostAddress>
#include <QList>
2011-05-19 16:29:25 +02:00
#include <QIODevice>
#include <QtDebug>
#include <xrme/connection.h>
2011-05-19 16:29:25 +02:00
class ICESession : public QIODevice {
Q_OBJECT
public:
enum Direction {
DirectionControlling = 0,
DirectionControlled,
};
explicit ICESession(QObject* parent = 0);
static void StaticInit();
bool Init(Direction direction);
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);
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_;
void InitialisationComplete(pj_status_t status);
static void PJLog(int level, const char* data, int len);
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