正在显示
5 个修改的文件
包含
19 行增加
和
32 行删除
| @@ -390,6 +390,7 @@ Remark: | @@ -390,6 +390,7 @@ Remark: | ||
| 390 | * v3.0, 2015-08-31, fix [#319][bug #319], http raw api support query global and vhost. | 390 | * v3.0, 2015-08-31, fix [#319][bug #319], http raw api support query global and vhost. |
| 391 | * v3.0, 2015-08-28, fix [#471][bug #471], api response the width and height. 3.0.2 | 391 | * v3.0, 2015-08-28, fix [#471][bug #471], api response the width and height. 3.0.2 |
| 392 | * v3.0, 2015-08-25, fix [#367][bug #367], support nginx-rtmp exec. 3.0.1 | 392 | * v3.0, 2015-08-25, fix [#367][bug #367], support nginx-rtmp exec. 3.0.1 |
| 393 | +* <strong>v2.0, 2016-11-09, [2.0 beta2(2.0.221)][r2.0b2] released. 86691 lines.</strong> | ||
| 393 | * <strong>v2.0, 2016-09-09, [2.0 beta1(2.0.215)][r2.0b1] released. 89941 lines.</strong> | 394 | * <strong>v2.0, 2016-09-09, [2.0 beta1(2.0.215)][r2.0b1] released. 89941 lines.</strong> |
| 394 | * <strong>v2.0, 2016-08-06, [2.0 beta0(2.0.210)][r2.0b0] released. 89704 lines.</strong> | 395 | * <strong>v2.0, 2016-08-06, [2.0 beta0(2.0.210)][r2.0b0] released. 89704 lines.</strong> |
| 395 | * <strong>v2.0, 2015-12-23, [2.0 alpha3(2.0.205)][r2.0a3] released. 89544 lines.</strong> | 396 | * <strong>v2.0, 2015-12-23, [2.0 alpha3(2.0.205)][r2.0a3] released. 89544 lines.</strong> |
| @@ -1232,11 +1232,9 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) | @@ -1232,11 +1232,9 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) | ||
| 1232 | } | 1232 | } |
| 1233 | } | 1233 | } |
| 1234 | 1234 | ||
| 1235 | - SrsSource* s = SrsSource::fetch(r); | ||
| 1236 | - if (!s) { | ||
| 1237 | - if ((ret = SrsSource::create(r, server, server, &s)) != ERROR_SUCCESS) { | ||
| 1238 | - return ret; | ||
| 1239 | - } | 1235 | + SrsSource* s = NULL; |
| 1236 | + if ((ret = SrsSource::fetch_or_create(r, server, server, &s)) != ERROR_SUCCESS) { | ||
| 1237 | + return ret; | ||
| 1240 | } | 1238 | } |
| 1241 | srs_assert(s != NULL); | 1239 | srs_assert(s != NULL); |
| 1242 | 1240 |
| @@ -709,11 +709,9 @@ int SrsRtmpConn::stream_service_cycle() | @@ -709,11 +709,9 @@ int SrsRtmpConn::stream_service_cycle() | ||
| 709 | rtmp->set_send_timeout(SRS_CONSTS_RTMP_TIMEOUT_US); | 709 | rtmp->set_send_timeout(SRS_CONSTS_RTMP_TIMEOUT_US); |
| 710 | 710 | ||
| 711 | // find a source to serve. | 711 | // find a source to serve. |
| 712 | - SrsSource* source = SrsSource::fetch(req); | ||
| 713 | - if (!source) { | ||
| 714 | - if ((ret = SrsSource::create(req, server, server, &source)) != ERROR_SUCCESS) { | ||
| 715 | - return ret; | ||
| 716 | - } | 712 | + SrsSource* source = NULL; |
| 713 | + if ((ret = SrsSource::fetch_or_create(req, server, server, &source)) != ERROR_SUCCESS) { | ||
| 714 | + return ret; | ||
| 717 | } | 715 | } |
| 718 | srs_assert(source != NULL); | 716 | srs_assert(source != NULL); |
| 719 | 717 |
| @@ -737,17 +737,23 @@ ISrsSourceHandler::~ISrsSourceHandler() | @@ -737,17 +737,23 @@ ISrsSourceHandler::~ISrsSourceHandler() | ||
| 737 | 737 | ||
| 738 | std::map<std::string, SrsSource*> SrsSource::pool; | 738 | std::map<std::string, SrsSource*> SrsSource::pool; |
| 739 | 739 | ||
| 740 | -int SrsSource::create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh, SrsSource** pps) | 740 | +int SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh, SrsSource** pps) |
| 741 | { | 741 | { |
| 742 | int ret = ERROR_SUCCESS; | 742 | int ret = ERROR_SUCCESS; |
| 743 | 743 | ||
| 744 | + SrsSource* source = NULL; | ||
| 745 | + if ((source = fetch(r)) != NULL) { | ||
| 746 | + *pps = source; | ||
| 747 | + return ret; | ||
| 748 | + } | ||
| 749 | + | ||
| 744 | string stream_url = r->get_stream_url(); | 750 | string stream_url = r->get_stream_url(); |
| 745 | string vhost = r->vhost; | 751 | string vhost = r->vhost; |
| 746 | 752 | ||
| 747 | // should always not exists for create a source. | 753 | // should always not exists for create a source. |
| 748 | srs_assert (pool.find(stream_url) == pool.end()); | 754 | srs_assert (pool.find(stream_url) == pool.end()); |
| 749 | 755 | ||
| 750 | - SrsSource* source = new SrsSource(); | 756 | + source = new SrsSource(); |
| 751 | if ((ret = source->initialize(r, h, hh)) != ERROR_SUCCESS) { | 757 | if ((ret = source->initialize(r, h, hh)) != ERROR_SUCCESS) { |
| 752 | srs_freep(source); | 758 | srs_freep(source); |
| 753 | return ret; | 759 | return ret; |
| @@ -780,20 +786,6 @@ SrsSource* SrsSource::fetch(SrsRequest* r) | @@ -780,20 +786,6 @@ SrsSource* SrsSource::fetch(SrsRequest* r) | ||
| 780 | return source; | 786 | return source; |
| 781 | } | 787 | } |
| 782 | 788 | ||
| 783 | -SrsSource* SrsSource::fetch(std::string vhost, std::string app, std::string stream) | ||
| 784 | -{ | ||
| 785 | - SrsSource* source = NULL; | ||
| 786 | - string stream_url = srs_generate_stream_url(vhost, app, stream); | ||
| 787 | - | ||
| 788 | - if (pool.find(stream_url) == pool.end()) { | ||
| 789 | - return NULL; | ||
| 790 | - } | ||
| 791 | - | ||
| 792 | - source = pool[stream_url]; | ||
| 793 | - | ||
| 794 | - return source; | ||
| 795 | -} | ||
| 796 | - | ||
| 797 | void SrsSource::dispose_all() | 789 | void SrsSource::dispose_all() |
| 798 | { | 790 | { |
| 799 | std::map<std::string, SrsSource*>::iterator it; | 791 | std::map<std::string, SrsSource*>::iterator it; |
| @@ -420,22 +420,20 @@ private: | @@ -420,22 +420,20 @@ private: | ||
| 420 | static std::map<std::string, SrsSource*> pool; | 420 | static std::map<std::string, SrsSource*> pool; |
| 421 | public: | 421 | public: |
| 422 | /** | 422 | /** |
| 423 | - * find stream by vhost/app/stream. | 423 | + * create source when fetch from cache failed. |
| 424 | * @param r the client request. | 424 | * @param r the client request. |
| 425 | * @param h the event handler for source. | 425 | * @param h the event handler for source. |
| 426 | * @param hh the event handler for hls. | 426 | * @param hh the event handler for hls. |
| 427 | * @param pps the matched source, if success never be NULL. | 427 | * @param pps the matched source, if success never be NULL. |
| 428 | */ | 428 | */ |
| 429 | - static int create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh, SrsSource** pps); | 429 | + static int fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh, SrsSource** pps); |
| 430 | +private: | ||
| 430 | /** | 431 | /** |
| 431 | * get the exists source, NULL when not exists. | 432 | * get the exists source, NULL when not exists. |
| 432 | * update the request and return the exists source. | 433 | * update the request and return the exists source. |
| 433 | */ | 434 | */ |
| 434 | static SrsSource* fetch(SrsRequest* r); | 435 | static SrsSource* fetch(SrsRequest* r); |
| 435 | - /** | ||
| 436 | - * get the exists source by stream info(vhost, app, stream), NULL when not exists. | ||
| 437 | - */ | ||
| 438 | - static SrsSource* fetch(std::string vhost, std::string app, std::string stream); | 436 | +public: |
| 439 | /** | 437 | /** |
| 440 | * dispose and cycle all sources. | 438 | * dispose and cycle all sources. |
| 441 | */ | 439 | */ |
-
请 注册 或 登录 后发表评论