diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2d56693..347b6d06 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +# SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. # # SPDX-License-Identifier: GPL-3.0-or-later @@ -270,8 +270,10 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/translations #hw机型增加DConfig配置 set(APPID org.deepin.camera) set(configFile ${PROJECT_SOURCE_DIR}/assets/org.deepin.camera.encode.json) +#日志规则配置(调试模式动态日志级别) +set(configFileLog ${PROJECT_SOURCE_DIR}/assets/org.deepin.camera.json) if (DTK_VERSION EQUAL "6") - dtk_add_config_meta_files(APPID ${APPID} FILES ${configFile}) + dtk_add_config_meta_files(APPID ${APPID} FILES ${configFile} ${configFileLog}) else() - install(FILES ${configFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/dsg/configs/org.deepin.camera/) + install(FILES ${configFile} ${configFileLog} DESTINATION ${CMAKE_INSTALL_DATADIR}/dsg/configs/org.deepin.camera/) endif() diff --git a/src/assets/org.deepin.camera.encode.json b/src/assets/org.deepin.camera.encode.json index 02e7a9b3..acc66702 100644 --- a/src/assets/org.deepin.camera.encode.json +++ b/src/assets/org.deepin.camera.encode.json @@ -2,19 +2,6 @@ "magic": "dsg.config.meta", "version": "1.0", "contents": { - "rules": { - "value": "*.debug=false;*.info=false;*.warning=true", - "serial": 0, - "flags": [ - "global" - ], - "name": "rules", - "name[zh_CN]": "日志规则", - "description": "log rules", - "description[zh_CN]": "日志规则", - "permissions": "readwrite", - "visibility": "public" - }, "mp4EncodeMode": { "value": -1, "serial": 0, diff --git a/src/assets/org.deepin.camera.json b/src/assets/org.deepin.camera.json new file mode 100644 index 00000000..54f5e39f --- /dev/null +++ b/src/assets/org.deepin.camera.json @@ -0,0 +1,17 @@ +{ + "magic": "dsg.config.meta", + "version": "1.0", + "contents": { + "log_rules": { + "value": "*.debug=false;*.info=false;org.deepin.camera*.warning=true", + "serial": 0, + "flags": ["global"], + "name": "log rules", + "name[zh_CN]": "日志规则", + "description": "log rules", + "description[zh_CN]": "日志规则", + "permissions": "readwrite", + "visibility": "public" + } + } +} diff --git a/src/main.cpp b/src/main.cpp index e189a5aa..ad18c204 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,8 @@ // // SPDX-License-Identifier: GPL-3.0-or-later +#include "ddlog.h" +using namespace DDLog; extern "C" { #include "camview.h" #include "v4l2_formats.h" @@ -56,22 +58,22 @@ DWIDGET_USE_NAMESPACE //判断是否采用wayland显示服务器 static bool CheckWayland() { - qDebug() << "Function started: CheckWayland"; + qCDebug(appLog) << "Function started: CheckWayland"; auto e = QProcessEnvironment::systemEnvironment(); QString XDG_SESSION_TYPE = e.value(QStringLiteral("XDG_SESSION_TYPE")); QString WAYLAND_DISPLAY = e.value(QStringLiteral("WAYLAND_DISPLAY")); if (XDG_SESSION_TYPE == QLatin1String("wayland") || WAYLAND_DISPLAY.contains(QLatin1String("wayland"), Qt::CaseInsensitive)) { - qDebug() << "Condition check: Wayland environment detected"; + qCDebug(appLog) << "Condition check: Wayland environment detected"; return true; } - qDebug() << "Condition check: Non-Wayland environment detected"; + qCDebug(appLog) << "Condition check: Non-Wayland environment detected"; return false; } static bool CheckFFmpegEnv() { - qDebug() << "Function started: CheckFFmpegEnv"; + qCDebug(appLog) << "Function started: CheckFFmpegEnv"; QDir dir; QString path = QLibraryInfo::location(QLibraryInfo::LibrariesPath); dir.setPath(path); @@ -83,7 +85,7 @@ static bool CheckFFmpegEnv() QRegularExpressionMatch match = re.match(list[i]); if (match.hasMatch()) { libName = list[i]; - qDebug() << "Found matching library:" << libName; + qCDebug(appLog) << "Found matching library:" << libName; break; } } @@ -92,7 +94,7 @@ static bool CheckFFmpegEnv() for (int i = 0; i < list.count(); i++) { if (re.exactMatch(list[i])) { libName = list[i]; - qDebug() << "Found matching library:" << libName; + qCDebug(appLog) << "Found matching library:" << libName; break; } } @@ -101,11 +103,11 @@ static bool CheckFFmpegEnv() QLibrary libavcodec; //检查编码器是否存在 libavcodec.setFileName(libName); if (!libavcodec.load()) { - qDebug() << "Condition check: Library loading failed"; - qWarning() << QString("Not found libavcodec: %1").arg(libavcodec.errorString()); + qCDebug(appLog) << "Condition check: Library loading failed"; + qCWarning(appLog) << QString("Not found libavcodec: %1").arg(libavcodec.errorString()); return false; } - qDebug() << "The libavcodec is loaded successfully."; + qCDebug(appLog) << "The libavcodec is loaded successfully."; typedef AVCodec *(*p_avcodec_find_encoder)(enum AVCodecID id); p_avcodec_find_encoder m_avcodec_find_encoder = nullptr; m_avcodec_find_encoder = reinterpret_cast(libavcodec.resolve("avcodec_find_encoder")); @@ -115,14 +117,14 @@ static bool CheckFFmpegEnv() pCodec = m_avcodec_find_encoder(AV_CODEC_ID_H264); if (pCodec) { - qDebug() << "Video encoder exists. AVCodecID:" << AV_CODEC_ID_H264; + qCDebug(appLog) << "Video encoder exists. AVCodecID:" << AV_CODEC_ID_H264; DataManager::instance()->setEncExists(true); } else { - qWarning() << "Can not find output video encoder! AVCodecID:" << AV_CODEC_ID_H264; + qCWarning(appLog) << "Can not find output video encoder! AVCodecID:" << AV_CODEC_ID_H264; DataManager::instance()->setEncExists(false); } - qDebug() << "Function completed: CheckFFmpegEnv"; + qCDebug(appLog) << "Function completed: CheckFFmpegEnv"; return true; } @@ -130,7 +132,7 @@ static bool CheckFFmpegEnv() // 添加信号处理函数 static void handleSignal(int sig) { - qWarning() << "Received signal:" << sig; + qCWarning(appLog) << "Received signal:" << sig; // 在HW机器、SW机器上,发现使用exit(0)退出会导致Qt某些函数空指针异常,从而导致崩溃,疑似在资源回收环节出了问题。所以我们使用QApplication::quit()更优雅地退出。 QTimer::singleShot(0, qApp, []() { QApplication::quit(); @@ -143,33 +145,33 @@ int main(int argc, char *argv[]) // 初始化日志规则:读取环境变量和 DConfig 配置 MLogger logger; - qInfo() << "Starting deepin-camera application..."; + qCInfo(appLog) << "Starting deepin-camera application..."; // Task 326583 不参与合成器崩溃重连 unsetenv("QT_WAYLAND_RECONNECT"); QAccessible::installFactory(accessibleFactory); bool bWayland = CheckWayland(); - qInfo() << "Wayland status:" << (bWayland ? "enabled" : "disabled"); + qCInfo(appLog) << "Wayland status:" << (bWayland ? "enabled" : "disabled"); bool bFFmpegEnv = CheckFFmpegEnv(); if (argc > 1) { - qDebug() << "Condition check: Arguments found"; + qCDebug(appLog) << "Condition check: Arguments found"; if (QString(argv[1]) == "-g") { bFFmpegEnv = false; - qDebug() << "Running in gstreamer test environment"; + qCDebug(appLog) << "Running in gstreamer test environment"; } } DataManager::instance()->setEncodeEnv(bFFmpegEnv ? FFmpeg_Env : GStreamer_Env); - qInfo() << "Encoding environment:" << (bFFmpegEnv ? "FFmpeg" : "GStreamer"); + qCInfo(appLog) << "Encoding environment:" << (bFFmpegEnv ? "FFmpeg" : "GStreamer"); //root login for this application if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) { setenv("XDG_CURRENT_DESKTOP", "Deepin", 1); - qDebug() << "Set XDG_CURRENT_DESKTOP to Deepin"; + qCDebug(appLog) << "Set XDG_CURRENT_DESKTOP to Deepin"; } if (bWayland) { - qDebug() << "Condition check: Wayland configuration required"; + qCDebug(appLog) << "Condition check: Wayland configuration required"; QSurfaceFormat format; format.setRenderableType(QSurfaceFormat::OpenGLES); format.setDefaultFormat(format); @@ -218,7 +220,7 @@ int main(int argc, char *argv[]) if (dconfig && dconfig->isValid() && dconfig->keyList().contains("enableUsbGroup")) { bool enable = dconfig->value("enableUsbGroup").toBool(); - qInfo() << "enable USB group:" << enable; + qCInfo(appLog) << "enable USB group:" << enable; DataManager::instance()->setEnableUsbGroup(enable); } @@ -227,20 +229,20 @@ int main(int argc, char *argv[]) // 8K预览功能默认关闭,因为多个厂家的摄像头在8K预览的时候表现异常 if (dconfig && dconfig->isValid() && dconfig->keyList().contains("enable8kPreview")) { bool enable = dconfig->value("enable8kPreview").toBool(); - qInfo() << "enable 8K preview:" << enable; + qCInfo(appLog) << "enable 8K preview:" << enable; DataManager::instance()->setEnable8kPreview(enable); set_enable_8k_preview(enable ? 1 : 0); } if (dconfig && dconfig->isValid() && dconfig->keyList().contains("deviceBlacklist")) { QStringList deviceBlacklist = dconfig->value("deviceBlacklist").toStringList(); - qInfo() << "device blacklist:" << deviceBlacklist; + qCInfo(appLog) << "device blacklist:" << deviceBlacklist; DataManager::instance()->setDeviceBlacklist(deviceBlacklist); } if (dconfig && dconfig->isValid() && dconfig->keyList().contains("preferredResolution")) { QString preferredResolution = dconfig->value("preferredResolution").toString(); - qInfo() << "preferred resolution:" << preferredResolution; + qCInfo(appLog) << "preferred resolution:" << preferredResolution; if (!preferredResolution.isEmpty()) { DataManager::instance()->setPreferredResolution(preferredResolution); QSize size = DataManager::instance()->getPreferredResolution(); @@ -253,10 +255,10 @@ int main(int argc, char *argv[]) if (dconfig && dconfig->isValid() && dconfig->keyList().contains("useRgbData")) { int useRgbData = dconfig->value("useRgbData").toInt(); if (useRgbData != -1 && useRgbData != 0 && useRgbData != 1) { - qWarning() << "Invalid useRgbData value in config:" << useRgbData << "- mapping to default value -1 (auto)"; + qCWarning(appLog) << "Invalid useRgbData value in config:" << useRgbData << "- mapping to default value -1 (auto)"; useRgbData = -1; } - qInfo() << "use RGB data for preview:" << useRgbData; + qCInfo(appLog) << "use RGB data for preview:" << useRgbData; DataManager::instance()->setUseRgbData(useRgbData); } @@ -268,12 +270,12 @@ int main(int argc, char *argv[]) qputenv("VDPAU_DRIVER", libVdpauDriverName.toLocal8Bit()); } #endif - qInfo() << "mp4EncodeMode value is:" << get_pugx_status(); - qInfo() << "projectID value is:" << get_project_id(); - qInfo() << "libVaDriverName value is:" << get_libva_driver_name(); - qInfo() << "libVdpauDriverName value is:" << get_libvdpau_driver_name(); - qInfo() << "LIBVA_DRIVER_NAME value is:" << qgetenv("LIBVA_DRIVER_NAME"); - qInfo() << "VDPAU_DRIVER value is:" << qgetenv("VDPAU_DRIVER"); + qCInfo(appLog) << "mp4EncodeMode value is:" << get_pugx_status(); + qCInfo(appLog) << "projectID value is:" << get_project_id(); + qCInfo(appLog) << "libVaDriverName value is:" << get_libva_driver_name(); + qCInfo(appLog) << "libVdpauDriverName value is:" << get_libvdpau_driver_name(); + qCInfo(appLog) << "LIBVA_DRIVER_NAME value is:" << qgetenv("LIBVA_DRIVER_NAME"); + qCInfo(appLog) << "VDPAU_DRIVER value is:" << qgetenv("VDPAU_DRIVER"); if (mp4Encode == -1) { //判断是否是X机型 QStringList options; @@ -291,15 +293,15 @@ int main(int argc, char *argv[]) if (str_output.contains("PGUX", Qt::CaseInsensitive)) { mp4Encode = 1; - qDebug() << "this is PGUX"; + qCDebug(appLog) << "this is PGUX"; } else { mp4Encode = 0; } - qInfo() << "process find mp4EncodeMode value is:" << get_pugx_status(); + qCInfo(appLog) << "process find mp4EncodeMode value is:" << get_pugx_status(); } set_pugx_status(mp4Encode); - qInfo() << "last mp4EncodeMode value is:" << get_pugx_status(); + qCInfo(appLog) << "last mp4EncodeMode value is:" << get_pugx_status(); #if QT_VERSION_MAJOR > 5 QElapsedTimer time; @@ -309,8 +311,8 @@ int main(int argc, char *argv[]) time.start(); QString lutDir = LUT_DIR; initFilters(lutDir.toStdString().c_str()); - qDebug() << "LUT_DIR: " << lutDir; - qDebug() << QString("Filter initialization completed in %1 ms").arg(time.elapsed()); + qCDebug(appLog) << "LUT_DIR: " << lutDir; + qCDebug(appLog) << QString("Filter initialization completed in %1 ms").arg(time.elapsed()); CApplication a(argc, argv); // 注册信号处理函数 // 放在此处,是为了确保Application已经创建了实例 @@ -336,60 +338,60 @@ int main(int argc, char *argv[]) //日志 DLogManager::registerConsoleAppender(); DLogManager::registerFileAppender(); - qInfo() << "Log system initialized. Log file:" << DLogManager::getlogFilePath(); + qCInfo(appLog) << "Log system initialized. Log file:" << DLogManager::getlogFilePath(); //版本 qApp->setApplicationVersion(DApplication::buildVersion(VERSION)); QIcon myIcon = QIcon::fromTheme("deepin-camera"); qApp->setWindowIcon(myIcon); qApp->setProductIcon(myIcon);//08月21获悉已添加到系统,故更改为从系统获取 - qDebug() << "Application version:" << DApplication::buildVersion(VERSION); + qCDebug(appLog) << "Application version:" << DApplication::buildVersion(VERSION); //应用描述 qApp->setApplicationDescription(QObject::tr("Camera is an image and video capture utility using your PC camera or webcam.")); dc::Settings::get().init(); - qDebug() << "Application settings initialized"; + qCDebug(appLog) << "Application settings initialized"; #if QT_VERSION_MAJOR <= 5 DApplicationSettings saveTheme; #endif if (!qApp->setSingleInstance("deepin-camera")) { - qWarning() << "Another deepin camera instance is already running"; + qCWarning(appLog) << "Another deepin camera instance is already running"; QDBusInterface iface("com.deepin.camera", QDir::separator(), "com.deepin.camera"); if (iface.isValid()) { - qDebug() << "Attempting to raise existing instance"; + qCDebug(appLog) << "Attempting to raise existing instance"; iface.asyncCall("Raise"); } - qDebug() << "Function completed: main (exit due to existing instance)"; + qCDebug(appLog) << "Function completed: main (exit due to existing instance)"; exit(0); } CMainWindow w; a.setMainWindow(&w); - qDebug() << "Main window created and set"; + qCDebug(appLog) << "Main window created and set"; Dtk::Widget::moveToCenter(&w); w.setWayland(bWayland); //判断是否是平板环境 if (CamApp->isPanelEnvironment()) { w.showMaximized(); - qDebug() << "Running in panel environment, showing maximized window"; + qCDebug(appLog) << "Running in panel environment, showing maximized window"; } else { w.setMinimumSize(CMainWindow::minWindowWidth, CMainWindow::minWindowHeight); - qDebug() << "Running in desktop environment, showing normal window"; + qCDebug(appLog) << "Running in desktop environment, showing normal window"; } w.show(); w.loadAfterShow(); - qInfo() << "Main window displayed and initialized"; + qCInfo(appLog) << "Main window displayed and initialized"; ApplicationAdaptor adaptor(&w); QDBusConnection::sessionBus().registerService("com.deepin.Camera"); QDBusConnection::sessionBus().registerObject("/com/deepin/camera", &w); - qDebug() << "DBus service and object registered"; + qCDebug(appLog) << "DBus service and object registered"; - qInfo() << "Application startup completed successfully"; + qCInfo(appLog) << "Application startup completed successfully"; return qApp->exec(); } diff --git a/src/src/Settings.cpp b/src/src/Settings.cpp index a26aea62..921cbd57 100644 --- a/src/src/Settings.cpp +++ b/src/src/Settings.cpp @@ -1,8 +1,10 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later +#include "ddlog.h" +using namespace DDLog; extern "C" { #include "v4l2_formats.h" } @@ -31,48 +33,48 @@ Settings::Settings() m_backend(nullptr), m_settings(nullptr) { - qDebug() << "Initializing Settings instance"; + qCDebug(appLog) << "Initializing Settings instance"; } void Settings::init() { - qDebug() << "Initializing Settings"; + qCDebug(appLog) << "Initializing Settings"; m_configPath.clear(); m_configPath.append(QString("%1/%2/%3/config.conf") .arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)) .arg(qApp->organizationName()) .arg(qApp->applicationName())); - qInfo() << "Loading config from path:" << m_configPath; + qCInfo(appLog) << "Loading config from path:" << m_configPath; m_backend = new QSettingBackend(m_configPath); if (CamApp->isPanelEnvironment()) { - qDebug() << "Loading panel environment settings"; + qCDebug(appLog) << "Loading panel environment settings"; m_settings = DSettings::fromJsonFile(":/resource/panel_settings.json"); } else { - qDebug() << "Loading normal environment settings"; + qCDebug(appLog) << "Loading normal environment settings"; m_settings = DSettings::fromJsonFile(":/resource/settings.json"); } QStringList videoFormatList; if (DataManager::instance()->encodeEnv() == FFmpeg_Env) { - qDebug() << "Using FFmpeg encoding environment"; + qCDebug(appLog) << "Using FFmpeg encoding environment"; if (DataManager::instance()->encExists()) { - qDebug() << "FFmpeg encoder exists, loading camera configuration"; + qCDebug(appLog) << "FFmpeg encoder exists, loading camera configuration"; GlobalUtils::loadCameraConf(); if (!GlobalUtils::isLowPerformanceBoard()) { - qDebug() << "High performance board detected, using mp4 and webm formats"; + qCDebug(appLog) << "High performance board detected, using mp4 and webm formats"; videoFormatList << tr("mp4") << tr("webm"); } else { - qDebug() << "Low performance board detected, using webm and mp4 formats"; + qCDebug(appLog) << "Low performance board detected, using webm and mp4 formats"; videoFormatList << tr("webm") << tr("mp4"); } } else { - qDebug() << "FFmpeg encoder not found, using webm format only"; + qCDebug(appLog) << "FFmpeg encoder not found, using webm format only"; videoFormatList << tr("webm"); m_settings->setOption("outsetting.outformat.vidformat", 0); } } else { - qDebug() << "Using non-FFmpeg encoding environment, using webm format only"; + qCDebug(appLog) << "Using non-FFmpeg encoding environment, using webm format only"; videoFormatList << "webm"; m_settings->setOption("outsetting.outformat.vidformat", 0); } @@ -82,29 +84,29 @@ void Settings::init() connect(m_settings, &DSettings::valueChanged, this, &Settings::onValueChanged); - qInfo() << "Available settings keys:" << m_settings->keys(); + qCInfo(appLog) << "Available settings keys:" << m_settings->keys(); setNewResolutionList(); } QVariant Settings::getOption(const QString &opt) { - qDebug() << "Getting option:" << opt; + qCDebug(appLog) << "Getting option:" << opt; return m_settings->getOption(opt); } void Settings::setOption(const QString &opt, const QVariant &v) { - qDebug() << "Setting option:" << opt << "to value:" << v; + qCDebug(appLog) << "Setting option:" << opt << "to value:" << v; m_settings->setOption(opt, v); } void Settings::setNewResolutionList() { - qDebug() << "Setting up new resolution list"; + qCDebug(appLog) << "Setting up new resolution list"; auto resolutionmodeFamily = m_settings->option("outsetting.resolutionsetting.resolution"); if (get_v4l2_device_handler() != nullptr) { - qDebug() << "V4L2 device handler found, getting resolution list"; + qCDebug(appLog) << "V4L2 device handler found, getting resolution list"; //格式索引 int format_index = v4l2core_get_frame_format_index( get_v4l2_device_handler(), @@ -117,7 +119,7 @@ void Settings::setNewResolutionList() v4l2core_get_frame_width(get_v4l2_device_handler()), v4l2core_get_frame_height(get_v4l2_device_handler())); - qDebug() << "Format index:" << format_index << "Resolution index:" << resolu_index; + qCDebug(appLog) << "Format index:" << format_index << "Resolution index:" << resolu_index; //获取当前摄像头的格式表 v4l2_stream_formats_t *list_stream_formats = v4l2core_get_formats_list(get_v4l2_device_handler()); @@ -129,7 +131,7 @@ void Settings::setNewResolutionList() //当前分辨率下标 if (format_index >= 0 && resolu_index >= 0) { - qDebug() << "Processing available resolutions"; + qCDebug(appLog) << "Processing available resolutions"; for (int i = 0 ; i < list_stream_formats[format_index].numb_res; i++) { int w = list_stream_formats[format_index].list_stream_cap[i].width; int h = list_stream_formats[format_index].list_stream_cap[i].height; @@ -139,13 +141,13 @@ void Settings::setNewResolutionList() //去重 if (resolutionDatabase.contains(res_str) == false) { resolutionDatabase.append(res_str); - qDebug() << "Added resolution:" << res_str; + qCDebug(appLog) << "Added resolution:" << res_str; } } } // Sort resolutions - qDebug() << "Sorting resolutions"; + qCDebug(appLog) << "Sorting resolutions"; int defres = 0; int tempostion = 0; int len = resolutionDatabase.size() - 1; @@ -175,7 +177,7 @@ void Settings::setNewResolutionList() if ((v4l2core_get_frame_width(get_v4l2_device_handler()) == resolutiontemp[0].toInt()) && (v4l2core_get_frame_height(get_v4l2_device_handler()) == resolutiontemp[1].toInt())) { defres = i; //set selected resolution index - qDebug() << "Found default resolution at index:" << defres; + qCDebug(appLog) << "Found default resolution at index:" << defres; break; } } @@ -185,7 +187,7 @@ void Settings::setNewResolutionList() //设置当前分辨率的索引 m_settings->setOption(QString("outsetting.resolutionsetting.resolution"), defres); } else { - qWarning() << "Invalid format or resolution index, setting default resolution"; + qCWarning(appLog) << "Invalid format or resolution index, setting default resolution"; resolutionDatabase.clear(); resolutionDatabase.append(QString(tr("None"))); m_settings->setOption(QString("outsetting.resolutionsetting.resolution"), 0); @@ -193,11 +195,11 @@ void Settings::setNewResolutionList() } } else { //初始化分辨率字符串表 - qDebug() << "No V4L2 device handler, using QCamera resolutions"; + qCDebug(appLog) << "No V4L2 device handler, using QCamera resolutions"; int defres = 0; QStringList resolutionDatabase = resolutionmodeFamily->data("items").toStringList(); if (DataManager::instance()->encodeEnv() == QCamera_Env && !Camera::instance()->getSupportResolutions().isEmpty()) { - qDebug() << "Using QCamera supported resolutions"; + qCDebug(appLog) << "Using QCamera supported resolutions"; resolutionDatabase = Camera::instance()->getSupportResolutions(); for (int i = 0; i < resolutionDatabase.size(); i++) { @@ -205,12 +207,12 @@ void Settings::setNewResolutionList() if ((Camera::instance()->getCameraResolution().width() == resolutiontemp[0].toInt()) && Camera::instance()->getCameraResolution().height() == resolutiontemp[1].toInt()) { defres = i; //设置分辨率下拉菜单当前索引 - qDebug() << "Found default QCamera resolution at index:" << defres; + qCDebug(appLog) << "Found default QCamera resolution at index:" << defres; break; } } } else { - qDebug() << "No supported resolutions found, using default"; + qCDebug(appLog) << "No supported resolutions found, using default"; if (resolutionDatabase.size() > 0) resolutionmodeFamily->data("items").clear(); @@ -222,37 +224,37 @@ void Settings::setNewResolutionList() } m_settings->sync(); - qDebug() << "Resolution list setup complete"; + qCDebug(appLog) << "Resolution list setup complete"; } void Settings::setPathOption(const QString &opt, const QVariant &v) { - qDebug() << "Setting path option:" << opt << "to:" << v; + qCDebug(appLog) << "Setting path option:" << opt << "to:" << v; m_settings->setOption(QString("base.save.%1").arg(opt), v); m_settings->sync(); } void Settings::setBackOption(const QString &opt, const QVariant &v) { - qDebug() << "Setting backend option:" << opt << "to:" << v; + qCDebug(appLog) << "Setting backend option:" << opt << "to:" << v; m_backend->setOption(opt,v); m_backend->sync(); } QVariant Settings::getBackOption(const QString &opt) { - qDebug() << "Getting backend option:" << opt; + qCDebug(appLog) << "Getting backend option:" << opt; return m_backend->getOption(opt); } void Settings::onValueChanged(const QString & key, const QVariant & value) { - qDebug() << "Settings value changed:" << key << "to:" << value; + qCDebug(appLog) << "Settings value changed:" << key << "to:" << value; if (key.startsWith("outsetting.resolutionsetting.resolution")) { auto mode_opt = m_settings->option("outsetting.resolutionsetting.resolution"); if (value.toInt() >= 0 && mode_opt->data("items").toStringList().size() > value.toInt()) { QString mode = mode_opt->data("items").toStringList()[value.toInt()]; - qInfo() << "Resolution changed to:" << mode; + qCInfo(appLog) << "Resolution changed to:" << mode; emit resolutionchanged(mode); } } @@ -260,7 +262,7 @@ void Settings::onValueChanged(const QString & key, const QVariant & value) if (key.startsWith("base.photogrid.photogrids")) { auto grid_opt1 = m_settings->option("base.photogrid.photogrids"); if (value.toInt() >= 0 && grid_opt1->data("items").toStringList().size() > value.toInt()) { - qInfo() << "Grid type changed to:" << value.toInt(); + qCInfo(appLog) << "Grid type changed to:" << value.toInt(); emit gridTypeChanged(value.toInt()); } } @@ -269,20 +271,20 @@ void Settings::onValueChanged(const QString & key, const QVariant & value) auto mode_opt1 = m_settings->option("photosetting.photosdelay.photodelays"); if (value.toInt() >= 0 && mode_opt1->data("items").toStringList().size() > value.toInt()) { QString mode1 = mode_opt1->data("items").toStringList()[value.toInt()]; - qInfo() << "Delay time changed to:" << mode1; + qCInfo(appLog) << "Delay time changed to:" << mode1; emit delayTimeChanged(mode1); } } if (key.startsWith("photosetting.mirrorMode.mirrorMode")){ bool bMirror = m_settings->getOption("photosetting.mirrorMode.mirrorMode").toBool(); - qInfo() << "Mirror mode changed to:" << bMirror; + qCInfo(appLog) << "Mirror mode changed to:" << bMirror; emit mirrorModeChanged(bMirror); } if (key.startsWith("photosetting.Flashlight.Flashlight")){ bool bLight = m_settings->getOption("photosetting.Flashlight.Flashlight").toBool(); - qInfo() << "Flashlight changed to:" << bLight; + qCInfo(appLog) << "Flashlight changed to:" << bLight; emit flashLightChanged(bLight); } @@ -290,7 +292,7 @@ void Settings::onValueChanged(const QString & key, const QVariant & value) QPointer formatOpt = m_settings->option("outsetting.outformat.vidformat"); if (value.toInt() >= 0 && formatOpt->data("items").toStringList().size() > value.toInt()) { QString videoFormat = formatOpt->data("items").toStringList()[value.toInt()]; - qInfo() << "Video format changed to:" << videoFormat; + qCInfo(appLog) << "Video format changed to:" << videoFormat; emit videoFormatChanged(videoFormat); } } @@ -298,7 +300,7 @@ void Settings::onValueChanged(const QString & key, const QVariant & value) Settings::~Settings() { - qDebug() << "Cleaning up Settings instance"; + qCDebug(appLog) << "Cleaning up Settings instance"; if (m_backend) { delete m_backend; m_backend = nullptr; diff --git a/src/src/audioprocessingthread.cpp b/src/src/audioprocessingthread.cpp index a799c094..e01a8ea5 100644 --- a/src/src/audioprocessingthread.cpp +++ b/src/src/audioprocessingthread.cpp @@ -1,15 +1,17 @@ -// Copyright (C) 2021 ~ 2022 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2021 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "audioprocessingthread.h" +#include "ddlog.h" +using namespace DDLog; #define FRAME_SIZE 512 AudioProcessingThread::AudioProcessingThread() { - qDebug() << "Initializing AudioProcessingThread"; + qCDebug(appLog) << "Initializing AudioProcessingThread"; m_auidoBuffer = nullptr; m_data = nullptr; m_datasize = 0; @@ -18,37 +20,37 @@ AudioProcessingThread::AudioProcessingThread() void AudioProcessingThread::stop() { - qDebug() << "Stopping audio processing thread"; + qCDebug(appLog) << "Stopping audio processing thread"; m_stopped = 1; } void AudioProcessingThread::init() { - qDebug() << "Initializing audio processing thread state"; + qCDebug(appLog) << "Initializing audio processing thread state"; m_stopped = 0; } void AudioProcessingThread::run() { - qDebug() << "Starting audio processing thread"; + qCDebug(appLog) << "Starting audio processing thread"; uint datasize = 0; audio_context_t *audio_ctx = get_audio_context(); if(!audio_ctx) { - qWarning() << "No audio context available: skipping audio processing"; + qCWarning(appLog) << "No audio context available: skipping audio processing"; return; } //初始化音频样本获取缓存大小 audio_set_cap_buffer_size(audio_ctx, FRAME_SIZE * audio_get_channels(audio_ctx)); - qDebug() << "Audio capture buffer size set to:" << FRAME_SIZE * audio_get_channels(audio_ctx); + qCDebug(appLog) << "Audio capture buffer size set to:" << FRAME_SIZE * audio_get_channels(audio_ctx); audio_start(audio_ctx); - qDebug() << "Audio capture started"; + qCDebug(appLog) << "Audio capture started"; datasize = audio_ctx->capture_buff_size * sizeof(sample_t); - qDebug() << "Audio data size:" << datasize << "bytes"; + qCDebug(appLog) << "Audio data size:" << datasize << "bytes"; /* * alloc the buffer after audio_start @@ -60,7 +62,7 @@ void AudioProcessingThread::run() m_auidoBuffer = audio_get_buffer(audio_ctx); uint sample_type = GV_SAMPLE_TYPE_FLOAT; - qDebug() << "Using sample type: FLOAT"; + qCDebug(appLog) << "Using sample type: FLOAT"; while (m_stopped == 0) { int ret = audio_get_next_buffer(audio_ctx, m_auidoBuffer, sample_type, get_audio_fx_mask()); @@ -76,7 +78,7 @@ void AudioProcessingThread::run() } else if (ret == 0) { if (m_datasize != datasize) { - qDebug() << "Resizing audio data buffer from" << m_datasize << "to" << datasize << "bytes"; + qCDebug(appLog) << "Resizing audio data buffer from" << m_datasize << "to" << datasize << "bytes"; m_datasize = datasize; if (m_data != nullptr) { delete [] m_data; @@ -92,24 +94,24 @@ void AudioProcessingThread::run() m_rwMtxData.unlock(); } else { - qWarning() << "Error getting next audio buffer, return code:" << ret; + qCWarning(appLog) << "Error getting next audio buffer, return code:" << ret; } } - qDebug() << "Stopping audio capture and cleaning up resources"; + qCDebug(appLog) << "Stopping audio capture and cleaning up resources"; audio_stop(audio_ctx); audio_delete_buffer(m_auidoBuffer); - qInfo() << "Audio processing thread stopped"; + qCInfo(appLog) << "Audio processing thread stopped"; return; } AudioProcessingThread::~AudioProcessingThread() { - qDebug() << "Destroying AudioProcessingThread"; + qCDebug(appLog) << "Destroying AudioProcessingThread"; if (m_data) { delete [] m_data; m_data = nullptr; } - qDebug() << "AudioProcessingThread destroyed"; + qCDebug(appLog) << "AudioProcessingThread destroyed"; } diff --git a/src/src/basepub/datamanager.cpp b/src/src/basepub/datamanager.cpp index 8d33eed6..43ebff69 100644 --- a/src/src/basepub/datamanager.cpp +++ b/src/src/basepub/datamanager.cpp @@ -3,6 +3,8 @@ // // SPDX-License-Identifier: GPL-3.0-or-later +#include "ddlog.h" +using namespace DDLog; extern "C" { #include "v4l2_formats.h" } @@ -73,7 +75,7 @@ void DataManager::setDeviceBlacklist(const QStringList &blacklist) // 无论是否为空,都先清空现有黑名单 m_deviceBlacklistSet.clear(); if (blacklist.isEmpty()) { - qInfo() << "Empty blacklist provided"; + qCInfo(appLog) << "Empty blacklist provided"; return; } @@ -83,24 +85,24 @@ void DataManager::setDeviceBlacklist(const QStringList &blacklist) for (const QString &item : blacklist) { QStringList parts = item.split(","); if (parts.size() != 3) { - qWarning() << "Drop blacklist item(format error):" << item; + qCWarning(appLog) << "Drop blacklist item(format error):" << item; continue; } // 验证VID和PID是否为4位十六进制数 static const QRegularExpression hexPattern("^[0-9a-fA-F]{4}$"); if (!hexPattern.match(parts[0]).hasMatch() || !hexPattern.match(parts[1]).hasMatch()) { - qWarning() << "Drop blacklist item(invalid VID/PID):" << item; + qCWarning(appLog) << "Drop blacklist item(invalid VID/PID):" << item; continue; } // 验证设备名称不为空,且长度不超过100个字符 if (parts[2].trimmed().isEmpty() || parts[2].size() > 100) { - qWarning() << "Drop blacklist item(empty device name OR too long):" << item; + qCWarning(appLog) << "Drop blacklist item(empty device name OR too long):" << item; continue; } - qInfo() << "Add blacklist item:" << item; + qCInfo(appLog) << "Add blacklist item:" << item; m_deviceBlacklistSet.insert(item.toLower()); } }; @@ -119,13 +121,13 @@ bool DataManager::isDeviceValid(const QString &vid, const QString &pid, const QS void DataManager::setPreferredResolution(const QString &resolution) { if (resolution.isEmpty()) { - qInfo() << "Preferred resolution is empty"; + qCInfo(appLog) << "Preferred resolution is empty"; return; } QStringList parts = resolution.split("x"); if (parts.size() != 2) { - qWarning() << "Invalid resolution format:" << resolution << "Expected format: WIDTHxHEIGHT"; + qCWarning(appLog) << "Invalid resolution format:" << resolution << "Expected format: WIDTHxHEIGHT"; return; } @@ -134,19 +136,19 @@ void DataManager::setPreferredResolution(const QString &resolution) int height = parts[1].toInt(&heightOk); if (!widthOk || !heightOk || width <= 0 || height <= 0) { - qWarning() << "Invalid resolution values:" << resolution; + qCWarning(appLog) << "Invalid resolution values:" << resolution; return; } // 添加合理的上限检查,例如16K static const int MAX_RESOLUTION = 16384; if (width > MAX_RESOLUTION || height > MAX_RESOLUTION) { - qWarning() << "Resolution exceeds maximum limit:" << resolution; + qCWarning(appLog) << "Resolution exceeds maximum limit:" << resolution; return; } if (!is_valid_resolution(width, height)) { - qWarning() << "Resolution does not meet validation requirements:" << resolution; + qCWarning(appLog) << "Resolution does not meet validation requirements:" << resolution; return; } diff --git a/src/src/camera.cpp b/src/src/camera.cpp index 39527a7d..7b1f66ed 100755 --- a/src/src/camera.cpp +++ b/src/src/camera.cpp @@ -1,9 +1,11 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #define TMPPATH "/tmp/tmp.jpg" +#include "ddlog.h" +using namespace DDLog; #include "camera.h" #if QT_VERSION_MAJOR > 5 @@ -101,7 +103,7 @@ Camera::Camera() , m_bReadyRecord(false) , m_bRecording(false) { - qDebug() << "Initializing Camera"; + qCDebug(appLog) << "Initializing Camera"; parseConfig(); initMember(); } @@ -109,34 +111,34 @@ Camera::Camera() void Camera::initMember() { // 连接相机surface,能够发送每帧QImage数据到外部 - qDebug() << "Initializing camera members"; + qCDebug(appLog) << "Initializing camera members"; #if QT_VERSION_MAJOR > 5 - qDebug() << "Condition check: Qt6 detected, using QVideoSink"; + qCDebug(appLog) << "Condition check: Qt6 detected, using QVideoSink"; #else - qDebug() << "Condition check: Qt5 detected, using VideoSurface"; + qCDebug(appLog) << "Condition check: Qt5 detected, using VideoSurface"; m_videoSurface = new VideoSurface(this); connect(m_videoSurface, &VideoSurface::presentImage, this, &Camera::presentImage); #endif // 初始设备名为空,默认启动config中的摄像头设备,若config设备名为空,则启动defaultCamera switchCamera(); - qDebug() << "Function completed: Camera::initMember"; + qCDebug(appLog) << "Function completed: Camera::initMember"; } void Camera::switchCamera() { - qDebug() << "Switching camera"; + qCDebug(appLog) << "Switching camera"; refreshCamDevList(); #if QT_VERSION_MAJOR > 5 QCameraDevice nextDevice; if (!m_cameraDeviceList.isEmpty()) { - qDebug() << "Condition check: Camera device list not empty"; + qCDebug(appLog) << "Condition check: Camera device list not empty"; int nCurIndex = m_cameraDeviceList.indexOf(m_curDevice); nCurIndex = (nCurIndex + 1) % m_cameraDeviceList.size(); nextDevice = m_cameraDeviceList[nCurIndex]; - qDebug() << "Switching to next camera device:" << nextDevice.description(); + qCDebug(appLog) << "Switching to next camera device:" << nextDevice.description(); } nextDevice = QMediaDevices::defaultVideoInput(); startCamera(nextDevice); @@ -144,43 +146,43 @@ void Camera::switchCamera() QString nextDevName; if (!m_cameraDevList.isEmpty()) { - qDebug() << "Condition check: Camera device list not empty"; + qCDebug(appLog) << "Condition check: Camera device list not empty"; int nCurIndex = m_cameraDevList.indexOf(m_curDevName); nCurIndex = (nCurIndex + 1) % m_cameraDevList.size(); nextDevName = m_cameraDevList[nCurIndex]; - qDebug() << "Switching to next camera device:" << nextDevName; + qCDebug(appLog) << "Switching to next camera device:" << nextDevName; } if (nextDevName.isEmpty()) { - qDebug() << "Condition check: No camera device selected, using config"; + qCDebug(appLog) << "Condition check: No camera device selected, using config"; nextDevName = camConfig.device_location; } if (nextDevName.isEmpty()) { - qDebug() << "Condition check: No device in config, using default"; + qCDebug(appLog) << "Condition check: No device in config, using default"; nextDevName = QCameraInfo::defaultCamera().deviceName(); - qDebug() << "Using default camera device:" << nextDevName; + qCDebug(appLog) << "Using default camera device:" << nextDevName; } startCamera(nextDevName); #endif - qDebug() << "Function completed: Camera::switchCamera"; + qCDebug(appLog) << "Function completed: Camera::switchCamera"; } void Camera::refreshCamera() { - qDebug() << "Refreshing camera"; + qCDebug(appLog) << "Refreshing camera"; refreshCamDevList(); // 设备链表找不到当前设备,发送设备断开信号 #if QT_VERSION_MAJOR > 5 if (!m_curDevice.isNull() && m_cameraDeviceList.indexOf(m_curDevice) == -1) { - qWarning() << "Current camera device disconnected"; + qCWarning(appLog) << "Current camera device disconnected"; m_curDevice = QCameraDevice(); emit currentCameraDisConnected(); } #else if (!m_curDevName.isEmpty() && m_cameraDevList.indexOf(m_curDevName) == -1) { - qWarning() << "Current camera device disconnected:" << m_curDevName; + qCWarning(appLog) << "Current camera device disconnected:" << m_curDevName; m_curDevName = ""; emit currentCameraDisConnected(); } @@ -188,17 +190,17 @@ void Camera::refreshCamera() // 若没有摄像头工作,则重启摄像头 restartCamera(); - qDebug() << "Function completed: Camera::refreshCamera"; + qCDebug(appLog) << "Function completed: Camera::refreshCamera"; } #include // 重启摄像头 void Camera::restartCamera() { - qDebug() << "Restarting camera"; + qCDebug(appLog) << "Restarting camera"; #if QT_VERSION_MAJOR > 5 if (!m_camera) { - qDebug() << "Condition check: No camera instance exists"; + qCDebug(appLog) << "Condition check: No camera instance exists"; QList availableCams = QMediaDevices::videoInputs(); if ((availableCams.isEmpty() || (m_camera && availableCams.indexOf(m_camera->cameraDevice()) != -1)) #if QT_VERSION_MAJOR > 5 @@ -206,17 +208,17 @@ void Camera::restartCamera() #else && !m_cameraDevList.isEmpty()) { #endif - qWarning() << "No available cameras found"; + qCWarning(appLog) << "No available cameras found"; emit cameraCannotUsed(); return; } #else if (!m_camera || m_camera->status() == QCamera::UnloadedStatus) { - qDebug() << "Condition check: Camera needs restart"; + qCDebug(appLog) << "Condition check: Camera needs restart"; QList availableCams = QCameraInfo::availableCameras(); if ((availableCams.isEmpty() || (m_camera && availableCams.indexOf(QCameraInfo(*m_camera)) != -1)) && !m_cameraDevList.isEmpty()) { - qWarning() << "No available cameras found"; + qCWarning(appLog) << "No available cameras found"; emit cameraCannotUsed(); return; } @@ -224,7 +226,7 @@ void Camera::restartCamera() } if (DataManager::instance()->getdevStatus() == CAM_CANUSE) { - qDebug() << "Camera is already in use"; + qCDebug(appLog) << "Camera is already in use"; return; } @@ -235,34 +237,34 @@ void Camera::restartCamera() #endif DataManager::instance()->setdevStatus(CAM_CANUSE); - qInfo() << "Camera restarted successfully"; + qCInfo(appLog) << "Camera restarted successfully"; emit cameraDevRestarted(); - qDebug() << "Function completed: Camera::restartCamera"; + qCDebug(appLog) << "Function completed: Camera::restartCamera"; } void Camera::refreshCamDevList() { - qDebug() << "Refreshing camera device list"; + qCDebug(appLog) << "Refreshing camera device list"; #if QT_VERSION_MAJOR > 5 m_cameraDeviceList.clear(); m_cameraDeviceList = QMediaDevices::videoInputs(); - qDebug() << "Found" << m_cameraDeviceList.size() << "camera devices"; + qCDebug(appLog) << "Found" << m_cameraDeviceList.size() << "camera devices"; #else m_cameraDevList.clear(); v4l2_device_list_t *devlist = get_device_list(); for (int i = 0; i < devlist->num_devices; i++) m_cameraDevList.push_back(devlist->list_devices[i].device); - qDebug() << "Found" << m_cameraDevList.size() << "camera devices"; + qCDebug(appLog) << "Found" << m_cameraDevList.size() << "camera devices"; #endif } #if QT_VERSION_MAJOR <= 5 void Camera::onCameraStatusChanged(QCamera::Status status) { - qDebug() << "Camera status changed to:" << status; + qCDebug(appLog) << "Camera status changed to:" << status; if (m_mediaRecoder) { - qDebug() << "Media recorder exists, checking status"; + qCDebug(appLog) << "Media recorder exists, checking status"; if (m_bReadyRecord && status == QCamera::ActiveStatus) { m_mediaRecoder->record(); m_bReadyRecord = false; @@ -273,12 +275,12 @@ void Camera::onCameraStatusChanged(QCamera::Status status) QStringList Camera::getSupportResolutions() { - qDebug() << "Getting supported resolutions"; + qCDebug(appLog) << "Getting supported resolutions"; QStringList resolutionsList; QList supportResolutionList = getSupportResolutionsSize(); if (supportResolutionList.isEmpty()) - qWarning() << "No supported resolutions found"; + qCWarning(appLog) << "No supported resolutions found"; int size = supportResolutionList.size(); resolutionsList.clear(); @@ -287,17 +289,17 @@ QStringList Camera::getSupportResolutions() resolutionsList.append(resol); } - qDebug() << "Supported resolutions:" << resolutionsList; + qCDebug(appLog) << "Supported resolutions:" << resolutionsList; return resolutionsList; } QList Camera::getSupportResolutionsSize() { - qDebug() << "Function started: Camera::getSupportResolutionsSize"; + qCDebug(appLog) << "Function started: Camera::getSupportResolutionsSize"; QList resolutions; #if QT_VERSION_MAJOR > 5 if (m_camera) { - qDebug() << "Condition check: Camera instance exists"; + qCDebug(appLog) << "Condition check: Camera instance exists"; resolutions = m_camera->cameraDevice().photoResolutions(); } #else @@ -305,20 +307,20 @@ QList Camera::getSupportResolutionsSize() resolutions = m_imageCapture->supportedResolutions(); #endif - qDebug() << "Function completed: Camera::getSupportResolutionsSize"; + qCDebug(appLog) << "Function completed: Camera::getSupportResolutionsSize"; return resolutions; } // 设置相机分辨率 void Camera::setCameraResolution(QSize size) { - qDebug() << "Setting camera resolution to:" << size; + qCDebug(appLog) << "Setting camera resolution to:" << size; #if QT_VERSION_MAJOR > 5 //TODO #else // 设置图片捕获器分辨率到相机 if (m_imageCapture) { - qDebug() << "Condition check: Setting image capture resolution"; + qCDebug(appLog) << "Condition check: Setting image capture resolution"; QImageEncoderSettings imageSettings = m_imageCapture->encodingSettings(); imageSettings.setResolution(size); m_imageCapture->setEncodingSettings(imageSettings); @@ -326,7 +328,7 @@ void Camera::setCameraResolution(QSize size) // 设置视频分辨率到相机 if (m_mediaRecoder) { - qDebug() << "Condition check: Setting media recorder resolution"; + qCDebug(appLog) << "Condition check: Setting media recorder resolution"; QAudioEncoderSettings audioSettings = m_mediaRecoder->audioSettings(); QVideoEncoderSettings videoSettings = m_mediaRecoder->videoSettings(); videoSettings.setCodec("video/x-vp8"); @@ -336,7 +338,7 @@ void Camera::setCameraResolution(QSize size) // 设置分辨率到相机 if (m_camera) { - qDebug() << "Condition check: Setting camera viewfinder resolution"; + qCDebug(appLog) << "Condition check: Setting camera viewfinder resolution"; QCameraViewfinderSettings viewfinderSettings = m_camera->viewfinderSettings(); viewfinderSettings.setResolution(size); m_camera->setViewfinderSettings(viewfinderSettings); @@ -347,12 +349,12 @@ void Camera::setCameraResolution(QSize size) camConfig.width = size.rwidth(); camConfig.height = size.rheight(); saveConfig(); - qDebug() << "Camera resolution set successfully"; + qCDebug(appLog) << "Camera resolution set successfully"; } QSize Camera::getCameraResolution() { - qDebug() << "Getting camera resolution"; + qCDebug(appLog) << "Getting camera resolution"; return QSize(camConfig.width,camConfig.height); } @@ -363,9 +365,9 @@ void Camera::startCamera(const QString &devName) #endif { // 存在上一相机,先停止 - qDebug() << "Starting camera"; + qCDebug(appLog) << "Starting camera"; if (m_camera) { - qDebug() << "Stopping existing camera"; + qCDebug(appLog) << "Stopping existing camera"; stopCamera(); } @@ -373,13 +375,13 @@ void Camera::startCamera(const QString &devName) m_camera = new QCamera(device); m_videoSink = new QVideoSink(this); m_curDevice = device; - qDebug() << "Started camera device:" << device.description(); + qCDebug(appLog) << "Started camera device:" << device.description(); #else m_camera = new QCamera(devName.toStdString().c_str()); QCameraInfo cameraInfo(*m_camera); connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged(QCamera::Status))); m_curDevName = devName; - qDebug() << "Started camera device:" << m_curDevName; + qCDebug(appLog) << "Started camera device:" << m_curDevName; m_imageCapture = new QCameraImageCapture(m_camera); m_mediaRecoder = new QMediaRecorder(m_camera); @@ -413,7 +415,7 @@ void Camera::startCamera(const QString &devName) if (m_curDevName != configDevName || (m_curDevName.isEmpty() && m_curDevName == configDevName)) { if (!supportList.isEmpty()) { - qDebug() << "Resetting resolution to maximum supported:" << supportList.last(); + qCDebug(appLog) << "Resetting resolution to maximum supported:" << supportList.last(); camConfig.width = supportList.last().rwidth(); camConfig.height = supportList.last().rheight(); } @@ -430,7 +432,7 @@ void Camera::startCamera(const QString &devName) } } if (bResetResolution) { - qDebug() << "Current resolution not supported, resetting to:" << supportList.last(); + qCDebug(appLog) << "Current resolution not supported, resetting to:" << supportList.last(); camConfig.width = supportList.last().width(); camConfig.height = supportList.last().height(); } @@ -446,7 +448,7 @@ void Camera::startCamera(const QString &devName) void Camera::stopCamera() { - qDebug() << "Stopping camera"; + qCDebug(appLog) << "Stopping camera"; if (m_camera) { #if QT_VERSION_MAJOR <= 5 connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(onCameraStatusChanged(QCamera::Status))); @@ -459,46 +461,46 @@ void Camera::stopCamera() #if QT_VERSION_MAJOR > 5 #else if (m_imageCapture) { - qDebug() << "Condition check: Image capture instance exists"; + qCDebug(appLog) << "Condition check: Image capture instance exists"; m_imageCapture->deleteLater(); m_imageCapture = nullptr; } #endif if (m_mediaRecoder) { - qDebug() << "Condition check: Media recorder instance exists"; + qCDebug(appLog) << "Condition check: Media recorder instance exists"; m_mediaRecoder->deleteLater(); m_mediaRecoder = nullptr; } - qDebug() << "Camera stopped successfully"; + qCDebug(appLog) << "Camera stopped successfully"; } void Camera::setVideoOutPutPath(QString &path) { - qDebug() << "Setting video output path:" << path; + qCDebug(appLog) << "Setting video output path:" << path; if (m_mediaRecoder) m_mediaRecoder->setOutputLocation(QUrl::fromLocalFile(path)); } void Camera::startRecoder() { - qDebug() << "Starting recorder"; + qCDebug(appLog) << "Starting recorder"; #if QT_VERSION_MAJOR > 5 #else m_bReadyRecord = true; if (m_camera && m_camera->captureMode() != QCamera::CaptureVideo) { - qDebug() << "Condition check: Setting camera to video capture mode"; + qCDebug(appLog) << "Condition check: Setting camera to video capture mode"; m_camera->setCaptureMode(QCamera::CaptureVideo); } m_bRecording = true; - qDebug() << "Recorder started successfully"; + qCDebug(appLog) << "Recorder started successfully"; #endif } void Camera::stopRecoder() { - qDebug() << "Stopping recorder"; + qCDebug(appLog) << "Stopping recorder"; #if QT_VERSION_MAJOR > 5 #else if (m_mediaRecoder) @@ -507,41 +509,41 @@ void Camera::stopRecoder() m_camera->setCaptureMode(QCamera::CaptureStillImage); m_bRecording = false; - qDebug() << "Recorder stopped successfully"; + qCDebug(appLog) << "Recorder stopped successfully"; #endif } qint64 Camera::getRecoderTime() { - qDebug() << "Function started: getRecoderTime"; + qCDebug(appLog) << "Function started: getRecoderTime"; qint64 nRecTime = 0; if (m_mediaRecoder) nRecTime = m_mediaRecoder->duration(); - qDebug() << "Function completed: getRecoderTime:" << nRecTime; + qCDebug(appLog) << "Function completed: getRecoderTime:" << nRecTime; return nRecTime; } #if QT_VERSION_MAJOR > 5 QMediaRecorder::RecorderState Camera::getRecoderState() { - qDebug() << "Function started: Camera::getRecoderState"; + qCDebug(appLog) << "Function started: Camera::getRecoderState"; QMediaRecorder::RecorderState recState = QMediaRecorder::StoppedState; if (m_mediaRecoder) recState = m_mediaRecoder->recorderState(); - qDebug() << "Function completed: Camera::getRecoderState"; + qCDebug(appLog) << "Function completed: Camera::getRecoderState"; return recState; } #else QMediaRecorder::State Camera::getRecoderState() { - qDebug() << "Function started: Camera::getRecoderState"; + qCDebug(appLog) << "Function started: Camera::getRecoderState"; QMediaRecorder::State recState = QMediaRecorder::StoppedState; if (m_mediaRecoder) recState = m_mediaRecoder->state(); - qDebug() << "Function completed: Camera::getRecoderState"; + qCDebug(appLog) << "Function completed: Camera::getRecoderState"; return recState; } #endif @@ -576,7 +578,7 @@ int Camera::parseConfig() { // qDebug() << "Condition check: Failed to open config file"; free(config_file); - qWarning() << "Could not open config file for reading:" << strerror(errno); + qCWarning(appLog) << "Could not open config file for reading:" << strerror(errno); return -1; } @@ -617,7 +619,7 @@ int Camera::parseConfig() /*skip invalid lines */ if(!token || !value || strlen(token) < 1 || strlen(value) < 1) { - qWarning() << "Skipping invalid config entry at line" << line; + qCWarning(appLog) << "Skipping invalid config entry at line" << line; if(token) free(token); if(value) @@ -627,18 +629,18 @@ int Camera::parseConfig() /*check tokens*/ if(strcmp(token, "width") == 0) { - qDebug() << "Condition check: Setting width"; + qCDebug(appLog) << "Condition check: Setting width"; camConfig.width = (int) strtoul(value, NULL, 10); } else if(strcmp(token, "height") == 0) { - qDebug() << "Condition check: Setting height"; + qCDebug(appLog) << "Condition check: Setting height"; camConfig.height = (int) strtoul(value, NULL, 10); } else if(strcmp(token, "device_name") == 0 && strlen(value) > 0) { - qDebug() << "Condition check: Setting device_name"; + qCDebug(appLog) << "Condition check: Setting device_name"; if(camConfig.device_name) free(camConfig.device_name); camConfig.device_name = strdup(value); } else if(strcmp(token, "device_location") == 0 && strlen(value) > 0) { - qDebug() << "Condition check: Setting device_location"; + qCDebug(appLog) << "Condition check: Setting device_location"; if(camConfig.device_location) free(camConfig.device_location); camConfig.device_location = strdup(value); @@ -652,13 +654,13 @@ int Camera::parseConfig() free(config_file); fclose(fp); - qDebug() << "Configuration parsed successfully"; + qCDebug(appLog) << "Configuration parsed successfully"; return 0; } int Camera::saveConfig() { - qDebug() << "Saving camera configuration"; + qCDebug(appLog) << "Saving camera configuration"; QString config_file = QString(getenv("HOME")) + QDir::separator() + QString(".config") + QDir::separator() + QString("deepin") + QDir::separator() + QString("deepin-camera") + QDir::separator() + QString("deepin-camera"); @@ -668,7 +670,7 @@ int Camera::saveConfig() /*open file for write*/ if((fp = fopen(filename,"w")) == NULL) { - qWarning() << "Could not open config file for writing:" << strerror(errno); + qCWarning(appLog) << "Could not open config file for writing:" << strerror(errno); free(filename); return -1; } @@ -710,10 +712,10 @@ int Camera::saveConfig() /* close file after fsync (sync file data to disk) */ if (fsync(fileno(fp)) || fclose(fp)) { - qWarning() << "Error writing configuration data to file:" << strerror(errno); + qCWarning(appLog) << "Error writing configuration data to file:" << strerror(errno); return -1; } - qDebug() << "Configuration saved successfully"; + qCDebug(appLog) << "Configuration saved successfully"; return 0; } diff --git a/src/src/capplication.cpp b/src/src/capplication.cpp index f7679b1d..2ebcad7f 100644 --- a/src/src/capplication.cpp +++ b/src/src/capplication.cpp @@ -1,16 +1,18 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later #include "capplication.h" +#include "ddlog.h" +using namespace DDLog; CApplication *CApplication::cameraCore = nullptr; CApplication::CApplication(int &argc, char **argv) : QtSingleApplication(argc, argv) { - qDebug() << "Function started: CApplication constructor"; + qCDebug(appLog) << "Function started: CApplication constructor"; m_mainwindow = nullptr; #ifndef TABLE_ENVIRONMENT m_bpanel = false; @@ -19,7 +21,7 @@ CApplication::CApplication(int &argc, char **argv) #endif if (cameraCore == nullptr) { - qDebug() << "Condition check: Setting cameraCore instance"; + qCDebug(appLog) << "Condition check: Setting cameraCore instance"; cameraCore = this; } @@ -28,7 +30,7 @@ CApplication::CApplication(int &argc, char **argv) Dtk::Core::DVtableHook::overrideVfptrFun(dApplication(), &DApplication::handleQuitAction, CamApp, &CApplication::QuitAction); - qDebug() << "Function completed: CApplication constructor"; + qCDebug(appLog) << "Function completed: CApplication constructor"; } CApplication *CApplication::CamApplication() diff --git a/src/src/circlepushbutton.cpp b/src/src/circlepushbutton.cpp index 818c21a3..a5832a5a 100644 --- a/src/src/circlepushbutton.cpp +++ b/src/src/circlepushbutton.cpp @@ -1,5 +1,5 @@ -// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd. -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// Copyright (C) 2020 - 2026 Uniontech Software Technology Co.,Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -11,6 +11,8 @@ #include #include #include +#include "ddlog.h" +using namespace DDLog; circlePushButton::circlePushButton(QWidget *parent): QPushButton(parent), m_radius(20) { @@ -270,7 +272,7 @@ void circlePushButton::setButtonRadius(int radius) { // qDebug() << "Function started: setButtonRadius"; if (radius <= 0) { - qWarning() << "Invalid button radius:" << radius; + qCWarning(appLog) << "Invalid button radius:" << radius; return; }