Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
3428846c
Commit
3428846c
authored
Jun 28, 2011
by
Tristan Matthews
Browse files
* #6288: cleanup in sdp.cpp/h
parent
1e547539
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
sflphone-common/src/sip/sdp.cpp
View file @
3428846c
This diff is collapsed.
Click to expand it.
sflphone-common/src/sip/sdp.h
View file @
3428846c
...
...
@@ -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 nego
c
iated sdp offer from the sip payload.
* Set the nego
t
iated sdp offer from the sip payload.
*
* @param sdp the nego
c
iated offer
* @param sdp the nego
t
iated offer
*/
void
setActiveLocalSdpSession
(
const
pjmedia_sdp_session
*
sdp
);
/**
* read accessor. Return the nego
c
iated local session
* read accessor. Return the nego
t
iated local session
*
* @return pjmedia_sdp_session The nego
c
iated offer
* @return pjmedia_sdp_session The nego
t
iated offer
*/
pjmedia_sdp_session
*
getActiveLocalSdpSession
(
void
)
{
return
activeLocalSession
;
return
activeLocalSession
_
;
}
/**
* Retrieve the nego
c
iated sdp offer from the sip payload.
* Retrieve the nego
t
iated sdp offer from the sip payload.
*
* @param sdp the nego
c
iated offer
* @param sdp the nego
t
iated offer
*/
void
setActiveRemoteSdpSession
(
const
pjmedia_sdp_session
*
sdp
);
/**
* read accessor. Return the nego
c
iated offer
* read accessor. Return the nego
t
iated offer
*
* @return pjmedia_sdp_session The nego
c
iated offer
* @return pjmedia_sdp_session The nego
t
iated 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 w
h
ether or not the media have been determined for this sdp session
*/
bool
hasSessionMedia
(
void
)
const
;
/**
* Return the codec of the first media after nego
c
iation
* Return the codec of the first media after nego
t
iation
*/
sfl
::
AudioCodec
*
getSessionMedia
(
void
)
throw
(
SdpException
);
/*
* On building an invite outside a dialog, build the local offer and create the
* SDP nego
c
iator instance with it.
* SDP nego
t
iator instance with it.
*/
int
createOffer
(
CodecOrder
selectedCodecs
);
/*
* On receiving an invite outside a dialog, build the local offer and create the
* SDP nego
c
iator instance with the remote offer.
* SDP nego
t
iator instance with the remote offer.
*
* @param remote The remote offer
*/
int
rec
i
eveOffer
(
const
pjmedia_sdp_session
*
remote
,
CodecOrder
selectedCodecs
);
int
rece
i
veOffer
(
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 nego
c
iator instance with the remote offer.
* SDP nego
t
iator 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 nego
c
iation.
* Start the sdp nego
t
iation.
*
* @return pj_status_t 0 on success
* 1 otherwise
*/
pj_status_t
startNego
c
iation
(
void
);
pj_status_t
startNego
t
iation
(
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
*/
S
dpMedia
List
getSessionMediaList
(
void
)
{
return
sessionAudioMedia
;
std
::
vector
<
s
dpMedia
*>
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
_
;
/** nego
c
iator */
pjmedia_sdp_neg
*
nego
c
iator
;
/** nego
t
iator */
pjmedia_sdp_neg
*
nego
t
iator
_
;
/**
* Local SDP
*/
pjmedia_sdp_session
*
localSession
;
pjmedia_sdp_session
*
localSession
_
;
/**
* Remote SDP
*/
pjmedia_sdp_session
*
remoteSession
;
pjmedia_sdp_session
*
remoteSession
_
;
/**
* The nego
c
iated SDP remote session
* Explanation: each endpoint's offer is nego
c
iated, and a new sdp offer results from this
* nego
c
iation, with the compatible media from each part
* The nego
t
iated SDP remote session
* Explanation: each endpoint's offer is nego
t
iated, and a new sdp offer results from this
* nego
t
iation, with the compatible media from each part
*/
pjmedia_sdp_session
*
activeLocalSession
;
pjmedia_sdp_session
*
activeLocalSession
_
;
/**
* The nego
c
iated SDP remote session
* Explanation: each endpoint's offer is nego
c
iated, and a new sdp offer results from this
* nego
c
iation, with the compatible media from each part
* The nego
t
iated SDP remote session
* Explanation: each endpoint's offer is nego
t
iated, and a new sdp offer results from this
* nego
t
iation, with the compatible media from each part
*/
pjmedia_sdp_session
*
activeRemoteSession
;
pjmedia_sdp_session
*
activeRemoteSession
_
;
/**
* Codec Map used for offer
*/
S
dpMedia
List
localAudioMediaCap
;
std
::
vector
<
s
dpMedia
*>
localAudioMediaCap
_
;
/**
* The media that will be used by the session (after the SDP nego
c
iation)
* The media that will be used by the session (after the SDP nego
t
iation)
*/
S
dpMedia
List
sessionAudioMedia
;
std
::
vector
<
s
dpMedia
*>
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
);
};
...
...
sflphone-common/src/sip/sipvoiplink.cpp
View file @
3428846c
...
...
@@ -768,7 +768,7 @@ SIPVoIPLink::answer (const CallID& id) throw (VoipLinkException)
if
(
status
==
PJ_SUCCESS
)
{
_debug
(
"UserAgent: SDP
N
ego
c
iation success! : call %s "
,
call
->
getCallId
().
c_str
());
_debug
(
"UserAgent: SDP
n
ego
t
iation 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)"
);
...
...
@@ -782,7 +782,7 @@ SIPVoIPLink::answer (const CallID& id) throw (VoipLinkException)
return
true
;
}
else
{
// Create and send a 488/Not acceptable because the SDP nego
c
iation failed
// Create and send a 488/Not acceptable because the SDP nego
t
iation 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)"
);
}
...
...
@@ -790,7 +790,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
N
ego
c
iation failed, terminate call %s "
,
call
->
getCallId
().
c_str
());
_debug
(
"UserAgent: SDP
n
ego
t
iation failed, terminate call %s "
,
call
->
getCallId
().
c_str
());
if
(
call
->
getAudioRtp
())
{
throw
VoipLinkException
(
"No audio rtp session for this call"
);
...
...
@@ -3344,8 +3344,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
()
->
rec
i
eveOffer
(
offer
,
account
->
getActiveCodecs
());
call
->
getLocalSDP
()
->
startNego
c
iation
();
status
=
call
->
getLocalSDP
()
->
rece
i
veOffer
(
offer
,
account
->
getActiveCodecs
());
call
->
getLocalSDP
()
->
startNego
t
iation
();
status
=
pjsip_inv_set_sdp_answer
(
call
->
getInvSession
(),
call
->
getLocalSDP
()
->
getLocalSdpSession
());
...
...
@@ -3412,7 +3412,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 nego
c
iation stopped"
);
_debug
(
"UserAgent: Call declined by peer, SDP nego
t
iation stopped"
);
return
;
}
...
...
@@ -3485,7 +3485,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 nego
c
iation successfull"
);
_debug
(
"UserAgent: SDES nego
t
iation successfull"
);
nego_success
=
true
;
_debug
(
"UserAgent: Set remote cryptographic context"
);
...
...
@@ -3507,7 +3507,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 nego
c
iation failed but Sdes enabled"
);
_debug
(
"UserAgent: Did not found any crypto or nego
t
iation failed but Sdes enabled"
);
call
->
getAudioRtp
()
->
stop
();
call
->
getAudioRtp
()
->
setSrtpEnabled
(
false
);
...
...
@@ -3987,7 +3987,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 nego
c
iation
// We retrieve the remote sdp offer in the rdata struct to begin the nego
t
iation
call
->
getLocalSDP
()
->
setLocalIP
(
addrSdp
);
// Init audio rtp session
...
...
@@ -4032,7 +4032,7 @@ transaction_request_cb (pjsip_rx_data *rdata)
sfl
::
SdesNegotiator
sdesnego
(
localCapabilities
,
crypto_offer
);
if
(
sdesnego
.
negotiate
())
{
_debug
(
"UserAgent: SDES nego
c
iation successfull
\n
"
);
_debug
(
"UserAgent: SDES nego
t
iation successfull
\n
"
);
nego_success
=
true
;
try
{
...
...
@@ -4048,7 +4048,7 @@ transaction_request_cb (pjsip_rx_data *rdata)
}
status
=
call
->
getLocalSDP
()
->
rec
i
eveOffer
(
r_sdp
,
account
->
getActiveCodecs
());
status
=
call
->
getLocalSDP
()
->
rece
i
veOffer
(
r_sdp
,
account
->
getActiveCodecs
());
if
(
status
!=
PJ_SUCCESS
)
{
delete
call
;
call
=
NULL
;
...
...
@@ -4702,8 +4702,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
;
...
...
sflphone-common/test/sdptest.cpp
View file @
3428846c
...
...
@@ -144,7 +144,7 @@ void SDPTest::testInitialOfferFirstCodec ()
_session
->
receivingAnswerAfterInitialOffer
(
remoteAnswer
);
_session
->
startNego
c
iation
();
_session
->
startNego
t
iation
();
_session
->
updateInternalState
();
...
...
@@ -177,9 +177,9 @@ void SDPTest::testInitialAnswerFirstCodec ()
_session
->
setLocalIP
(
"127.0.0.1"
);
_session
->
setLocalPublishedAudioPort
(
49567
);
_session
->
rec
i
eveOffer
(
remoteOffer
,
codecSelection
);
_session
->
rece
i
veOffer
(
remoteOffer
,
codecSelection
);
_session
->
startNego
c
iation
();
_session
->
startNego
t
iation
();
_session
->
updateInternalState
();
...
...
@@ -217,7 +217,7 @@ void SDPTest::testInitialOfferLastCodec ()
_session
->
receivingAnswerAfterInitialOffer
(
remoteAnswer
);
_session
->
startNego
c
iation
();
_session
->
startNego
t
iation
();
_session
->
updateInternalState
();
...
...
@@ -250,9 +250,9 @@ void SDPTest::testInitialAnswerLastCodec ()
_session
->
setLocalIP
(
"127.0.0.1"
);
_session
->
setLocalPublishedAudioPort
(
49567
);
_session
->
rec
i
eveOffer
(
remoteOffer
,
codecSelection
);
_session
->
rece
i
veOffer
(
remoteOffer
,
codecSelection
);
_session
->
startNego
c
iation
();
_session
->
startNego
t
iation
();
_session
->
updateInternalState
();
...
...
@@ -292,7 +292,7 @@ void SDPTest::testReinvite ()
_session
->
receivingAnswerAfterInitialOffer
(
remoteAnswer
);
_session
->
startNego
c
iation
();
_session
->
startNego
t
iation
();
_session
->
updateInternalState
();
...
...
@@ -304,9 +304,9 @@ void SDPTest::testReinvite ()
pjmedia_sdp_parse
(
_testPool
,
(
char
*
)
sdp_reinvite
,
strlen
(
sdp_reinvite
),
&
reinviteOffer
);
_session
->
rec
i
eveOffer
(
reinviteOffer
,
codecSelection
);
_session
->
rece
i
veOffer
(
reinviteOffer
,
codecSelection
);
_session
->
startNego
c
iation
();
_session
->
startNego
t
iation
();
_session
->
updateInternalState
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment