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
bc04bcd6
Commit
bc04bcd6
authored
4 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
sip utils: add as_view
Change-Id: I6b19b1897b5e69909ce8a5efd41d0b182ab84aa2
parent
d82fd211
Branches
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/sip/sip_utils.h
+6
-0
6 additions, 0 deletions
src/sip/sip_utils.h
src/sip/sipaccount.cpp
+7
-8
7 additions, 8 deletions
src/sip/sipaccount.cpp
src/sip/sipvoiplink.cpp
+2
-3
2 additions, 3 deletions
src/sip/sipvoiplink.cpp
with
15 additions
and
11 deletions
src/sip/sip_utils.h
+
6
−
0
View file @
bc04bcd6
...
...
@@ -131,6 +131,12 @@ CONST_PJ_STR(const std::string_view& str) noexcept
return
{
const_cast
<
char
*>
(
str
.
data
()),
(
pj_ssize_t
)
str
.
size
()};
}
inline
constexpr
std
::
string_view
as_view
(
const
pj_str_t
&
str
)
noexcept
{
return
{
str
.
ptr
,
(
size_t
)
str
.
slen
};
}
// PJSIP dialog locking in RAII way
// Usage: declare local variable like this: sip_utils::PJDialogLock lock {dialog};
// The lock is kept until the local variable is deleted
...
...
This diff is collapsed.
Click to expand it.
src/sip/sipaccount.cpp
+
7
−
8
View file @
bc04bcd6
...
...
@@ -1434,7 +1434,9 @@ SIPAccount::getFromUri() const
{
std
::
string
scheme
;
std
::
string
transport
;
std
::
string
username
(
username_
);
// Get login name if username is not specified
std
::
string
username
(
username_
.
empty
()
?
getLoginName
()
:
username_
);
std
::
string
hostname
(
hostname_
);
// UDP does not require the transport specification
...
...
@@ -1444,18 +1446,15 @@ SIPAccount::getFromUri() const
}
else
scheme
=
"sip:"
;
// Get login name if username is not specified
if
(
username_
.
empty
())
username
=
getLoginName
();
// Get machine hostname if not provided
if
(
hostname_
.
empty
())
hostname
=
std
::
string
(
pj_gethostname
()
->
ptr
,
pj_gethostname
()
->
slen
);
if
(
hostname_
.
empty
())
{
hostname
=
sip_utils
::
as_view
(
*
pj_gethostname
());
}
if
(
IpAddr
::
isIpv6
(
hostname
))
hostname
=
IpAddr
(
hostname
).
toString
(
false
,
true
);
const
std
::
string
uri
=
"<"
+
scheme
+
username
+
"@"
+
hostname
+
transport
+
">"
;
std
::
string
uri
=
"<"
+
scheme
+
username
+
"@"
+
hostname
+
transport
+
">"
;
if
(
not
displayName_
.
empty
())
return
"
\"
"
+
displayName_
+
"
\"
"
+
uri
;
return
uri
;
...
...
This diff is collapsed.
Click to expand it.
src/sip/sipvoiplink.cpp
+
2
−
3
View file @
bc04bcd6
...
...
@@ -1412,8 +1412,7 @@ SIPVoIPLink::findLocalAddressFromTransport(pjsip_transport* transport,
port
=
pjsip_transport_get_default_port_for_type
(
transportType
);
// Initialize the sip address with the hostname
const
auto
pjMachineName
=
pj_gethostname
();
addr
=
std
::
string
(
pjMachineName
->
ptr
,
pjMachineName
->
slen
);
addr
=
sip_utils
::
as_view
(
*
pj_gethostname
());
// Update address and port with active transport
RETURN_IF_NULL
(
transport
,
...
...
@@ -1441,7 +1440,7 @@ SIPVoIPLink::findLocalAddressFromTransport(pjsip_transport* transport,
}
// Update local address based on the transport type
addr
=
s
td
::
string
(
param
.
ret_addr
.
ptr
,
param
.
ret_addr
.
slen
);
addr
=
s
ip_utils
::
as_view
(
param
.
ret_addr
);
// Determine the local port based on transport information
port
=
param
.
ret_port
;
...
...
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