diff --git a/src/account.cpp b/src/account.cpp index 4111ad595bb230aa03830294fcf6dfce63ec4ec2..bcbcdbff8affb80491719cf3d54afb7ef5bcad4e 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -360,15 +360,6 @@ Account::setActiveCodecs(const std::vector<unsigned>& list) const std::shared_ptr<AccountCodecInfo>& b) { return a->order < b->order; }); - - if (!hasActiveCodec(MEDIA_AUDIO)) { - JAMI_WARN("All audio codecs disabled, enabling all"); - setAllCodecsActive(MEDIA_AUDIO, true); - } - if (!hasActiveCodec(MEDIA_VIDEO)) { - JAMI_WARN("All video codecs disabled, enabling all"); - setAllCodecsActive(MEDIA_VIDEO, true); - } } std::string @@ -563,6 +554,15 @@ Account::setAllCodecsActive(MediaType mediaType, bool active) } } +void +Account::setCodecActive(unsigned codecId) +{ + for (auto& codecIt: accountCodecInfoList_) { + if (codecIt->systemCodecInfo.avcodecId == codecId) + codecIt->isActive = true; + } +} + std::vector<std::shared_ptr<AccountCodecInfo>> Account::getActiveAccountCodecInfoList(MediaType mediaType) const { diff --git a/src/account.h b/src/account.h index 575da296b293b997aa71bb83506fd31699f8ef80..97a6d9b0c7450cd7ad7a938f9333a0592a77dc3d 100644 --- a/src/account.h +++ b/src/account.h @@ -248,7 +248,7 @@ class Account : public Serializable, public std::enable_shared_from_this<Account * Update both the codec order structure and the codec string used for * SDP offer and configuration respectively */ - void setActiveCodecs(const std::vector<unsigned>& list); + virtual void setActiveCodecs(const std::vector<unsigned>& list); std::shared_ptr<AccountCodecInfo> searchCodecById(unsigned codecId, MediaType mediaType); std::vector<std::shared_ptr<AccountCodecInfo>> getActiveAccountCodecInfoList(MediaType mediaType) const; std::shared_ptr<AccountCodecInfo> searchCodecByPayload(unsigned payload, MediaType mediaType); @@ -493,6 +493,7 @@ class Account : public Serializable, public std::enable_shared_from_this<Account std::shared_ptr<AccountCodecInfo> searchCodecByName(const std::string& name, MediaType mediaType); std::vector<unsigned> getAccountCodecInfoIdList(MediaType mediaType) const; void setAllCodecsActive(MediaType mediaType, bool active); + void setCodecActive(unsigned codecId); }; static inline std::ostream& diff --git a/src/client/configurationmanager.cpp b/src/client/configurationmanager.cpp index 0ecbddaf78229dbe8f2db67962d46b49ecb62c85..de861aac79c38aac2d7bf29510c39b8945c00c8d 100644 --- a/src/client/configurationmanager.cpp +++ b/src/client/configurationmanager.cpp @@ -570,8 +570,7 @@ getActiveCodecList(const std::string& accountID) } void -setActiveCodecList(const std::string& accountID - , const std::vector<unsigned>& list) +setActiveCodecList(const std::string& accountID, const std::vector<unsigned>& list) { if (auto acc = jami::Manager::instance().getAccount(accountID)) { diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index 7c798d75d44f57e271418d6794df7709a377a01c..72c2f509d6316270cda364884c417238300226a6 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -313,6 +313,8 @@ JamiAccount::JamiAccount(const std::string& accountID, bool /* presenceEnabled * std::ifstream proxyCache(cachePath_ + DIR_SEPARATOR_STR "dhtproxy"); if (proxyCache) std::getline(proxyCache, proxyServerCached_); + + setActiveCodecs({}); } JamiAccount::~JamiAccount() @@ -3744,4 +3746,17 @@ JamiAccount::getNearbyPeers() const return discoveredPeerMap_; } + +void +JamiAccount::setActiveCodecs(const std::vector<unsigned>& list) +{ + Account::setActiveCodecs(list); + if (!hasActiveCodec(MEDIA_AUDIO)) + setCodecActive(AV_CODEC_ID_OPUS); + if (!hasActiveCodec(MEDIA_VIDEO)) { + setCodecActive(AV_CODEC_ID_H264); + setCodecActive(AV_CODEC_ID_VP8); + } +} + } // namespace jami diff --git a/src/jamidht/jamiaccount.h b/src/jamidht/jamiaccount.h index 2edb7ed07a516572bf6cc0fedb5a32132f8d72f0..e21208840b153f7e1c32dc4cfa5209b78fb1fe25 100644 --- a/src/jamidht/jamiaccount.h +++ b/src/jamidht/jamiaccount.h @@ -162,6 +162,8 @@ class JamiAccount : public SIPAccountBase { */ std::map<std::string, bool> getTrackedBuddyPresence() const; + void setActiveCodecs(const std::vector<unsigned>& list) override; + /** * Connect to the DHT. */ diff --git a/src/manager.cpp b/src/manager.cpp index 879473294dd1b86857d927b67c05e681dc5c3b1b..8d0c00fa62a053bc805eb45869784ff1eef6dfe8 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -2754,11 +2754,10 @@ Manager::addAccount(const std::map<std::string, std::string>& details, const std } newAccount->setAccountDetails(details); - - preferences.addAccount(newAccountID); - + saveConfig(newAccount); newAccount->doRegister(); + preferences.addAccount(newAccountID); saveConfig(); emitSignal<DRing::ConfigurationSignal::AccountsChanged>(); diff --git a/src/media/media_codec.h b/src/media/media_codec.h index b5158acdd9c0feaf4b823d2664c4ee4f5eebb640..4ce09983743a53a37c148b8bee23002bb4fa033d 100644 --- a/src/media/media_codec.h +++ b/src/media/media_codec.h @@ -159,7 +159,7 @@ struct AccountCodecInfo const SystemCodecInfo& systemCodecInfo; unsigned order {0}; /*used to define preferred codec list order in UI*/ - bool isActive {true}; + bool isActive {false}; /* account custom values */ unsigned payloadType; unsigned bitrate; diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index aed61a2b47b0023bb51e49d34323b8419fed3793..597753b863b12f8ccfd36bab70b1325c62fa00e0 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -157,6 +157,7 @@ SIPAccount::SIPAccount(const std::string& accountID, bool presenceEnabled) via_addr_.host.ptr = 0; via_addr_.host.slen = 0; via_addr_.port = 0; + setActiveCodecs({}); } SIPAccount::~SIPAccount() @@ -2226,4 +2227,18 @@ SIPAccount::createBindingAddress() return ret; } +void +SIPAccount::setActiveCodecs(const std::vector<unsigned>& list) +{ + Account::setActiveCodecs(list); + if (!hasActiveCodec(MEDIA_AUDIO)) { + JAMI_WARN("All audio codecs disabled, enabling all"); + setAllCodecsActive(MEDIA_AUDIO, true); + } + if (!hasActiveCodec(MEDIA_VIDEO)) { + JAMI_WARN("All video codecs disabled, enabling all"); + setAllCodecsActive(MEDIA_VIDEO, true); + } +} + } // namespace jami diff --git a/src/sip/sipaccount.h b/src/sip/sipaccount.h index fae3b6b45978e3cd46a012b0d4a01fcf2e50d535..f577c86396f7deb7234d9ca9f59596460587aed4 100644 --- a/src/sip/sipaccount.h +++ b/src/sip/sipaccount.h @@ -533,6 +533,8 @@ class SIPAccount : public SIPAccountBase { */ IpAddr createBindingAddress(); + void setActiveCodecs(const std::vector<unsigned>& list) override; + private: void doRegister1_(); void doRegister2_();