diff --git a/bin/dbus/dbusvideomanager.cpp b/bin/dbus/dbusvideomanager.cpp index 6367f6b761c97231dce509bed0d77c21e2c075ca..5c968eb2f8d8b319cdb0e8364f391497872682f3 100644 --- a/bin/dbus/dbusvideomanager.cpp +++ b/bin/dbus/dbusvideomanager.cpp @@ -84,3 +84,15 @@ DBusVideoManager::hasCameraStarted() -> decltype(DRing::hasCameraStarted()) { return DRing::hasCameraStarted(); } + +bool +DBusVideoManager::getDecodingAccelerated() +{ + return DRing::getDecodingAccelerated(); +} + +void +DBusVideoManager::setDecodingAccelerated(bool state) +{ + DRing::setDecodingAccelerated(state); +} diff --git a/bin/dbus/dbusvideomanager.h b/bin/dbus/dbusvideomanager.h index ef4a16170ecd4abaccf0d5d04e9303233ca7bd61..119c172dc3094dac43b240a5c50ab95bc64c1a09 100644 --- a/bin/dbus/dbusvideomanager.h +++ b/bin/dbus/dbusvideomanager.h @@ -60,6 +60,8 @@ class DBusVideoManager : void stopCamera(); bool switchInput(const std::string& resource); bool hasCameraStarted(); + bool getDecodingAccelerated(); + void setDecodingAccelerated(bool state); }; #endif // __RING_DBUSVIDEOMANAGER_H__ diff --git a/src/client/videomanager.cpp b/src/client/videomanager.cpp index 05072f651b0be4b88fffa373063d726ecbf04cf1..8e966ed1856afa5676e9fcc8645d98fc80f58924 100644 --- a/src/client/videomanager.cpp +++ b/src/client/videomanager.cpp @@ -162,6 +162,25 @@ registerSinkTarget(const std::string& sinkId, const SinkTarget& target) RING_WARN("No sink found for id '%s'", sinkId.c_str()); } +bool +getDecodingAccelerated() +{ +#ifdef RING_ACCEL + return ring::Manager::instance().videoPreferences.getDecodingAccelerated(); +#else + return false; +#endif +} + +void +setDecodingAccelerated(bool state) +{ +#ifdef RING_ACCEL + RING_DBG("%s hardware acceleration", (state ? "Enabling" : "Disabling")); + ring::Manager::instance().videoPreferences.setDecodingAccelerated(state); +#endif +} + #if defined(__ANDROID__) || defined(RING_UWP) void addVideoDevice(const std::string &node, std::vector<std::map<std::string, std::string>> const * devInfo) diff --git a/src/dring/videomanager_interface.h b/src/dring/videomanager_interface.h index e9b85583b992be1ddafdfdd18df9c5360f995d9d..ee18bd34136b263fb5468e95ea5d10fd59dad8f5 100644 --- a/src/dring/videomanager_interface.h +++ b/src/dring/videomanager_interface.h @@ -77,6 +77,9 @@ void* obtainFrame(int length); void releaseFrame(void* frame); #endif +bool getDecodingAccelerated(); +void setDecodingAccelerated(bool state); + // Video signal type definitions struct VideoSignal { struct DeviceEvent { diff --git a/src/manager.cpp b/src/manager.cpp index b3edbad11ecf0b30e0f79a32766d048be5a8563a..444dbc677379076d27d51aba9f103406fb556201 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -3063,19 +3063,24 @@ Manager::getSinkClient(const std::string& id) return nullptr; } -#ifdef RING_ACCEL bool Manager::getDecodingAccelerated() const { +#ifdef RING_ACCEL return videoPreferences.getDecodingAccelerated(); +#else + return false; +#endif } void Manager::setDecodingAccelerated(bool isAccelerated) { +#ifdef RING_ACCEL videoPreferences.setDecodingAccelerated(isAccelerated); + saveConfig(); +#endif } -#endif // RING_ACCEL #endif // RING_VIDEO RingBufferPool& diff --git a/src/manager.h b/src/manager.h index 6a35fedea2ca9f9130cf36fa180534d992d7c588..c9a5407fd167149c56a207581dd959d79bcb11de 100644 --- a/src/manager.h +++ b/src/manager.h @@ -881,11 +881,9 @@ class Manager { VideoManager& getVideoManager() const; -#ifdef RING_ACCEL bool getDecodingAccelerated() const; void setDecodingAccelerated(bool isAccelerated); -#endif #endif // RING_VIDEO std::atomic<unsigned> dhtLogLevel {0}; // default = disable diff --git a/src/preferences.cpp b/src/preferences.cpp index 9fa90d026d72306c763ec83e6f5ee002ecd7f9f0..04c066a69920d6c78974e963c728c12d4c9b1d03 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -129,10 +129,8 @@ static const char * const TOGGLE_PICKUP_HANGUP_SHORT_KEY = "togglePickupHangup"; #ifdef RING_VIDEO // video preferences constexpr const char * const VideoPreferences::CONFIG_LABEL; -#ifdef RING_ACCEL static const char * const DECODING_ACCELERATED_KEY = "decodingAccelerated"; #endif -#endif static const char * const DFT_PULSE_LENGTH_STR = "250"; /** Default DTMF lenght */ static const char * const ALSA_DFT_CARD = "0"; /** Default sound card index */ @@ -547,9 +545,7 @@ void ShortcutPreferences::unserialize(const YAML::Node &in) #ifdef RING_VIDEO VideoPreferences::VideoPreferences() -#ifdef RING_ACCEL : decodingAccelerated_(true) -#endif { } diff --git a/src/preferences.h b/src/preferences.h index 9ac97c3052b2e3f81216d8c4a154bde7ebfde858..2a93aca21069bf5c1eaa671cb281a0e074faf3f6 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -447,7 +447,6 @@ class VideoPreferences : public Serializable { void serialize(YAML::Emitter &out); void unserialize(const YAML::Node &in); -#ifdef RING_ACCEL bool getDecodingAccelerated() const { return decodingAccelerated_; } @@ -455,7 +454,6 @@ class VideoPreferences : public Serializable { void setDecodingAccelerated(bool decodingAccelerated) { decodingAccelerated_ = decodingAccelerated; } -#endif // RING_ACCEL private: bool decodingAccelerated_;