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.
 
 
 
 
 
 

94 lines
2.8 KiB

#ifndef __PROTOCOL_ZL_MEDIASERVER_REST_HEADER__
#define __PROTOCOL_ZL_MEDIASERVER_REST_HEADER__
#ifdef __linux__
#include <features.h>
#endif
#include "../../components/base/basicFunctionality.h"
#include "../../components/base/basicLogCollection.h"
#include "../../components/base/basicSettingsProvider.h"
#include "protocolHTTP.h"
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/timeb.h>
#include <sys/types.h>
#include <time.h>
#include <vector>
// https://github.com/xia-chu/ZLMediaKit/wiki
#define ZL_CMD_ADD_FFMPEG 1
#define ZL_CMD_ADD_PROXY 2
#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<ZL_STREAM_INFO *> 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(uint8_t CMD, 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);
CSTR addFFmpegSource(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