2014-03-27 04:14:04 +00:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
|
2014-12-31 12:32:09 +00:00
|
|
|
Copyright (c) 2013-2015 winlin
|
2014-03-27 04:14:04 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SRS_APP_HTTP_CONN_HPP
|
|
|
|
#define SRS_APP_HTTP_CONN_HPP
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include <srs_app_http_conn.hpp>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <srs_core.hpp>
|
|
|
|
|
2014-04-15 06:01:57 +00:00
|
|
|
#ifdef SRS_AUTO_HTTP_SERVER
|
2014-04-01 07:42:27 +00:00
|
|
|
|
2014-03-27 05:25:08 +00:00
|
|
|
#include <srs_app_st.hpp>
|
|
|
|
#include <srs_app_conn.hpp>
|
2014-04-04 10:55:21 +00:00
|
|
|
#include <srs_app_http.hpp>
|
2014-04-01 04:36:56 +00:00
|
|
|
|
2014-07-26 12:08:37 +00:00
|
|
|
class SrsStSocket;
|
2014-04-02 04:03:49 +00:00
|
|
|
class SrsHttpParser;
|
2014-04-01 10:40:24 +00:00
|
|
|
class SrsHttpMessage;
|
2014-04-02 10:07:34 +00:00
|
|
|
class SrsHttpHandler;
|
2014-04-01 04:36:56 +00:00
|
|
|
|
2015-01-17 15:00:40 +00:00
|
|
|
// for http server.
|
|
|
|
class SrsHttpServer
|
2014-04-04 10:55:21 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-01-17 15:00:40 +00:00
|
|
|
SrsGoHttpServeMux mux;
|
2014-04-04 10:55:21 +00:00
|
|
|
public:
|
2015-01-17 15:00:40 +00:00
|
|
|
SrsHttpServer();
|
|
|
|
virtual ~SrsHttpServer();
|
2014-04-04 10:55:21 +00:00
|
|
|
public:
|
2015-01-17 15:00:40 +00:00
|
|
|
virtual int initialize();
|
2014-04-04 10:55:21 +00:00
|
|
|
};
|
|
|
|
|
2014-03-27 05:25:08 +00:00
|
|
|
class SrsHttpConn : public SrsConnection
|
2014-03-27 04:14:04 +00:00
|
|
|
{
|
2014-04-01 04:36:56 +00:00
|
|
|
private:
|
2014-04-02 04:03:49 +00:00
|
|
|
SrsHttpParser* parser;
|
2015-01-17 15:00:40 +00:00
|
|
|
SrsHttpServer* mux;
|
2014-03-27 04:14:04 +00:00
|
|
|
public:
|
2015-01-17 15:00:40 +00:00
|
|
|
SrsHttpConn(SrsServer* svr, st_netfd_t fd, SrsHttpServer* m);
|
2014-03-27 04:14:04 +00:00
|
|
|
virtual ~SrsHttpConn();
|
2014-06-19 07:28:05 +00:00
|
|
|
public:
|
|
|
|
virtual void kbps_resample();
|
|
|
|
// interface IKbpsDelta
|
|
|
|
public:
|
|
|
|
virtual int64_t get_send_bytes_delta();
|
|
|
|
virtual int64_t get_recv_bytes_delta();
|
2014-03-27 05:25:08 +00:00
|
|
|
protected:
|
|
|
|
virtual int do_cycle();
|
2014-04-01 04:36:56 +00:00
|
|
|
private:
|
2015-01-17 15:00:40 +00:00
|
|
|
virtual int process_request(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r);
|
2014-03-27 04:14:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2014-04-01 07:42:27 +00:00
|
|
|
|
|
|
|
#endif
|
2014-08-02 14:18:39 +00:00
|
|
|
|