main.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 "mainwindow.h"
  14. #include "thememanager.h"
  15. #include "themesettingswidget.h"
  16. #include "tlogger.h"
  17. #include "AVPlayer/avplayerwidget.h"
  18. #include "AVPlayer/vframe.h"
  19. #include "widgets/recorderwidget.h"
  20. #undef ERROR
  21. // Qt输出(用于兼容现有Qt日志系统)
  22. namespace TC {
  23. class QtOutput : public LogOutput
  24. {
  25. public:
  26. void write(LogLevel level, const std::string &message) override;
  27. };
  28. void QtOutput::write(LogLevel level, const std::string &message)
  29. {
  30. const QString qmsg = QString::fromUtf8(message.c_str());
  31. switch (level) {
  32. case LogLevel::DEBUG:
  33. qDebug() << qmsg;
  34. break;
  35. case LogLevel::INFO:
  36. qInfo() << qmsg;
  37. break;
  38. case LogLevel::WARNING:
  39. qWarning() << qmsg;
  40. break;
  41. case LogLevel::ERROR:
  42. qCritical() << qmsg;
  43. break;
  44. }
  45. }
  46. } // namespace TC
  47. int main(int argc, char *argv[])
  48. {
  49. // "player.controller.ReadThread=false\n"
  50. QLoggingCategory::setFilterRules(QStringLiteral("player.controller.AudioPlayThread=false\n"
  51. "player.controller.AudioDecodeThread=false\n"));
  52. // QLoggingCategory::setFilterRules("*.debug=false\n"
  53. // "*.info=false\n"
  54. // "*.warning=false\n"
  55. // "*.critical=false\n"
  56. // "player.controller.*.debug=true\n"
  57. // "player.controller.*.info=true\n");
  58. // 安装日志处理器
  59. //qInstallMessageHandler(myMessageHandler);
  60. // std::freopen(nullptr, "w", stdout);
  61. setvbuf(stdout, nullptr, _IONBF, 0);
  62. #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
  63. QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
  64. Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
  65. #endif
  66. #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  67. QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  68. QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
  69. #endif
  70. QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
  71. QApplication a(argc, argv);
  72. qRegisterMetaType<AVFrame *>("AVFrame*");
  73. qRegisterMetaType<QSharedPointer<VideoFrame>>("QSharedPointer<VideoFrame>");
  74. ThemeManager::instance().setThemeMode(ThemeManager::Light);
  75. // 注册Room 相关的类型 方便 序列化
  76. void initRoomType();
  77. initRoomType();
  78. /*
  79. docker run -itd --name zlmediakit --restart=always
  80. -p 1935:1935 -p 8080:80 -p 8443:443
  81. -p 8554:554 -p 10000:10000
  82. -p 10000:10000/udp -p 8000:8000/udp
  83. -p 9000:9000/udp
  84. -v /data/zlmediakit/media/bin:/opt/media/bin
  85. -v /data/zlmediakit/media/conf:/opt/media/conf
  86. zlmediakit/zlmediakit:master
  87. */
  88. MainWindow w;
  89. w.show();
  90. // RecorderWidget testRecorder;
  91. // testRecorder.show();
  92. // AVPlayerWidget avPlayerWidget;
  93. // avPlayerWidget.show();
  94. int ret = a.exec();
  95. return ret;
  96. }