Skip to content
Snippets Groups Projects
Commit 734cefc5 authored by llea's avatar llea
Browse files

Clean up code

parent 53755324
Branches
Tags
No related merge requests found
...@@ -120,7 +120,6 @@ SipVoIPLink::init (void) ...@@ -120,7 +120,6 @@ SipVoIPLink::init (void)
} }
eXosip_set_user_agent(tmp.data()); eXosip_set_user_agent(tmp.data());
// initRtpmapCodec();
_evThread->start(); _evThread->start();
return 1; return 1;
} }
...@@ -135,12 +134,6 @@ SipVoIPLink::isInRtpmap (int index, int payload, CodecDescriptorVector* cdv) { ...@@ -135,12 +134,6 @@ SipVoIPLink::isInRtpmap (int index, int payload, CodecDescriptorVector* cdv) {
return false; return false;
} }
void
SipVoIPLink::initRtpmapCodec (void)
{
}
void void
SipVoIPLink::quit(void) SipVoIPLink::quit(void)
{ {
...@@ -361,11 +354,6 @@ SipVoIPLink::onhold (short id) ...@@ -361,11 +354,6 @@ SipVoIPLink::onhold (short id)
return -1; return -1;
} }
/*
char port[10];
snprintf (port, 10, "%d", getSipCall(id)->getLocalAudioPort());
*/
eXosip_lock (); eXosip_lock ();
// Build INVITE_METHOD for put call on-hold // Build INVITE_METHOD for put call on-hold
i = eXosip_call_build_request (did, INVITE_METHOD, &invite); i = eXosip_call_build_request (did, INVITE_METHOD, &invite);
...@@ -425,11 +413,6 @@ SipVoIPLink::offhold (short id) ...@@ -425,11 +413,6 @@ SipVoIPLink::offhold (short id)
return -1; return -1;
} }
/*
char port[10];
snprintf (port, 10, "%d", getSipCall(id)->getLocalAudioPort());
*/
eXosip_lock (); eXosip_lock ();
// Build INVITE_METHOD for put call off-hold // Build INVITE_METHOD for put call off-hold
i = eXosip_call_build_request (did, INVITE_METHOD, &invite); i = eXosip_call_build_request (did, INVITE_METHOD, &invite);
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
using namespace std; using namespace std;
#define EXPIRES_VALUE 180 #define EXPIRES_VALUE 180
// To build request
#define INVITE_METHOD "INVITE" #define INVITE_METHOD "INVITE"
// 1XX responses // 1XX responses
#define DIALOG_ESTABLISHED 101 #define DIALOG_ESTABLISHED 101
...@@ -63,7 +64,14 @@ class CodecDescriptor; ...@@ -63,7 +64,14 @@ class CodecDescriptor;
class EventThread; class EventThread;
class SipCall; class SipCall;
/*
* Vector of Sipcall
*/
typedef vector<SipCall*, allocator<SipCall*> > SipCallVector; typedef vector<SipCall*, allocator<SipCall*> > SipCallVector;
/*
* Vector of CodecDescriptor
*/
typedef vector<CodecDescriptor*, allocator<CodecDescriptor*> > CodecDescriptorVector; typedef vector<CodecDescriptor*, allocator<CodecDescriptor*> > CodecDescriptorVector;
class SipVoIPLink : public VoIPLink { class SipVoIPLink : public VoIPLink {
...@@ -73,7 +81,6 @@ public: ...@@ -73,7 +81,6 @@ public:
virtual int init (void); virtual int init (void);
virtual bool checkNetwork (void); virtual bool checkNetwork (void);
virtual void initRtpmapCodec (void);
virtual void quit (void); virtual void quit (void);
virtual int setRegister (void); virtual int setRegister (void);
virtual int outgoingInvite (short id, const string& to_url); virtual int outgoingInvite (short id, const string& to_url);
...@@ -87,6 +94,9 @@ public: ...@@ -87,6 +94,9 @@ public:
virtual int getEvent (void); virtual int getEvent (void);
virtual void carryingDTMFdigits (short id, char code); virtual void carryingDTMFdigits (short id, char code);
/*
* To handle the local port
*/
int getLocalPort (void); int getLocalPort (void);
void setLocalPort (int); void setLocalPort (int);
...@@ -106,27 +116,78 @@ public: ...@@ -106,27 +116,78 @@ public:
*/ */
SipCall* getSipCall(short callid); SipCall* getSipCall(short callid);
/*
* Accessor to the audio codec of SipCall with identifiant 'id'
*/
AudioCodec* getAudioCodec(short callid); AudioCodec* getAudioCodec(short callid);
// To Cancel // Use to Cancel
inline void setCid (int cid) { _cid = cid; } inline void setCid (int cid) { _cid = cid; }
inline int getCid (void) { return _cid; } inline int getCid (void) { return _cid; }
private: private:
/*
* If you are behind a NAT, you have to use STUN server, specified in
* STUN configuration(you can change this one by default) to give you an
* public IP address and assign a port number.
*
* Return 0 if an error occured and 1 if no error.
*/
int behindNat (void); int behindNat (void);
/*
* To Store the local IP address, and allow to know if the network is
* available.
*
* Return -1 if an error occured and 0 if no error
*/
int getLocalIp (void); int getLocalIp (void);
/*
* Return -1 if an error occured and 0 if no error
*/
int checkUrl(const string& url); int checkUrl(const string& url);
/*
* Allow the authentication when you want register
* Return -1 if an error occured and 0 if no error
*/
int setAuthentication (void); int setAuthentication (void);
/*
* Build a sip address from the user configuration
* Example: "Display user name" <sip:user@host.com>
* Return the result in a string
*/
string fromHeader (const string& user, const string& host); string fromHeader (const string& user, const string& host);
/*
* Build a sip address with the number that you want to call
* Example: sip:124@domain.com
* Return the result in a string
*/
string toHeader(const string& to); string toHeader(const string& to);
/*
* Beginning point to make outgoing call.
* Check the 'from' and 'to' url.
* Allocate local audio port.
* Build SDP body.
* Return -1 if an error occured and 0 if no error
*/
int startCall (short id, const string& from, const string& to, int startCall (short id, const string& from, const string& to,
const string& subject, const string& route); const string& subject, const string& route);
/* /*
* Look for call with same cid/did * Look for call with same cid/did
* Return the id of the found call * Return the id of the found call
*/ */
short findCallId (eXosip_event_t *e); short findCallId (eXosip_event_t *e);
short findCallIdWhenRinging (void); short findCallIdWhenRinging (void);
/*
* Return true if payload is already in the rtpmap and false if not
*/
bool isInRtpmap (int index, int payload, CodecDescriptorVector* cdv); bool isInRtpmap (int index, int payload, CodecDescriptorVector* cdv);
/* /*
...@@ -144,12 +205,14 @@ private: ...@@ -144,12 +205,14 @@ private:
*/ */
int sdp_off_hold_call (sdp_message_t * sdp); int sdp_off_hold_call (sdp_message_t * sdp);
///////////////////////////
// Private member variables
///////////////////////////
EventThread* _evThread; EventThread* _evThread;
SipCallVector* _sipcallVector; SipCallVector* _sipcallVector;
AudioRtp* _audiortp; AudioRtp* _audiortp;
int _localPort; int _localPort;
int _cid; int _cid;
}; };
#endif // __SIP_VOIP_LINK_H__ #endif // __SIP_VOIP_LINK_H__
...@@ -31,15 +31,16 @@ enum VoIPLinkType { ...@@ -31,15 +31,16 @@ enum VoIPLinkType {
class AudioCodec; class AudioCodec;
class Call; class Call;
class VoIPLink { class VoIPLink {
public: public:
VoIPLink (short id); VoIPLink (short id);
virtual ~VoIPLink (void); virtual ~VoIPLink (void);
// Pure virtual functions
virtual int getEvent (void) = 0; virtual int getEvent (void) = 0;
virtual int init (void) = 0; virtual int init (void) = 0;
virtual bool checkNetwork (void) = 0; virtual bool checkNetwork (void) = 0;
virtual void initRtpmapCodec (void) = 0;
virtual void quit (void) = 0; virtual void quit (void) = 0;
virtual void newOutgoingCall (short callid) = 0; virtual void newOutgoingCall (short callid) = 0;
virtual void newIncomingCall (short callid) = 0; virtual void newIncomingCall (short callid) = 0;
...@@ -54,7 +55,6 @@ public: ...@@ -54,7 +55,6 @@ public:
virtual int refuse (short id) = 0; virtual int refuse (short id) = 0;
virtual int setRegister (void) = 0; virtual int setRegister (void) = 0;
virtual void carryingDTMFdigits(short id, char code) = 0; virtual void carryingDTMFdigits(short id, char code) = 0;
virtual AudioCodec* getAudioCodec (short callid) = 0; virtual AudioCodec* getAudioCodec (short callid) = 0;
void setId (short id); void setId (short id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment