正在显示
5 个修改的文件
包含
53 行增加
和
9 行删除
| @@ -476,7 +476,10 @@ Supported operating systems and hardware: | @@ -476,7 +476,10 @@ Supported operating systems and hardware: | ||
| 476 | [#179](https://github.com/winlinvip/simple-rtmp-server/issues/179) and | 476 | [#179](https://github.com/winlinvip/simple-rtmp-server/issues/179) and |
| 477 | [274](https://github.com/winlinvip/simple-rtmp-server/issues/274). | 477 | [274](https://github.com/winlinvip/simple-rtmp-server/issues/274). |
| 478 | 1. Support rtmp remux to http flv live stream, read | 478 | 1. Support rtmp remux to http flv live stream, read |
| 479 | -[#293](https://github.com/winlinvip/simple-rtmp-server/issues/293). | 479 | +[#293](https://github.com/winlinvip/simple-rtmp-server/issues/293)( |
| 480 | +[CN](https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_DeliveryHttpFlvStream), | ||
| 481 | +[EN](https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_DeliveryHttpFlvStream) | ||
| 482 | +). | ||
| 480 | 1. [no-plan] Support <500ms latency, FRSC(Fast RTMP-compatible Stream Channel tech). | 483 | 1. [no-plan] Support <500ms latency, FRSC(Fast RTMP-compatible Stream Channel tech). |
| 481 | 1. [no-plan] Support RTMP 302 redirect [#92](https://github.com/winlinvip/simple-rtmp-server/issues/92). | 484 | 1. [no-plan] Support RTMP 302 redirect [#92](https://github.com/winlinvip/simple-rtmp-server/issues/92). |
| 482 | 1. [no-plan] Support multiple processes, for both origin and edge | 485 | 1. [no-plan] Support multiple processes, for both origin and edge |
| @@ -402,6 +402,7 @@ int SrsGoHttpFileServer::copy(ISrsGoHttpResponseWriter* w, SrsFileReader* fs, Sr | @@ -402,6 +402,7 @@ int SrsGoHttpFileServer::copy(ISrsGoHttpResponseWriter* w, SrsFileReader* fs, Sr | ||
| 402 | 402 | ||
| 403 | SrsGoHttpMuxEntry::SrsGoHttpMuxEntry() | 403 | SrsGoHttpMuxEntry::SrsGoHttpMuxEntry() |
| 404 | { | 404 | { |
| 405 | + enabled = true; | ||
| 405 | explicit_match = false; | 406 | explicit_match = false; |
| 406 | handler = NULL; | 407 | handler = NULL; |
| 407 | } | 408 | } |
| @@ -572,6 +573,10 @@ int SrsGoHttpServeMux::match(SrsHttpMessage* r, ISrsGoHttpHandler** ph) | @@ -572,6 +573,10 @@ int SrsGoHttpServeMux::match(SrsHttpMessage* r, ISrsGoHttpHandler** ph) | ||
| 572 | std::string pattern = it->first; | 573 | std::string pattern = it->first; |
| 573 | SrsGoHttpMuxEntry* entry = it->second; | 574 | SrsGoHttpMuxEntry* entry = it->second; |
| 574 | 575 | ||
| 576 | + if (!entry->enabled) { | ||
| 577 | + continue; | ||
| 578 | + } | ||
| 579 | + | ||
| 575 | if (!path_match(pattern, path)) { | 580 | if (!path_match(pattern, path)) { |
| 576 | continue; | 581 | continue; |
| 577 | } | 582 | } |
| @@ -230,6 +230,7 @@ public: | @@ -230,6 +230,7 @@ public: | ||
| 230 | bool explicit_match; | 230 | bool explicit_match; |
| 231 | ISrsGoHttpHandler* handler; | 231 | ISrsGoHttpHandler* handler; |
| 232 | std::string pattern; | 232 | std::string pattern; |
| 233 | + bool enabled; | ||
| 233 | public: | 234 | public: |
| 234 | SrsGoHttpMuxEntry(); | 235 | SrsGoHttpMuxEntry(); |
| 235 | virtual ~SrsGoHttpMuxEntry(); | 236 | virtual ~SrsGoHttpMuxEntry(); |
| @@ -282,12 +282,22 @@ int SrsLiveStream::send_messages(SrsFlvEncoder* enc, SrsSharedPtrMessage** msgs, | @@ -282,12 +282,22 @@ int SrsLiveStream::send_messages(SrsFlvEncoder* enc, SrsSharedPtrMessage** msgs, | ||
| 282 | return ret; | 282 | return ret; |
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | +SrsLiveEntry::SrsLiveEntry() | ||
| 286 | +{ | ||
| 287 | + stream = NULL; | ||
| 288 | +} | ||
| 289 | + | ||
| 285 | SrsHttpServer::SrsHttpServer() | 290 | SrsHttpServer::SrsHttpServer() |
| 286 | { | 291 | { |
| 287 | } | 292 | } |
| 288 | 293 | ||
| 289 | SrsHttpServer::~SrsHttpServer() | 294 | SrsHttpServer::~SrsHttpServer() |
| 290 | { | 295 | { |
| 296 | + std::map<std::string, SrsLiveEntry*>::iterator it; | ||
| 297 | + for (it = flvs.begin(); it != flvs.end(); ++it) { | ||
| 298 | + SrsLiveEntry* entry = it->second; | ||
| 299 | + srs_freep(entry); | ||
| 300 | + } | ||
| 291 | flvs.clear(); | 301 | flvs.clear(); |
| 292 | } | 302 | } |
| 293 | 303 | ||
| @@ -317,8 +327,16 @@ int SrsHttpServer::mount(SrsSource* s, SrsRequest* r) | @@ -317,8 +327,16 @@ int SrsHttpServer::mount(SrsSource* s, SrsRequest* r) | ||
| 317 | srs_info("ignore mount flv stream for disabled"); | 327 | srs_info("ignore mount flv stream for disabled"); |
| 318 | return ret; | 328 | return ret; |
| 319 | } | 329 | } |
| 330 | + | ||
| 331 | + SrsLiveEntry* entry = flvs[r->vhost]; | ||
| 332 | + | ||
| 333 | + // TODO: FIXME: supports reload. | ||
| 334 | + if (entry->stream) { | ||
| 335 | + entry->stream->entry->enabled = true; | ||
| 336 | + return ret; | ||
| 337 | + } | ||
| 320 | 338 | ||
| 321 | - std::string mount = flvs[r->vhost]; | 339 | + std::string mount = entry->mount; |
| 322 | 340 | ||
| 323 | // replace the vhost variable | 341 | // replace the vhost variable |
| 324 | mount = srs_string_replace(mount, "[vhost]", r->vhost); | 342 | mount = srs_string_replace(mount, "[vhost]", r->vhost); |
| @@ -328,8 +346,10 @@ int SrsHttpServer::mount(SrsSource* s, SrsRequest* r) | @@ -328,8 +346,10 @@ int SrsHttpServer::mount(SrsSource* s, SrsRequest* r) | ||
| 328 | // remove the default vhost mount | 346 | // remove the default vhost mount |
| 329 | mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/"); | 347 | mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/"); |
| 330 | 348 | ||
| 349 | + entry->stream = new SrsLiveStream(s, r); | ||
| 350 | + | ||
| 331 | // mount the http flv stream. | 351 | // mount the http flv stream. |
| 332 | - if ((ret = mux.handle(mount, new SrsLiveStream(s, r))) != ERROR_SUCCESS) { | 352 | + if ((ret = mux.handle(mount, entry->stream)) != ERROR_SUCCESS) { |
| 333 | srs_error("http: mount flv stream for vhost=%s failed. ret=%d", r->vhost.c_str(), ret); | 353 | srs_error("http: mount flv stream for vhost=%s failed. ret=%d", r->vhost.c_str(), ret); |
| 334 | return ret; | 354 | return ret; |
| 335 | } | 355 | } |
| @@ -344,8 +364,9 @@ void SrsHttpServer::unmount(SrsSource* s, SrsRequest* r) | @@ -344,8 +364,9 @@ void SrsHttpServer::unmount(SrsSource* s, SrsRequest* r) | ||
| 344 | srs_info("ignore unmount flv stream for disabled"); | 364 | srs_info("ignore unmount flv stream for disabled"); |
| 345 | return; | 365 | return; |
| 346 | } | 366 | } |
| 347 | - | ||
| 348 | - // TODO: FIXME: implements it. | 367 | + |
| 368 | + SrsLiveEntry* entry = flvs[r->vhost]; | ||
| 369 | + entry->stream->entry->enabled = false; | ||
| 349 | } | 370 | } |
| 350 | 371 | ||
| 351 | int SrsHttpServer::on_reload_vhost_http_updated() | 372 | int SrsHttpServer::on_reload_vhost_http_updated() |
| @@ -440,10 +461,12 @@ int SrsHttpServer::mount_flv_streaming() | @@ -440,10 +461,12 @@ int SrsHttpServer::mount_flv_streaming() | ||
| 440 | continue; | 461 | continue; |
| 441 | } | 462 | } |
| 442 | 463 | ||
| 443 | - std::string mount = _srs_config->get_vhost_http_flv_mount(vhost); | ||
| 444 | - flvs[vhost] = mount; | 464 | + SrsLiveEntry* entry = new SrsLiveEntry(); |
| 465 | + entry->vhost = vhost; | ||
| 466 | + entry->mount = _srs_config->get_vhost_http_flv_mount(vhost); | ||
| 467 | + flvs[vhost] = entry; | ||
| 445 | srs_trace("http flv live stream, vhost=%s, mount=%s", | 468 | srs_trace("http flv live stream, vhost=%s, mount=%s", |
| 446 | - vhost.c_str(), mount.c_str()); | 469 | + vhost.c_str(), entry->mount.c_str()); |
| 447 | } | 470 | } |
| 448 | 471 | ||
| 449 | return ret; | 472 | return ret; |
| @@ -101,6 +101,18 @@ private: | @@ -101,6 +101,18 @@ private: | ||
| 101 | }; | 101 | }; |
| 102 | 102 | ||
| 103 | /** | 103 | /** |
| 104 | +* the srs live entry | ||
| 105 | +*/ | ||
| 106 | +struct SrsLiveEntry | ||
| 107 | +{ | ||
| 108 | + std::string vhost; | ||
| 109 | + std::string mount; | ||
| 110 | + SrsLiveStream* stream; | ||
| 111 | + | ||
| 112 | + SrsLiveEntry(); | ||
| 113 | +}; | ||
| 114 | + | ||
| 115 | +/** | ||
| 104 | * the http server instance, | 116 | * the http server instance, |
| 105 | * serve http static file, flv vod stream and flv live stream. | 117 | * serve http static file, flv vod stream and flv live stream. |
| 106 | */ | 118 | */ |
| @@ -109,7 +121,7 @@ class SrsHttpServer : public ISrsReloadHandler | @@ -109,7 +121,7 @@ class SrsHttpServer : public ISrsReloadHandler | ||
| 109 | public: | 121 | public: |
| 110 | SrsGoHttpServeMux mux; | 122 | SrsGoHttpServeMux mux; |
| 111 | // the flv live streaming template. | 123 | // the flv live streaming template. |
| 112 | - std::map<std::string, std::string> flvs; | 124 | + std::map<std::string, SrsLiveEntry*> flvs; |
| 113 | public: | 125 | public: |
| 114 | SrsHttpServer(); | 126 | SrsHttpServer(); |
| 115 | virtual ~SrsHttpServer(); | 127 | virtual ~SrsHttpServer(); |
-
请 注册 或 登录 后发表评论