Files
dvr/http_server.h
2026-02-08 08:58:29 +08:00

48 lines
818 B
C++

#ifndef HTTP_SERVER_H
#define HTTP_SERVER_H
#include <QString>
#include <QDebug>
#include <QTimer>
#include "mongoose.h"
#include "hk-net-sdk.h"
#include "camera.h"
#include "camera_info.h"
class HttpServer : public QObject
{
Q_OBJECT
public:
/**
* 单例
*/
static HttpServer& instance();
/**
* 启动服务
*/
void start(const QString &host, int port);
/**
* 停止服务
*/
void stop();
private:
HttpServer() = default;
~HttpServer();
HttpServer(const HttpServer&) = delete;
HttpServer& operator=(const HttpServer&) = delete;
struct mg_mgr mgr;
QTimer *timer{nullptr};
static void ev_handler(struct mg_connection *c, int ev, void *ev_data);
static QHash<unsigned long, Camera*> sockets;
};
#endif // HTTP_SERVER_H