You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
3.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
6 years ago
​
​
​
​
​
6 years ago
​
​
​
​
6 years ago
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __PROTOCOL_ZL_MEDIASERVER_REST_HEADER__
  2. #define __PROTOCOL_ZL_MEDIASERVER_REST_HEADER__
  3. #ifdef __linux__
  4. #include <features.h>
  5. #endif
  6. #include "protocolHTTP.h"
  7. #include <time.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <sys/types.h>
  11. #include <sys/timeb.h>
  12. #include <string>
  13. #include <vector>
  14. #include "../../components/base/basicFunctionality.h"
  15. #include "../../components/base/basicLogCollection.h"
  16. #include "../../components/base/basicSettingsProvider.h"
  17. //https://github.com/xia-chu/ZLMediaKit/wiki
  18. #define ZL_ADD_ENCODER_SOURCE ((CSTR) "index/api/addFFmpegSource" )
  19. #define ZL_ADD_STREAM_PROXY ((CSTR) "index/api/addStreamProxy" )
  20. #define ZL_CLOSE_STREAM ((CSTR) "index/api/close_stream" )
  21. #define ZL_DEL_ENCODER_SOURCE ((CSTR) "index/api/delFFmepgSource" )
  22. #define ZL_DEL_STREAM_PROXY ((CSTR) "index/api/delStreamProxy" )
  23. #define ZL_LIST_SESSIONS ((CSTR) "index/api/getAllSession" )
  24. #define ZL_LIST_API ((CSTR) "index/api/getApiList" )
  25. #define ZL_LIST_MEDIA ((CSTR) "index/api/getMediaList" )
  26. #define ZL_GET_SERVER_CONFIG ((CSTR) "index/api/getServerConfig" )
  27. #define ZL_GET_LOAD_STATS ((CSTR) "index/api/getThreadsLoad" )
  28. #define ZL_GET_WORK_LOAD_STATS ((CSTR) "index/api/getWorkThreadsLoad" )
  29. #define ZL_KICK_SESSION ((CSTR) "index/api/kick_session" )
  30. #define ZL_RESTART_SERVER ((CSTR) "index/api/restartServer" )
  31. #define ZL_SET_SERVER_CONFIG ((CSTR) "index/api/setServerConfig" )
  32. #define ZL_IS_MEDIA_ONLINE ((CSTR) "index/api/isMediaOnline" )
  33. typedef struct S_ZL_STREAM_INFO{
  34. uint32_t streamId;
  35. char key[129];
  36. }ZL_STREAM_INFO;
  37. typedef std::vector<ZL_STREAM_INFO *> V_ZL_STREAM_INFO;
  38. class protocolZLMEDIA : public protocolHTTP {
  39. private:
  40. basicLogCollection * m_pLog;
  41. config_setting_t * m_pSettings;
  42. char m_pSecret[256];
  43. char m_pAccessPoint[256];
  44. char m_pVHost[256];
  45. char m_pIP[16];
  46. bool m_bSessionOnGo;
  47. bool m_bServerIsPresent;
  48. bool m_bUseSSL;
  49. uint16_t m_nPort;
  50. V_ZL_STREAM_INFO m_vCurrentStreams;
  51. char m_pLastValue[256];
  52. CSTR buildURL( CSTR base, uint32_t streamId, CSTR host, CSTR app, CSTR src );
  53. protected:
  54. virtual bool packetHandler( protocolPackage *Package );
  55. public:
  56. explicit protocolZLMEDIA( config_setting_t *Settings = NULL );
  57. explicit protocolZLMEDIA( CSTR key, CSTR host, CSTR ip, uint32_t port );
  58. ~protocolZLMEDIA();
  59. bool isOnline();
  60. bool restartServer();
  61. bool getConfig();
  62. CSTR addStreamProxy( uint32_t streamId, CSTR app, CSTR mrl );
  63. bool delStreamProxy( CSTR key );
  64. bool delAllStreamProxys( void );
  65. bool listMedia();
  66. V_ZL_STREAM_INFO *getStreams(){ return &m_vCurrentStreams;};
  67. bool requestIsFinished();
  68. };
  69. #endif