Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modify the default video format for recording to webm #278

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "gviewv4l2core.h"
#include "capplication.h"
#include "camera.h"
#include "globalutils.h"

#include <QtCore>
#include <QtGui>
Expand Down Expand Up @@ -48,7 +49,12 @@ void Settings::init()
QStringList videoFormatList;
if (DataManager::instance()->encodeEnv() == FFmpeg_Env) {
if (DataManager::instance()->encExists()) {
videoFormatList << tr("mp4") << tr("webm");
if (!GlobalUtils::isBXCBoard()) {
videoFormatList << tr("mp4") << tr("webm");
} else {
videoFormatList << tr("webm") << tr("mp4");
}

} else {
videoFormatList << tr("webm");
m_settings->setOption("outsetting.outformat.vidformat", 0);
Expand Down
69 changes: 69 additions & 0 deletions src/src/globalutils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "globalutils.h"

#include <QDebug>
#include <QtDBus>
#include <QDBusInterface>
#include <QDBusArgument>
#include <QDBusReply>

struct DMIInfo {
QString biosManufacturer;
QString biosVersion;
QString biosRelease;
QString productName;
QString serialNumber;
QString Manufacturer;
QString version;
QString sysProductName;
QString Family;
QString sysSerialNumber;
QString sysUUID;
};
Q_DECLARE_METATYPE(DMIInfo)

// Marshall the MyStructure data into a D-Bus argument
QDBusArgument &operator<<(QDBusArgument &argument, const DMIInfo &mystruct)
{
argument.beginStructure();
argument << mystruct.biosManufacturer << mystruct.biosVersion << mystruct.biosRelease << mystruct.productName
<< mystruct.serialNumber << mystruct.Manufacturer << mystruct.version << mystruct.sysProductName
<< mystruct.Family << mystruct.sysSerialNumber << mystruct.sysUUID;
argument.endStructure();
return argument;
}

// Retrieve the MyStructure data from the D-Bus argument
const QDBusArgument &operator>>(const QDBusArgument &argument, DMIInfo &mystruct)
{
argument.beginStructure();
argument >> mystruct.biosManufacturer >> mystruct.biosVersion >> mystruct.biosRelease >> mystruct.productName
>> mystruct.serialNumber >> mystruct.Manufacturer >> mystruct.version >> mystruct.sysProductName
>> mystruct.Family >> mystruct.sysSerialNumber >> mystruct.sysUUID;
argument.endStructure();
return argument;
}

bool GlobalUtils::isBXCBoard()
{
qDBusRegisterMetaType<DMIInfo>();
QDBusInterface *monitorInterface = new QDBusInterface("com.deepin.system.SystemInfo", "/com/deepin/system/SystemInfo", "org.freedesktop.DBus.Properties", QDBusConnection::systemBus());
if (!monitorInterface->isValid())
return false;

DMIInfo dmiInfo;
QDBusReply<QDBusVariant> replay = monitorInterface->call("Get", "com.deepin.system.SystemInfo", "DMIInfo");

replay.value().variant().value<QDBusArgument>() >> dmiInfo;

qDebug() << __func__ << "dmiInfo.productName: " << dmiInfo.productName;
if (dmiInfo.productName.contains("600F") || dmiInfo.productName.contains("NZ275D")) {
return true;
} else {
return false;
}
}
17 changes: 17 additions & 0 deletions src/src/globalutils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef GLOBALUTILS_H
#define GLOBALUTILS_H

#include <QString>

class GlobalUtils
{
public:
static bool isBXCBoard();
};

#endif // GLOBALUTILS_H
11 changes: 9 additions & 2 deletions src/src/videowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "camera.h"
#include "eventlogutils.h"
#include "config.h"
#include "globalutils.h"

#include <DBlurEffectWidget>

Expand Down Expand Up @@ -214,9 +215,15 @@ videowidget::videowidget(DWidget *parent)
// 默认不显示网格线
setGridType(Grid_None);

if (dc::Settings::get().getOption("outsetting.outformat.vidformat").toInt() ||
DataManager::instance()->encodeEnv() != FFmpeg_Env || !DataManager::instance()->encExists())
if (DataManager::instance()->encodeEnv() != FFmpeg_Env || !DataManager::instance()->encExists() || GlobalUtils::isBXCBoard()) {
m_videoFormat = "webm";
}
if (dc::Settings::get().getOption("outsetting.outformat.vidformat").toInt()) {
if (!GlobalUtils::isBXCBoard())
m_videoFormat = "webm";
else
m_videoFormat = "mp4";
}
}

//延迟加载
Expand Down
2 changes: 1 addition & 1 deletion src/src/windowstatethread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ windowStateThread::windowStateThread(bool isWayland, QObject *parent /*= nullptr
windowStateThread::~windowStateThread()
{
#ifdef USE_DEEPIN_WAYLAND
if (m_connectionThread == nullptr) {
if (m_connectionThread != nullptr) {
m_connectionThread->quit();
m_connectionThread->wait();
m_connectionThreadObject->deleteLater();
Expand Down