From 751d8c911e35370a9eb57b620705701aca289050 Mon Sep 17 00:00:00 2001 From: chundonglinlin Date: Wed, 12 Jan 2022 19:55:40 +0800 Subject: [PATCH] LiveSource: Refine fetch for external exposed interface. --- trunk/src/app/srs_app_rtc_source.cpp | 13 ++++--------- trunk/src/app/srs_app_rtc_source.hpp | 1 - trunk/src/app/srs_app_source.cpp | 15 +++++---------- trunk/src/app/srs_app_source.hpp | 1 - 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 8e79f443a63..374d37c6247 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -256,6 +256,8 @@ srs_error_t SrsRtcSourceManager::fetch_or_create(SrsRequest* r, SrsRtcSource** p SrsRtcSource* source = NULL; if ((source = fetch(r)) != NULL) { + // update requst + source->update_auth(r); *pps = source; return err; } @@ -285,17 +287,10 @@ SrsRtcSource* SrsRtcSourceManager::fetch(SrsRequest* r) SrsRtcSource* source = NULL; string stream_url = r->get_stream_url(); - if (pool.find(stream_url) == pool.end()) { - return NULL; + if (pool.find(stream_url) != pool.end()) { + source = pool[stream_url]; } - source = pool[stream_url]; - - // we always update the request of resource, - // for origin auth is on, the token in request maybe invalid, - // and we only need to update the token of request, it's simple. - source->update_auth(r); - return source; } diff --git a/trunk/src/app/srs_app_rtc_source.hpp b/trunk/src/app/srs_app_rtc_source.hpp index c98db956194..1b9555a049b 100644 --- a/trunk/src/app/srs_app_rtc_source.hpp +++ b/trunk/src/app/srs_app_rtc_source.hpp @@ -114,7 +114,6 @@ class SrsRtcSourceManager virtual srs_error_t fetch_or_create(SrsRequest* r, SrsRtcSource** pps); private: // Get the exists source, NULL when not exists. - // update the request and return the exists source. virtual SrsRtcSource* fetch(SrsRequest* r); }; diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index d297f0f4aa2..3b48b91f88a 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1713,6 +1713,8 @@ srs_error_t SrsLiveSourceManager::fetch_or_create(SrsRequest* r, ISrsLiveSourceH SrsLiveSource* source = NULL; if ((source = fetch(r)) != NULL) { + // update request + source->update_auth(r); *pps = source; return err; } @@ -1745,17 +1747,10 @@ SrsLiveSource* SrsLiveSourceManager::fetch(SrsRequest* r) SrsLiveSource* source = NULL; string stream_url = r->get_stream_url(); - if (pool.find(stream_url) == pool.end()) { - return NULL; + if (pool.find(stream_url) != pool.end()) { + source = pool[stream_url]; } - - source = pool[stream_url]; - - // we always update the request of resource, - // for origin auth is on, the token in request maybe invalid, - // and we only need to update the token of request, it's simple. - source->update_auth(r); - + return source; } diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index d1bf0b3dc33..78d04958d7a 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -450,7 +450,6 @@ class SrsLiveSourceManager : public ISrsHourGlass virtual srs_error_t fetch_or_create(SrsRequest* r, ISrsLiveSourceHandler* h, SrsLiveSource** pps); public: // Get the exists source, NULL when not exists. - // update the request and return the exists source. virtual SrsLiveSource* fetch(SrsRequest* r); public: // dispose and cycle all sources.