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.

84 lines
3.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
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_CMD_ADD_FFMPEG 1
  19. #define ZL_CMD_ADD_PROXY 2
  20. #define ZL_ADD_ENCODER_SOURCE ((CSTR) "index/api/addFFmpegSource" )
  21. #define ZL_ADD_STREAM_PROXY ((CSTR) "index/api/addStreamProxy" )
  22. #define ZL_CLOSE_STREAM ((CSTR) "index/api/close_stream" )
  23. #define ZL_DEL_ENCODER_SOURCE ((CSTR) "index/api/delFFmepgSource" )
  24. #define ZL_DEL_STREAM_PROXY ((CSTR) "index/api/delStreamProxy" )
  25. #define ZL_LIST_SESSIONS ((CSTR) "index/api/getAllSession" )
  26. #define ZL_LIST_API ((CSTR) "index/api/getApiList" )
  27. #define ZL_LIST_MEDIA ((CSTR) "index/api/getMediaList" )
  28. #define ZL_GET_SERVER_CONFIG ((CSTR) "index/api/getServerConfig" )
  29. #define ZL_GET_LOAD_STATS ((CSTR) "index/api/getThreadsLoad" )
  30. #define ZL_GET_WORK_LOAD_STATS ((CSTR) "index/api/getWorkThreadsLoad" )
  31. #define ZL_KICK_SESSION ((CSTR) "index/api/kick_session" )
  32. #define ZL_RESTART_SERVER ((CSTR) "index/api/restartServer" )
  33. #define ZL_SET_SERVER_CONFIG ((CSTR) "index/api/setServerConfig" )
  34. #define ZL_IS_MEDIA_ONLINE ((CSTR) "index/api/isMediaOnline" )
  35. typedef struct S_ZL_STREAM_INFO{
  36. uint32_t streamId;
  37. char key[129];
  38. }ZL_STREAM_INFO;
  39. typedef std::vector<ZL_STREAM_INFO *> V_ZL_STREAM_INFO;
  40. class protocolZLMEDIA : public protocolHTTP {
  41. private:
  42. basicLogCollection * m_pLog;
  43. config_setting_t * m_pSettings;
  44. char m_pSecret[256];
  45. char m_pAccessPoint[256];
  46. char m_pVHost[256];
  47. char m_pIP[16];
  48. bool m_bSessionOnGo;
  49. bool m_bServerIsPresent;
  50. bool m_bUseSSL;
  51. uint16_t m_nPort;
  52. V_ZL_STREAM_INFO m_vCurrentStreams;
  53. char m_pLastValue[256];
  54. CSTR buildURL( uint8_t CMD, uint32_t streamId, CSTR host, CSTR app, CSTR src );
  55. protected:
  56. virtual bool packetHandler( protocolPackage *Package );
  57. public:
  58. explicit protocolZLMEDIA( config_setting_t *Settings = NULL );
  59. explicit protocolZLMEDIA( CSTR key, CSTR host, CSTR ip, uint32_t port );
  60. ~protocolZLMEDIA();
  61. bool isOnline();
  62. bool restartServer();
  63. bool getConfig();
  64. CSTR addStreamProxy( uint32_t streamId, CSTR app, CSTR mrl );
  65. CSTR addFFmpegSource( uint32_t streamId, CSTR app, CSTR mrl );
  66. bool delStreamProxy( CSTR key );
  67. bool delAllStreamProxys( void );
  68. bool listMedia();
  69. V_ZL_STREAM_INFO *getStreams(){ return &m_vCurrentStreams;};
  70. bool requestIsFinished();
  71. };
  72. #endif