main.cpp 2.5 KB

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