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
d87f2d32
Commit
d87f2d32
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
smarttools: use main scheduler instead of dedicated thread
Change-Id: I9fdfd1a0e1815d37dbacc871c8ef27586a7a605f
parent
5e345065
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/smartools.cpp
+23
-38
23 additions, 38 deletions
src/smartools.cpp
src/smartools.h
+28
-26
28 additions, 26 deletions
src/smartools.h
with
51 additions
and
64 deletions
src/smartools.cpp
+
23
−
38
View file @
d87f2d32
...
...
@@ -18,12 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include
"smartools.h"
#include
"media/media_decoder.h"
#include
"media/video/video_input.h"
#include
"media/video/video_device.h"
#include
"manager.h"
#include
"dring/callmanager_interface.h"
#include
"client/ring_signal.h"
#include
"string_utils.h"
namespace
jami
{
...
...
@@ -34,14 +31,8 @@ Smartools& Smartools::getInstance()
return
instance_
;
}
// Launch process() in new thread
Smartools
::
Smartools
()
:
loop_
([]
{
return
true
;
},
[
this
]
{
process
();
},
[]
{})
{}
Smartools
::~
Smartools
()
{
loop_
.
join
();
Smartools
::~
Smartools
()
{
stop
();
}
void
...
...
@@ -52,21 +43,16 @@ Smartools::sendInfo()
information_
.
clear
();
}
void
Smartools
::
process
()
{
// Send the signal SmartInfo
Smartools
::
sendInfo
();
std
::
this_thread
::
sleep_for
(
refreshTimeMs_
);
}
void
Smartools
::
start
(
std
::
chrono
::
milliseconds
refreshTimeMs
)
{
JAMI_DBG
(
"Start SmartInfo"
);
refreshTimeMs_
=
refreshTimeMs
;
loop_
.
stop
();
loop_
.
start
();
if
(
auto
t
=
std
::
move
(
task_
))
t
->
cancel
();
task_
=
Manager
::
instance
().
scheduler
().
scheduleAtFixedRate
([
this
]{
sendInfo
();
return
true
;
},
refreshTimeMs
);
}
void
...
...
@@ -74,7 +60,8 @@ Smartools::stop()
{
std
::
lock_guard
<
std
::
mutex
>
lk
(
mutexInfo_
);
JAMI_DBG
(
"Stop SmartInfo"
);
loop_
.
stop
();
if
(
auto
t
=
std
::
move
(
task_
))
t
->
cancel
();
information_
.
clear
();
}
...
...
@@ -131,12 +118,9 @@ Smartools::setRemoteVideoCodec(const std::string& remoteVideoCodec, const std::s
{
std
::
lock_guard
<
std
::
mutex
>
lk
(
mutexInfo_
);
information_
[
"remote video codec"
]
=
remoteVideoCodec
;
auto
call
=
Manager
::
instance
().
getCallFromCallID
(
callID
);
if
(
!
call
)
{
return
;
}
if
(
auto
call
=
Manager
::
instance
().
getCallFromCallID
(
callID
))
{
auto
confID
=
call
->
getConfId
();
if
(
confID
!=
""
)
{
if
(
not
confID
.
empty
())
{
information_
[
"type"
]
=
"conference"
;
information_
[
"callID"
]
=
confID
;
}
else
{
...
...
@@ -144,5 +128,6 @@ Smartools::setRemoteVideoCodec(const std::string& remoteVideoCodec, const std::s
information_
[
"callID"
]
=
callID
;
}
}
}
}
// end namespace jami
This diff is collapsed.
Click to expand it.
src/smartools.h
+
28
−
26
View file @
d87f2d32
...
...
@@ -19,11 +19,15 @@
*/
#pragma once
#include
"threadloop.h"
#include
"manager.h"
#include
<string>
#include
<chrono>
#include
<mutex>
#include
<map>
#include
<memory>
namespace
jami
{
class
RepeatedTask
;
class
Smartools
{
// Use for the unit tests
...
...
@@ -44,12 +48,10 @@ class Smartools
void
sendInfo
();
private:
Smartools
();
Smartools
()
{}
;
~
Smartools
();
void
process
();
std
::
map
<
std
::
string
,
std
::
string
>
information_
;
std
::
mutex
mutexInfo_
;
// Protect information_ from multithreading
std
::
chrono
::
milliseconds
refreshTimeMs_
{
500
}
;
ThreadLoop
loop_
;
// Has to be last member
std
::
map
<
std
::
string
,
std
::
string
>
information_
;
std
::
shared_ptr
<
RepeatedTask
>
task_
;
};
}
//ring namespace
}
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