mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 19:38:48 +03:00
Fix char out of range and media player signals
This commit is contained in:
parent
c775a93f77
commit
159bec3654
6 changed files with 91 additions and 103 deletions
|
@ -4040,9 +4040,8 @@ Cache::displayName(const QString &room_id, const QString &user_id)
|
||||||
static bool
|
static bool
|
||||||
isDisplaynameSafe(const std::string &s)
|
isDisplaynameSafe(const std::string &s)
|
||||||
{
|
{
|
||||||
for (uint32_t cc : QString::fromStdString(s).toStdU32String()) {
|
for (char32_t c : QString::fromStdString(s).toUcs4()) {
|
||||||
auto c = QChar(cc);
|
if (QChar::isPrint(c) && !QChar::isSpace(c))
|
||||||
if (c.isPrint() && !c.isSpace())
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -292,8 +292,10 @@ main(int argc, char *argv[])
|
||||||
app.installTranslator(&qtTranslator);
|
app.installTranslator(&qtTranslator);
|
||||||
|
|
||||||
QTranslator appTranslator;
|
QTranslator appTranslator;
|
||||||
if(appTranslator.load(
|
if (appTranslator.load(QLocale(),
|
||||||
QLocale(), QStringLiteral("nheko"), QStringLiteral("_"), QStringLiteral(":/translations")))
|
QStringLiteral("nheko"),
|
||||||
|
QStringLiteral("_"),
|
||||||
|
QStringLiteral(":/translations")))
|
||||||
app.installTranslator(&appTranslator);
|
app.installTranslator(&appTranslator);
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
|
|
@ -5,20 +5,20 @@
|
||||||
|
|
||||||
#include "InputBar.h"
|
#include "InputBar.h"
|
||||||
|
|
||||||
#include <QVideoSink>
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QInputMethod>
|
#include <QInputMethod>
|
||||||
#include <QVideoFrame>
|
|
||||||
#include <QMediaMetaData>
|
#include <QMediaMetaData>
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTextBoundaryFinder>
|
#include <QTextBoundaryFinder>
|
||||||
|
#include <QVideoFrame>
|
||||||
|
#include <QVideoSink>
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <mtx/responses/common.hpp>
|
#include <mtx/responses/common.hpp>
|
||||||
|
@ -758,8 +758,10 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
||||||
|
|
||||||
if (mimeClass_ == u"video") {
|
if (mimeClass_ == u"video") {
|
||||||
auto newSurface = new QVideoSink(this);
|
auto newSurface = new QVideoSink(this);
|
||||||
connect(
|
connect(newSurface,
|
||||||
newSurface, &QVideoSink::videoFrameChanged, this, [this, mediaPlayer](const QVideoFrame& frame) {
|
&QVideoSink::videoFrameChanged,
|
||||||
|
this,
|
||||||
|
[this, mediaPlayer](const QVideoFrame &frame) {
|
||||||
QImage img = frame.toImage();
|
QImage img = frame.toImage();
|
||||||
|
|
||||||
if (img.size().isEmpty())
|
if (img.size().isEmpty())
|
||||||
|
@ -767,10 +769,11 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
||||||
|
|
||||||
mediaPlayer->stop();
|
mediaPlayer->stop();
|
||||||
|
|
||||||
auto orientation = mediaPlayer->metaData().value(QMediaMetaData::Orientation).toInt();
|
auto orientation =
|
||||||
|
mediaPlayer->metaData().value(QMediaMetaData::Orientation).toInt();
|
||||||
if (orientation == 90 || orientation == 270 || orientation == 180) {
|
if (orientation == 90 || orientation == 270 || orientation == 180) {
|
||||||
img =
|
img = img.transformed(QTransform().rotate(orientation),
|
||||||
img.transformed(QTransform().rotate(orientation), Qt::SmoothTransformation);
|
Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
nhlog::ui()->debug("Got image {}x{}", img.width(), img.height());
|
nhlog::ui()->debug("Got image {}x{}", img.width(), img.height());
|
||||||
|
@ -797,10 +800,7 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
||||||
mediaPlayer->setVideoOutput(newSurface);
|
mediaPlayer->setVideoOutput(newSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(mediaPlayer,
|
connect(mediaPlayer, &QMediaPlayer::errorChanged, this, [mediaPlayer]() {
|
||||||
&QMediaPlayer::error,
|
|
||||||
this,
|
|
||||||
[mediaPlayer]() {
|
|
||||||
nhlog::ui()->debug("Media player error {} and errorStr {}",
|
nhlog::ui()->debug("Media player error {} and errorStr {}",
|
||||||
mediaPlayer->error(),
|
mediaPlayer->error(),
|
||||||
mediaPlayer->errorString().toStdString());
|
mediaPlayer->errorString().toStdString());
|
||||||
|
@ -811,9 +811,7 @@ MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
||||||
nhlog::ui()->debug(
|
nhlog::ui()->debug(
|
||||||
"Media player status {} and error {}", status, mediaPlayer->error());
|
"Media player status {} and error {}", status, mediaPlayer->error());
|
||||||
});
|
});
|
||||||
connect(mediaPlayer,
|
connect(mediaPlayer, &QMediaPlayer::metaDataChanged, [this, mediaPlayer]() {
|
||||||
&QMediaPlayer::metaDataChanged,
|
|
||||||
[this, mediaPlayer]() {
|
|
||||||
nhlog::ui()->debug("Got metadata");
|
nhlog::ui()->debug("Got metadata");
|
||||||
|
|
||||||
if (mediaPlayer->duration() > 0)
|
if (mediaPlayer->duration() > 0)
|
||||||
|
|
|
@ -24,21 +24,14 @@ MxcMediaProxy::MxcMediaProxy(QObject *parent)
|
||||||
{
|
{
|
||||||
connect(this, &MxcMediaProxy::eventIdChanged, &MxcMediaProxy::startDownload);
|
connect(this, &MxcMediaProxy::eventIdChanged, &MxcMediaProxy::startDownload);
|
||||||
connect(this, &MxcMediaProxy::roomChanged, &MxcMediaProxy::startDownload);
|
connect(this, &MxcMediaProxy::roomChanged, &MxcMediaProxy::startDownload);
|
||||||
connect(this,
|
connect(this, &MxcMediaProxy::error, [this]() {
|
||||||
&MxcMediaProxy::error,
|
nhlog::ui()->info(
|
||||||
[this]() {
|
"Media player error {} and errorStr {}", error(), this->errorString().toStdString());
|
||||||
nhlog::ui()->info("Media player error {} and errorStr {}",
|
|
||||||
error(),
|
|
||||||
this->errorString().toStdString());
|
|
||||||
});
|
});
|
||||||
connect(this, &MxcMediaProxy::mediaStatusChanged, [this](QMediaPlayer::MediaStatus status) {
|
connect(this, &MxcMediaProxy::mediaStatusChanged, [this](QMediaPlayer::MediaStatus status) {
|
||||||
nhlog::ui()->info("Media player status {} and error {}", status, this->error());
|
nhlog::ui()->info("Media player status {} and error {}", status, this->error());
|
||||||
});
|
});
|
||||||
connect(this,
|
connect(this, &MxcMediaProxy::metaDataChanged, [this]() { emit orientationChanged(); });
|
||||||
&MxcMediaProxy::metaDataChanged,
|
|
||||||
[this]() {
|
|
||||||
emit orientationChanged();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QVideoSink>
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QVideoSink>
|
||||||
|
|
||||||
#include "timeline/TimelineModel.h"
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
#include "timeline/TimelineModel.h"
|
||||||
|
|
||||||
class TimelineModel;
|
class TimelineModel;
|
||||||
|
|
||||||
|
|
|
@ -142,10 +142,7 @@ CallManager::CallManager(QObject *parent)
|
||||||
player_.play();
|
player_.play();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(&player_,
|
connect(&player_, &QMediaPlayer::errorChanged, this, [this]() {
|
||||||
&QMediaPlayer::error,
|
|
||||||
this,
|
|
||||||
[this]() {
|
|
||||||
stopRingtone();
|
stopRingtone();
|
||||||
switch (player_.error()) {
|
switch (player_.error()) {
|
||||||
case QMediaPlayer::FormatError:
|
case QMediaPlayer::FormatError:
|
||||||
|
@ -496,8 +493,7 @@ CallManager::retrieveTurnServer()
|
||||||
void
|
void
|
||||||
CallManager::playRingtone(const QUrl &ringtone, bool repeat)
|
CallManager::playRingtone(const QUrl &ringtone, bool repeat)
|
||||||
{
|
{
|
||||||
player_.setLoops(repeat ? QMediaPlayer::Infinite :
|
player_.setLoops(repeat ? QMediaPlayer::Infinite : 1);
|
||||||
1);
|
|
||||||
player_.setSource(ringtone);
|
player_.setSource(ringtone);
|
||||||
// player_.audioOutput()->setVolume(100);
|
// player_.audioOutput()->setVolume(100);
|
||||||
player_.play();
|
player_.play();
|
||||||
|
|
Loading…
Reference in a new issue