clang: change AlignConsecutiveAssignments to false

Change-Id: I2dd97518218a5a777ddde2ce8d23e2d5dde4dcf0
parent 02e65ffd
......@@ -8,7 +8,7 @@
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignEscapedNewlines: DontAlign
......
......@@ -60,33 +60,33 @@ using random_device = dht::crypto::random_device;
namespace jami {
const char* const Account::ALL_CODECS_KEY = "allCodecs";
const char* const Account::VIDEO_CODEC_ENABLED = "enabled";
const char* const Account::VIDEO_CODEC_NAME = "name";
const char* const Account::VIDEO_CODEC_PARAMETERS = "parameters";
const char* const Account::VIDEO_CODEC_BITRATE = "bitrate";
const char* const Account::RINGTONE_PATH_KEY = "ringtonePath";
const char* const Account::RINGTONE_ENABLED_KEY = "ringtoneEnabled";
const char* const Account::VIDEO_ENABLED_KEY = "videoEnabled";
const char* const Account::DISPLAY_NAME_KEY = "displayName";
const char* const Account::ALIAS_KEY = "alias";
const char* const Account::TYPE_KEY = "type";
const char* const Account::ID_KEY = "id";
const char* const Account::USERNAME_KEY = "username";
const char* const Account::AUTHENTICATION_USERNAME_KEY = "authenticationUsername";
const char* const Account::PASSWORD_KEY = "password";
const char* const Account::HOSTNAME_KEY = "hostname";
const char* const Account::ACCOUNT_ENABLE_KEY = "enable";
const char* const Account::ACCOUNT_AUTOANSWER_KEY = "autoAnswer";
const char* const Account::ACCOUNT_ISRENDEZVOUS_KEY = "rendezVous";
const char* const Account::ALL_CODECS_KEY = "allCodecs";
const char* const Account::VIDEO_CODEC_ENABLED = "enabled";
const char* const Account::VIDEO_CODEC_NAME = "name";
const char* const Account::VIDEO_CODEC_PARAMETERS = "parameters";
const char* const Account::VIDEO_CODEC_BITRATE = "bitrate";
const char* const Account::RINGTONE_PATH_KEY = "ringtonePath";
const char* const Account::RINGTONE_ENABLED_KEY = "ringtoneEnabled";
const char* const Account::VIDEO_ENABLED_KEY = "videoEnabled";
const char* const Account::DISPLAY_NAME_KEY = "displayName";
const char* const Account::ALIAS_KEY = "alias";
const char* const Account::TYPE_KEY = "type";
const char* const Account::ID_KEY = "id";
const char* const Account::USERNAME_KEY = "username";
const char* const Account::AUTHENTICATION_USERNAME_KEY = "authenticationUsername";
const char* const Account::PASSWORD_KEY = "password";
const char* const Account::HOSTNAME_KEY = "hostname";
const char* const Account::ACCOUNT_ENABLE_KEY = "enable";
const char* const Account::ACCOUNT_AUTOANSWER_KEY = "autoAnswer";
const char* const Account::ACCOUNT_ISRENDEZVOUS_KEY = "rendezVous";
const char* const Account::ACCOUNT_ACTIVE_CALL_LIMIT_KEY = "activeCallLimit";
const char* const Account::MAILBOX_KEY = "mailbox";
const char* const Account::DEFAULT_USER_AGENT = PACKAGE_NAME;
const char* const Account::USER_AGENT_KEY = "useragent";
const char* const Account::HAS_CUSTOM_USER_AGENT_KEY = "hasCustomUserAgent";
const char* const Account::PRESENCE_MODULE_ENABLED_KEY = "presenceModuleEnabled";
const char* const Account::UPNP_ENABLED_KEY = "upnpEnabled";
const char* const Account::ACTIVE_CODEC_KEY = "activeCodecs";
const char* const Account::MAILBOX_KEY = "mailbox";
const char* const Account::DEFAULT_USER_AGENT = PACKAGE_NAME;
const char* const Account::USER_AGENT_KEY = "useragent";
const char* const Account::HAS_CUSTOM_USER_AGENT_KEY = "hasCustomUserAgent";
const char* const Account::PRESENCE_MODULE_ENABLED_KEY = "presenceModuleEnabled";
const char* const Account::UPNP_ENABLED_KEY = "upnpEnabled";
const char* const Account::ACTIVE_CODEC_KEY = "activeCodecs";
#ifdef __ANDROID__
constexpr const char* const DEFAULT_RINGTONE_PATH
......@@ -167,7 +167,7 @@ Account::setRegistrationState(RegistrationState state,
registrationState_ = state;
// Notify the client
runOnMainThread([accountId = accountID_,
state = mapStateNumberToString(registrationState_),
state = mapStateNumberToString(registrationState_),
detail_code,
detail_str,
details = getVolatileAccountDetails()] {
......@@ -261,7 +261,7 @@ Account::unserialize(const YAML::Node& node)
std::string allCodecs;
if (parseValueOptional(node, ALL_CODECS_KEY, allCodecs)) {
JAMI_WARN("Converting deprecated codec list");
auto list = convertIdToAVId(split_string_to_unsigned(allCodecs, '/'));
auto list = convertIdToAVId(split_string_to_unsigned(allCodecs, '/'));
auto codec = searchCodecByName("H265", MEDIA_ALL);
// set H265 as first active codec if found
if (codec)
......@@ -376,7 +376,7 @@ Account::setActiveCodecs(const std::vector<unsigned>& list)
for (const auto& item : list) {
if (auto accCodec = searchCodecById(item, MEDIA_ALL)) {
accCodec->isActive = true;
accCodec->order = order;
accCodec->order = order;
++order;
}
}
......
......@@ -217,7 +217,7 @@ public:
* @param state The registration state of underlying VoIPLink
*/
virtual void setRegistrationState(RegistrationState state,
unsigned detail_code = 0,
unsigned detail_code = 0,
const std::string& detail_str = {});
/* They should be treated like macro definitions by the C++ compiler */
......
......@@ -145,7 +145,7 @@ AccountFactory::getAccount(const std::string& id) const
std::lock_guard<std::recursive_mutex> lock(mutex_);
for (const auto& item : accountMaps_) {
const auto& map = item.second;
const auto& map = item.second;
const auto& iter = map.find(id);
if (iter != map.cend())
return iter->second;
......
......@@ -31,83 +31,83 @@ namespace jami {
namespace Conf {
// Common account parameters
static const char* const CONFIG_ACCOUNT_TYPE = "Account.type";
static const char* const CONFIG_ACCOUNT_ALIAS = "Account.alias";
static const char* const CONFIG_ACCOUNT_DISPLAYNAME = "Account.displayName";
static const char* const CONFIG_ACCOUNT_MAILBOX = "Account.mailbox";
static const char* const CONFIG_ACCOUNT_ENABLE = "Account.enable";
static const char* const CONFIG_ACCOUNT_AUTOANSWER = "Account.autoAnswer";
static const char* const CONFIG_ACCOUNT_ISRENDEZVOUS = "Account.rendezVous";
static const char* const CONFIG_ACCOUNT_REGISTRATION_EXPIRE = "Account.registrationExpire";
static const char* const CONFIG_ACCOUNT_DTMF_TYPE = "Account.dtmfType";
static const char* const CONFIG_RINGTONE_PATH = "Account.ringtonePath";
static const char* const CONFIG_RINGTONE_ENABLED = "Account.ringtoneEnabled";
static const char* const CONFIG_VIDEO_ENABLED = "Account.videoEnabled";
static const char* const CONFIG_KEEP_ALIVE_ENABLED = "Account.keepAliveEnabled";
static const char* const CONFIG_PRESENCE_ENABLED = "Account.presenceEnabled";
static const char* const CONFIG_PRESENCE_PUBLISH_SUPPORTED = "Account.presencePublishSupported";
static const char* const CONFIG_ACCOUNT_TYPE = "Account.type";
static const char* const CONFIG_ACCOUNT_ALIAS = "Account.alias";
static const char* const CONFIG_ACCOUNT_DISPLAYNAME = "Account.displayName";
static const char* const CONFIG_ACCOUNT_MAILBOX = "Account.mailbox";
static const char* const CONFIG_ACCOUNT_ENABLE = "Account.enable";
static const char* const CONFIG_ACCOUNT_AUTOANSWER = "Account.autoAnswer";
static const char* const CONFIG_ACCOUNT_ISRENDEZVOUS = "Account.rendezVous";
static const char* const CONFIG_ACCOUNT_REGISTRATION_EXPIRE = "Account.registrationExpire";
static const char* const CONFIG_ACCOUNT_DTMF_TYPE = "Account.dtmfType";
static const char* const CONFIG_RINGTONE_PATH = "Account.ringtonePath";
static const char* const CONFIG_RINGTONE_ENABLED = "Account.ringtoneEnabled";
static const char* const CONFIG_VIDEO_ENABLED = "Account.videoEnabled";
static const char* const CONFIG_KEEP_ALIVE_ENABLED = "Account.keepAliveEnabled";
static const char* const CONFIG_PRESENCE_ENABLED = "Account.presenceEnabled";
static const char* const CONFIG_PRESENCE_PUBLISH_SUPPORTED = "Account.presencePublishSupported";
static const char* const CONFIG_PRESENCE_SUBSCRIBE_SUPPORTED = "Account.presenceSubscribeSupported";
static const char* const CONFIG_PRESENCE_STATUS = "Account.presenceStatus";
static const char* const CONFIG_PRESENCE_NOTE = "Account.presenceNote";
static const char* const CONFIG_PRESENCE_STATUS = "Account.presenceStatus";
static const char* const CONFIG_PRESENCE_NOTE = "Account.presenceNote";
static const char* const CONFIG_ACCOUNT_HOSTNAME = "Account.hostname";
static const char* const CONFIG_ACCOUNT_USERNAME = "Account.username";
static const char* const CONFIG_ACCOUNT_ROUTESET = "Account.routeset";
static const char* const CONFIG_ACCOUNT_PASSWORD = "Account.password";
static const char* const CONFIG_ACCOUNT_REALM = "Account.realm";
static const char* const CONFIG_ACCOUNT_USERAGENT = "Account.useragent";
static const char* const CONFIG_ACCOUNT_HOSTNAME = "Account.hostname";
static const char* const CONFIG_ACCOUNT_USERNAME = "Account.username";
static const char* const CONFIG_ACCOUNT_ROUTESET = "Account.routeset";
static const char* const CONFIG_ACCOUNT_PASSWORD = "Account.password";
static const char* const CONFIG_ACCOUNT_REALM = "Account.realm";
static const char* const CONFIG_ACCOUNT_USERAGENT = "Account.useragent";
static const char* const CONFIG_ACCOUNT_HAS_CUSTOM_USERAGENT = "Account.hasCustomUserAgent";
static const char* const CONFIG_ACCOUNT_AUDIO_PORT_MIN = "Account.audioPortMin";
static const char* const CONFIG_ACCOUNT_AUDIO_PORT_MAX = "Account.audioPortMax";
static const char* const CONFIG_ACCOUNT_VIDEO_PORT_MIN = "Account.videoPortMin";
static const char* const CONFIG_ACCOUNT_VIDEO_PORT_MAX = "Account.videoPortMax";
static const char* const CONFIG_ACCOUNT_AUDIO_PORT_MIN = "Account.audioPortMin";
static const char* const CONFIG_ACCOUNT_AUDIO_PORT_MAX = "Account.audioPortMax";
static const char* const CONFIG_ACCOUNT_VIDEO_PORT_MIN = "Account.videoPortMin";
static const char* const CONFIG_ACCOUNT_VIDEO_PORT_MAX = "Account.videoPortMax";
static const char* const CONFIG_BIND_ADDRESS = "Account.bindAddress";
static const char* const CONFIG_LOCAL_INTERFACE = "Account.localInterface";
static const char* const CONFIG_BIND_ADDRESS = "Account.bindAddress";
static const char* const CONFIG_LOCAL_INTERFACE = "Account.localInterface";
static const char* const CONFIG_PUBLISHED_SAMEAS_LOCAL = "Account.publishedSameAsLocal";
static const char* const CONFIG_LOCAL_PORT = "Account.localPort";
static const char* const CONFIG_PUBLISHED_PORT = "Account.publishedPort";
static const char* const CONFIG_PUBLISHED_ADDRESS = "Account.publishedAddress";
static const char* const CONFIG_UPNP_ENABLED = "Account.upnpEnabled";
static const char* const CONFIG_LOCAL_PORT = "Account.localPort";
static const char* const CONFIG_PUBLISHED_PORT = "Account.publishedPort";
static const char* const CONFIG_PUBLISHED_ADDRESS = "Account.publishedAddress";
static const char* const CONFIG_UPNP_ENABLED = "Account.upnpEnabled";
// SIP specific parameters
static const char* const CONFIG_STUN_SERVER = "STUN.server";
static const char* const CONFIG_STUN_ENABLE = "STUN.enable";
static const char* const CONFIG_TURN_SERVER = "TURN.server";
static const char* const CONFIG_TURN_ENABLE = "TURN.enable";
static const char* const CONFIG_STUN_SERVER = "STUN.server";
static const char* const CONFIG_STUN_ENABLE = "STUN.enable";
static const char* const CONFIG_TURN_SERVER = "TURN.server";
static const char* const CONFIG_TURN_ENABLE = "TURN.enable";
static const char* const CONFIG_TURN_SERVER_UNAME = "TURN.username";
static const char* const CONFIG_TURN_SERVER_PWD = "TURN.password";
static const char* const CONFIG_TURN_SERVER_PWD = "TURN.password";
static const char* const CONFIG_TURN_SERVER_REALM = "TURN.realm";
// SRTP specific parameters
static const char* const CONFIG_SRTP_ENABLE = "SRTP.enable";
static const char* const CONFIG_SRTP_ENABLE = "SRTP.enable";
static const char* const CONFIG_SRTP_KEY_EXCHANGE = "SRTP.keyExchange";
static const char* const CONFIG_SRTP_RTP_FALLBACK = "SRTP.rtpFallback";
static const char* const CONFIG_TLS_LISTENER_PORT = "TLS.listenerPort";
static const char* const CONFIG_TLS_ENABLE = "TLS.enable";
static const char* const CONFIG_TLS_CA_LIST_FILE = "TLS.certificateListFile";
static const char* const CONFIG_TLS_CERTIFICATE_FILE = "TLS.certificateFile";
static const char* const CONFIG_TLS_PRIVATE_KEY_FILE = "TLS.privateKeyFile";
static const char* const CONFIG_TLS_PASSWORD = "TLS.password";
static const char* const CONFIG_TLS_METHOD = "TLS.method";
static const char* const CONFIG_TLS_CIPHERS = "TLS.ciphers";
static const char* const CONFIG_TLS_SERVER_NAME = "TLS.serverName";
static const char* const CONFIG_TLS_VERIFY_SERVER = "TLS.verifyServer";
static const char* const CONFIG_TLS_VERIFY_CLIENT = "TLS.verifyClient";
static const char* const CONFIG_TLS_LISTENER_PORT = "TLS.listenerPort";
static const char* const CONFIG_TLS_ENABLE = "TLS.enable";
static const char* const CONFIG_TLS_CA_LIST_FILE = "TLS.certificateListFile";
static const char* const CONFIG_TLS_CERTIFICATE_FILE = "TLS.certificateFile";
static const char* const CONFIG_TLS_PRIVATE_KEY_FILE = "TLS.privateKeyFile";
static const char* const CONFIG_TLS_PASSWORD = "TLS.password";
static const char* const CONFIG_TLS_METHOD = "TLS.method";
static const char* const CONFIG_TLS_CIPHERS = "TLS.ciphers";
static const char* const CONFIG_TLS_SERVER_NAME = "TLS.serverName";
static const char* const CONFIG_TLS_VERIFY_SERVER = "TLS.verifyServer";
static const char* const CONFIG_TLS_VERIFY_CLIENT = "TLS.verifyClient";
static const char* const CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE = "TLS.requireClientCertificate";
static const char* const CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC = "TLS.negotiationTimeoutSec";
static const char* const CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC = "TLS.negotiationTimeoutSec";
// DHT specific parameters
static const char* const CONFIG_DHT_PORT = "DHT.port";
static const char* const CONFIG_DHT_PORT = "DHT.port";
static const char* const CONFIG_DHT_PUBLIC_IN_CALLS = "DHT.PublicInCalls";
// Volatile parameters
static const char* const CONFIG_ACCOUNT_REGISTRATION_STATUS = "Account.registrationStatus";
static const char* const CONFIG_ACCOUNT_REGISTRATION_STATUS = "Account.registrationStatus";
static const char* const CONFIG_ACCOUNT_REGISTRATION_STATE_CODE = "Account.registrationCode";
static const char* const CONFIG_ACCOUNT_REGISTRATION_STATE_DESC = "Account.registrationDescription";
static const char* const CONFIG_TRANSPORT_STATE_CODE = "Transport.statusCode";
static const char* const CONFIG_TRANSPORT_STATE_DESC = "Transport.statusDescription";
static const char* const CONFIG_TRANSPORT_STATE_CODE = "Transport.statusCode";
static const char* const CONFIG_TRANSPORT_STATE_DESC = "Transport.statusDescription";
} // namespace Conf
} // namespace jami
......
......@@ -117,8 +117,8 @@ exportAccounts(const std::vector<std::string>& accountIDs,
}
std::size_t found = filepath.find_last_of(DIR_SEPARATOR_CH);
auto toDir = filepath.substr(0, found);
auto filename = filepath.substr(found + 1);
auto toDir = filepath.substr(0, found);
auto filename = filepath.substr(found + 1);
if (!fileutils::isDirectory(toDir)) {
JAMI_ERR("%s is not a directory", toDir.c_str());
......@@ -142,8 +142,8 @@ exportAccounts(const std::vector<std::string>& accountIDs,
root["accounts"] = array;
Json::StreamWriterBuilder wbuilder;
wbuilder["commentStyle"] = "None";
wbuilder["indentation"] = "";
auto output = Json::writeString(wbuilder, root);
wbuilder["indentation"] = "";
auto output = Json::writeString(wbuilder, root);
// Compress
std::vector<uint8_t> compressed;
......@@ -202,7 +202,7 @@ importAccounts(const std::string& archivePath, const std::string& password)
try {
const auto* char_file_begin = reinterpret_cast<const char*>(&file[0]);
const auto* char_file_end = reinterpret_cast<const char*>(&file[file.size()]);
const auto* char_file_end = reinterpret_cast<const char*>(&file[file.size()]);
// Add
std::string err;
......@@ -218,7 +218,7 @@ importAccounts(const std::string& archivePath, const std::string& password)
for (int i = 0, n = accounts.size(); i < n; ++i) {
// Generate a new account id
auto accountId = jami::Manager::instance().getNewAccountId();
auto details = jsonValueToAccount(accounts[i], accountId);
auto details = jsonValueToAccount(accounts[i], accountId);
jami::Manager::instance().addAccount(details, accountId);
}
} catch (const std::exception& ex) {
......@@ -284,7 +284,7 @@ decompress(const std::vector<uint8_t>& str)
if (inflateInit(&zs) != Z_OK)
throw std::runtime_error("inflateInit failed while decompressing.");
zs.next_in = (Bytef*) str.data();
zs.next_in = (Bytef*) str.data();
zs.avail_in = str.size();
int ret;
......@@ -293,7 +293,7 @@ decompress(const std::vector<uint8_t>& str)
// get the decompressed bytes blockwise using repeated calls to inflate
do {
std::array<uint8_t, 32768> outbuffer;
zs.next_out = reinterpret_cast<Bytef*>(outbuffer.data());
zs.next_out = reinterpret_cast<Bytef*>(outbuffer.data());
zs.avail_out = outbuffer.size();
ret = inflate(&zs, 0);
......@@ -331,7 +331,7 @@ openGzip(const std::string& path, const char* mode)
#ifdef ENABLE_PLUGIN
// LIBARCHIVE DEFINITIONS
//==========================
using ArchivePtr = std::unique_ptr<archive, void (*)(archive*)>;
using ArchivePtr = std::unique_ptr<archive, void (*)(archive*)>;
using ArchiveEntryPtr = std::unique_ptr<archive_entry, void (*)(archive_entry*)>;
struct DataBlock
......@@ -407,7 +407,7 @@ uncompressArchive(const std::string& archivePath, const std::string& dir, const
#ifdef ENABLE_PLUGIN
int r;
ArchivePtr archiveReader = createArchiveReader();
ArchivePtr archiveReader = createArchiveReader();
ArchivePtr archiveDiskWriter = createArchiveDiskWriter();
struct archive_entry* entry;
......
......@@ -271,8 +271,8 @@ Call::setState(CallState call_state, ConnectionState cnx_state, signed code)
// Emit client state only if changed
auto old_client_state = getStateStr();
callState_ = call_state;
connectionState_ = cnx_state;
callState_ = call_state;
connectionState_ = cnx_state;
auto new_client_state = getStateStr();
for (auto& l : stateChangedListeners_)
......@@ -432,7 +432,7 @@ Call::onTextMessage(std::map<std::string, std::string>&& messages)
void
Call::peerHungup()
{
const auto state = getState();
const auto state = getState();
const auto aborted = state == CallState::ACTIVE or state == CallState::HOLD;
setState(ConnectionState::DISCONNECTED, aborted ? ECONNABORTED : ECONNREFUSED);
}
......@@ -463,7 +463,7 @@ Call::addSubCall(Call& subcall)
subcall.sendTextMessage(msg.first, msg.second);
subcall.addStateListener(
[sub = subcall.weak(),
[sub = subcall.weak(),
parent = weak()](Call::CallState new_state, Call::ConnectionState new_cstate, int code) {
runOnMainThread([sub, parent, new_state, new_cstate, code]() {
if (auto p = parent.lock()) {
......@@ -660,7 +660,7 @@ Call::setConferenceInfo(const std::string& msg)
{
std::lock_guard<std::mutex> lk(confInfoMutex_);
confInfo_ = std::move(newInfo);
toSend = confInfo_.toVectorMapStringString();
toSend = confInfo_.toVectorMapStringString();
}
// Inform client that layout has changed
......
......@@ -63,7 +63,7 @@ class Call : public Recordable, public std::enable_shared_from_this<Call>
public:
using SubcallSet = std::set<std::shared_ptr<Call>, std::owner_less<std::shared_ptr<Call>>>;
using OnNeedFallbackCb = std::function<void()>;
using OnReadyCb = std::function<void(bool)>;
using OnReadyCb = std::function<void(bool)>;
static const char* const DEFAULT_ID;
......
......@@ -38,7 +38,7 @@ CallFactory::removeCall(Call& call)
const auto& id = call.getCallId();
JAMI_DBG("Removing call %s", id.c_str());
const auto& linkType = call.getLinkType();
auto& map = callMaps_.at(linkType);
auto& map = callMaps_.at(linkType);
map.erase(id);
JAMI_DBG("Remaining %zu %s call(s)", map.size(), linkType);
}
......@@ -102,7 +102,7 @@ CallFactory::getCall<Call>(const std::string& id) const
std::lock_guard<std::recursive_mutex> lk(callMapsMutex_);
for (const auto& item : callMaps_) {
const auto& map = item.second;
const auto& map = item.second;
const auto& iter = map.find(id);
if (iter != map.cend())
return iter->second;
......
......@@ -52,7 +52,7 @@ template<typename T, std::size_t N = 0>
class _ChannelBase
{
public:
using value_type = T;
using value_type = T;
const std::size_t max_size = N; ///< maximal size of the Channel, 0 means no size limits
// Pop operations
......
......@@ -107,11 +107,11 @@ AudioFrame::AudioFrame(const jami::AudioFormat& format, size_t nb_samples)
void
AudioFrame::setFormat(const jami::AudioFormat& format)
{
auto d = pointer();
d->channels = format.nb_channels;
auto d = pointer();
d->channels = format.nb_channels;
d->channel_layout = av_get_default_channel_layout(format.nb_channels);
d->sample_rate = format.sample_rate;
d->format = format.sampleFormat;
d->sample_rate = format.sample_rate;
d->format = format.sampleFormat;
}
jami::AudioFormat
......@@ -132,7 +132,7 @@ void
AudioFrame::reserve(size_t nb_samples)
{
if (nb_samples != 0) {
auto d = pointer();
auto d = pointer();
d->nb_samples = nb_samples;
int err;
if ((err = av_frame_get_buffer(d, 0)) < 0) {
......@@ -144,7 +144,7 @@ AudioFrame::reserve(size_t nb_samples)
void
AudioFrame::mix(const AudioFrame& frame)
{
auto& f = *pointer();
auto& f = *pointer();
auto& fIn = *frame.pointer();
if (f.channels != fIn.channels || f.format != fIn.format || f.sample_rate != fIn.sample_rate) {
throw std::invalid_argument("Can't mix frames with different formats");
......@@ -155,13 +155,13 @@ AudioFrame::mix(const AudioFrame& frame)
} else if (f.nb_samples != fIn.nb_samples) {
throw std::invalid_argument("Can't mix frames with different length");
}
AVSampleFormat fmt = (AVSampleFormat) f.format;
bool isPlanar = av_sample_fmt_is_planar(fmt);
AVSampleFormat fmt = (AVSampleFormat) f.format;
bool isPlanar = av_sample_fmt_is_planar(fmt);
unsigned samplesPerChannel = isPlanar ? f.nb_samples : f.nb_samples * f.channels;
unsigned channels = isPlanar ? f.channels : 1;
unsigned channels = isPlanar ? f.channels : 1;
if (fmt == AV_SAMPLE_FMT_S16 || fmt == AV_SAMPLE_FMT_S16P) {
for (unsigned i = 0; i < channels; i++) {
auto c = (int16_t*) f.extended_data[i];
auto c = (int16_t*) f.extended_data[i];
auto cIn = (int16_t*) fIn.extended_data[i];
for (unsigned s = 0; s < samplesPerChannel; s++) {
c[s] = std::clamp((int32_t) c[s] + (int32_t) cIn[s],
......@@ -171,7 +171,7 @@ AudioFrame::mix(const AudioFrame& frame)
}
} else if (fmt == AV_SAMPLE_FMT_FLT || fmt == AV_SAMPLE_FMT_FLTP) {
for (unsigned i = 0; i < channels; i++) {
auto c = (float*) f.extended_data[i];
auto c = (float*) f.extended_data[i];
auto cIn = (float*) fIn.extended_data[i];
for (unsigned s = 0; s < samplesPerChannel; s++) {
c[s] += cIn[s];
......@@ -186,11 +186,11 @@ AudioFrame::mix(const AudioFrame& frame)
float
AudioFrame::calcRMS() const
{
double rms = 0.0;
auto fmt = static_cast<AVSampleFormat>(frame_->format);
bool planar = av_sample_fmt_is_planar(fmt);
double rms = 0.0;
auto fmt = static_cast<AVSampleFormat>(frame_->format);
bool planar = av_sample_fmt_is_planar(fmt);
int perChannel = planar ? frame_->nb_samples : frame_->nb_samples * frame_->channels;
int channels = planar ? frame_->channels : 1;
int channels = planar ? frame_->channels : 1;
if (fmt == AV_SAMPLE_FMT_S16 || fmt == AV_SAMPLE_FMT_S16P) {
for (int c = 0; c < channels; ++c) {
auto buf = reinterpret_cast<int16_t*>(frame_->extended_data[c]);
......@@ -226,7 +226,7 @@ void
VideoFrame::reset() noexcept
{
MediaFrame::reset();
allocated_ = false;
allocated_ = false;
releaseBufferCb_ = {};
}
......@@ -234,7 +234,7 @@ void
VideoFrame::copyFrom(const VideoFrame& o)
{
MediaFrame::copyFrom(o);
ptr_ = o.ptr_;
ptr_ = o.ptr_;
allocated_ = o.allocated_;
}
......@@ -269,7 +269,7 @@ void
VideoFrame::setGeometry(int format, int width, int height) noexcept
{
frame_->format = format;
frame_->width = width;
frame_->width = width;
frame_->height = height;
}
......@@ -288,7 +288,7 @@ VideoFrame::reserve(int format, int width, int height)
setGeometry(format, width, height);
if (av_frame_get_buffer(libav_frame, 32))
throw std::bad_alloc();
allocated_ = true;
allocated_ = true;
releaseBufferCb_ = {};
}
......@@ -318,7 +318,7 @@ VideoFrame::setFromMemory(uint8_t* ptr,
setFromMemory(ptr, format, width, height);
if (cb) {
releaseBufferCb_ = cb;
ptr_ = ptr;
ptr_ = ptr;
}