main.cpp 3.7 KB

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