Skip to content

Commit

Permalink
DVR: copy req from publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Haibo Chen committed Nov 5, 2021
1 parent 97b81c6 commit a377af8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions trunk/src/app/srs_app_dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ srs_error_t SrsDvrPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsReque
srs_error_t SrsDvrPlan::on_publish(SrsRequest* r)
{
// @see https://github.com/ossrs/srs/issues/1613#issuecomment-960623359
if (req) srs_freep(req);
srs_freep(req);
req = r->copy();

return srs_success;
Expand Down Expand Up @@ -917,13 +917,14 @@ SrsDvr::~SrsDvr()
_srs_config->unsubscribe(this);

srs_freep(plan);
srs_freep(req);
}

srs_error_t SrsDvr::initialize(SrsOriginHub* h, SrsRequest* r)
{
srs_error_t err = srs_success;

req = r;
req = r->copy();
hub = h;

SrsConfDirective* conf = _srs_config->get_dvr_apply(r->vhost);
Expand All @@ -949,7 +950,7 @@ srs_error_t SrsDvr::initialize(SrsOriginHub* h, SrsRequest* r)
return err;
}

srs_error_t SrsDvr::on_publish()
srs_error_t SrsDvr::on_publish(SrsRequest* r)
{
srs_error_t err = srs_success;

Expand All @@ -958,9 +959,12 @@ srs_error_t SrsDvr::on_publish()
return err;
}

if ((err = plan->on_publish(req)) != srs_success) {
if ((err = plan->on_publish(r)) != srs_success) {
return srs_error_wrap(err, "publish");
}

srs_freep(req);
req = r->copy();

return err;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_dvr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class SrsDvr : public ISrsReloadHandler
// publish stream event,
// when encoder start to publish RTMP stream.
// @param fetch_sequence_header whether fetch sequence from source.
virtual srs_error_t on_publish();
virtual srs_error_t on_publish(SrsRequest* r);
// the unpublish event.,
// when encoder stop(unpublish) to publish RTMP stream.
virtual void on_unpublish();
Expand Down
5 changes: 3 additions & 2 deletions trunk/src/app/srs_app_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,8 @@ srs_error_t SrsOriginHub::on_publish()
return srs_error_wrap(err, "dash publish");
}

if ((err = dvr->on_publish()) != srs_success) {
// @see https://github.com/ossrs/srs/issues/1613#issuecomment-961657927
if ((err = dvr->on_publish(req)) != srs_success) {
return srs_error_wrap(err, "dvr publish");
}

Expand Down Expand Up @@ -1401,7 +1402,7 @@ srs_error_t SrsOriginHub::on_reload_vhost_dvr(string vhost)
}

// start to publish by new plan.
if ((err = dvr->on_publish()) != srs_success) {
if ((err = dvr->on_publish(req)) != srs_success) {
return srs_error_wrap(err, "dvr publish failed");
}

Expand Down

0 comments on commit a377af8

Please sign in to comment.