Skip to content
Snippets Groups Projects
Commit afe8b7c3 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

dbus: add startShmSink

Since the video split, the daemon can manages a lot of Sink clients
which are generally not used by any client. This introduces a lot
of wasted computation.
One of the problems is that every sink client have a SHM memory if
dbus is enabled and any update generates frames for this SHM memory
even if the client is not showing them.
This patch introduces VideoManager::startShmSink, which enable
or disable transfer and works like VideoManager::registerSinkTarget.
Thus, a transfer will only be done if the client is explicitly
asking to transfer frames.

Change-Id: I1d265b7ffcdc37aff9c5f729a146fa26c5d7d4a1
GitLab: https://git.jami.net/savoirfairelinux/jami-product-backlog/-/issues/9
parent e215d54a
No related branches found
No related tags found
No related merge requests found
...@@ -150,6 +150,16 @@ ...@@ -150,6 +150,16 @@
</arg> </arg>
</method> </method>
<method name="startShmSink" tp:name-for-bindings="startShmSink">
<tp:docstring>Ask the sink client to do the transfer for a renderer</tp:docstring>
<arg type="s" name="sinkId" direction="in">
<tp:docstring>Sink id</tp:docstring>
</arg>
<arg type="b" name="value" direction="in">
<tp:docstring>true to start transfer ; false to stop</tp:docstring>
</arg>
</method>
<signal name="deviceEvent" tp:name-for-bindings="deviceEvent"> <signal name="deviceEvent" tp:name-for-bindings="deviceEvent">
<tp:docstring>Signal triggered by changes in the detected v4l2 devices, e.g. a camera being unplugged.</tp:docstring> <tp:docstring>Signal triggered by changes in the detected v4l2 devices, e.g. a camera being unplugged.</tp:docstring>
</signal> </signal>
......
...@@ -113,6 +113,12 @@ DBusVideoManager::setDeviceOrientation(const std::string& deviceId, const int& a ...@@ -113,6 +113,12 @@ DBusVideoManager::setDeviceOrientation(const std::string& deviceId, const int& a
DRing::setDeviceOrientation(deviceId, angle); DRing::setDeviceOrientation(deviceId, angle);
} }
void
DBusVideoManager::startShmSink(const std::string& sinkId, const bool& value)
{
DRing::startShmSink(sinkId, value);
}
std::map<std::string, std::string> std::map<std::string, std::string>
DBusVideoManager::getRenderer(const std::string& callId) DBusVideoManager::getRenderer(const std::string& callId)
{ {
......
...@@ -64,6 +64,7 @@ class DRING_PUBLIC DBusVideoManager : ...@@ -64,6 +64,7 @@ class DRING_PUBLIC DBusVideoManager :
bool getEncodingAccelerated(); bool getEncodingAccelerated();
void setEncodingAccelerated(const bool& state); void setEncodingAccelerated(const bool& state);
void setDeviceOrientation(const std::string& deviceId, const int& angle); void setDeviceOrientation(const std::string& deviceId, const int& angle);
void startShmSink(const std::string& sinkId, const bool& value);
std::map<std::string, std::string> getRenderer(const std::string& callId); std::map<std::string, std::string> getRenderer(const std::string& callId);
std::string startLocalMediaRecorder(const std::string& videoInputId, const std::string& filepath); std::string startLocalMediaRecorder(const std::string& videoInputId, const std::string& filepath);
void stopLocalRecorder(const std::string& filepath); void stopLocalRecorder(const std::string& filepath);
......
...@@ -536,6 +536,19 @@ registerSinkTarget(const std::string& sinkId, const SinkTarget& target) ...@@ -536,6 +536,19 @@ registerSinkTarget(const std::string& sinkId, const SinkTarget& target)
#endif #endif
} }
#if HAVE_SHM
void
startShmSink(const std::string& sinkId, bool value)
{
#ifdef ENABLE_VIDEO
if (auto sink = jami::Manager::instance().getSinkClient(sinkId))
sink->enableShm(value);
else
JAMI_WARN("No sink found for id '%s'", sinkId.c_str());
#endif
}
#endif
void void
registerAVSinkTarget(const std::string& sinkId, const AVSinkTarget& target) registerAVSinkTarget(const std::string& sinkId, const AVSinkTarget& target)
{ {
......
...@@ -211,6 +211,9 @@ int64_t getPlayerPosition(const std::string& id); ...@@ -211,6 +211,9 @@ int64_t getPlayerPosition(const std::string& id);
DRING_PUBLIC void registerSinkTarget(const std::string& sinkId, const SinkTarget& target); DRING_PUBLIC void registerSinkTarget(const std::string& sinkId, const SinkTarget& target);
DRING_PUBLIC void registerAVSinkTarget(const std::string& sinkId, const AVSinkTarget& target); DRING_PUBLIC void registerAVSinkTarget(const std::string& sinkId, const AVSinkTarget& target);
#if HAVE_SHM
DRING_PUBLIC void startShmSink(const std::string& sinkId, bool value);
#endif
DRING_PUBLIC std::map<std::string, std::string> getRenderer(const std::string& callId); DRING_PUBLIC std::map<std::string, std::string> getRenderer(const std::string& callId);
DRING_PUBLIC std::string startLocalMediaRecorder(const std::string& videoInputId, DRING_PUBLIC std::string startLocalMediaRecorder(const std::string& videoInputId,
......
...@@ -375,7 +375,7 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/, ...@@ -375,7 +375,7 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/,
bool doTransfer = (target_.pull != nullptr); bool doTransfer = (target_.pull != nullptr);
#if HAVE_SHM #if HAVE_SHM
doTransfer |= (shm_ != nullptr); doTransfer |= (shm_ && doShmTransfer_);
#endif #endif
if (doTransfer) { if (doTransfer) {
...@@ -430,7 +430,7 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/, ...@@ -430,7 +430,7 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/,
return; return;
} }
#if HAVE_SHM #if HAVE_SHM
if (shm_) if (shm_ && doShmTransfer_)
shm_->renderFrame(*frame); shm_->renderFrame(*frame);
#endif #endif
if (target_.pull) { if (target_.pull) {
......
...@@ -82,6 +82,10 @@ public: ...@@ -82,6 +82,10 @@ public:
} }
void registerAVTarget(const DRing::AVSinkTarget& target) noexcept { avTarget_ = target; } void registerAVTarget(const DRing::AVSinkTarget& target) noexcept { avTarget_ = target; }
#if HAVE_SHM
void enableShm(bool value) { doShmTransfer_.store(value); }
#endif
private: private:
const std::string id_; const std::string id_;
// True if the instance is used by a mixer. // True if the instance is used by a mixer.
...@@ -110,6 +114,7 @@ private: ...@@ -110,6 +114,7 @@ private:
#if HAVE_SHM #if HAVE_SHM
// using shared_ptr and not unique_ptr as ShmHolder is forwared only // using shared_ptr and not unique_ptr as ShmHolder is forwared only
std::shared_ptr<ShmHolder> shm_; std::shared_ptr<ShmHolder> shm_;
std::atomic_bool doShmTransfer_ {false};
#endif // HAVE_SHM #endif // HAVE_SHM
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment