main.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // #include "AVPlayer2/mainwindowa.h"
  2. #include <QApplication>
  3. #include <QDateTime>
  4. #include <QDebug>
  5. #include <QFile>
  6. #include <QLoggingCategory>
  7. #include <QMutex>
  8. #include <QTextStream>
  9. #include <QVBoxLayout>
  10. #include <qendian.h>
  11. #include <qmath.h>
  12. #include "AVPlayer/vframe.h"
  13. #include "MainPanel.h"
  14. #include "mainwindow.h"
  15. #include "thememanager.h"
  16. #include "themesettingswidget.h"
  17. #include "tlogger.h"
  18. #include "AVPlayer/avplayerwidget.h"
  19. #include "AVPlayer/vframe.h"
  20. #include "widgets/recorderwidget.h"
  21. #undef ERROR
  22. // Qt输出(用于兼容现有Qt日志系统)
  23. namespace TC {
  24. class QtOutput : public LogOutput
  25. {
  26. public:
  27. void write(LogLevel level, const std::string &message) override;
  28. };
  29. void QtOutput::write(LogLevel level, const std::string &message)
  30. {
  31. const QString qmsg = QString::fromUtf8(message.c_str());
  32. switch (level) {
  33. case LogLevel::DEBUG:
  34. qDebug() << qmsg;
  35. break;
  36. case LogLevel::INFO:
  37. qInfo() << qmsg;
  38. break;
  39. case LogLevel::WARNING:
  40. qWarning() << qmsg;
  41. break;
  42. case LogLevel::ERROR:
  43. qCritical() << qmsg;
  44. break;
  45. }
  46. }
  47. } // namespace TC
  48. int main(int argc, char *argv[])
  49. {
  50. // "player.controller.ReadThread=false\n"
  51. QLoggingCategory::setFilterRules(QStringLiteral("player.controller.AudioPlayThread=false\n"
  52. "player.controller.AudioDecodeThread=false\n"));
  53. // QLoggingCategory::setFilterRules("*.debug=false\n"
  54. // "*.info=false\n"
  55. // "*.warning=false\n"
  56. // "*.critical=false\n"
  57. // "player.controller.*.debug=true\n"
  58. // "player.controller.*.info=true\n");
  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. qRegisterMetaType<AVFrame *>("AVFrame*");
  74. qRegisterMetaType<QSharedPointer<VideoFrame>>("QSharedPointer<VideoFrame>");
  75. ThemeManager::instance().setThemeMode(ThemeManager::Light);
  76. // 注册Room 相关的类型 方便 序列化
  77. void initRoomType();
  78. initRoomType();
  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. MainPanel MainPanel;
  92. MainPanel.show();
  93. MainPanel.startStreamingTest();
  94. // RecorderWidget testRecorder;
  95. // testRecorder.show();
  96. // AVPlayerWidget avPlayerWidget;
  97. // avPlayerWidget.show();
  98. int ret = a.exec();
  99. return ret;
  100. }