Skip to content

Commit

Permalink
For #2282, #2181, Move DVR async worker from SrsDvrPlan to global.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 4, 2021
1 parent 90b5ed2 commit 6bb11a7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The changelog for SRS.

## SRS 4.0 Changelog

* v4.0, 2021-09-04, For [#2282](https://github.com/ossrs/srs/pull/2282), [#2181](https://github.com/ossrs/srs/issues/2181), Move DVR async worker from SrsDvrPlan to global.
* v4.0, 2021-09-04, For [#2282](https://github.com/ossrs/srs/pull/2282), [#2181](https://github.com/ossrs/srs/issues/2181), Remove reload for dvr_apply. 4.0.160
* v4.0, 2021-08-28, RTC: Merge [#1859](https://github.com/ossrs/srs/pull/1859), Enhancement: Add param and stream to on_connect. 4.0.159
* v4.0, 2021-08-27, RTC: Merge [#2544](https://github.com/ossrs/srs/pull/2544), Support for multiple SPS/PPS, then pick the first one. 4.0.158
Expand Down
15 changes: 4 additions & 11 deletions trunk/src/app/srs_app_dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,20 +566,20 @@ string SrsDvrAsyncCallOnDvr::to_string()
return ss.str();
}

extern SrsAsyncCallWorker* _srs_dvr_async;

SrsDvrPlan::SrsDvrPlan()
{
req = NULL;
hub = NULL;

dvr_enabled = false;
segment = NULL;
async = new SrsAsyncCallWorker();
}

SrsDvrPlan::~SrsDvrPlan()
{
srs_freep(segment);
srs_freep(async);
}

srs_error_t SrsDvrPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsRequest* r)
Expand All @@ -599,18 +599,11 @@ srs_error_t SrsDvrPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsReque

srs_error_t SrsDvrPlan::on_publish()
{
srs_error_t err = srs_success;

if ((err = async->start()) != srs_success) {
return srs_error_wrap(err, "async");
}

return err;
return srs_success;
}

void SrsDvrPlan::on_unpublish()
{
async->stop();
}

srs_error_t SrsDvrPlan::on_meta_data(SrsSharedPtrMessage* shared_metadata)
Expand Down Expand Up @@ -663,7 +656,7 @@ srs_error_t SrsDvrPlan::on_reap_segment()
SrsFragment* fragment = segment->current();
string fullpath = fragment->fullpath();

if ((err = async->execute(new SrsDvrAsyncCallOnDvr(cid, req, fullpath))) != srs_success) {
if ((err = _srs_dvr_async->execute(new SrsDvrAsyncCallOnDvr(cid, req, fullpath))) != srs_success) {
return srs_error_wrap(err, "reap segment");
}

Expand Down
1 change: 0 additions & 1 deletion trunk/src/app/srs_app_dvr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ class SrsDvrPlan : public ISrsReloadHandler
protected:
SrsOriginHub* hub;
SrsDvrSegmenter* segment;
SrsAsyncCallWorker* async;
bool dvr_enabled;
public:
SrsDvrPlan();
Expand Down
8 changes: 8 additions & 0 deletions trunk/src/app/srs_app_threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <srs_app_pithy_print.hpp>
#include <srs_app_rtc_server.hpp>
#include <srs_app_log.hpp>
#include <srs_app_async_call.hpp>

#ifdef SRS_RTC
#include <srs_app_rtc_dtls.hpp>
Expand Down Expand Up @@ -268,6 +269,7 @@ srs_error_t SrsCircuitBreaker::on_timer(srs_utime_t interval)
}

SrsCircuitBreaker* _srs_circuit_breaker = NULL;
SrsAsyncCallWorker* _srs_dvr_async = NULL;

srs_error_t srs_thread_initialize()
{
Expand Down Expand Up @@ -408,6 +410,12 @@ srs_error_t srs_thread_initialize()
_srs_pps_objs_rothers = new SrsPps();
#endif

// Create global async worker for DVR.
_srs_dvr_async = new SrsAsyncCallWorker();
if ((err = _srs_dvr_async->start()) != srs_success) {
return srs_error_wrap(err, "dvr async");
}

return err;
}

0 comments on commit 6bb11a7

Please sign in to comment.