main.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. // 打开日志文件(覆盖模式)
  50. g_logFile.setFileName("log.txt");
  51. g_logFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
  52. g_logStream = new QTextStream(&g_logFile);
  53. // 安装日志处理器
  54. //qInstallMessageHandler(myMessageHandler);
  55. // std::freopen(nullptr, "w", stdout);
  56. setvbuf(stdout, nullptr, _IONBF, 0);
  57. #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
  58. QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
  59. Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
  60. #endif
  61. #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  62. QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  63. QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
  64. #endif
  65. QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
  66. QApplication a(argc, argv);
  67. ThemeManager::instance().setThemeMode(ThemeManager::Light);
  68. // 注册Room 相关的类型 方便 序列化
  69. void initRoomType();
  70. initRoomType();
  71. // 初始化wgc
  72. avrecorder::video::InitWinRTCapture();
  73. /*
  74. docker run -itd --name zlmediakit --restart=always
  75. -p 1935:1935 -p 8080:80 -p 8443:443
  76. -p 8554:554 -p 10000:10000
  77. -p 10000:10000/udp -p 8000:8000/udp
  78. -p 9000:9000/udp
  79. -v /data/zlmediakit/media/bin:/opt/media/bin
  80. -v /data/zlmediakit/media/conf:/opt/media/conf
  81. zlmediakit/zlmediakit:master
  82. */
  83. // MainWindow w;
  84. // w.show();
  85. // ThemeSettingsWidget ThemeSettingsWidget;
  86. // ThemeSettingsWidget.show();
  87. // PlayerWindow w;
  88. // w.resize(960, 540);
  89. // w.show();
  90. MainWindowA aa;
  91. aa.show();
  92. // // 这里填你的流地址
  93. // // w.startPlay("http://vd3.bdstatic.com/mda-jennyc5ci1ugrxzi/mda-jennyc5ci1ugrxzi.mp4");
  94. // w.open("C:/Users/zhuizhu/Videos/1.mp4");
  95. // // w.startPlay("rtmp://192.168.3.76:1935/stream/V1/stream");
  96. int ret = a.exec();
  97. delete g_logStream;
  98. g_logFile.close();
  99. return ret;
  100. }