main.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #include "AvPlayer/playerdemowindow.h"
  2. #include "mainwindow.h"
  3. #include "thememanager.h"
  4. #include "themesettingswidget.h"
  5. #include <QApplication>
  6. #include <QAudioDeviceInfo>
  7. #include <QAudioOutput>
  8. #include <QDebug>
  9. #include <QVBoxLayout>
  10. #include <qendian.h>
  11. #include <qmath.h>
  12. #include <QFile>
  13. #include <QTextStream>
  14. #include <QDateTime>
  15. #include <QMutex>
  16. QFile g_logFile;
  17. QTextStream* g_logStream = nullptr;
  18. QMutex g_logMutex;
  19. void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
  20. {
  21. QMutexLocker locker(&g_logMutex);
  22. if (!g_logStream) return;
  23. QString typeStr;
  24. switch (type) {
  25. case QtDebugMsg: typeStr = "DEBUG"; break;
  26. case QtWarningMsg: typeStr = "WARN "; break;
  27. case QtCriticalMsg: typeStr = "ERROR"; break;
  28. case QtFatalMsg: typeStr = "FATAL"; break;
  29. case QtInfoMsg:
  30. break;
  31. }
  32. QString logMsg = QString("%1 [%2] %3 (%4:%5)\n")
  33. .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz"))
  34. .arg(typeStr)
  35. .arg(msg)
  36. .arg(QString(context.file ? context.file : ""))
  37. .arg(context.line);
  38. (*g_logStream) << logMsg;
  39. g_logStream->flush();
  40. if (type == QtFatalMsg)
  41. abort();
  42. }
  43. namespace avrecorder::video { void InitWinRTCapture(); }
  44. int main(int argc, char* argv[])
  45. {
  46. // 打开日志文件(覆盖模式)
  47. g_logFile.setFileName("log.txt");
  48. g_logFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
  49. g_logStream = new QTextStream(&g_logFile);
  50. // 安装日志处理器
  51. //qInstallMessageHandler(myMessageHandler);
  52. // std::freopen(nullptr, "w", stdout);
  53. setvbuf(stdout, nullptr, _IONBF, 0);
  54. #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
  55. QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
  56. Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
  57. #endif
  58. #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  59. QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  60. QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
  61. #endif
  62. QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
  63. QApplication a(argc, argv);
  64. ThemeManager::instance().setThemeMode(ThemeManager::Light);
  65. // 注册Room 相关的类型 方便 序列化
  66. void initRoomType();
  67. initRoomType();
  68. // 初始化wgc
  69. avrecorder::video::InitWinRTCapture();
  70. /*
  71. docker run -itd --name zlmediakit --restart=always
  72. -p 1935:1935 -p 8080:80 -p 8443:443
  73. -p 8554:554 -p 10000:10000
  74. -p 10000:10000/udp -p 8000:8000/udp
  75. -p 9000:9000/udp
  76. -v /data/zlmediakit/media/bin:/opt/media/bin
  77. -v /data/zlmediakit/media/conf:/opt/media/conf
  78. zlmediakit/zlmediakit:master
  79. */
  80. MainWindow w;
  81. w.show();
  82. // ThemeSettingsWidget ThemeSettingsWidget;
  83. // ThemeSettingsWidget.show();
  84. // PlayerWindow w;
  85. // w.resize(960, 540);
  86. // w.show();
  87. // MainWindowA aa;
  88. // aa.show();
  89. // // 这里填你的流地址
  90. // // w.startPlay("http://vd3.bdstatic.com/mda-jennyc5ci1ugrxzi/mda-jennyc5ci1ugrxzi.mp4");
  91. // w.open("C:/Users/zhuizhu/Videos/1.mp4");
  92. // // w.startPlay("rtmp://192.168.3.76:1935/stream/V1/stream");
  93. int ret = a.exec();
  94. delete g_logStream;
  95. g_logFile.close();
  96. return ret;
  97. }