main.cpp 2.6 KB

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