main.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 {
  19. void InitWinRTCapture();
  20. }
  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. 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. ThemeManager::instance().setThemeMode(ThemeManager::Light);
  75. // 注册Room 相关的类型 方便 序列化
  76. void initRoomType();
  77. initRoomType();
  78. // 初始化wgc
  79. avrecorder::video::InitWinRTCapture();
  80. /*
  81. docker run -itd --name zlmediakit --restart=always
  82. -p 1935:1935 -p 8080:80 -p 8443:443
  83. -p 8554:554 -p 10000:10000
  84. -p 10000:10000/udp -p 8000:8000/udp
  85. -p 9000:9000/udp
  86. -v /data/zlmediakit/media/bin:/opt/media/bin
  87. -v /data/zlmediakit/media/conf:/opt/media/conf
  88. zlmediakit/zlmediakit:master
  89. */
  90. MainWindow w;
  91. w.show();
  92. // PlayWidget playWidget;
  93. // playWidget.resize(960, 540);
  94. // playWidget.show();
  95. // for (int var = 0; var < 20; ++var) {
  96. // playWidget.startToPlay("C:/Users/zhuizhu/Videos/2.mp4");
  97. // }
  98. // AvRecorder avRecorder;
  99. // avRecorder.show();
  100. // ThemeSettingsWidget ThemeSettingsWidget;
  101. // ThemeSettingsWidget.show();
  102. // PlayerWindow w;
  103. // w.resize(960, 540);
  104. // w.show();
  105. // MainWindowA aa;
  106. // aa.show();
  107. // // 这里填你的流地址
  108. // // w.startPlay("http://vd3.bdstatic.com/mda-jennyc5ci1ugrxzi/mda-jennyc5ci1ugrxzi.mp4");
  109. // w.open("C:/Users/zhuizhu/Videos/1.mp4");
  110. // // w.startPlay("rtmp://192.168.3.76:1935/stream/V1/stream");
  111. int ret = a.exec();
  112. return ret;
  113. }