main.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #include "AvPlayer/playerdemowindow.h"
  2. #include "mainwindow.h"
  3. #include "thememanager.h"
  4. #include "themesettingswidget.h"
  5. #include <QApplication>
  6. #include <QAudioDeviceInfo>
  7. #include <QAudioOutput>
  8. #include <QDebug>
  9. #include <QVBoxLayout>
  10. #include <qendian.h>
  11. #include <qmath.h>
  12. #include <QFile>
  13. #include <QTextStream>
  14. #include <QDateTime>
  15. #include <QMutex>
  16. #include <AvRecorder/capturer/video/wgc_capturer.h>
  17. QFile g_logFile;
  18. QTextStream* g_logStream = nullptr;
  19. QMutex g_logMutex;
  20. void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
  21. {
  22. QMutexLocker locker(&g_logMutex);
  23. if (!g_logStream) return;
  24. QString typeStr;
  25. switch (type) {
  26. case QtDebugMsg: typeStr = "DEBUG"; break;
  27. case QtWarningMsg: typeStr = "WARN "; break;
  28. case QtCriticalMsg: typeStr = "ERROR"; break;
  29. case QtFatalMsg: typeStr = "FATAL"; break;
  30. case QtInfoMsg:
  31. break;
  32. }
  33. QString logMsg = QString("%1 [%2] %3 (%4:%5)\n")
  34. .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz"))
  35. .arg(typeStr)
  36. .arg(msg)
  37. .arg(QString(context.file ? context.file : ""))
  38. .arg(context.line);
  39. (*g_logStream) << logMsg;
  40. g_logStream->flush();
  41. if (type == QtFatalMsg)
  42. abort();
  43. }
  44. int main(int argc, char* argv[])
  45. {
  46. // 打开日志文件(覆盖模式)
  47. g_logFile.setFileName("log.txt");
  48. g_logFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
  49. g_logStream = new QTextStream(&g_logFile);
  50. // 安装日志处理器
  51. //qInstallMessageHandler(myMessageHandler);
  52. // std::freopen(nullptr, "w", stdout);
  53. setvbuf(stdout, nullptr, _IONBF, 0);
  54. QApplication a(argc, argv);
  55. ThemeManager::instance().setThemeMode(ThemeManager::Light);
  56. // 注册Room 相关的类型 方便 序列化
  57. void initRoomType();
  58. initRoomType();
  59. // 初始化wgc
  60. WgcCapturer::Init();
  61. /*
  62. docker run -itd --name zlmediakit --restart=always
  63. -p 1935:1935 -p 8080:80 -p 8443:443
  64. -p 8554:554 -p 10000:10000
  65. -p 10000:10000/udp -p 8000:8000/udp
  66. -p 9000:9000/udp
  67. -v /data/zlmediakit/media/bin:/opt/media/bin
  68. -v /data/zlmediakit/media/conf:/opt/media/conf
  69. zlmediakit/zlmediakit:master
  70. */
  71. MainWindow w;
  72. w.show();
  73. // ThemeSettingsWidget ThemeSettingsWidget;
  74. // ThemeSettingsWidget.show();
  75. // PlayerWindow w;
  76. // w.resize(960, 540);
  77. // w.show();
  78. // MainWindowA aa;
  79. // aa.show();
  80. // // 这里填你的流地址
  81. // // w.startPlay("http://vd3.bdstatic.com/mda-jennyc5ci1ugrxzi/mda-jennyc5ci1ugrxzi.mp4");
  82. // w.open("C:/Users/zhuizhu/Videos/1.mp4");
  83. // // w.startPlay("rtmp://192.168.3.76:1935/stream/V1/stream");
  84. int ret = a.exec();
  85. delete g_logStream;
  86. g_logFile.close();
  87. return ret;
  88. }