Browse Source

Merge pull request #1 from tux3/master

Rebasing on upstream
pull/57/head
F1ynn 11 years ago
parent
commit
126a36083d
  1. 10
      core.cpp
  2. 12
      settings.cpp
  3. 5
      settings.h
  4. 64
      widget/camera.cpp
  5. 2
      widget/form/chatform.cpp
  6. 10
      widget/form/settingsform.cpp
  7. 3
      widget/form/settingsform.h

10
core.cpp

@ -63,7 +63,13 @@ Core::~Core() @@ -63,7 +63,13 @@ Core::~Core()
void Core::start()
{
tox = tox_new(0); // IPv6 causes some weird routers to crash, according to anon
// IPv6 needed for LAN discovery, but can crash some weird routers. On by default, can be disabled in options.
bool enableIPv6 = Settings::getInstance().getEnableIPv6();
if (enableIPv6)
qDebug() << "Core starting with IPv6 enabled";
else
qWarning() << "Core starting with IPv6 disabled. LAN discovery may not work properly.";
tox = tox_new(enableIPv6);
if (tox == nullptr)
{
qCritical() << "Tox core failed to start";
@ -1275,7 +1281,7 @@ void Core::sendCallAudio(int callId, ToxAv* toxav) @@ -1275,7 +1281,7 @@ void Core::sendCallAudio(int callId, ToxAv* toxav)
calls[callId].sendAudioTimer.start();
return;
}
calls[callId].sendAudioTimer.start(0);
calls[callId].sendAudioTimer.start();
}
else
calls[callId].sendAudioTimer.start();

12
settings.cpp

@ -83,6 +83,7 @@ void Settings::load() @@ -83,6 +83,7 @@ void Settings::load()
s.beginGroup("General");
username = s.value("username", "My name").toString();
statusMessage = s.value("statusMessage", "My status").toString();
enableIPv6 = s.value("enableIPv6", true).toBool();
s.endGroup();
s.beginGroup("Widgets");
@ -142,6 +143,7 @@ void Settings::save() @@ -142,6 +143,7 @@ void Settings::save()
s.beginGroup("General");
s.setValue("username", username);
s.setValue("statusMessage", statusMessage);
s.setValue("enableIPv6", enableIPv6);
s.endGroup();
s.beginGroup("Widgets");
@ -209,6 +211,16 @@ void Settings::setStatusMessage(const QString& newMessage) @@ -209,6 +211,16 @@ void Settings::setStatusMessage(const QString& newMessage)
statusMessage = newMessage;
}
bool Settings::getEnableIPv6() const
{
return enableIPv6;
}
void Settings::setEnableIPv6(bool newValue)
{
enableIPv6 = newValue;
}
bool Settings::getEnableLogging() const
{
return enableLogging;

5
settings.h

@ -49,6 +49,9 @@ public: @@ -49,6 +49,9 @@ public:
QString getStatusMessage() const;
void setStatusMessage(const QString& newMessage);
bool getEnableIPv6() const;
void setEnableIPv6(bool newValue);
bool getEnableLogging() const;
void setEnableLogging(bool newValue);
@ -130,6 +133,8 @@ private: @@ -130,6 +133,8 @@ private:
QString username;
QString statusMessage;
bool enableIPv6;
bool enableLogging;
bool encryptLogs;

64
widget/camera.cpp

@ -4,19 +4,35 @@ @@ -4,19 +4,35 @@
#include <QVideoEncoderSettings>
#include <QVideoEncoderSettingsControl>
static inline float getR(int Y, int V)
static inline void fromYCbCrToRGB(
uint8_t Y, uint8_t Cb, uint8_t Cr,
uint8_t& R, uint8_t& G, uint8_t& B)
{
return qMax(qMin((int)(1.164*(Y - 16) + 1.596*(V - 128)),255),0);
}
int r = Y + ((1436 * (Cr - 128)) >> 10),
g = Y - ((354 * (Cb - 128) + 732 * (Cr - 128)) >> 10),
b = Y + ((1814 * (Cb - 128)) >> 10);
static inline float getG(int Y, int U, int V)
{
return qMax(qMin((int)(1.164*(Y - 16) - 0.813*(V - 128) - 0.391*(U - 128)),255),0);
}
if(r < 0) {
r = 0;
} else if(r > 255) {
r = 255;
}
static inline float getB(int Y, int U)
{
return qMax(qMin((int)(1.164*(Y - 16) + 2.018*(U - 128)),255),0);
if(g < 0) {
g = 0;
} else if(g > 255) {
g = 255;
}
if(b < 0) {
b = 0;
} else if(b > 255) {
b = 255;
}
R = static_cast<uint8_t>(r);
G = static_cast<uint8_t>(g);
B = static_cast<uint8_t>(b);
}
Camera::Camera()
@ -155,13 +171,12 @@ QImage Camera::getLastImage() @@ -155,13 +171,12 @@ QImage Camera::getLastImage()
uint32_t* scanline = (uint32_t*)img.scanLine(i);
for (int j=0; j < bpl; j++)
{
int Y = yData[i*bpl + j];
int U = uData[i/2*cxbpl + j/2];
int V = vData[i/2*cxbpl + j/2];
uint8_t Y = yData[i*bpl + j];
uint8_t U = uData[i/2*cxbpl + j/2];
uint8_t V = vData[i/2*cxbpl + j/2];
uint8_t R = getR(Y,V);
uint8_t G = getG(Y,U,V);
uint8_t B = getB(Y,U);
uint8_t R, G, B;
fromYCbCrToRGB(Y, U, V, R, G, B);
scanline[j] = (0xFF<<24) + (R<<16) + (G<<8) + B;
}
@ -177,13 +192,12 @@ QImage Camera::getLastImage() @@ -177,13 +192,12 @@ QImage Camera::getLastImage()
uint32_t* scanline = (uint32_t*)img.scanLine(i);
for (int j=0; j < bpl; j++)
{
int Y = yData[i*bpl + j];
int U = uData[i/2*cxbpl + j/2];
int V = vData[i/2*cxbpl + j/2];
uint8_t Y = yData[i*bpl + j];
uint8_t U = uData[i/2*cxbpl + j/2];
uint8_t V = vData[i/2*cxbpl + j/2];
uint8_t R = getR(Y,V);
uint8_t G = getG(Y,U,V);
uint8_t B = getB(Y,U);
uint8_t R, G, B;
fromYCbCrToRGB(Y, U, V, R, G, B);
scanline[j] = (0xFF<<24) + (R<<16) + (G<<8) + B;
}
@ -203,7 +217,11 @@ vpx_image Camera::getLastVPXImage() @@ -203,7 +217,11 @@ vpx_image Camera::getLastVPXImage()
vpx_image img;
if (!lastFrame.isValid())
return img;
lastFrame.map(QAbstractVideoBuffer::ReadOnly);
if (!lastFrame.map(QAbstractVideoBuffer::ReadOnly))
{
qWarning() << "Camera::getLastVPXImage: Error maping last frame";
return img;
}
int w = lastFrame.width(), h = lastFrame.height();
int bpl = lastFrame.bytesPerLine();
vpx_img_alloc(&img, VPX_IMG_FMT_I420, w, h, 1); // I420 == YUV420P, same as YV12 with U and V switched

2
widget/form/chatform.cpp

@ -226,7 +226,7 @@ void ChatForm::addMessage(QLabel* author, QLabel* message, QLabel* date) @@ -226,7 +226,7 @@ void ChatForm::addMessage(QLabel* author, QLabel* message, QLabel* date)
if (author->text() == Widget::getInstance()->getUsername())
{
QPalette pal;
pal.setColor(QPalette::WindowText, Qt::gray);
pal.setColor(QPalette::WindowText, QColor(100,100,100));
author->setPalette(pal);
message->setPalette(pal);
}

10
widget/form/settingsform.cpp

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "settingsform.h"
#include "widget/widget.h"
#include "settings.h"
#include <QFont>
SettingsForm::SettingsForm()
@ -19,6 +20,8 @@ SettingsForm::SettingsForm() @@ -19,6 +20,8 @@ SettingsForm::SettingsForm()
id.setTextInteractionFlags(Qt::TextSelectableByMouse);
videoTest.setText("Test video");
enableIPv6.setText("Enable IPv6 (recommended)");
enableIPv6.setChecked(Settings::getInstance().getEnableIPv6());
main->setLayout(&layout);
layout.addWidget(&nameLabel);
@ -28,12 +31,14 @@ SettingsForm::SettingsForm() @@ -28,12 +31,14 @@ SettingsForm::SettingsForm()
layout.addWidget(&idLabel);
layout.addWidget(&id);
layout.addWidget(&videoTest);
layout.addWidget(&enableIPv6);
layout.addStretch();
head->setLayout(&headLayout);
headLayout.addWidget(&headLabel);
connect(&videoTest, SIGNAL(clicked()), this, SLOT(onTestVideoClicked()));
connect(&enableIPv6, SIGNAL(stateChanged(int)), this, SLOT(onEnableIPv6Updated()));
}
SettingsForm::~SettingsForm()
@ -59,3 +64,8 @@ void SettingsForm::onTestVideoClicked() @@ -59,3 +64,8 @@ void SettingsForm::onTestVideoClicked()
{
Widget::getInstance()->showTestCamview();
}
void SettingsForm::onEnableIPv6Updated()
{
Settings::getInstance().setEnableIPv6(enableIPv6.isChecked());
}

3
widget/form/settingsform.h

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include <QString>
#include <QObject>
#include <QSpacerItem>
#include <QCheckBox>
#include "ui_widget.h"
#include "widget/selfcamview.h"
@ -24,10 +25,12 @@ public slots: @@ -24,10 +25,12 @@ public slots:
private slots:
void onTestVideoClicked();
void onEnableIPv6Updated();
private:
QLabel headLabel, nameLabel, statusTextLabel, idLabel, id;
QPushButton videoTest;
QCheckBox enableIPv6;
QVBoxLayout layout, headLayout;
QWidget *main, *head;

Loading…
Cancel
Save