Commit 79354e7c authored by Pierre Lespagnol's avatar Pierre Lespagnol Committed by Philippe Gorley

account: enable codecs by default

Enables Opus, H264 and VP8 for Jami accounts, and all codecs for SIP
accounts.

Change-Id: Ie7b7773d50afa52ddb2adf917eaee8c4dd6af07f
parent b145265f
......@@ -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
{
......
......@@ -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&
......
......@@ -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))
{
......
......@@ -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
......@@ -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.
*/
......
......@@ -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>();
......
......@@ -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;
......
......@@ -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
......@@ -533,6 +533,8 @@ class SIPAccount : public SIPAccountBase {
*/
IpAddr createBindingAddress();
void setActiveCodecs(const std::vector<unsigned>& list) override;
private:
void doRegister1_();
void doRegister2_();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment