mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
CppCheck, some video perf improvements
This commit is contained in:
parent
64bd3b7b47
commit
c32eb98e6c
|
@ -1251,8 +1251,6 @@ bool Core::loadConfiguration(QString path)
|
||||||
// tox core is already decrypted
|
// tox core is already decrypted
|
||||||
if (Settings::getInstance().getEnableLogging() && Settings::getInstance().getEncryptLogs())
|
if (Settings::getInstance().getEnableLogging() && Settings::getInstance().getEncryptLogs())
|
||||||
{
|
{
|
||||||
bool error = true;
|
|
||||||
|
|
||||||
// get salt
|
// get salt
|
||||||
QFile file(HistoryKeeper::getHistoryPath());
|
QFile file(HistoryKeeper::getHistoryPath());
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
|
@ -1266,6 +1264,7 @@ bool Core::loadConfiguration(QString path)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool error = true;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
while (!pwsaltedkeys[ptHistory])
|
while (!pwsaltedkeys[ptHistory])
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
ToxCall Core::calls[TOXAV_MAX_CALLS];
|
ToxCall Core::calls[TOXAV_MAX_CALLS];
|
||||||
#ifdef QTOX_FILTER_AUDIO
|
#ifdef QTOX_FILTER_AUDIO
|
||||||
AudioFilterer * Core::filterer[TOXAV_MAX_CALLS] { nullptr};
|
AudioFilterer * Core::filterer[TOXAV_MAX_CALLS] {nullptr};
|
||||||
#endif
|
#endif
|
||||||
const int Core::videobufsize{TOXAV_MAX_VIDEO_WIDTH * TOXAV_MAX_VIDEO_HEIGHT * 4};
|
const int Core::videobufsize{TOXAV_MAX_VIDEO_WIDTH * TOXAV_MAX_VIDEO_HEIGHT * 4};
|
||||||
uint8_t* Core::videobuf;
|
uint8_t* Core::videobuf;
|
||||||
|
@ -252,10 +252,11 @@ void Core::sendCallAudio(int callId, ToxAv* toxav)
|
||||||
|
|
||||||
const int framesize = (calls[callId].codecSettings.audio_frame_duration * calls[callId].codecSettings.audio_sample_rate) / 1000 * av_DefaultSettings.audio_channels;
|
const int framesize = (calls[callId].codecSettings.audio_frame_duration * calls[callId].codecSettings.audio_sample_rate) / 1000 * av_DefaultSettings.audio_channels;
|
||||||
const int bufsize = framesize * 2 * av_DefaultSettings.audio_channels;
|
const int bufsize = framesize * 2 * av_DefaultSettings.audio_channels;
|
||||||
uint8_t buf[bufsize], dest[bufsize];
|
uint8_t buf[bufsize];
|
||||||
|
|
||||||
if (Audio::tryCaptureSamples(buf, framesize))
|
if (Audio::tryCaptureSamples(buf, framesize))
|
||||||
{
|
{
|
||||||
|
uint8_t dest[bufsize];
|
||||||
int r;
|
int r;
|
||||||
if ((r = toxav_prepare_audio_frame(toxav, callId, dest, framesize*2, (int16_t*)buf, framesize)) < 0)
|
if ((r = toxav_prepare_audio_frame(toxav, callId, dest, framesize*2, (int16_t*)buf, framesize)) < 0)
|
||||||
{
|
{
|
||||||
|
@ -625,9 +626,8 @@ void Core::sendGroupCallAudio(int groupId, ToxAv* toxav)
|
||||||
|
|
||||||
if (Audio::tryCaptureSamples(buf, framesize))
|
if (Audio::tryCaptureSamples(buf, framesize))
|
||||||
{
|
{
|
||||||
int r;
|
if (toxav_group_send_audio(toxav_get_tox(toxav), groupId, (int16_t*)buf,
|
||||||
if ((r = toxav_group_send_audio(toxav_get_tox(toxav), groupId, (int16_t*)buf,
|
framesize, av_DefaultSettings.audio_channels, av_DefaultSettings.audio_sample_rate) < 0)
|
||||||
framesize, av_DefaultSettings.audio_channels, av_DefaultSettings.audio_sample_rate)) < 0)
|
|
||||||
{
|
{
|
||||||
qDebug() << "Core: toxav_group_send_audio error";
|
qDebug() << "Core: toxav_group_send_audio error";
|
||||||
groupCalls[groupId].sendAudioTimer->start();
|
groupCalls[groupId].sendAudioTimer->start();
|
||||||
|
|
|
@ -23,6 +23,13 @@ bool ToxFile::open(bool write)
|
||||||
return write ? file->open(QIODevice::ReadWrite) : file->open(QIODevice::ReadOnly);
|
return write ? file->open(QIODevice::ReadWrite) : file->open(QIODevice::ReadOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToxID::ToxID(const ToxID& other)
|
||||||
|
{
|
||||||
|
publicKey = other.publicKey;
|
||||||
|
noSpam = other.noSpam;
|
||||||
|
checkSum = other.checkSum;
|
||||||
|
}
|
||||||
|
|
||||||
QString ToxID::toString() const
|
QString ToxID::toString() const
|
||||||
{
|
{
|
||||||
return publicKey + noSpam + checkSum;
|
return publicKey + noSpam + checkSum;
|
||||||
|
|
|
@ -16,6 +16,9 @@ enum class Status : int {Online = 0, Away, Busy, Offline};
|
||||||
|
|
||||||
struct ToxID
|
struct ToxID
|
||||||
{
|
{
|
||||||
|
ToxID()=default;
|
||||||
|
ToxID(const ToxID& other);
|
||||||
|
|
||||||
QString publicKey;
|
QString publicKey;
|
||||||
QString noSpam;
|
QString noSpam;
|
||||||
QString checkSum;
|
QString checkSum;
|
||||||
|
|
|
@ -23,12 +23,11 @@
|
||||||
#include "src/misc/settings.h"
|
#include "src/misc/settings.h"
|
||||||
|
|
||||||
Friend::Friend(int FriendId, const ToxID &UserId)
|
Friend::Friend(int FriendId, const ToxID &UserId)
|
||||||
: friendId(FriendId)
|
: userName{Core::getInstance()->getPeerName(UserId)},
|
||||||
|
userID{UserId}, friendId{FriendId}
|
||||||
{
|
{
|
||||||
hasNewEvents = 0;
|
hasNewEvents = 0;
|
||||||
friendStatus = Status::Offline;
|
friendStatus = Status::Offline;
|
||||||
userID = UserId;
|
|
||||||
userName = Core::getInstance()->getPeerName(UserId);
|
|
||||||
if (userName.size() == 0)
|
if (userName.size() == 0)
|
||||||
userName = UserId.publicKey;
|
userName = UserId.publicKey;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,9 @@ struct Friend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Friend(int FriendId, const ToxID &UserId);
|
Friend(int FriendId, const ToxID &UserId);
|
||||||
|
Friend(const Friend& other)=delete;
|
||||||
~Friend();
|
~Friend();
|
||||||
|
Friend& operator=(const Friend& other)=delete;
|
||||||
|
|
||||||
void setName(QString name);
|
void setName(QString name);
|
||||||
void setAlias(QString name);
|
void setAlias(QString name);
|
||||||
|
|
|
@ -63,10 +63,10 @@ private:
|
||||||
void updateAliases();
|
void updateAliases();
|
||||||
QPair<int, ChatType> getChatID(const QString &id_str, ChatType ct);
|
QPair<int, ChatType> getChatID(const QString &id_str, ChatType ct);
|
||||||
int getAliasID(const QString &id_str);
|
int getAliasID(const QString &id_str);
|
||||||
QString wrapMessage(const QString &str);
|
|
||||||
QString unWrapMessage(const QString &str);
|
|
||||||
|
|
||||||
ChatType convertToChatType(int);
|
static QString wrapMessage(const QString &str);
|
||||||
|
static QString unWrapMessage(const QString &str);
|
||||||
|
static ChatType convertToChatType(int);
|
||||||
|
|
||||||
GenericDdInterface *db;
|
GenericDdInterface *db;
|
||||||
QMap<QString, int> aliases;
|
QMap<QString, int> aliases;
|
||||||
|
|
|
@ -36,7 +36,7 @@ uint8_t* CData::data()
|
||||||
return cData;
|
return cData;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t CData::size()
|
uint16_t CData::size() const
|
||||||
{
|
{
|
||||||
return cDataSize;
|
return cDataSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,13 @@ class CData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
uint8_t* data();
|
uint8_t* data();
|
||||||
uint16_t size();
|
uint16_t size() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit CData(const QString& data, uint16_t byteSize);
|
explicit CData(const QString& data, uint16_t byteSize);
|
||||||
|
CData(const CData& other)=delete;
|
||||||
virtual ~CData();
|
virtual ~CData();
|
||||||
|
CData& operator=(const CData& other)=delete;
|
||||||
|
|
||||||
static QString toString(const uint8_t* cData, const uint16_t cDataSize);
|
static QString toString(const uint8_t* cData, const uint16_t cDataSize);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ uint8_t* CString::data()
|
||||||
return cString;
|
return cString;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t CString::size()
|
uint16_t CString::size() const
|
||||||
{
|
{
|
||||||
return cStringSize;
|
return cStringSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
~CString();
|
~CString();
|
||||||
|
|
||||||
uint8_t* data();
|
uint8_t* data();
|
||||||
uint16_t size();
|
uint16_t size() const;
|
||||||
|
|
||||||
static QString toString(const uint8_t* cMessage, const uint16_t cMessageSize);
|
static QString toString(const uint8_t* cMessage, const uint16_t cMessageSize);
|
||||||
static uint16_t fromString(const QString& message, uint8_t* cMessage);
|
static uint16_t fromString(const QString& message, uint8_t* cMessage);
|
||||||
|
|
|
@ -99,7 +99,7 @@ double Camera::getProp(Camera::Prop prop)
|
||||||
return worker->getProp(int(prop));
|
return worker->getProp(int(prop));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::onNewFrameAvailable(const VideoFrame frame)
|
void Camera::onNewFrameAvailable(const VideoFrame &frame)
|
||||||
{
|
{
|
||||||
emit frameAvailable(frame);
|
emit frameAvailable(frame);
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ private:
|
||||||
CameraWorker* worker;
|
CameraWorker* worker;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onNewFrameAvailable(const VideoFrame frame);
|
void onNewFrameAvailable(const VideoFrame& frame);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,12 @@ CameraWorker::CameraWorker(int index)
|
||||||
qRegisterMetaType<QList<QSize>>();
|
qRegisterMetaType<QList<QSize>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CameraWorker::~CameraWorker()
|
||||||
|
{
|
||||||
|
if (clock)
|
||||||
|
delete clock;
|
||||||
|
}
|
||||||
|
|
||||||
void CameraWorker::onStart()
|
void CameraWorker::onStart()
|
||||||
{
|
{
|
||||||
clock = new QTimer(this);
|
clock = new QTimer(this);
|
||||||
|
|
|
@ -34,6 +34,7 @@ class CameraWorker : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CameraWorker(int index);
|
CameraWorker(int index);
|
||||||
|
~CameraWorker();
|
||||||
void doWork();
|
void doWork();
|
||||||
|
|
||||||
void suspend();
|
void suspend();
|
||||||
|
@ -48,7 +49,7 @@ public slots:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void started();
|
void started();
|
||||||
void newFrameAvailable(const VideoFrame frame);
|
void newFrameAvailable(const VideoFrame& frame);
|
||||||
void resProbingFinished(QList<QSize> res);
|
void resProbingFinished(QList<QSize> res);
|
||||||
void propProbingFinished(int prop, double val);
|
void propProbingFinished(int prop, double val);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "videosource.h"
|
#include "videosource.h"
|
||||||
|
|
||||||
class vpx_image;
|
struct vpx_image;
|
||||||
|
|
||||||
class NetVideoSource : public VideoSource
|
class NetVideoSource : public VideoSource
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
virtual void unsubscribe() = 0;
|
virtual void unsubscribe() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void frameAvailable(const VideoFrame frame);
|
void frameAvailable(const VideoFrame& frame);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
const QString TabCompleter::nickSuffix = QString(": ");
|
const QString TabCompleter::nickSuffix = QString(": ");
|
||||||
|
|
||||||
TabCompleter::TabCompleter(ChatTextEdit* msgEdit, Group* group)
|
TabCompleter::TabCompleter(ChatTextEdit* msgEdit, Group* group)
|
||||||
: QObject(msgEdit), msgEdit(msgEdit), group(group), enabled(false)
|
: QObject{msgEdit}, msgEdit{msgEdit}, group{group},
|
||||||
|
enabled{false}, lastCompletionLength{0}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct SortableString {
|
struct SortableString {
|
||||||
inline SortableString(const QString &n) { contents = n; }
|
inline SortableString(const QString &n) : contents{n} {}
|
||||||
bool operator<(const SortableString &other) const;
|
bool operator<(const SortableString &other) const;
|
||||||
QString contents;
|
QString contents;
|
||||||
};
|
};
|
||||||
|
|
|
@ -99,16 +99,9 @@ void GroupWidget::updateStatusLight()
|
||||||
Group *g = GroupList::findGroup(groupId);
|
Group *g = GroupList::findGroup(groupId);
|
||||||
|
|
||||||
if (!g->getEventFlag())
|
if (!g->getEventFlag())
|
||||||
{
|
|
||||||
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!g->getMentionedFlag())
|
|
||||||
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
|
||||||
else
|
else
|
||||||
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupWidget::setChatForm(Ui::MainWindow &ui)
|
void GroupWidget::setChatForm(Ui::MainWindow &ui)
|
||||||
|
|
|
@ -29,7 +29,8 @@ class ChatAction : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ChatAction(const bool &me, const QString &author, const QString &date) : isMe(me), name(author), date(date) {;}
|
ChatAction(const bool &me, const QString &author, const QString &date)
|
||||||
|
: isMe{me}, name{author}, date{date}, textTable{nullptr}, textEdit{nullptr} {;}
|
||||||
virtual ~ChatAction(){;}
|
virtual ~ChatAction(){;}
|
||||||
|
|
||||||
void assignPlace(QTextTable *position, QTextEdit* te);
|
void assignPlace(QTextTable *position, QTextEdit* te);
|
||||||
|
|
|
@ -23,12 +23,14 @@
|
||||||
|
|
||||||
VideoSurface::VideoSurface(QWidget* parent)
|
VideoSurface::VideoSurface(QWidget* parent)
|
||||||
: QGLWidget(QGLFormat(QGL::SingleBuffer), parent)
|
: QGLWidget(QGLFormat(QGL::SingleBuffer), parent)
|
||||||
, source(nullptr)
|
, source{nullptr}
|
||||||
, pbo{nullptr, nullptr}
|
, pbo{nullptr, nullptr}
|
||||||
, textureId(0)
|
, bgrProgramm{nullptr}
|
||||||
, pboAllocSize(0)
|
, yuvProgramm{nullptr}
|
||||||
, hasSubscribed(false)
|
, textureId{0}
|
||||||
, pboIndex(0)
|
, pboAllocSize{0}
|
||||||
|
, hasSubscribed{false}
|
||||||
|
, pboIndex{0}
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -180,14 +182,6 @@ void VideoSurface::paintGL()
|
||||||
pbo[nextPboIndex]->release();
|
pbo[nextPboIndex]->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// render pbo
|
|
||||||
static float values[] = {
|
|
||||||
-1, -1,
|
|
||||||
1, -1,
|
|
||||||
-1, 1,
|
|
||||||
1, 1
|
|
||||||
};
|
|
||||||
|
|
||||||
// background
|
// background
|
||||||
glClearColor(0, 0, 0, 1);
|
glClearColor(0, 0, 0, 1);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
@ -220,6 +214,14 @@ void VideoSurface::paintGL()
|
||||||
|
|
||||||
if (programm)
|
if (programm)
|
||||||
{
|
{
|
||||||
|
// render pbo
|
||||||
|
static float values[] = {
|
||||||
|
-1, -1,
|
||||||
|
1, -1,
|
||||||
|
-1, 1,
|
||||||
|
1, 1
|
||||||
|
};
|
||||||
|
|
||||||
programm->bind();
|
programm->bind();
|
||||||
programm->setAttributeArray(0, GL_FLOAT, values, 2);
|
programm->setAttributeArray(0, GL_FLOAT, values, 2);
|
||||||
programm->enableAttributeArray(0);
|
programm->enableAttributeArray(0);
|
||||||
|
@ -259,7 +261,7 @@ void VideoSurface::unsubscribe()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoSurface::onNewFrameAvailable(const VideoFrame newFrame)
|
void VideoSurface::onNewFrameAvailable(const VideoFrame& newFrame)
|
||||||
{
|
{
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
frame = newFrame;
|
frame = newFrame;
|
||||||
|
|
|
@ -44,7 +44,7 @@ protected:
|
||||||
void unsubscribe();
|
void unsubscribe();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onNewFrameAvailable(const VideoFrame newFrame);
|
void onNewFrameAvailable(const VideoFrame &newFrame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VideoSource* source;
|
VideoSource* source;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user