Commit 38b92733 authored by Adrien Béraud's avatar Adrien Béraud

clang-tidy: fix issues

Change-Id: Ic4514b6e68346cd8488ccf750796c8590cee653a
parent 3b7f1513
......@@ -492,11 +492,11 @@ Account::searchCodecById(unsigned codecId, MediaType mediaType)
}
std::shared_ptr<AccountCodecInfo>
Account::searchCodecByName(std::string name, MediaType mediaType)
Account::searchCodecByName(const std::string& name, MediaType mediaType)
{
if (mediaType != MEDIA_NONE) {
for (auto& codecIt: accountCodecInfoList_) {
if ((codecIt->systemCodecInfo.name.compare(name) == 0) &&
if (codecIt->systemCodecInfo.name == name &&
(codecIt->systemCodecInfo.mediaType & mediaType ))
return codecIt;
}
......
......@@ -486,7 +486,7 @@ class Account : public Serializable, public std::enable_shared_from_this<Account
/**
* private account codec searching functions
*/
std::shared_ptr<AccountCodecInfo> searchCodecByName(std::string name, MediaType mediaType);
std::shared_ptr<AccountCodecInfo> searchCodecByName(const std::string& name, MediaType mediaType);
std::vector<unsigned> getAccountCodecInfoIdList(MediaType mediaType) const;
void setAllCodecsActive(MediaType mediaType, bool active);
};
......
......@@ -66,32 +66,29 @@ jsonValueToAccount(Json::Value& value, const std::string& accountId) {
}
Json::Value
accountToJsonValue(std::map<std::string, std::string> details) {
accountToJsonValue(const std::map<std::string, std::string>& details) {
Json::Value root;
std::map<std::string, std::string>::iterator iter;
for (iter = details.begin(); iter != details.end(); ++iter) {
if (iter->first.compare(DRing::Account::ConfProperties::Ringtone::PATH) == 0) {
for (const auto& i : details) {
if (i.first == DRing::Account::ConfProperties::Ringtone::PATH) {
// Ringtone path is not exportable
} else if (iter->first.compare(DRing::Account::ConfProperties::TLS::CA_LIST_FILE) == 0 ||
iter->first.compare(DRing::Account::ConfProperties::TLS::CERTIFICATE_FILE) == 0 ||
iter->first.compare(DRing::Account::ConfProperties::TLS::PRIVATE_KEY_FILE) == 0) {
} else if (i.first == DRing::Account::ConfProperties::TLS::CA_LIST_FILE ||
i.first == DRing::Account::ConfProperties::TLS::CERTIFICATE_FILE ||
i.first == DRing::Account::ConfProperties::TLS::PRIVATE_KEY_FILE) {
// replace paths by the files content
std::ifstream ifs(iter->second);
std::ifstream ifs(i.second);
std::string fileContent((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
root[iter->first] = fileContent;
root[i.first] = fileContent;
} else
root[iter->first] = iter->second;
root[i.first] = i.second;
}
return root;
}
int
exportAccounts(std::vector<std::string> accountIDs,
std::string filepath,
std::string password)
exportAccounts(const std::vector<std::string>& accountIDs,
const std::string& filepath,
const std::string& password)
{
if (filepath.empty() || !accountIDs.size()) {
JAMI_ERR("Missing arguments");
......
......@@ -40,9 +40,9 @@ namespace archiver {
* @param password The mandatory password to set on the archive
* @returns 0 for OK, error code otherwise
*/
int exportAccounts(std::vector<std::string> accountIDs,
std::string filepath,
std::string password);
int exportAccounts(const std::vector<std::string>& accountIDs,
const std::string& filepath,
const std::string& password);
/**
* Read a protected archive and add accounts found in it
......@@ -51,7 +51,7 @@ int exportAccounts(std::vector<std::string> accountIDs,
* @param password The password to read the archive
* @returns 0 for OK, error code otherwise
*/
int importAccounts(std::string archivePath, std::string password);
int importAccounts(const std::string& archivePath, const std::string& password);
/**
* Compress a STL string using zlib with given compression level and return
......
......@@ -1508,10 +1508,9 @@ Manager::createConfFromParticipantList(const std::vector< std::string > &partici
int successCounter = 0;
for (const auto &p : participantList) {
std::string numberaccount(p);
std::string tostr(numberaccount.substr(0, numberaccount.find(",")));
std::string account(numberaccount.substr(numberaccount.find(",") + 1, numberaccount.size()));
for (const auto& numberaccount : participantList) {
std::string tostr(numberaccount.substr(0, numberaccount.find(',')));
std::string account(numberaccount.substr(numberaccount.find(',') + 1, numberaccount.size()));
pimpl_->unsetCurrentCall();
......@@ -1652,7 +1651,7 @@ Manager::joinConference(const std::string& conf_id1,
void
Manager::addAudio(Call& call)
{
const auto call_id = call.getCallId();
const auto& call_id = call.getCallId();
if (isConferenceParticipant(call_id)) {
JAMI_DBG("[conf:%s] Attach local audio", call_id.c_str());
......@@ -1683,7 +1682,7 @@ Manager::addAudio(Call& call)
void
Manager::removeAudio(Call& call)
{
const auto call_id = call.getCallId();
const auto& call_id = call.getCallId();
JAMI_DBG("[call:%s] Remove local audio", call_id.c_str());
getRingBufferPool().unBindAll(call_id);
}
......@@ -1992,7 +1991,7 @@ Manager::sendCallTextMessage(const std::string& callID,
void
Manager::peerAnsweredCall(Call& call)
{
const auto call_id = call.getCallId();
const auto& call_id = call.getCallId();
JAMI_DBG("[call:%s] Peer answered", call_id.c_str());
// The if statement is useful only if we sent two calls at the same time.
......@@ -2025,7 +2024,7 @@ Manager::peerRingingCall(Call& call)
void
Manager::peerHungupCall(Call& call)
{
const auto call_id = call.getCallId();
const auto& call_id = call.getCallId();
JAMI_DBG("[call:%s] Peer hungup", call_id.c_str());
if (isConferenceParticipant(call_id)) {
......@@ -2065,7 +2064,7 @@ Manager::callBusy(Call& call)
void
Manager::callFailure(Call& call)
{
const auto call_id = call.getCallId();
const auto& call_id = call.getCallId();
JAMI_DBG("[call:%s] Failed", call.getCallId().c_str());
if (isCurrentCall(call)) {
......@@ -2161,7 +2160,7 @@ Manager::playRingtone(const std::string& accountID)
std::string ringchoice = account->getRingtonePath();
#ifndef _WIN32
if (ringchoice.find(DIR_SEPARATOR_STR) == std::string::npos) {
if (ringchoice.find(DIR_SEPARATOR_CH) == std::string::npos) {
// check inside global share directory
static const char * const RINGDIR = "ringtones";
ringchoice = std::string(PROGSHAREDIR) + DIR_SEPARATOR_STR
......@@ -2897,7 +2896,7 @@ std::vector<std::string>
Manager::getCallList() const
{
std::vector<std::string> results;
for (auto call: callFactory.getAllCalls()) {
for (const auto& call: callFactory.getAllCalls()) {
if (!call->isSubcall())
results.push_back(call->getCallId());
}
......@@ -3047,7 +3046,7 @@ int
Manager::getMessageStatus(uint64_t id) const
{
const auto& allAccounts = accountFactory.getAllAccounts();
for (auto acc : allAccounts) {
for (const auto& acc : allAccounts) {
auto status = acc->getMessageStatus(id);
if (status != im::MessageStatus::UNKNOWN)
return statusFromImStatus(status);
......
......@@ -40,8 +40,8 @@ generateId()
/*
* SystemCodecInfo
*/
SystemCodecInfo::SystemCodecInfo(unsigned avcodecId, const std::string name,
std::string libName,
SystemCodecInfo::SystemCodecInfo(unsigned avcodecId, const std::string& name,
const std::string& libName,
MediaType mediaType, CodecType codecType,
unsigned bitrate,
unsigned payloadType,
......@@ -66,8 +66,8 @@ SystemCodecInfo::~SystemCodecInfo()
* SystemAudioCodecInfo
*/
SystemAudioCodecInfo::SystemAudioCodecInfo(unsigned m_avcodecId,
const std::string m_name,
std::string m_libName,
const std::string& m_name,
const std::string& m_libName,
CodecType m_type, unsigned m_bitrate,
unsigned m_sampleRate,
unsigned m_nbChannels,
......@@ -96,8 +96,8 @@ SystemAudioCodecInfo::getCodecSpecifications()
* SystemVideoCodecInfo
*/
SystemVideoCodecInfo::SystemVideoCodecInfo(unsigned m_avcodecId,
const std::string m_name,
std::string m_libName,
const std::string& m_name,
const std::string& m_libName,
CodecType m_type,
unsigned m_bitrate,
unsigned m_minQuality,
......@@ -137,19 +137,6 @@ AccountCodecInfo::AccountCodecInfo(const SystemCodecInfo& sysCodecInfo) noexcept
quality = SystemCodecInfo::DEFAULT_NO_QUALITY;
}
AccountCodecInfo&
AccountCodecInfo::operator=(AccountCodecInfo&& o)
{
if (&systemCodecInfo != &o.systemCodecInfo)
throw std::runtime_error("cannot assign codec info object pointing to another codec.");
order = o.order;
isActive = o.isActive;
payloadType = o.payloadType;
bitrate = o.bitrate;
quality = o.quality;
return *this;
}
AccountCodecInfo&
AccountCodecInfo::operator=(const AccountCodecInfo& o)
{
......
......@@ -73,8 +73,8 @@ struct SystemCodecInfo
static constexpr unsigned DEFAULT_MIN_BITRATE {250};
static constexpr unsigned DEFAULT_MAX_BITRATE {3000};
SystemCodecInfo(unsigned avcodecId, const std::string name,
std::string libName, MediaType mediaType,
SystemCodecInfo(unsigned avcodecId, const std::string& name,
const std::string& libName, MediaType mediaType,
CodecType codecType = CODEC_NONE, unsigned bitrate = 0,
unsigned payloadType = 0,
unsigned m_minQuality = DEFAULT_NO_QUALITY,
......@@ -106,8 +106,8 @@ struct SystemCodecInfo
*/
struct SystemAudioCodecInfo : SystemCodecInfo
{
SystemAudioCodecInfo(unsigned avcodecId, const std::string name,
std::string libName, CodecType type,
SystemAudioCodecInfo(unsigned avcodecId, const std::string& name,
const std::string& libName, CodecType type,
unsigned bitrate = 0,
unsigned sampleRate = 0, unsigned nbChannels = 0,
unsigned payloadType = 0);
......@@ -126,8 +126,8 @@ struct SystemAudioCodecInfo : SystemCodecInfo
*/
struct SystemVideoCodecInfo : SystemCodecInfo
{
SystemVideoCodecInfo(unsigned avcodecId, const std::string name,
std::string libName, CodecType type = CODEC_NONE,
SystemVideoCodecInfo(unsigned avcodecId, const std::string& name,
const std::string& libName, CodecType type = CODEC_NONE,
unsigned bitrate = 0,
unsigned m_minQuality = 0,
unsigned m_maxQuality = 0,
......@@ -153,9 +153,9 @@ struct AccountCodecInfo
{
AccountCodecInfo(const SystemCodecInfo& sysCodecInfo) noexcept;
AccountCodecInfo(const AccountCodecInfo&) noexcept = default;
AccountCodecInfo(AccountCodecInfo&&) noexcept = default;
AccountCodecInfo(AccountCodecInfo&&) noexcept = delete;
AccountCodecInfo& operator=(const AccountCodecInfo&);
AccountCodecInfo& operator=(AccountCodecInfo&&);
AccountCodecInfo& operator=(AccountCodecInfo&&) noexcept = delete;
const SystemCodecInfo& systemCodecInfo;
unsigned order {0}; /*used to define preferred codec list order in UI*/
......@@ -165,7 +165,6 @@ struct AccountCodecInfo
unsigned bitrate;
unsigned quality;
std::map<std::string, std::string> getCodecSpecifications();
};
struct AccountAudioCodecInfo : AccountCodecInfo
......
......@@ -458,6 +458,8 @@ MediaEncoder::encodeAudio(AudioFrame& frame)
int
MediaEncoder::encode(AVFrame* frame, int streamIdx)
{
if (not frame)
return -1;
if (!initialized_) {
// Initialize on first video frame, or first audio frame if no video stream
bool isVideo = (frame->width > 0 && frame->height > 0);
......
......@@ -196,11 +196,11 @@ SystemCodecContainer::searchCodecById(unsigned codecId, MediaType mediaType)
return {};
}
std::shared_ptr<SystemCodecInfo>
SystemCodecContainer::searchCodecByName(std::string name, MediaType mediaType)
SystemCodecContainer::searchCodecByName(const std::string& name, MediaType mediaType)
{
for (const auto& codecIt: availableCodecList_) {
if ((codecIt->name.compare(name) == 0) &&
(codecIt->mediaType & mediaType ))
if (codecIt->name == name &&
(codecIt->mediaType & mediaType))
return codecIt;
}
return {};
......
......@@ -50,7 +50,7 @@ class SystemCodecContainer
searchCodecById(unsigned codecId, MediaType type = MEDIA_ALL);
std::shared_ptr<SystemCodecInfo>
searchCodecByName(std::string name, MediaType type = MEDIA_ALL);
searchCodecByName(const std::string& name, MediaType type = MEDIA_ALL);
std::shared_ptr<SystemCodecInfo>
searchCodecByPayload(unsigned payload, MediaType type = MEDIA_ALL);
......
......@@ -80,7 +80,7 @@ VideoRtpSession::updateMedia(const MediaDescription& send, const MediaDescriptio
void
VideoRtpSession::setRequestKeyFrameCallback(std::function<void(void)> cb)
{
requestKeyFrameCallback_ = cb;
requestKeyFrameCallback_ = std::move(cb);
}
void VideoRtpSession::startSender()
......@@ -611,7 +611,7 @@ VideoRtpSession::deinitRecorder(std::shared_ptr<MediaRecorder>& rec)
void
VideoRtpSession::setChangeOrientationCallback(std::function<void(int)> cb)
{
changeOrientationCallback_ = cb;
changeOrientationCallback_ = std::move(cb);
}
}} // namespace jami::video
......@@ -144,7 +144,7 @@ VideoSender::useCodec(const jami::AccountVideoCodecInfo* codec) const
void
VideoSender::setChangeOrientationCallback(std::function<void(int)> cb)
{
changeOrientationCallback_ = cb;
changeOrientationCallback_ = std::move(cb);
}
}} // namespace jami::video
......@@ -88,8 +88,6 @@
namespace jami {
using sip_utils::CONST_PJ_STR;
namespace Migration {
enum class State { // Contains all the Migration states
......@@ -2859,7 +2857,7 @@ RingAccount::loadValues() const
}
tls::DhParams
RingAccount::loadDhParams(const std::string path)
RingAccount::loadDhParams(std::string path)
{
try {
// writeTime throw exception if file doesn't exist
......
......@@ -603,7 +603,7 @@ class RingAccount : public SIPAccountBase {
const std::shared_ptr<dht::crypto::Certificate>& from_cert,
const dht::InfoHash& from);
static tls::DhParams loadDhParams(const std::string path);
static tls::DhParams loadDhParams(std::string path);
/**
* If privkeyPath_ is a valid private key file (PEM or DER),
......
......@@ -50,7 +50,6 @@ using random_device = dht::crypto::random_device;
namespace jami {
using std::string;
using std::map;
using std::vector;
using std::stringstream;
......
......@@ -1566,18 +1566,15 @@ void SIPAccount::keepAliveRegistrationCb(UNUSED pj_timer_heap_t *th, pj_timer_en
void
SIPAccount::Credentials::computePasswordHash()
{
#define MD5_APPEND(pms,buf,len) pj_md5_update(pms, (const pj_uint8_t*)buf, len)
pj_md5_context pms;
/* Compute md5 hash = MD5(username ":" realm ":" password) */
pj_md5_init(&pms);
MD5_APPEND(&pms, username.data(), username.length());
MD5_APPEND(&pms, ":", 1);
MD5_APPEND(&pms, realm.data(), realm.length());
MD5_APPEND(&pms, ":", 1);
MD5_APPEND(&pms, password.data(), password.length());
#undef MD5_APPEND
pj_md5_update(&pms, (const uint8_t*)username.data(), username.length());
pj_md5_update(&pms, (const uint8_t*)":", 1);
pj_md5_update(&pms, (const uint8_t*)realm.data(), realm.length());
pj_md5_update(&pms, (const uint8_t*)":", 1);
pj_md5_update(&pms, (const uint8_t*)password.data(), password.length());
unsigned char digest[16];
pj_md5_final(&pms, digest);
......
......@@ -57,16 +57,6 @@ ThreadLoop::ThreadLoop(const std::function<bool()>& setup,
, thread_()
{}
ThreadLoop::ThreadLoop(ThreadLoop&& other)
: setup_(std::move(other.setup_))
, process_(std::move(other.process_))
, cleanup_(std::move(other.cleanup_))
, state_(other.state_.load())
, thread_(std::move(other.thread_))
{
other.state_ = READY;
}
ThreadLoop::~ThreadLoop()
{
if (isRunning()) {
......
......@@ -41,9 +41,6 @@ public:
ThreadLoop(const std::function<bool()>& setup,
const std::function<void()>& process,
const std::function<void()>& cleanup);
ThreadLoop(ThreadLoop&&);
virtual ~ThreadLoop();
void start();
......@@ -57,6 +54,11 @@ public:
std::thread::id get_id() const noexcept;
private:
ThreadLoop(const ThreadLoop&) = delete;
ThreadLoop(ThreadLoop&&) noexcept = delete;
ThreadLoop& operator=(const ThreadLoop&) = delete;
ThreadLoop& operator=(ThreadLoop&&) noexcept = delete;
// These must be provided by users of ThreadLoop
std::function<bool()> setup_;
std::function<void()> process_;
......
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