Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
70b8ba60
Commit
70b8ba60
authored
4 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
sdp: cleanup
Avoids some unneeded strlen Change-Id: I4324f858fff51e27f77819f5f9e7744b46a22260
parent
2b0e7ef7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/jamidht/jamiaccount.cpp
+6
-6
6 additions, 6 deletions
src/jamidht/jamiaccount.cpp
src/sip/sdes_negotiator.h
+6
-4
6 additions, 4 deletions
src/sip/sdes_negotiator.h
src/sip/sdp.cpp
+25
-31
25 additions, 31 deletions
src/sip/sdp.cpp
with
37 additions
and
41 deletions
src/jamidht/jamiaccount.cpp
+
6
−
6
View file @
70b8ba60
...
...
@@ -739,14 +739,14 @@ JamiAccount::SIPStartCall(SIPCall& call, IpAddr target)
getToUri
(
call
.
getPeerNumber
()
+
"@"
+
target
.
toString
(
true
).
c_str
()));
// expecting a fully well formed sip uri
pj_str_t
pjTo
=
pj_str
((
char
*
)
toUri
.
c_str
()
);
pj_str_t
pjTo
=
sip_utils
::
CONST_PJ_STR
(
toUri
);
// Create the from header
std
::
string
from
(
getFromUri
());
pj_str_t
pjFrom
=
pj_str
((
char
*
)
from
.
c_str
()
);
pj_str_t
pjFrom
=
sip_utils
::
CONST_PJ_STR
(
from
);
std
::
string
targetStr
=
getToUri
(
target
.
toString
(
true
)
/*+";transport=ICE"*/
);
pj_str_t
pjTarget
=
pj_str
((
char
*
)
targetStr
.
c_str
()
);
pj_str_t
pjTarget
=
sip_utils
::
CONST_PJ_STR
(
targetStr
);
pj_str_t
pjContact
;
{
...
...
@@ -3579,9 +3579,9 @@ JamiAccount::sendSIPMessage(SipConnection& conn,
// Build SIP message
constexpr
pjsip_method
msg_method
=
{
PJSIP_OTHER_METHOD
,
jami
::
sip_utils
::
CONST_PJ_STR
(
"MESSAGE"
)};
pj_str_t
pjFrom
=
pj_str
((
char
*
)
from
.
c_str
()
);
pj_str_t
pjTo
=
pj_str
((
char
*
)
toURI
.
c_str
()
);
sip_utils
::
CONST_PJ_STR
(
"MESSAGE"
)};
pj_str_t
pjFrom
=
sip_utils
::
CONST_PJ_STR
(
from
);
pj_str_t
pjTo
=
sip_utils
::
CONST_PJ_STR
(
toURI
);
// Create request.
pj_status_t
status
=
pjsip_endpt_create_request
(
link_
.
getEndpoint
(),
...
...
This diff is collapsed.
Click to expand it.
src/sip/sdes_negotiator.h
+
6
−
4
View file @
70b8ba60
...
...
@@ -27,6 +27,8 @@
#include
<string>
#include
<vector>
using
namespace
std
::
literals
;
namespace
jami
{
/**
...
...
@@ -53,7 +55,7 @@ enum KeyMethod {
struct
CryptoSuiteDefinition
{
const
char
*
name
;
std
::
string_view
name
;
int
masterKeyLength
;
int
masterSaltLength
;
int
srtpLifetime
;
...
...
@@ -73,11 +75,11 @@ struct CryptoSuiteDefinition
*/
static
std
::
vector
<
CryptoSuiteDefinition
>
CryptoSuites
=
{
{
"AES_CM_128_HMAC_SHA1_80"
,
128
,
112
,
48
,
31
,
AESCounterMode
,
128
,
HMACSHA1
,
80
,
80
,
160
,
160
},
{
"AES_CM_128_HMAC_SHA1_80"
sv
,
128
,
112
,
48
,
31
,
AESCounterMode
,
128
,
HMACSHA1
,
80
,
80
,
160
,
160
},
{
"AES_CM_128_HMAC_SHA1_32"
,
128
,
112
,
48
,
31
,
AESCounterMode
,
128
,
HMACSHA1
,
32
,
80
,
160
,
160
},
{
"AES_CM_128_HMAC_SHA1_32"
sv
,
128
,
112
,
48
,
31
,
AESCounterMode
,
128
,
HMACSHA1
,
32
,
80
,
160
,
160
},
{
"F8_128_HMAC_SHA1_80"
,
128
,
112
,
48
,
31
,
AESF8Mode
,
128
,
HMACSHA1
,
80
,
80
,
160
,
160
}};
{
"F8_128_HMAC_SHA1_80"
sv
,
128
,
112
,
48
,
31
,
AESF8Mode
,
128
,
HMACSHA1
,
80
,
80
,
160
,
160
}};
class
SdesNegotiator
{
...
...
This diff is collapsed.
Click to expand it.
src/sip/sdp.cpp
+
25
−
31
View file @
70b8ba60
...
...
@@ -160,10 +160,9 @@ Sdp::generateSdesAttribute()
// generate keys
randomFill
(
keyAndSalt
);
std
::
string
tag
=
"1"
;
std
::
string
crypto_attr
=
tag
+
" "
+
jami
::
CryptoSuites
[
cryptoSuite
].
name
std
::
string
crypto_attr
=
"1 "
s
+
jami
::
CryptoSuites
[
cryptoSuite
].
name
+
" inline:"
+
base64
::
encode
(
keyAndSalt
);
pj_str_t
val
{
(
char
*
)
crypto_attr
.
c_str
(),
static_cast
<
pj_ssize_t
>
(
crypto_attr
.
size
()
)};
pj_str_t
val
{
sip_utils
::
CONST_PJ_STR
(
crypto_attr
)};
return
pjmedia_sdp_attr_create
(
memPool_
.
get
(),
"crypto"
,
&
val
);
}
...
...
@@ -172,13 +171,12 @@ Sdp::setMediaDescriptorLines(bool audio, bool holding, sip_utils::KeyExchangePro
{
pjmedia_sdp_media
*
med
=
PJ_POOL_ZALLOC_T
(
memPool_
.
get
(),
pjmedia_sdp_media
);
med
->
desc
.
media
=
audio
?
pj_str
((
char
*
)
"audio"
)
:
pj_str
((
char
*
)
"video"
);
med
->
desc
.
media
=
audio
?
sip_utils
::
CONST_PJ_STR
(
"audio"
)
:
sip_utils
::
CONST_PJ_STR
(
"video"
);
med
->
desc
.
port_count
=
1
;
med
->
desc
.
port
=
audio
?
localAudioDataPort_
:
localVideoDataPort_
;
// in case of sdes, media are tagged as "RTP/SAVP", RTP/AVP elsewhere
med
->
desc
.
transport
=
pj_str
(
kx
==
sip_utils
::
KeyExchangeProtocol
::
NONE
?
(
char
*
)
"RTP/AVP"
:
(
char
*
)
"RTP/SAVP"
);
med
->
desc
.
transport
=
kx
==
sip_utils
::
KeyExchangeProtocol
::
NONE
?
sip_utils
::
CONST_PJ_STR
(
"RTP/AVP"
)
:
sip_utils
::
CONST_PJ_STR
(
"RTP/SAVP"
);
unsigned
dynamic_payload
=
96
;
...
...
@@ -199,8 +197,7 @@ Sdp::setMediaDescriptorLines(bool audio, bool holding, sip_utils::KeyExchangePro
if
(
accountAudioCodec
->
audioformat
.
nb_channels
>
1
)
{
channels
=
std
::
to_string
(
accountAudioCodec
->
audioformat
.
nb_channels
);
rtpmap
.
param
.
ptr
=
(
char
*
)
channels
.
c_str
();
rtpmap
.
param
.
slen
=
strlen
(
channels
.
c_str
());
// don't include NULL terminator
rtpmap
.
param
=
sip_utils
::
CONST_PJ_STR
(
channels
);
}
// G722 requires G722/8000 media description even though it's @ 16000 Hz
// See http://tools.ietf.org/html/rfc3551#section-4.5.2
...
...
@@ -224,7 +221,7 @@ Sdp::setMediaDescriptorLines(bool audio, bool holding, sip_utils::KeyExchangePro
// We could add one only for dynamic payloads because the codecs with static RTP payloads
// are entirely defined in the RFC 3351
rtpmap
.
pt
=
med
->
desc
.
fmt
[
i
];
rtpmap
.
enc_name
=
pj_str
((
char
*
)
enc_name
.
c_str
()
);
rtpmap
.
enc_name
=
sip_utils
::
CONST_PJ_STR
(
enc_name
);
pjmedia_sdp_attr
*
attr
;
pjmedia_sdp_rtpmap_to_attr
(
memPool_
.
get
(),
&
rtpmap
,
&
attr
);
...
...
@@ -284,10 +281,10 @@ Sdp::setPublishedIP(const std::string& addr, pj_uint16_t addr_type)
publishedIpAddrType_
=
addr_type
;
if
(
localSession_
)
{
if
(
addr_type
==
pj_AF_INET6
())
localSession_
->
origin
.
addr_type
=
pj_str
((
char
*
)
"IP6"
);
localSession_
->
origin
.
addr_type
=
sip_utils
::
CONST_PJ_STR
(
"IP6"
);
else
localSession_
->
origin
.
addr_type
=
pj_str
((
char
*
)
"IP4"
);
localSession_
->
origin
.
addr
=
pj_str
((
char
*
)
publishedIpAddr_
.
c_str
()
);
localSession_
->
origin
.
addr_type
=
sip_utils
::
CONST_PJ_STR
(
"IP4"
);
localSession_
->
origin
.
addr
=
sip_utils
::
CONST_PJ_STR
(
publishedIpAddr_
);
localSession_
->
conn
->
addr
=
localSession_
->
origin
.
addr
;
if
(
pjmedia_sdp_validate
(
localSession_
)
!=
PJ_SUCCESS
)
JAMI_ERR
(
"Could not validate SDP"
);
...
...
@@ -310,15 +307,15 @@ Sdp::setTelephoneEventRtpmap(pjmedia_sdp_media* med)
pjmedia_sdp_attr
*
attr_rtpmap
=
static_cast
<
pjmedia_sdp_attr
*>
(
pj_pool_zalloc
(
memPool_
.
get
(),
sizeof
(
pjmedia_sdp_attr
)));
attr_rtpmap
->
name
=
pj_str
((
char
*
)
"rtpmap"
);
attr_rtpmap
->
value
=
pj_str
((
char
*
)
"101 telephone-event/8000"
);
attr_rtpmap
->
name
=
sip_utils
::
CONST_PJ_STR
(
"rtpmap"
);
attr_rtpmap
->
value
=
sip_utils
::
CONST_PJ_STR
(
"101 telephone-event/8000"
);
med
->
attr
[
med
->
attr_count
++
]
=
attr_rtpmap
;
pjmedia_sdp_attr
*
attr_fmtp
=
static_cast
<
pjmedia_sdp_attr
*>
(
pj_pool_zalloc
(
memPool_
.
get
(),
sizeof
(
pjmedia_sdp_attr
)));
attr_fmtp
->
name
=
pj_str
((
char
*
)
"fmtp"
);
attr_fmtp
->
value
=
pj_str
((
char
*
)
"101 0-15"
);
attr_fmtp
->
name
=
sip_utils
::
CONST_PJ_STR
(
"fmtp"
);
attr_fmtp
->
value
=
sip_utils
::
CONST_PJ_STR
(
"101 0-15"
);
med
->
attr
[
med
->
attr_count
++
]
=
attr_fmtp
;
}
...
...
@@ -397,16 +394,16 @@ Sdp::createLocalSession(const std::vector<std::shared_ptr<AccountCodecInfo>>& se
pj_time_val
tv
;
pj_gettimeofday
(
&
tv
);
localSession_
->
origin
.
user
=
pj_str
(
pj_gethostname
()
->
ptr
)
;
localSession_
->
origin
.
user
=
*
pj_gethostname
();
// Use Network Time Protocol format timestamp to ensure uniqueness.
localSession_
->
origin
.
id
=
tv
.
sec
+
2208988800UL
;
localSession_
->
origin
.
net_type
=
pj_str
((
char
*
)
"IN"
);
localSession_
->
origin
.
net_type
=
sip_utils
::
CONST_PJ_STR
(
"IN"
);
if
(
publishedIpAddrType_
==
pj_AF_INET6
())
localSession_
->
origin
.
addr_type
=
pj_str
((
char
*
)
"IP6"
);
localSession_
->
origin
.
addr_type
=
sip_utils
::
CONST_PJ_STR
(
"IP6"
);
else
localSession_
->
origin
.
addr_type
=
pj_str
((
char
*
)
"IP4"
);
localSession_
->
origin
.
addr
=
pj_str
((
char
*
)
publishedIpAddr_
.
c_str
()
);
localSession_
->
name
=
pj_str
((
char
*
)
PACKAGE_NAME
);
localSession_
->
origin
.
addr_type
=
sip_utils
::
CONST_PJ_STR
(
"IP4"
);
localSession_
->
origin
.
addr
=
sip_utils
::
CONST_PJ_STR
(
publishedIpAddr_
);
localSession_
->
name
=
sip_utils
::
CONST_PJ_STR
(
PACKAGE_NAME
);
localSession_
->
conn
->
net_type
=
localSession_
->
origin
.
net_type
;
localSession_
->
conn
->
addr_type
=
localSession_
->
origin
.
addr_type
;
localSession_
->
conn
->
addr
=
localSession_
->
origin
.
addr
;
...
...
@@ -590,8 +587,8 @@ Sdp::getFilteredSdp(const pjmedia_sdp_session* session, unsigned media_keep, uns
std
::
vector
<
MediaDescription
>
Sdp
::
getMediaSlots
(
const
pjmedia_sdp_session
*
session
,
bool
remote
)
const
{
static
constexpr
pj_str_t
STR_RTPMAP
{
(
char
*
)
"rtpmap"
,
6
};
static
constexpr
pj_str_t
STR_FMTP
{
(
char
*
)
"fmtp"
,
4
};
static
constexpr
pj_str_t
STR_RTPMAP
{
sip_utils
::
CONST_PJ_STR
(
"rtpmap"
)
};
static
constexpr
pj_str_t
STR_FMTP
{
sip_utils
::
CONST_PJ_STR
(
"fmtp"
)
};
std
::
vector
<
MediaDescription
>
ret
;
for
(
unsigned
i
=
0
;
i
<
session
->
media_count
;
i
++
)
{
...
...
@@ -719,7 +716,7 @@ Sdp::addIceCandidates(unsigned media_index, const std::vector<std::string>& cand
auto
media
=
localSession_
->
media
[
media_index
];
for
(
const
auto
&
item
:
cands
)
{
pj_str_t
val
=
{(
char
*
)
item
.
c_str
(),
static_cast
<
pj_ssize_t
>
(
item
.
size
())}
;
const
pj_str_t
val
=
sip_utils
::
CONST_PJ_STR
(
item
)
;
pjmedia_sdp_attr
*
attr
=
pjmedia_sdp_attr_create
(
memPool_
.
get
(),
"candidate"
,
&
val
);
if
(
pjmedia_sdp_media_add_attr
(
media
,
attr
)
!=
PJ_SUCCESS
)
...
...
@@ -762,16 +759,13 @@ Sdp::getIceCandidates(unsigned media_index) const
void
Sdp
::
addIceAttributes
(
const
IceTransport
::
Attribute
&&
ice_attrs
)
{
pj_str_t
value
;
pjmedia_sdp_attr
*
attr
;
value
=
{(
char
*
)
ice_attrs
.
ufrag
.
c_str
(),
static_cast
<
pj_ssize_t
>
(
ice_attrs
.
ufrag
.
size
())};
attr
=
pjmedia_sdp_attr_create
(
memPool_
.
get
(),
"ice-ufrag"
,
&
value
);
pj_str_t
value
=
sip_utils
::
CONST_PJ_STR
(
ice_attrs
.
ufrag
);
pjmedia_sdp_attr
*
attr
=
pjmedia_sdp_attr_create
(
memPool_
.
get
(),
"ice-ufrag"
,
&
value
);
if
(
pjmedia_sdp_attr_add
(
&
localSession_
->
attr_count
,
localSession_
->
attr
,
attr
)
!=
PJ_SUCCESS
)
throw
SdpException
(
"Could not add ICE.ufrag attribute to local SDP"
);
value
=
{(
char
*
)
ice_attrs
.
pwd
.
c_str
(),
static_cast
<
pj_ssize_t
>
(
ice_attrs
.
pwd
.
size
())}
;
value
=
sip_utils
::
CONST_PJ_STR
(
ice_attrs
.
pwd
)
;
attr
=
pjmedia_sdp_attr_create
(
memPool_
.
get
(),
"ice-pwd"
,
&
value
);
if
(
pjmedia_sdp_attr_add
(
&
localSession_
->
attr_count
,
localSession_
->
attr
,
attr
)
!=
PJ_SUCCESS
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment