Commit 20900d15 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6288: cleanup in sdp.cpp/h

parent ed028bb1
This diff is collapsed.
......@@ -68,7 +68,6 @@ class SdpException : public std::exception
};
typedef std::vector<std::string> CryptoOffer;
typedef std::vector<sdpMedia *> SdpMediaList;
class Sdp
{
......@@ -82,24 +81,11 @@ class Sdp
*/
Sdp (pj_pool_t *pool);
/* Class destructor */
~Sdp();
/*
* Read accessor. Get the list of the local media capabilities.
*
* @return std::vector<sdpMedia*> the vector containing the different media
*/
std::vector<sdpMedia *> getLocalMediaCap (void) {
return localAudioMediaCap;
}
/**
* Accessor for the internal memory pool
*/
pj_pool_t *getMemoryPool (void) const {
return memPool;
return memPool_;
}
/**
......@@ -108,7 +94,7 @@ class Sdp
* @return The structure that describes a SDP session
*/
pjmedia_sdp_session *getLocalSdpSession (void) {
return localSession;
return localSession_;
}
/**
......@@ -117,70 +103,70 @@ class Sdp
* @return The structure that describe the SDP session
*/
pjmedia_sdp_session *getRemoteSdpSession(void) {
return remoteSession;
return remoteSession_;
}
/**
* Set the negociated sdp offer from the sip payload.
* Set the negotiated sdp offer from the sip payload.
*
* @param sdp the negociated offer
* @param sdp the negotiated offer
*/
void setActiveLocalSdpSession (const pjmedia_sdp_session *sdp);
/**
* read accessor. Return the negociated local session
* read accessor. Return the negotiated local session
*
* @return pjmedia_sdp_session The negociated offer
* @return pjmedia_sdp_session The negotiated offer
*/
pjmedia_sdp_session* getActiveLocalSdpSession (void) {
return activeLocalSession;
return activeLocalSession_;
}
/**
* Retrieve the negociated sdp offer from the sip payload.
* Retrieve the negotiated sdp offer from the sip payload.
*
* @param sdp the negociated offer
* @param sdp the negotiated offer
*/
void setActiveRemoteSdpSession (const pjmedia_sdp_session *sdp);
/**
* read accessor. Return the negociated offer
* read accessor. Return the negotiated offer
*
* @return pjmedia_sdp_session The negociated offer
* @return pjmedia_sdp_session The negotiated offer
*/
pjmedia_sdp_session* getActiveRemoteSdpSession (void) {
return activeRemoteSession;
return activeRemoteSession_;
}
/**
* Return wether or not the media have been determined for this sdp session
*/
bool hasSessionMedia(void);
* Return whether or not the media have been determined for this sdp session
*/
bool hasSessionMedia(void) const;
/**
* Return the codec of the first media after negociation
* Return the codec of the first media after negotiation
*/
sfl::AudioCodec* getSessionMedia (void) throw(SdpException);
/*
* On building an invite outside a dialog, build the local offer and create the
* SDP negociator instance with it.
* SDP negotiator instance with it.
*/
int createOffer (CodecOrder selectedCodecs);
/*
* On receiving an invite outside a dialog, build the local offer and create the
* SDP negociator instance with the remote offer.
* SDP negotiator instance with the remote offer.
*
* @param remote The remote offer
*/
int recieveOffer (const pjmedia_sdp_session* remote, CodecOrder selectedCodecs);
int receiveOffer (const pjmedia_sdp_session* remote, CodecOrder selectedCodecs);
/*
* On receiving a message, check if it contains SDP and negotiate. Should be used for
* SDP answer and offer but currently is only used for answer.
* SDP negociator instance with the remote offer.
* SDP negotiator instance with the remote offer.
*
* @param inv The the invitation
* @param rdata The remote data
......@@ -193,12 +179,12 @@ class Sdp
int generateAnswerAfterInitialOffer(void);
/**
* Start the sdp negociation.
* Start the sdp negotiation.
*
* @return pj_status_t 0 on success
* 1 otherwise
*/
pj_status_t startNegociation (void);
pj_status_t startNegotiation (void);
/**
* Update internal state after negotiation
......@@ -215,12 +201,6 @@ class Sdp
*/
void cleanLocalMediaCapabilities (void);
/**
* Return a string description of the media added to the session,
* ie the local media capabilities
*/
std::string mediaToString (void);
/*
* Attribute the specified port to every medias provided
* This is valid only because we are using one media
......@@ -230,33 +210,32 @@ class Sdp
*/
void setPortToAllMedia (int port);
/*
* Write accessor. Set the local IP address that will be used in the sdp session
*/
void setLocalIP (std::string ip_addr) {
localIpAddr = ip_addr;
void setLocalIP (const std::string &ip_addr) {
localIpAddr_ = ip_addr;
}
/*
* Read accessor. Get the local IP address
*/
std::string getLocalIP (void) {
return localIpAddr;
std::string getLocalIP (void) const {
return localIpAddr_;
}
/**
* @param Set the published audio port
*/
void setLocalPublishedAudioPort (int port) {
localAudioPort = port;
localAudioPort_ = port;
}
/**
* @return The published audio port
*/
int getLocalPublishedAudioPort (void) {
return localAudioPort;
int getLocalPublishedAudioPort (void) const {
return localAudioPort_;
}
/**
......@@ -264,7 +243,7 @@ class Sdp
* @param ip The remote IP address
*/
void setRemoteIP (const std::string& ip) {
remoteIpAddr = ip;
remoteIpAddr_ = ip;
}
/**
......@@ -272,7 +251,7 @@ class Sdp
* @return const std:string The remote IP address
*/
const std::string& getRemoteIP() {
return remoteIpAddr;
return remoteIpAddr_;
}
/**
......@@ -280,22 +259,23 @@ class Sdp
* @param port The remote audio port
*/
void setRemoteAudioPort (unsigned int port) {
remoteAudioPort = port;
remoteAudioPort_ = port;
}
/**
* Return audio port at destination [mutex protected]
* @return unsigned int The remote audio port
*/
unsigned int getRemoteAudioPort() {
return remoteAudioPort;
unsigned int getRemoteAudioPort() const {
return remoteAudioPort_;
}
/**
* Get media list for this session
*/
SdpMediaList getSessionMediaList (void) {
return sessionAudioMedia;
std::vector<sdpMedia *> getSessionMediaList (void) const {
return sessionAudioMedia_;
}
/**
......@@ -308,7 +288,6 @@ class Sdp
*/
void removeAttributeFromLocalAudioMedia(std::string);
/**
* Get SRTP master key
* @param remote sdp session
......@@ -321,7 +300,7 @@ class Sdp
* @param mk The Master Key of a srtp session.
*/
void setLocalSdpCrypto (const std::vector<std::string> lc) {
srtpCrypto = lc;
srtpCrypto_ = lc;
}
/**
......@@ -331,99 +310,91 @@ class Sdp
* @param hash The hello hash of a rtp session. (Only audio at the moment)
*/
void setZrtpHash (const std::string& hash) {
zrtpHelloHash = hash;
zrtpHelloHash_ = hash;
}
unsigned int getTelephoneEventType() {
return telephoneEventPayload;
unsigned int getTelephoneEventType() const {
return telephoneEventPayload_;
}
/**
* Print internal state info
*/
void toString (void);
private:
/**
* The pool to allocate memory, ownership to SipCall
* SDP should not release the pool itself
*/
pj_pool_t *memPool;
pj_pool_t *memPool_;
/** negociator */
pjmedia_sdp_neg *negociator;
/** negotiator */
pjmedia_sdp_neg *negotiator_;
/**
* Local SDP
*/
pjmedia_sdp_session *localSession;
pjmedia_sdp_session *localSession_;
/**
* Remote SDP
*/
pjmedia_sdp_session *remoteSession;
pjmedia_sdp_session *remoteSession_;
/**
* The negociated SDP remote session
* Explanation: each endpoint's offer is negociated, and a new sdp offer results from this
* negociation, with the compatible media from each part
* The negotiated SDP remote session
* Explanation: each endpoint's offer is negotiated, and a new sdp offer results from this
* negotiation, with the compatible media from each part
*/
pjmedia_sdp_session *activeLocalSession;
pjmedia_sdp_session *activeLocalSession_;
/**
* The negociated SDP remote session
* Explanation: each endpoint's offer is negociated, and a new sdp offer results from this
* negociation, with the compatible media from each part
* The negotiated SDP remote session
* Explanation: each endpoint's offer is negotiated, and a new sdp offer results from this
* negotiation, with the compatible media from each part
*/
pjmedia_sdp_session *activeRemoteSession;
pjmedia_sdp_session *activeRemoteSession_;
/**
* Codec Map used for offer
*/
SdpMediaList localAudioMediaCap;
std::vector<sdpMedia *> localAudioMediaCap_;
/**
* The media that will be used by the session (after the SDP negociation)
* The media that will be used by the session (after the SDP negotiation)
*/
SdpMediaList sessionAudioMedia;
std::vector<sdpMedia *> sessionAudioMedia_;
/**
* IP address
*/
std::string localIpAddr;
std::string localIpAddr_;
/**
* Remote's IP address
*/
std::string remoteIpAddr;
std::string remoteIpAddr_;
/**
* Local audio port
*/
int localAudioPort;
int localAudioPort_;
/**
* Remote audio port
*/
unsigned int remoteAudioPort;
unsigned int remoteAudioPort_;
/**
* Zrtp hello hash
*/
std::string zrtpHelloHash;
std::string zrtpHelloHash_;
/**
* "a=crypto" sdes local attributes obtained from AudioSrtpSession
*/
std::vector<std::string> srtpCrypto;
std::vector<std::string> srtpCrypto_;
/**
* Payload type for dtmf telephone event
*/
unsigned int telephoneEventPayload;
unsigned int telephoneEventPayload_;
Sdp (const Sdp&); //No Copy Constructor
......@@ -482,7 +453,6 @@ class Sdp
*/
void addTiming (void);
/*
* Optional field: Session information ("s=")
* Provides textual information about the session.
......@@ -557,8 +527,6 @@ class Sdp
void getRemoteSdpTelephoneEventFromOffer(const pjmedia_sdp_session *remote_sdp);
void getRemoteSdpMediaFromOffer (const pjmedia_sdp_session* remote_sdp, pjmedia_sdp_media** r_media);
};
......
......@@ -764,7 +764,7 @@ SIPVoIPLink::answer (const CallID& id) throw (VoipLinkException)
if (status == PJ_SUCCESS) {
_debug ("UserAgent: SDP Negociation success! : call %s ", call->getCallId().c_str());
_debug ("UserAgent: SDP negotiation success! : call %s ", call->getCallId().c_str());
// Create and send a 200(OK) response
if((status = pjsip_inv_answer (inv_session, PJSIP_SC_OK, NULL, NULL, &tdata)) != PJ_SUCCESS) {
throw VoipLinkException("Could not init invite request answer (200 OK)");
......@@ -778,7 +778,7 @@ SIPVoIPLink::answer (const CallID& id) throw (VoipLinkException)
return true;
} else {
// Create and send a 488/Not acceptable because the SDP negociation failed
// Create and send a 488/Not acceptable because the SDP negotiation failed
if((status = pjsip_inv_answer (inv_session, PJSIP_SC_NOT_ACCEPTABLE_HERE, NULL, NULL, &tdata)) != PJ_SUCCESS) {
throw VoipLinkException("Could not init invite answer (488 not acceptable here)");
}
......@@ -786,7 +786,7 @@ SIPVoIPLink::answer (const CallID& id) throw (VoipLinkException)
throw VoipLinkException("Could not init invite request answer (488 NOT ACCEPTABLE HERE)");
}
// Terminate the call
_debug ("UserAgent: SDP Negociation failed, terminate call %s ", call->getCallId().c_str());
_debug ("UserAgent: SDP negotiation failed, terminate call %s ", call->getCallId().c_str());
if(call->getAudioRtp()) {
throw VoipLinkException("No audio rtp session for this call");
......@@ -3329,8 +3329,8 @@ void sdp_request_offer_cb (pjsip_inv_session *inv, const pjmedia_sdp_session *of
SIPAccount *account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (accId));
status = call->getLocalSDP()->recieveOffer (offer, account->getActiveCodecs ());
call->getLocalSDP()->startNegociation();
status = call->getLocalSDP()->receiveOffer (offer, account->getActiveCodecs ());
call->getLocalSDP()->startNegotiation();
status = pjsip_inv_set_sdp_answer (call->getInvSession(), call->getLocalSDP()->getLocalSdpSession());
......@@ -3397,7 +3397,7 @@ void sdp_media_update_cb (pjsip_inv_session *inv, pj_status_t status)
call = reinterpret_cast<SIPCall *> (inv->mod_data[getModId()]);
if (call == NULL) {
_debug ("UserAgent: Call declined by peer, SDP negociation stopped");
_debug ("UserAgent: Call declined by peer, SDP negotiation stopped");
return;
}
......@@ -3470,7 +3470,7 @@ void sdp_media_update_cb (pjsip_inv_session *inv, pj_status_t status)
sfl::SdesNegotiator sdesnego (localCapabilities, crypto_offer);
if (sdesnego.negotiate()) {
_debug ("UserAgent: SDES negociation successfull");
_debug ("UserAgent: SDES negotiation successfull");
nego_success = true;
_debug ("UserAgent: Set remote cryptographic context");
......@@ -3492,7 +3492,7 @@ void sdp_media_update_cb (pjsip_inv_session *inv, pj_status_t status)
// We did not found any crypto context for this media
// @TODO if SRTPONLY, CallFail
_debug ("UserAgent: Did not found any crypto or negociation failed but Sdes enabled");
_debug ("UserAgent: Did not found any crypto or negotiation failed but Sdes enabled");
call->getAudioRtp()->stop();
call->getAudioRtp()->setSrtpEnabled (false);
......@@ -3972,7 +3972,7 @@ transaction_request_cb (pjsip_rx_data *rdata)
// Set the codec map, IP, peer number and so on... for the SIPCall object
setCallMediaLocal (call, addrToUse);
// We retrieve the remote sdp offer in the rdata struct to begin the negociation
// We retrieve the remote sdp offer in the rdata struct to begin the negotiation
call->getLocalSDP()->setLocalIP (addrSdp);
// Init audio rtp session
......@@ -4017,7 +4017,7 @@ transaction_request_cb (pjsip_rx_data *rdata)
sfl::SdesNegotiator sdesnego (localCapabilities, crypto_offer);
if (sdesnego.negotiate()) {
_debug ("UserAgent: SDES negociation successfull \n");
_debug ("UserAgent: SDES negotiation successfull \n");
nego_success = true;
try {
......@@ -4033,7 +4033,7 @@ transaction_request_cb (pjsip_rx_data *rdata)
}
status = call->getLocalSDP()->recieveOffer (r_sdp, account->getActiveCodecs ());
status = call->getLocalSDP()->receiveOffer (r_sdp, account->getActiveCodecs ());
if (status!=PJ_SUCCESS) {
delete call;
call = NULL;
......@@ -4687,8 +4687,6 @@ bool setCallMediaLocal (SIPCall* call, const std::string &localIP)
account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (account_id));
// Setting Audio
unsigned int callLocalAudioPort = RANDOM_LOCAL_PORT;
unsigned int callLocalExternAudioPort = callLocalAudioPort;
......
......@@ -144,7 +144,7 @@ void SDPTest::testInitialOfferFirstCodec ()
_session->receivingAnswerAfterInitialOffer(remoteAnswer);
_session->startNegociation();
_session->startNegotiation();
_session->updateInternalState();
......@@ -177,9 +177,9 @@ void SDPTest::testInitialAnswerFirstCodec ()
_session->setLocalIP("127.0.0.1");
_session->setLocalPublishedAudioPort(49567);
_session->recieveOffer(remoteOffer, codecSelection);
_session->receiveOffer(remoteOffer, codecSelection);
_session->startNegociation();
_session->startNegotiation();
_session->updateInternalState();
......@@ -217,7 +217,7 @@ void SDPTest::testInitialOfferLastCodec ()
_session->receivingAnswerAfterInitialOffer(remoteAnswer);
_session->startNegociation();
_session->startNegotiation();
_session->updateInternalState();
......@@ -250,9 +250,9 @@ void SDPTest::testInitialAnswerLastCodec ()
_session->setLocalIP("127.0.0.1");
_session->setLocalPublishedAudioPort(49567);
_session->recieveOffer(remoteOffer, codecSelection);
_session->receiveOffer(remoteOffer, codecSelection);
_session->startNegociation();
_session->startNegotiation();
_session->updateInternalState();
......@@ -292,7 +292,7 @@ void SDPTest::testReinvite ()
_session->receivingAnswerAfterInitialOffer(remoteAnswer);
_session->startNegociation();
_session->startNegotiation();
_session->updateInternalState();
......@@ -304,9 +304,9 @@ void SDPTest::testReinvite ()
pjmedia_sdp_parse(_testPool, (char*)sdp_reinvite, strlen(sdp_reinvite), &reinviteOffer);
_session->recieveOffer(reinviteOffer, codecSelection);
_session->receiveOffer(reinviteOffer, codecSelection);
_session->startNegociation();
_session->startNegotiation();
_session->updateInternalState();
......
Supports Markdown
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