正在显示
12 个修改的文件
包含
133 行增加
和
31 行删除
| @@ -25,23 +25,66 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -25,23 +25,66 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 25 | 25 | ||
| 26 | #ifdef SRS_AUTO_STREAM_CASTER | 26 | #ifdef SRS_AUTO_STREAM_CASTER |
| 27 | 27 | ||
| 28 | +#include <algorithm> | ||
| 29 | +using namespace std; | ||
| 30 | + | ||
| 28 | #include <srs_app_config.hpp> | 31 | #include <srs_app_config.hpp> |
| 29 | #include <srs_kernel_error.hpp> | 32 | #include <srs_kernel_error.hpp> |
| 30 | #include <srs_kernel_log.hpp> | 33 | #include <srs_kernel_log.hpp> |
| 31 | #include <srs_app_config.hpp> | 34 | #include <srs_app_config.hpp> |
| 32 | #include <srs_app_pithy_print.hpp> | 35 | #include <srs_app_pithy_print.hpp> |
| 36 | +#include <srs_app_http.hpp> | ||
| 37 | +#include <srs_app_http_conn.hpp> | ||
| 33 | 38 | ||
| 34 | SrsAppCasterFlv::SrsAppCasterFlv(SrsConfDirective* c) | 39 | SrsAppCasterFlv::SrsAppCasterFlv(SrsConfDirective* c) |
| 35 | { | 40 | { |
| 41 | + http_mux = new SrsHttpServeMux(); | ||
| 42 | + output = _srs_config->get_stream_caster_output(c); | ||
| 36 | } | 43 | } |
| 37 | 44 | ||
| 38 | SrsAppCasterFlv::~SrsAppCasterFlv() | 45 | SrsAppCasterFlv::~SrsAppCasterFlv() |
| 39 | { | 46 | { |
| 40 | } | 47 | } |
| 41 | 48 | ||
| 49 | +int SrsAppCasterFlv::initialize() | ||
| 50 | +{ | ||
| 51 | + int ret = ERROR_SUCCESS; | ||
| 52 | + | ||
| 53 | + if ((ret = http_mux->handle("/", this)) != ERROR_SUCCESS) { | ||
| 54 | + return ret; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + return ret; | ||
| 58 | +} | ||
| 59 | + | ||
| 42 | int SrsAppCasterFlv::on_tcp_client(st_netfd_t stfd) | 60 | int SrsAppCasterFlv::on_tcp_client(st_netfd_t stfd) |
| 43 | { | 61 | { |
| 44 | int ret = ERROR_SUCCESS; | 62 | int ret = ERROR_SUCCESS; |
| 63 | + | ||
| 64 | + SrsHttpConn* conn = new SrsHttpConn(this, stfd, http_mux); | ||
| 65 | + conns.push_back(conn); | ||
| 66 | + | ||
| 67 | + if ((ret = conn->start()) != ERROR_SUCCESS) { | ||
| 68 | + return ret; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + return ret; | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +void SrsAppCasterFlv::remove(SrsConnection* c) | ||
| 75 | +{ | ||
| 76 | + std::vector<SrsHttpConn*>::iterator it; | ||
| 77 | + if ((it = std::find(conns.begin(), conns.end(), c)) != conns.end()) { | ||
| 78 | + conns.erase(it); | ||
| 79 | + } | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | +int SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 83 | +{ | ||
| 84 | + int ret = ERROR_SUCCESS; | ||
| 85 | + | ||
| 86 | + srs_trace("flv: handle request at %s", r->path().c_str()); | ||
| 87 | + | ||
| 45 | return ret; | 88 | return ret; |
| 46 | } | 89 | } |
| 47 | 90 |
| @@ -30,21 +30,41 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -30,21 +30,41 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 30 | 30 | ||
| 31 | #include <srs_core.hpp> | 31 | #include <srs_core.hpp> |
| 32 | 32 | ||
| 33 | +#include <string> | ||
| 34 | +#include <vector> | ||
| 35 | + | ||
| 33 | #ifdef SRS_AUTO_STREAM_CASTER | 36 | #ifdef SRS_AUTO_STREAM_CASTER |
| 34 | 37 | ||
| 35 | class SrsConfDirective; | 38 | class SrsConfDirective; |
| 39 | +class SrsHttpServeMux; | ||
| 40 | +class SrsHttpConn; | ||
| 36 | 41 | ||
| 37 | #include <srs_app_st.hpp> | 42 | #include <srs_app_st.hpp> |
| 38 | #include <srs_app_listener.hpp> | 43 | #include <srs_app_listener.hpp> |
| 44 | +#include <srs_app_conn.hpp> | ||
| 45 | +#include <srs_app_http.hpp> | ||
| 39 | 46 | ||
| 40 | -class SrsAppCasterFlv : public ISrsTcpHandler | 47 | +class SrsAppCasterFlv : virtual public ISrsTcpHandler |
| 48 | + , virtual public IConnectionManager, virtual public ISrsHttpHandler | ||
| 41 | { | 49 | { |
| 50 | +private: | ||
| 51 | + std::string output; | ||
| 52 | + SrsHttpServeMux* http_mux; | ||
| 53 | + std::vector<SrsHttpConn*> conns; | ||
| 42 | public: | 54 | public: |
| 43 | SrsAppCasterFlv(SrsConfDirective* c); | 55 | SrsAppCasterFlv(SrsConfDirective* c); |
| 44 | virtual ~SrsAppCasterFlv(); | 56 | virtual ~SrsAppCasterFlv(); |
| 57 | +public: | ||
| 58 | + virtual int initialize(); | ||
| 45 | // ISrsTcpHandler | 59 | // ISrsTcpHandler |
| 46 | public: | 60 | public: |
| 47 | virtual int on_tcp_client(st_netfd_t stfd); | 61 | virtual int on_tcp_client(st_netfd_t stfd); |
| 62 | +// IConnectionManager | ||
| 63 | +public: | ||
| 64 | + virtual void remove(SrsConnection* c); | ||
| 65 | +// ISrsHttpHandler | ||
| 66 | +public: | ||
| 67 | + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r); | ||
| 48 | }; | 68 | }; |
| 49 | 69 | ||
| 50 | #endif | 70 | #endif |
| @@ -25,14 +25,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -25,14 +25,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 25 | 25 | ||
| 26 | #include <srs_kernel_log.hpp> | 26 | #include <srs_kernel_log.hpp> |
| 27 | #include <srs_kernel_error.hpp> | 27 | #include <srs_kernel_error.hpp> |
| 28 | -#include <srs_app_server.hpp> | ||
| 29 | #include <srs_app_utility.hpp> | 28 | #include <srs_app_utility.hpp> |
| 30 | 29 | ||
| 31 | -SrsConnection::SrsConnection(SrsServer* srs_server, st_netfd_t client_stfd) | 30 | +IConnectionManager::IConnectionManager() |
| 31 | +{ | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +IConnectionManager::~IConnectionManager() | ||
| 35 | +{ | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c) | ||
| 32 | { | 39 | { |
| 33 | id = 0; | 40 | id = 0; |
| 34 | - server = srs_server; | ||
| 35 | - stfd = client_stfd; | 41 | + manager = cm; |
| 42 | + stfd = c; | ||
| 36 | 43 | ||
| 37 | // the client thread should reap itself, | 44 | // the client thread should reap itself, |
| 38 | // so we never use joinable. | 45 | // so we never use joinable. |
| @@ -86,7 +93,7 @@ int SrsConnection::cycle() | @@ -86,7 +93,7 @@ int SrsConnection::cycle() | ||
| 86 | void SrsConnection::on_thread_stop() | 93 | void SrsConnection::on_thread_stop() |
| 87 | { | 94 | { |
| 88 | // TODO: FIXME: never remove itself, use isolate thread to do cleanup. | 95 | // TODO: FIXME: never remove itself, use isolate thread to do cleanup. |
| 89 | - server->remove(this); | 96 | + manager->remove(this); |
| 90 | } | 97 | } |
| 91 | 98 | ||
| 92 | int SrsConnection::srs_id() | 99 | int SrsConnection::srs_id() |
| @@ -36,7 +36,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -36,7 +36,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 36 | #include <srs_app_thread.hpp> | 36 | #include <srs_app_thread.hpp> |
| 37 | #include <srs_app_kbps.hpp> | 37 | #include <srs_app_kbps.hpp> |
| 38 | 38 | ||
| 39 | -class SrsServer; | 39 | +class SrsConnection; |
| 40 | + | ||
| 41 | +/** | ||
| 42 | + * the manager for connection. | ||
| 43 | + */ | ||
| 44 | +class IConnectionManager | ||
| 45 | +{ | ||
| 46 | +public: | ||
| 47 | + IConnectionManager(); | ||
| 48 | + virtual ~IConnectionManager(); | ||
| 49 | +public: | ||
| 50 | + /** | ||
| 51 | + * remove the specified connection. | ||
| 52 | + */ | ||
| 53 | + virtual void remove(SrsConnection* c) = 0; | ||
| 54 | +}; | ||
| 40 | 55 | ||
| 41 | /** | 56 | /** |
| 42 | * the basic connection of SRS, | 57 | * the basic connection of SRS, |
| @@ -57,9 +72,9 @@ private: | @@ -57,9 +72,9 @@ private: | ||
| 57 | int id; | 72 | int id; |
| 58 | protected: | 73 | protected: |
| 59 | /** | 74 | /** |
| 60 | - * the server object to manage the connection. | 75 | + * the manager object to manage the connection. |
| 61 | */ | 76 | */ |
| 62 | - SrsServer* server; | 77 | + IConnectionManager* manager; |
| 63 | /** | 78 | /** |
| 64 | * the underlayer st fd handler. | 79 | * the underlayer st fd handler. |
| 65 | */ | 80 | */ |
| @@ -69,7 +84,7 @@ protected: | @@ -69,7 +84,7 @@ protected: | ||
| 69 | */ | 84 | */ |
| 70 | std::string ip; | 85 | std::string ip; |
| 71 | public: | 86 | public: |
| 72 | - SrsConnection(SrsServer* srs_server, st_netfd_t client_stfd); | 87 | + SrsConnection(IConnectionManager* cm, st_netfd_t c); |
| 73 | virtual ~SrsConnection(); | 88 | virtual ~SrsConnection(); |
| 74 | public: | 89 | public: |
| 75 | /** | 90 | /** |
| @@ -473,8 +473,8 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -473,8 +473,8 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 473 | return srs_go_http_response_json(w, ss.str()); | 473 | return srs_go_http_response_json(w, ss.str()); |
| 474 | } | 474 | } |
| 475 | 475 | ||
| 476 | -SrsHttpApi::SrsHttpApi(SrsServer* svr, st_netfd_t fd, SrsHttpServeMux* m) | ||
| 477 | - : SrsConnection(svr, fd) | 476 | +SrsHttpApi::SrsHttpApi(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m) |
| 477 | + : SrsConnection(cm, fd) | ||
| 478 | { | 478 | { |
| 479 | mux = m; | 479 | mux = m; |
| 480 | parser = new SrsHttpParser(); | 480 | parser = new SrsHttpParser(); |
| @@ -166,7 +166,7 @@ private: | @@ -166,7 +166,7 @@ private: | ||
| 166 | SrsHttpServeMux* mux; | 166 | SrsHttpServeMux* mux; |
| 167 | bool crossdomain_required; | 167 | bool crossdomain_required; |
| 168 | public: | 168 | public: |
| 169 | - SrsHttpApi(SrsServer* svr, st_netfd_t fd, SrsHttpServeMux* m); | 169 | + SrsHttpApi(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m); |
| 170 | virtual ~SrsHttpApi(); | 170 | virtual ~SrsHttpApi(); |
| 171 | // interface IKbpsDelta | 171 | // interface IKbpsDelta |
| 172 | public: | 172 | public: |
| @@ -1334,11 +1334,11 @@ int SrsHttpServer::initialize_hls_streaming() | @@ -1334,11 +1334,11 @@ int SrsHttpServer::initialize_hls_streaming() | ||
| 1334 | return ret; | 1334 | return ret; |
| 1335 | } | 1335 | } |
| 1336 | 1336 | ||
| 1337 | -SrsHttpConn::SrsHttpConn(SrsServer* svr, st_netfd_t fd, SrsHttpServer* m) | ||
| 1338 | - : SrsConnection(svr, fd) | 1337 | +SrsHttpConn::SrsHttpConn(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m) |
| 1338 | + : SrsConnection(cm, fd) | ||
| 1339 | { | 1339 | { |
| 1340 | parser = new SrsHttpParser(); | 1340 | parser = new SrsHttpParser(); |
| 1341 | - http_server = m; | 1341 | + http_mux = m; |
| 1342 | } | 1342 | } |
| 1343 | 1343 | ||
| 1344 | SrsHttpConn::~SrsHttpConn() | 1344 | SrsHttpConn::~SrsHttpConn() |
| @@ -1424,7 +1424,7 @@ int SrsHttpConn::process_request(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -1424,7 +1424,7 @@ int SrsHttpConn::process_request(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 1424 | r->method_str().c_str(), r->url().c_str(), r->content_length()); | 1424 | r->method_str().c_str(), r->url().c_str(), r->content_length()); |
| 1425 | 1425 | ||
| 1426 | // use default server mux to serve http request. | 1426 | // use default server mux to serve http request. |
| 1427 | - if ((ret = http_server->mux.serve_http(w, r)) != ERROR_SUCCESS) { | 1427 | + if ((ret = http_mux->serve_http(w, r)) != ERROR_SUCCESS) { |
| 1428 | if (!srs_is_client_gracefully_close(ret)) { | 1428 | if (!srs_is_client_gracefully_close(ret)) { |
| 1429 | srs_error("serve http msg failed. ret=%d", ret); | 1429 | srs_error("serve http msg failed. ret=%d", ret); |
| 1430 | } | 1430 | } |
| @@ -39,6 +39,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -39,6 +39,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 39 | #include <srs_kernel_file.hpp> | 39 | #include <srs_kernel_file.hpp> |
| 40 | #include <srs_app_thread.hpp> | 40 | #include <srs_app_thread.hpp> |
| 41 | 41 | ||
| 42 | +class SrsServer; | ||
| 42 | class SrsSource; | 43 | class SrsSource; |
| 43 | class SrsRequest; | 44 | class SrsRequest; |
| 44 | class SrsConsumer; | 45 | class SrsConsumer; |
| @@ -375,9 +376,9 @@ class SrsHttpConn : public SrsConnection | @@ -375,9 +376,9 @@ class SrsHttpConn : public SrsConnection | ||
| 375 | { | 376 | { |
| 376 | private: | 377 | private: |
| 377 | SrsHttpParser* parser; | 378 | SrsHttpParser* parser; |
| 378 | - SrsHttpServer* http_server; | 379 | + SrsHttpServeMux* http_mux; |
| 379 | public: | 380 | public: |
| 380 | - SrsHttpConn(SrsServer* svr, st_netfd_t fd, SrsHttpServer* m); | 381 | + SrsHttpConn(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m); |
| 381 | virtual ~SrsHttpConn(); | 382 | virtual ~SrsHttpConn(); |
| 382 | // interface IKbpsDelta | 383 | // interface IKbpsDelta |
| 383 | public: | 384 | public: |
| @@ -75,12 +75,13 @@ using namespace std; | @@ -75,12 +75,13 @@ using namespace std; | ||
| 75 | // when edge timeout, retry next. | 75 | // when edge timeout, retry next. |
| 76 | #define SRS_EDGE_TOKEN_TRAVERSE_TIMEOUT_US (int64_t)(3*1000*1000LL) | 76 | #define SRS_EDGE_TOKEN_TRAVERSE_TIMEOUT_US (int64_t)(3*1000*1000LL) |
| 77 | 77 | ||
| 78 | -SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd) | ||
| 79 | - : SrsConnection(srs_server, client_stfd) | 78 | +SrsRtmpConn::SrsRtmpConn(SrsServer* svr, st_netfd_t c) |
| 79 | + : SrsConnection(svr, c) | ||
| 80 | { | 80 | { |
| 81 | + server = svr; | ||
| 81 | req = new SrsRequest(); | 82 | req = new SrsRequest(); |
| 82 | res = new SrsResponse(); | 83 | res = new SrsResponse(); |
| 83 | - skt = new SrsStSocket(client_stfd); | 84 | + skt = new SrsStSocket(c); |
| 84 | rtmp = new SrsRtmpServer(skt); | 85 | rtmp = new SrsRtmpServer(skt); |
| 85 | refer = new SrsRefer(); | 86 | refer = new SrsRefer(); |
| 86 | bandwidth = new SrsBandwidth(); | 87 | bandwidth = new SrsBandwidth(); |
| @@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 34 | #include <srs_app_conn.hpp> | 34 | #include <srs_app_conn.hpp> |
| 35 | #include <srs_app_reload.hpp> | 35 | #include <srs_app_reload.hpp> |
| 36 | 36 | ||
| 37 | +class SrsServer; | ||
| 37 | class SrsRtmpServer; | 38 | class SrsRtmpServer; |
| 38 | class SrsRequest; | 39 | class SrsRequest; |
| 39 | class SrsResponse; | 40 | class SrsResponse; |
| @@ -61,6 +62,7 @@ class SrsRtmpConn : public virtual SrsConnection, public virtual ISrsReloadHandl | @@ -61,6 +62,7 @@ class SrsRtmpConn : public virtual SrsConnection, public virtual ISrsReloadHandl | ||
| 61 | // for the thread to directly access any field of connection. | 62 | // for the thread to directly access any field of connection. |
| 62 | friend class SrsPublishRecvThread; | 63 | friend class SrsPublishRecvThread; |
| 63 | private: | 64 | private: |
| 65 | + SrsServer* server; | ||
| 64 | SrsRequest* req; | 66 | SrsRequest* req; |
| 65 | SrsResponse* res; | 67 | SrsResponse* res; |
| 66 | SrsStSocket* skt; | 68 | SrsStSocket* skt; |
| @@ -81,7 +83,7 @@ private: | @@ -81,7 +83,7 @@ private: | ||
| 81 | // @see https://github.com/simple-rtmp-server/srs/issues/257 | 83 | // @see https://github.com/simple-rtmp-server/srs/issues/257 |
| 82 | bool realtime; | 84 | bool realtime; |
| 83 | public: | 85 | public: |
| 84 | - SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd); | 86 | + SrsRtmpConn(SrsServer* svr, st_netfd_t c); |
| 85 | virtual ~SrsRtmpConn(); | 87 | virtual ~SrsRtmpConn(); |
| 86 | protected: | 88 | protected: |
| 87 | virtual int do_cycle(); | 89 | virtual int do_cycle(); |
| @@ -106,6 +106,8 @@ std::string srs_listener_type2string(SrsListenerType type) | @@ -106,6 +106,8 @@ std::string srs_listener_type2string(SrsListenerType type) | ||
| 106 | return "MPEG-TS over UDP"; | 106 | return "MPEG-TS over UDP"; |
| 107 | case SrsListenerRtsp: | 107 | case SrsListenerRtsp: |
| 108 | return "RTSP"; | 108 | return "RTSP"; |
| 109 | + case SrsListenerFlv: | ||
| 110 | + return "HTTP-FLV"; | ||
| 109 | default: | 111 | default: |
| 110 | return "UNKONWN"; | 112 | return "UNKONWN"; |
| 111 | } | 113 | } |
| @@ -238,8 +240,8 @@ SrsHttpFlvListener::SrsHttpFlvListener(SrsServer* server, SrsListenerType type, | @@ -238,8 +240,8 @@ SrsHttpFlvListener::SrsHttpFlvListener(SrsServer* server, SrsListenerType type, | ||
| 238 | 240 | ||
| 239 | // the caller already ensure the type is ok, | 241 | // the caller already ensure the type is ok, |
| 240 | // we just assert here for unknown stream caster. | 242 | // we just assert here for unknown stream caster. |
| 241 | - srs_assert(_type == SrsListenerRtsp); | ||
| 242 | - if (_type == SrsListenerRtsp) { | 243 | + srs_assert(_type == SrsListenerFlv); |
| 244 | + if (_type == SrsListenerFlv) { | ||
| 243 | caster = new SrsAppCasterFlv(c); | 245 | caster = new SrsAppCasterFlv(c); |
| 244 | } | 246 | } |
| 245 | } | 247 | } |
| @@ -256,11 +258,15 @@ int SrsHttpFlvListener::listen(string ip, int port) | @@ -256,11 +258,15 @@ int SrsHttpFlvListener::listen(string ip, int port) | ||
| 256 | 258 | ||
| 257 | // the caller already ensure the type is ok, | 259 | // the caller already ensure the type is ok, |
| 258 | // we just assert here for unknown stream caster. | 260 | // we just assert here for unknown stream caster. |
| 259 | - srs_assert(_type == SrsListenerRtsp); | 261 | + srs_assert(_type == SrsListenerFlv); |
| 260 | 262 | ||
| 261 | _ip = ip; | 263 | _ip = ip; |
| 262 | _port = port; | 264 | _port = port; |
| 263 | 265 | ||
| 266 | + if ((ret = caster->initialize()) != ERROR_SUCCESS) { | ||
| 267 | + return ret; | ||
| 268 | + } | ||
| 269 | + | ||
| 264 | srs_freep(listener); | 270 | srs_freep(listener); |
| 265 | listener = new SrsTcpListener(this, ip, port); | 271 | listener = new SrsTcpListener(this, ip, port); |
| 266 | 272 | ||
| @@ -1157,7 +1163,7 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd) | @@ -1157,7 +1163,7 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd) | ||
| 1157 | #endif | 1163 | #endif |
| 1158 | } else if (type == SrsListenerHttpStream) { | 1164 | } else if (type == SrsListenerHttpStream) { |
| 1159 | #ifdef SRS_AUTO_HTTP_SERVER | 1165 | #ifdef SRS_AUTO_HTTP_SERVER |
| 1160 | - conn = new SrsHttpConn(this, client_stfd, http_stream_mux); | 1166 | + conn = new SrsHttpConn(this, client_stfd, &http_stream_mux->mux); |
| 1161 | #else | 1167 | #else |
| 1162 | srs_warn("close http client for server not support http-server"); | 1168 | srs_warn("close http client for server not support http-server"); |
| 1163 | srs_close_stfd(client_stfd); | 1169 | srs_close_stfd(client_stfd); |
| @@ -38,6 +38,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -38,6 +38,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 38 | #include <srs_app_source.hpp> | 38 | #include <srs_app_source.hpp> |
| 39 | #include <srs_app_hls.hpp> | 39 | #include <srs_app_hls.hpp> |
| 40 | #include <srs_app_listener.hpp> | 40 | #include <srs_app_listener.hpp> |
| 41 | +#include <srs_app_conn.hpp> | ||
| 41 | 42 | ||
| 42 | class SrsServer; | 43 | class SrsServer; |
| 43 | class SrsConnection; | 44 | class SrsConnection; |
| @@ -51,6 +52,9 @@ class ISrsTcpHandler; | @@ -51,6 +52,9 @@ class ISrsTcpHandler; | ||
| 51 | class ISrsUdpHandler; | 52 | class ISrsUdpHandler; |
| 52 | class SrsUdpListener; | 53 | class SrsUdpListener; |
| 53 | class SrsTcpListener; | 54 | class SrsTcpListener; |
| 55 | +#ifdef SRS_AUTO_STREAM_CASTER | ||
| 56 | +class SrsAppCasterFlv; | ||
| 57 | +#endif | ||
| 54 | 58 | ||
| 55 | // listener type for server to identify the connection, | 59 | // listener type for server to identify the connection, |
| 56 | // that is, use different type to process the connection. | 60 | // that is, use different type to process the connection. |
| @@ -66,7 +70,7 @@ enum SrsListenerType | @@ -66,7 +70,7 @@ enum SrsListenerType | ||
| 66 | SrsListenerMpegTsOverUdp = 3, | 70 | SrsListenerMpegTsOverUdp = 3, |
| 67 | // TCP stream, RTSP stream. | 71 | // TCP stream, RTSP stream. |
| 68 | SrsListenerRtsp = 4, | 72 | SrsListenerRtsp = 4, |
| 69 | - // HTTP stream, FLV over HTTP POST. | 73 | + // TCP stream, FLV stream over HTTP. |
| 70 | SrsListenerFlv = 5, | 74 | SrsListenerFlv = 5, |
| 71 | }; | 75 | }; |
| 72 | 76 | ||
| @@ -126,13 +130,13 @@ public: | @@ -126,13 +130,13 @@ public: | ||
| 126 | }; | 130 | }; |
| 127 | 131 | ||
| 128 | /** | 132 | /** |
| 129 | - * the tcp listener, for http flv server. | 133 | + * the tcp listener, for flv stream server. |
| 130 | */ | 134 | */ |
| 131 | class SrsHttpFlvListener : virtual public SrsListener, virtual public ISrsTcpHandler | 135 | class SrsHttpFlvListener : virtual public SrsListener, virtual public ISrsTcpHandler |
| 132 | { | 136 | { |
| 133 | private: | 137 | private: |
| 134 | SrsTcpListener* listener; | 138 | SrsTcpListener* listener; |
| 135 | - ISrsTcpHandler* caster; | 139 | + SrsAppCasterFlv* caster; |
| 136 | public: | 140 | public: |
| 137 | SrsHttpFlvListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c); | 141 | SrsHttpFlvListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c); |
| 138 | virtual ~SrsHttpFlvListener(); | 142 | virtual ~SrsHttpFlvListener(); |
| @@ -215,6 +219,7 @@ public: | @@ -215,6 +219,7 @@ public: | ||
| 215 | */ | 219 | */ |
| 216 | class SrsServer : virtual public ISrsReloadHandler | 220 | class SrsServer : virtual public ISrsReloadHandler |
| 217 | , virtual public ISrsSourceHandler, virtual public ISrsHlsHandler | 221 | , virtual public ISrsSourceHandler, virtual public ISrsHlsHandler |
| 222 | + , virtual public IConnectionManager | ||
| 218 | { | 223 | { |
| 219 | private: | 224 | private: |
| 220 | #ifdef SRS_AUTO_HTTP_API | 225 | #ifdef SRS_AUTO_HTTP_API |
| @@ -279,7 +284,7 @@ public: | @@ -279,7 +284,7 @@ public: | ||
| 279 | virtual int http_handle(); | 284 | virtual int http_handle(); |
| 280 | virtual int ingest(); | 285 | virtual int ingest(); |
| 281 | virtual int cycle(); | 286 | virtual int cycle(); |
| 282 | -// server utility | 287 | +// IConnectionManager |
| 283 | public: | 288 | public: |
| 284 | /** | 289 | /** |
| 285 | * callback for connection to remove itself. | 290 | * callback for connection to remove itself. |
| @@ -287,6 +292,8 @@ public: | @@ -287,6 +292,8 @@ public: | ||
| 287 | * @see SrsConnection.on_thread_stop(). | 292 | * @see SrsConnection.on_thread_stop(). |
| 288 | */ | 293 | */ |
| 289 | virtual void remove(SrsConnection* conn); | 294 | virtual void remove(SrsConnection* conn); |
| 295 | +// server utilities. | ||
| 296 | +public: | ||
| 290 | /** | 297 | /** |
| 291 | * callback for signal manager got a signal. | 298 | * callback for signal manager got a signal. |
| 292 | * the signal manager convert signal to io message, | 299 | * the signal manager convert signal to io message, |
-
请 注册 或 登录 后发表评论