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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
1a68b3ad
Commit
1a68b3ad
authored
17 years ago
by
Alexandre Bourget
Browse files
Options
Downloads
Patches
Plain Diff
Implement registration refreshing for IAX. Fixes
#15
parent
080f42c9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/iaxaccount.cpp
+1
-1
1 addition, 1 deletion
src/iaxaccount.cpp
src/iaxvoiplink.cpp
+61
-37
61 additions, 37 deletions
src/iaxvoiplink.cpp
src/iaxvoiplink.h
+15
-2
15 additions, 2 deletions
src/iaxvoiplink.h
with
77 additions
and
40 deletions
src/iaxaccount.cpp
+
1
−
1
View file @
1a68b3ad
...
...
@@ -52,7 +52,7 @@ IAXAccount::registerAccount()
{
if
(
_link
&&
!
_registered
)
{
init
();
unregisterAccount
();
//
unregisterAccount();
No need to unregister first.
IAXVoIPLink
*
tmplink
=
dynamic_cast
<
IAXVoIPLink
*>
(
_link
);
if
(
tmplink
)
{
// Stuff needed for IAX registration
...
...
This diff is collapsed.
Click to expand it.
src/iaxvoiplink.cpp
+
61
−
37
View file @
1a68b3ad
...
...
@@ -53,6 +53,7 @@ IAXVoIPLink::IAXVoIPLink(const AccountID& accountID)
{
_evThread
=
new
EventThread
(
this
);
_regSession
=
NULL
;
_nextRefreshStamp
=
0
;
// to get random number for RANDOM_PORT
srand
(
time
(
NULL
));
...
...
@@ -279,7 +280,10 @@ IAXVoIPLink::getEvent()
_mutexIAX
.
leaveMutex
();
}
//iaxRefreshRegistrations();
// Refresh registration.
if
(
_nextRefreshStamp
&&
_nextRefreshStamp
-
2
<
time
(
NULL
))
{
setRegister
();
}
// thread wait 5 millisecond
_evThread
->
sleep
(
5
);
...
...
@@ -305,7 +309,7 @@ bool
IAXVoIPLink
::
setRegister
()
{
bool
result
=
false
;
if
(
_regSession
==
NULL
)
{
if
(
_host
.
empty
())
{
Manager
::
instance
().
displayConfigError
(
"Fill host field for IAX Account"
);
return
false
;
...
...
@@ -317,10 +321,13 @@ IAXVoIPLink::setRegister()
// lock
_mutexIAX
.
enterMutex
();
_regSession
=
iax_session_new
();
if
(
_regSession
==
NULL
)
{
_regSession
=
iax_session_new
();
}
if
(
!
_regSession
)
{
_debug
(
"error when generating new session for register"
);
_debug
(
"Error when generating new session for register"
);
}
else
{
// refresh
// last reg
...
...
@@ -330,16 +337,20 @@ IAXVoIPLink::setRegister()
strcpy
(
user
,
_user
.
c_str
());
char
pass
[
_pass
.
length
()
+
1
];
strcpy
(
pass
,
_pass
.
c_str
());
//iax_register don't use const char*
//
iax_register do
es
n't use const char*
_debug
(
"IAX Sending registration to %s with user %s
\n
"
,
host
,
user
);
int
val
=
iax_register
(
_regSession
,
host
,
user
,
pass
,
30
0
);
int
val
=
iax_register
(
_regSession
,
host
,
user
,
pass
,
12
0
);
_debug
(
"Return value: %d
\n
"
,
val
);
// set the time-out to 15 seconds, after that, resend a registration request.
// until we unregister.
_nextRefreshStamp
=
time
(
NULL
)
+
10
;
result
=
true
;
}
// unlock
_mutexIAX
.
leaveMutex
();
}
return
result
;
}
...
...
@@ -350,14 +361,16 @@ bool
IAXVoIPLink
::
setUnregister
()
{
if
(
_regSession
)
{
// lock here
/** @todo Should send a REGREL in setUnregister()... */
_mutexIAX
.
enterMutex
();
//iax_send_regrel(); doesn't exist yet :)
iax_destroy
(
_regSession
);
_regSession
=
NULL
;
// unlock here
_mutexIAX
.
leaveMutex
();
return
false
;
_regSession
=
NULL
;
}
_nextRefreshStamp
=
0
;
return
false
;
}
...
...
@@ -738,13 +751,24 @@ IAXVoIPLink::iaxHandleRegReply(iax_event* event)
{
if
(
event
->
etype
==
IAX_EVENT_REGREJ
)
{
/* Authentication failed! */
_mutexIAX
.
enterMutex
();
iax_destroy
(
_regSession
);
_mutexIAX
.
leaveMutex
();
_regSession
=
NULL
;
Manager
::
instance
().
registrationFailed
(
getAccountID
());
Manager
::
instance
().
registrationFailed
(
getAccountID
());
}
else
if
(
event
->
etype
==
IAX_EVENT_REGACK
)
{
/* Authentication succeeded */
_mutexIAX
.
enterMutex
();
iax_destroy
(
_regSession
);
_mutexIAX
.
leaveMutex
();
_regSession
=
NULL
;
// I mean, save the timestamp, so that we re-register again in the REFRESH time.
// Defaults to 60, as per draft-guy-iax-03.
_nextRefreshStamp
=
time
(
NULL
)
+
(
event
->
ies
.
refresh
?
event
->
ies
.
refresh
:
60
);
Manager
::
instance
().
registrationSucceed
(
getAccountID
());
}
}
...
...
This diff is collapsed.
Click to expand it.
src/iaxvoiplink.h
+
15
−
2
View file @
1a68b3ad
...
...
@@ -49,6 +49,11 @@ public:
bool
checkNetwork
(
void
)
{
return
false
;
}
void
terminate
(
void
);
/**
* Send out registration
*
* @return The new registration state (are we registered ?)
*/
bool
setRegister
(
void
);
/**
...
...
@@ -155,8 +160,16 @@ private:
/** IAX full name */
std
::
string
_fullName
;
/** Timestamp of when we should refresh the registration up with
* the registrar. Values can be: EPOCH timestamp, 0 if we want no registration, 1
* to force a registration. */
int
_nextRefreshStamp
;
/** Mutex for iax_ calls, since we're the only one dealing with the incorporated
* iax_stuff inside this class. */
ost
::
Mutex
_mutexIAX
;
/** Connection to audio card/device */
AudioLayer
*
audiolayer
;
/** When we receive data, we decode it inside this buffer */
...
...
@@ -164,8 +177,8 @@ private:
/** When we send data, we encode it inside this buffer*/
unsigned
char
*
_sendDataEncoded
;
/** After that we send the data inside this buffer if there is a format conversion or rate conversion */
/*
*
Also use for getting mic-ringbuffer data */
/** After that we send the data inside this buffer if there is a format conversion or rate conversion
.
*/
/* Also use for getting mic-ringbuffer data */
SFLDataFormat
*
_dataAudioLayer
;
/** Buffer for 8000hz samples in conversion */
...
...
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