main.cpp 3.3 KB

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