#ifndef C85BB91A_0670_4C40_AB2B_A96B8DDBC346 #define C85BB91A_0670_4C40_AB2B_A96B8DDBC346 /* ******************************************************************************* * INCLUDE ******************************************************************************* */ #include #include "Poco/Dynamic/Struct.h" #include "Poco/Tuple.h" #include "Poco/JSON/Object.h" #include "Poco/JSON/Parser.h" #include "Poco/JSON/Query.h" #include "Poco/JSON/JSONException.h" #include #include namespace Video { namespace ZLMediaKit { /* ******************************************************************************* * CLASS DECLARE ******************************************************************************* */ class Service { public: struct StremPusherProxyInfo { int code = 0; std::string msg; int status = 1; uint64_t liveSeconds; uint64_t republishCount; }; struct StreamProxyInfo { int code = 0; std::string msg; int status = 1; uint64_t liveSecs; uint64_t rePullCount; }; public: static std::string getDefaultHost(); static Poco::Dynamic::Array getMediaList(std::string schema = "", std::string app = "", std::string stream = ""); static bool isMediaOnline(std::string schema, std::string app, std::string stream); static Poco::Tuple addStreamPusherProxy(std::string schema, std::string app, std::string stream, std::string url, std::string rtp_type = "1"); static int delStreamPusherProxy(std::string key); static int getStremPusherProxyInfo(std::string key, StremPusherProxyInfo& info); static int startSendRtp(std::string app, std::string stream, std::string ssrc, std::string url, std::string port, std::string udp = "1"); static int startSendRtpPassive(std::string app, std::string stream, std::string ssrc, std::string udp = "1"); static int stopSendRtp(std::string app, std::string stream, std::string ssrc); static bool isRecording(std::string app, std::string stream, int type); static bool startRecord(std::string app, std::string stream, int type, std::string customized_path, int max_second); static bool stopRecord(std::string app, std::string stream, int type); static std::string getMp4RecordFile(std::string app, std::string stream, std::string period, std::string customized_path); static Poco::Tuple addStreamProxy(std::string app, std::string stream, std::string url, int auto_close = 1, int rtp_type = 0); static bool delStreamProxy(std::string key); static int getProxyInfo(std::string key, StreamProxyInfo& info); static Poco::Tuple close_streams(std::string app, std::string stream, int force = 1); static Poco::JSON::Object::Ptr getServerConfig(); template static T getServerConfigOne(std::string paramKey) { auto allConfig = getServerConfig(); T t = allConfig->getValue(paramKey); return t; } static bool setServerConfig(std::string key, std::string val); static Poco::Dynamic::Array listStreamProxy(); static Poco::Dynamic::Array listStreamPusherProxy(); private: static Poco::DynamicStruct sendRequest(std::string url); static Poco::JSON::Object::Ptr sendRequestReturnJson(std::string uri); static void addSecurityParameter(Poco::URI& uri); static Poco::AutoPtr loadIniFileConfig(); static int getHttpPort(); }; } } #endif