Skip to content

Commit

Permalink
LiveSource: Refine fetch_src for external exposed interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
chundonglinlin committed Jan 11, 2022
1 parent e08c68b commit 2f6ae6d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_rtc_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe

// For RTMP to RTC, fail if disabled and RTMP is active, see https://github.com/ossrs/srs/issues/2728
if (!_srs_config->get_rtc_from_rtmp(ruc.req_->vhost)) {
SrsLiveSource* rtmp = _srs_sources->fetch(ruc.req_);
SrsLiveSource* rtmp = _srs_sources->fetch_src(ruc.req_);
if (rtmp && !rtmp->inactive()) {
return srs_error_new(ERROR_RTC_DISABLED, "Disabled rtmp_to_rtc of %s, see #2728", ruc.req_->vhost.c_str());
}
Expand Down
10 changes: 10 additions & 0 deletions trunk/src/app/srs_app_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,16 @@ SrsLiveSource* SrsLiveSourceManager::fetch(SrsRequest* r)
return source;
}

SrsLiveSource* SrsLiveSourceManager::fetch_src(SrsRequest* r)
{
string stream_url = r->get_stream_url();
if (pool.find(stream_url) == pool.end()) {
return NULL;
}

return pool[stream_url];
}

void SrsLiveSourceManager::dispose()
{
std::map<std::string, SrsLiveSource*>::iterator it;
Expand Down
5 changes: 4 additions & 1 deletion trunk/src/app/srs_app_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,13 @@ class SrsLiveSourceManager : public ISrsHourGlass
// @param h the event handler for source.
// @param pps the matched source, if success never be NULL.
virtual srs_error_t fetch_or_create(SrsRequest* r, ISrsLiveSourceHandler* h, SrsLiveSource** pps);
public:
private:
// Get the exists source, NULL when not exists.
// update the request and return the exists source.
virtual SrsLiveSource* fetch(SrsRequest* r);
public:
// Get the exists source, NULL when not exists.
virtual SrsLiveSource* fetch_src(SrsRequest* r);
public:
// dispose and cycle all sources.
virtual void dispose();
Expand Down

0 comments on commit 2f6ae6d

Please sign in to comment.