user_app.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #pragma once
  2. #include <iostream>
  3. #include <signal.h>
  4. // ZLMediaKit
  5. #include "Util/logger.h"
  6. #include "Util/NoticeCenter.h"
  7. #include "Poller/EventPoller.h"
  8. #include "Player/PlayerProxy.h"
  9. #include "Rtmp/RtmpPusher.h"
  10. #include "Common/config.h"
  11. #include "Pusher/MediaPusher.h"
  12. #include "Extension/Frame.h"
  13. #include "Util/SqlPool.h"
  14. #include "Network/TcpClient.h"
  15. #include "Poller/Timer.h"
  16. #include "TCPClient.h"
  17. #include "inifile.h"
  18. #include <gst/gst.h>
  19. #include <vector>
  20. #include <map>
  21. #include <time.h>
  22. #include "inference.h"
  23. #include "DataSource.h"
  24. // dataType
  25. #include "SendLogin.h"
  26. #include "NettyServerCommandEnum.h"
  27. #include "NettyServerResultMsg.h"
  28. #include "NettyClientResultMsg.h"
  29. #include "SendLogin.h"
  30. #include "NettyClientCommandEnum.h"
  31. #include "InferData.h"
  32. #include "PIDSClientResultMsg.h"
  33. #include "PIDSServerResultMsg.h"
  34. #include "Notices.h"
  35. using namespace toolkit;
  36. using namespace mediakit;
  37. using namespace inifile;
  38. using namespace std;
  39. namespace MIVA
  40. {
  41. class UserApp
  42. {
  43. public:
  44. static std::shared_ptr<UserApp> CreateNew();
  45. UserApp();
  46. ~UserApp();
  47. int32_t Init(std::string appName);
  48. void Destroy();
  49. void StartTask();
  50. static void makeAddr(struct sockaddr *out,const char *ip,uint16_t port);
  51. static uint32_t DataCalculation(uint32_t noLoad, uint32_t dynamicLoad, int num);
  52. static uint8_t GradeDetermination(int num);
  53. private:
  54. IniFile m_ini;
  55. std::string m_appName;
  56. const std::string m_configSrc = "../config/config.ini";
  57. private:
  58. // Natty
  59. std::string Netty_ip;
  60. int32_t Netty_port;
  61. std::string Netty_idName;
  62. // PIS
  63. std::string PIS_ip;
  64. int32_t PIS_port;
  65. std::string PIS_IdName;
  66. // Mysql
  67. std::string sql_ip;
  68. int32_t sql_port;
  69. std::string user;
  70. std::string password;
  71. std::string character;
  72. int device_id;
  73. private:
  74. std::shared_ptr<TCPClient> m_tcpClient = NULL;
  75. std::shared_ptr<Inference> m_Infer = NULL;
  76. Socket::Ptr m_udpClient = NULL;
  77. std::list<DataSource> DataList;
  78. Timer::Ptr m_timer0;
  79. Timer::Ptr m_timer1;
  80. Timer::Ptr m_timer2;
  81. private:
  82. void ListenInfer(int Source_id, int num);
  83. void ListenNettyData(const Buffer::Ptr &pBuf);
  84. void ListenPISData(const Buffer::Ptr &buf, struct sockaddr *addr);
  85. void ListenClosed();
  86. void ConnectNetty();
  87. void ReportData();
  88. };
  89. }