#ifndef __PROTOCOL_ZL_MEDIASERVER_REST_HEADER__ #define __PROTOCOL_ZL_MEDIASERVER_REST_HEADER__ #ifdef __linux__ #include #endif #include "protocolHTTP.h" #include #include #include #include #include #include #include #include "../../components/base/basicFunctionality.h" #include "../../components/base/basicLogCollection.h" #include "../../components/base/basicSettingsProvider.h" //https://github.com/xia-chu/ZLMediaKit/wiki #define ZL_ADD_ENCODER_SOURCE ((CSTR) "index/api/addFFmpegSource" ) #define ZL_ADD_STREAM_PROXY ((CSTR) "index/api/addStreamProxy" ) #define ZL_CLOSE_STREAM ((CSTR) "index/api/close_stream" ) #define ZL_DEL_ENCODER_SOURCE ((CSTR) "index/api/delFFmepgSource" ) #define ZL_DEL_STREAM_PROXY ((CSTR) "index/api/delStreamProxy" ) #define ZL_LIST_SESSIONS ((CSTR) "index/api/getAllSession" ) #define ZL_LIST_API ((CSTR) "index/api/getApiList" ) #define ZL_LIST_MEDIA ((CSTR) "index/api/getMediaList" ) #define ZL_GET_SERVER_CONFIG ((CSTR) "index/api/getServerConfig" ) #define ZL_GET_LOAD_STATS ((CSTR) "index/api/getThreadsLoad" ) #define ZL_GET_WORK_LOAD_STATS ((CSTR) "index/api/getWorkThreadsLoad" ) #define ZL_KICK_SESSION ((CSTR) "index/api/kick_session" ) #define ZL_RESTART_SERVER ((CSTR) "index/api/restartServer" ) #define ZL_SET_SERVER_CONFIG ((CSTR) "index/api/setServerConfig" ) #define ZL_IS_MEDIA_ONLINE ((CSTR) "index/api/isMediaOnline" ) typedef struct S_ZL_STREAM_INFO{ uint32_t streamId; char key[129]; }ZL_STREAM_INFO; typedef std::vector V_ZL_STREAM_INFO; class protocolZLMEDIA : public protocolHTTP { private: basicLogCollection * m_pLog; config_setting_t * m_pSettings; char m_pSecret[256]; char m_pAccessPoint[256]; char m_pVHost[256]; char m_pIP[16]; bool m_bSessionOnGo; bool m_bServerIsPresent; bool m_bUseSSL; uint16_t m_nPort; V_ZL_STREAM_INFO m_vCurrentStreams; char m_pLastValue[256]; CSTR buildURL( CSTR base, uint32_t streamId, CSTR host, CSTR app, CSTR src ); protected: virtual bool packetHandler( protocolPackage *Package ); public: explicit protocolZLMEDIA( config_setting_t *Settings = NULL ); explicit protocolZLMEDIA( CSTR key, CSTR host, CSTR ip, uint32_t port ); ~protocolZLMEDIA(); bool isOnline(); bool restartServer(); bool getConfig(); CSTR addStreamProxy( uint32_t streamId, CSTR app, CSTR mrl ); bool delStreamProxy( CSTR key ); bool delAllStreamProxys( void ); bool listMedia(); V_ZL_STREAM_INFO *getStreams(){ return &m_vCurrentStreams;}; bool requestIsFinished(); }; #endif