Commit 4a57b5b5 authored by Alexandre Bourget's avatar Alexandre Bourget

Move stuff from SIPCall to Call, for future IAX support.

parent 0ddc602c
......@@ -19,10 +19,16 @@
*/
#include "call.h"
Call::Call(const CallID& id, Call::CallType type) : _id(id), _type(type)
Call::Call(const CallID& id, Call::CallType type) : _id(id), _type(type),
_localIPAddress(""),
_remoteIPAddress("")
{
_connectionState = Call::Disconnected;
_callState = Call::Inactive;
_audioCodec = 0;
_localAudioPort = 0;
_localExternalAudioPort = 0;
_remoteAudioPort = 0;
}
......@@ -59,3 +65,58 @@ Call::getState()
return _callState;
}
CodecDescriptorMap&
Call::getCodecMap()
{
return _codecMap;
}
const std::string&
Call::getLocalIp()
{
ost::MutexLock m(_callMutex);
return _localIPAddress;
}
unsigned int
Call::getLocalAudioPort()
{
ost::MutexLock m(_callMutex);
return _localAudioPort;
}
unsigned int
Call::getRemoteAudioPort()
{
ost::MutexLock m(_callMutex);
return _remoteAudioPort;
}
const std::string&
Call::getRemoteIp()
{
ost::MutexLock m(_callMutex);
return _remoteIPAddress;
}
AudioCodec*
Call::getAudioCodec()
{
ost::MutexLock m(_callMutex);
return _audioCodec;
}
void
Call::setAudioStart(bool start)
{
ost::MutexLock m(_callMutex);
_audioStarted = start;
}
bool
Call::isAudioStarted()
{
ost::MutexLock m(_callMutex);
return _audioStarted;
}
......@@ -22,11 +22,13 @@
#include <string>
#include <cc++/thread.h> // for mutex
#include "audio/codecDescriptor.h"
typedef std::string CallID;
/**
* A call is the base classes for protocol-based calls
* A call is the base class for protocol-based calls
*
* @author Yan Morin <yan.morin@gmail.com>
*/
class Call{
......@@ -88,10 +90,91 @@ public:
*/
CallState getState();
/**
* Set the audio start boolean (protected by mutex)
* @param start true if we start the audio
*/
void setAudioStart(bool start);
/**
* Tell if the audio is started (protected by mutex)
* @return true if it's already started
*/
bool isAudioStarted();
// AUDIO
/** Set internal codec Map: initialization only, not protected */
void setCodecMap(const CodecDescriptorMap& map) { _codecMap = map; }
CodecDescriptorMap& getCodecMap();
/** Set my IP [not protected] */
void setLocalIp(const std::string& ip) { _localIPAddress = ip; }
/** Set local audio port, as seen by me [not protected] */
void setLocalAudioPort(unsigned int port) { _localAudioPort = port;}
/** Set the audio port that remote will see. */
void setLocalExternAudioPort(unsigned int port) { _localExternalAudioPort = port; }
/** Return the audio port seen by the remote side. */
unsigned int getLocalExternAudioPort() { return _localExternalAudioPort; }
/** Return my IP [mutex protected] */
const std::string& getLocalIp();
/** Return port used locally (for my machine) [mutex protected] */
unsigned int getLocalAudioPort();
/** Return audio port at destination [mutex protected] */
unsigned int getRemoteAudioPort();
/** Return IP of destination [mutex protected] */
const std::string& getRemoteIp();
/** Return audio codec [mutex protected] */
AudioCodec* getAudioCodec();
protected:
/** Protect every attribute that can be changed by two threads */
ost::Mutex _callMutex;
/** Set remote's IP addr. [not protected] */
void setRemoteIP(const std::string& ip) { _remoteIPAddress = ip; }
/** Set remote's audio port. [not protected] */
void setRemoteAudioPort(unsigned int port) { _remoteAudioPort = port; }
/** Set the audio codec used. [not protected] */
void setAudioCodec(AudioCodec* audioCodec) { _audioCodec = audioCodec; }
/** Codec Map */
CodecDescriptorMap _codecMap;
/** Codec pointer */
AudioCodec* _audioCodec;
bool _audioStarted;
// Informations about call socket / audio
/** My IP address */
std::string _localIPAddress;
/** Local audio port, as seen by me. */
unsigned int _localAudioPort;
/** Port assigned to my machine by the NAT, as seen by remote peer (he connects there) */
unsigned int _localExternalAudioPort;
/** Remote's IP address */
std::string _remoteIPAddress;
/** Remote's audio port */
unsigned int _remoteAudioPort;
private:
/** Unique ID of the call */
CallID _id;
......@@ -108,6 +191,7 @@ private:
/** Number of the peer */
std::string _peerNumber;
};
#endif
......@@ -26,28 +26,17 @@
#define _SENDONLY 1
#define _RECVONLY 2
SIPCall::SIPCall(const CallID& id, Call::CallType type) : Call(id, type),
_localIPAddress(""), _remoteIPAddress("")
SIPCall::SIPCall(const CallID& id, Call::CallType type) : Call(id, type)
{
_cid = 0;
_did = 0;
_tid = 0;
_audioCodec = 0;
_localAudioPort = 0;
_localExternalAudioPort = 0;
_remoteAudioPort = 0;
}
SIPCall::~SIPCall()
{
}
CodecDescriptorMap&
SIPCall::getCodecMap()
{
return _codecMap;
}
/**
* Answer incoming call correclty before telling the user
* @param event eXosip Event
......@@ -335,55 +324,6 @@ SIPCall::SIPCallAnsweredWithoutHold(eXosip_event_t* event)
return true;
}
const std::string&
SIPCall::getLocalIp()
{
ost::MutexLock m(_callMutex);
return _localIPAddress;
}
unsigned int
SIPCall::getLocalAudioPort()
{
ost::MutexLock m(_callMutex);
return _localAudioPort;
}
unsigned int
SIPCall::getRemoteAudioPort()
{
ost::MutexLock m(_callMutex);
return _remoteAudioPort;
}
const std::string&
SIPCall::getRemoteIp()
{
ost::MutexLock m(_callMutex);
return _remoteIPAddress;
}
AudioCodec*
SIPCall::getAudioCodec()
{
ost::MutexLock m(_callMutex);
return _audioCodec;
}
void
SIPCall::setAudioStart(bool start)
{
ost::MutexLock m(_callMutex);
_audioStarted = start;
}
bool
SIPCall::isAudioStarted()
{
ost::MutexLock m(_callMutex);
return _audioStarted;
}
//TODO: humm?
int
SIPCall::sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg)
......
......@@ -50,17 +50,6 @@ public:
/** @param did SIP transaction id : protected by eXosip lock */
void setTid(int tid) { _tid = tid; }
// AUDIO
/** Set internal codec Map: initialization only, not protected */
void setCodecMap(const CodecDescriptorMap& map) { _codecMap = map; }
CodecDescriptorMap& getCodecMap();
/** set internal, not protected */
void setLocalIp(const std::string& ip) { _localIPAddress = ip; }
void setLocalAudioPort(unsigned int port) { _localAudioPort = port;}
void setLocalExternAudioPort(unsigned int port) { _localExternalAudioPort = port; }
unsigned int getLocalExternAudioPort() { return _localExternalAudioPort; }
/**
* Answer incoming call correclty before telling the user
* @param event eXosip Event
......@@ -89,33 +78,11 @@ public:
*/
bool SIPCallAnsweredWithoutHold(eXosip_event_t *event);
/** protected */
const std::string& getLocalIp();
unsigned int getLocalAudioPort();
unsigned int getRemoteAudioPort();
const std::string& getRemoteIp();
AudioCodec* getAudioCodec();
/**
* Set the audio start boolean (protected by mutex)
* @param start true if we start the audio
*/
void setAudioStart(bool start);
/**
* Tell if the audio is started (protected by mutex)
* @return true if it's already started
*/
bool isAudioStarted();
//TODO: humm?
int sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg);
private:
/** set internal, not protected */
void setRemoteIP(const std::string& ip) { _remoteIPAddress = ip; }
void setRemoteAudioPort(unsigned int port) { _remoteAudioPort = port; }
void setAudioCodec(AudioCodec* audioCodec) { _audioCodec = audioCodec; }
// TODO: hum???
int sdp_analyse_attribute (sdp_message_t * sdp, sdp_media_t * med);
......@@ -124,9 +91,11 @@ private:
* @param event eXosip event
* @return false the event is invalid
*/
bool setPeerInfoFromRequest(eXosip_event_t *event);
/**
* Get a valid remote SDP or return a 400 bad request response if invalid
*
* @param event eXosip event
* @return valid remote_sdp or 0
*/
......@@ -134,6 +103,7 @@ private:
/**
* Get a valid remote media or return a 415 unsupported media type
*
* @param tid transaction id
* @param remote_sdp Remote SDP pointer
* @return valid sdp_media_t or 0
......@@ -163,19 +133,6 @@ private:
/** SIP transaction id */
int _tid;
/** Codec Map */
CodecDescriptorMap _codecMap;
/** codec pointer */
AudioCodec* _audioCodec;
bool _audioStarted;
// Informations about call socket / audio
std::string _localIPAddress;
unsigned int _localAudioPort;
unsigned int _localExternalAudioPort; // what peer (NAT) should connect to
std::string _remoteIPAddress;
unsigned int _remoteAudioPort;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment