main.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 <AvPlayer2/PlayWidget.h>
  13. #include "mainwindow.h"
  14. #include "thememanager.h"
  15. #include "themesettingswidget.h"
  16. #include "tlogger.h"
  17. #include "ui/av_recorder.h"
  18. namespace avrecorder::video { void InitWinRTCapture(); }
  19. #undef ERROR
  20. // Qt输出(用于兼容现有Qt日志系统)
  21. namespace TC {
  22. class QtOutput : public LogOutput
  23. {
  24. public:
  25. void write(LogLevel level, const std::string &message) override;
  26. };
  27. void QtOutput::write(LogLevel level, const std::string &message)
  28. {
  29. QString qmsg = QString::fromUtf8(message.c_str());
  30. switch (level) {
  31. case LogLevel::DEBUG:
  32. qDebug() << qmsg;
  33. break;
  34. case LogLevel::INFO:
  35. qInfo() << qmsg;
  36. break;
  37. case LogLevel::WARNING:
  38. qWarning() << qmsg;
  39. break;
  40. case LogLevel::ERROR:
  41. qCritical() << qmsg;
  42. break;
  43. }
  44. }
  45. } // namespace TC
  46. int main(int argc, char *argv[])
  47. {
  48. // "player.controller.ReadThread=false\n"
  49. QLoggingCategory::setFilterRules(QStringLiteral("player.controller.AudioPlayThread=false\n"
  50. "player.controller.AudioDecodeThread=false\n"));
  51. // QLoggingCategory::setFilterRules("*.debug=false\n"
  52. // "*.info=false\n"
  53. // "*.warning=false\n"
  54. // "*.critical=false\n"
  55. // "player.controller.*.debug=true\n"
  56. // "player.controller.*.info=true\n");
  57. // 安装日志处理器
  58. //qInstallMessageHandler(myMessageHandler);
  59. // std::freopen(nullptr, "w", stdout);
  60. setvbuf(stdout, nullptr, _IONBF, 0);
  61. #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
  62. QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
  63. Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
  64. #endif
  65. #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  66. QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  67. QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
  68. #endif
  69. QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
  70. QApplication a(argc, argv);
  71. qRegisterMetaType<AVFrame *>("AVFrame*");
  72. ThemeManager::instance().setThemeMode(ThemeManager::Light);
  73. // 注册Room 相关的类型 方便 序列化
  74. void initRoomType();
  75. initRoomType();
  76. // 初始化wgc
  77. avrecorder::video::InitWinRTCapture();
  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. // PlayWidget playWidget;
  91. // playWidget.resize(960, 540);
  92. // playWidget.show();
  93. // for (int var = 0; var < 20; ++var) {
  94. // playWidget.startToPlay("C:/Users/zhuizhu/Videos/2.mp4");
  95. // }
  96. // AvRecorder avRecorder;
  97. // avRecorder.show();
  98. // ThemeSettingsWidget ThemeSettingsWidget;
  99. // ThemeSettingsWidget.show();
  100. // PlayerWindow w;
  101. // w.resize(960, 540);
  102. // w.show();
  103. // MainWindowA aa;
  104. // aa.show();
  105. // // 这里填你的流地址
  106. // // w.startPlay("http://vd3.bdstatic.com/mda-jennyc5ci1ugrxzi/mda-jennyc5ci1ugrxzi.mp4");
  107. // w.open("C:/Users/zhuizhu/Videos/1.mp4");
  108. // // w.startPlay("rtmp://192.168.3.76:1935/stream/V1/stream");
  109. int ret = a.exec();
  110. return ret;
  111. }