1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00
srs/trunk/src/app/srs_app_http_api.hpp

230 lines
5.8 KiB
C++
Raw Normal View History

2017-03-25 09:21:39 +00:00
/**
* The MIT License (MIT)
*
2018-01-07 02:58:53 +00:00
* Copyright (c) 2013-2018 Winlin
2017-03-25 09:21:39 +00:00
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
2014-03-27 04:14:04 +00:00
#ifndef SRS_APP_HTTP_API_HPP
#define SRS_APP_HTTP_API_HPP
#include <srs_core.hpp>
class SrsStSocket;
class ISrsHttpMessage;
2014-04-02 04:55:10 +00:00
class SrsHttpParser;
2014-04-02 10:07:34 +00:00
class SrsHttpHandler;
2015-08-27 10:11:50 +00:00
class SrsServer;
2014-04-02 04:55:10 +00:00
#include <srs_app_st.hpp>
#include <srs_app_conn.hpp>
2015-05-22 14:34:03 +00:00
#include <srs_http_stack.hpp>
#include <srs_app_reload.hpp>
2014-04-02 10:07:34 +00:00
// for http root.
class SrsGoApiRoot : public ISrsHttpHandler
2014-04-02 10:07:34 +00:00
{
public:
SrsGoApiRoot();
virtual ~SrsGoApiRoot();
2014-04-02 10:07:34 +00:00
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
};
class SrsGoApiApi : public ISrsHttpHandler
{
public:
SrsGoApiApi();
virtual ~SrsGoApiApi();
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2014-04-02 10:07:34 +00:00
};
class SrsGoApiV1 : public ISrsHttpHandler
{
public:
SrsGoApiV1();
virtual ~SrsGoApiV1();
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
};
class SrsGoApiVersion : public ISrsHttpHandler
{
public:
SrsGoApiVersion();
virtual ~SrsGoApiVersion();
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
};
class SrsGoApiSummaries : public ISrsHttpHandler
{
public:
SrsGoApiSummaries();
virtual ~SrsGoApiSummaries();
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
};
class SrsGoApiRusages : public ISrsHttpHandler
2014-04-19 13:23:34 +00:00
{
public:
SrsGoApiRusages();
virtual ~SrsGoApiRusages();
2014-04-19 13:23:34 +00:00
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2014-04-19 13:23:34 +00:00
};
class SrsGoApiSelfProcStats : public ISrsHttpHandler
2014-04-19 13:23:34 +00:00
{
public:
SrsGoApiSelfProcStats();
virtual ~SrsGoApiSelfProcStats();
2014-04-19 13:23:34 +00:00
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2014-04-19 13:23:34 +00:00
};
class SrsGoApiSystemProcStats : public ISrsHttpHandler
2014-04-19 13:43:13 +00:00
{
public:
SrsGoApiSystemProcStats();
virtual ~SrsGoApiSystemProcStats();
2014-04-19 13:43:13 +00:00
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2014-04-19 13:43:13 +00:00
};
class SrsGoApiMemInfos : public ISrsHttpHandler
2014-04-19 13:43:13 +00:00
{
public:
SrsGoApiMemInfos();
virtual ~SrsGoApiMemInfos();
2014-04-19 13:43:13 +00:00
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2014-04-19 13:43:13 +00:00
};
class SrsGoApiAuthors : public ISrsHttpHandler
2014-04-19 16:15:26 +00:00
{
public:
SrsGoApiAuthors();
virtual ~SrsGoApiAuthors();
2014-04-19 16:15:26 +00:00
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2014-04-19 16:15:26 +00:00
};
2015-08-22 03:08:56 +00:00
class SrsGoApiFeatures : public ISrsHttpHandler
{
public:
SrsGoApiFeatures();
virtual ~SrsGoApiFeatures();
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2015-08-22 03:08:56 +00:00
};
class SrsGoApiRequests : public ISrsHttpHandler
2014-04-03 05:48:52 +00:00
{
public:
SrsGoApiRequests();
virtual ~SrsGoApiRequests();
2014-04-03 05:48:52 +00:00
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2014-04-03 05:48:52 +00:00
};
class SrsGoApiVhosts : public ISrsHttpHandler
2015-01-03 04:57:13 +00:00
{
public:
SrsGoApiVhosts();
virtual ~SrsGoApiVhosts();
2015-01-03 04:57:13 +00:00
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2015-01-03 04:57:13 +00:00
};
class SrsGoApiStreams : public ISrsHttpHandler
2015-01-03 04:57:13 +00:00
{
public:
SrsGoApiStreams();
virtual ~SrsGoApiStreams();
2015-01-03 04:57:13 +00:00
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2015-01-03 04:57:13 +00:00
};
class SrsGoApiClients : public ISrsHttpHandler
{
public:
SrsGoApiClients();
virtual ~SrsGoApiClients();
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
};
class SrsGoApiRaw : virtual public ISrsHttpHandler, virtual public ISrsReloadHandler
2015-08-27 10:11:50 +00:00
{
private:
SrsServer* server;
private:
bool raw_api;
bool allow_reload;
2015-08-28 05:01:04 +00:00
bool allow_query;
2015-08-30 15:08:27 +00:00
bool allow_update;
2015-08-27 10:11:50 +00:00
public:
SrsGoApiRaw(SrsServer* svr);
virtual ~SrsGoApiRaw();
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
// interface ISrsReloadHandler
public:
2017-09-22 08:14:30 +00:00
virtual srs_error_t on_reload_http_api_raw_api();
2015-08-27 10:11:50 +00:00
};
2015-08-10 08:41:25 +00:00
class SrsGoApiError : public ISrsHttpHandler
{
public:
SrsGoApiError();
virtual ~SrsGoApiError();
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
2015-08-10 08:41:25 +00:00
};
class SrsHttpApi : virtual public SrsConnection, virtual public ISrsReloadHandler
2014-03-27 04:14:04 +00:00
{
2014-04-02 04:55:10 +00:00
private:
SrsHttpParser* parser;
2016-12-15 07:00:08 +00:00
SrsHttpCorsMux* cors;
SrsHttpServeMux* mux;
2014-03-27 04:14:04 +00:00
public:
SrsHttpApi(IConnectionManager* cm, srs_netfd_t fd, SrsHttpServeMux* m, std::string cip);
2014-03-27 04:14:04 +00:00
virtual ~SrsHttpApi();
// interface IKbpsDelta
public:
virtual void resample();
virtual int64_t get_send_bytes_delta();
virtual int64_t get_recv_bytes_delta();
virtual void cleanup();
protected:
2017-07-29 13:39:57 +00:00
virtual srs_error_t do_cycle();
2014-04-02 04:55:10 +00:00
private:
2017-07-29 13:39:57 +00:00
virtual srs_error_t process_request(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
// interface ISrsReloadHandler
public:
2017-07-29 13:39:57 +00:00
virtual srs_error_t on_reload_http_api_crossdomain();
2014-03-27 04:14:04 +00:00
};
#endif
2014-04-01 08:06:32 +00:00