Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DVR: copy req from publish #2714

Merged
merged 2 commits into from
Nov 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions trunk/src/app/srs_app_dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,12 @@ srs_error_t SrsDvrPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsReque
return err;
}

srs_error_t SrsDvrPlan::on_publish()
srs_error_t SrsDvrPlan::on_publish(SrsRequest* r)
{
// @see https://github.com/ossrs/srs/issues/1613#issuecomment-960623359
srs_freep(req);
req = r->copy();

return srs_success;
}

Expand Down Expand Up @@ -687,11 +691,11 @@ SrsDvrSessionPlan::~SrsDvrSessionPlan()
{
}

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

if ((err = SrsDvrPlan::on_publish()) != srs_success) {
if ((err = SrsDvrPlan::on_publish(r)) != srs_success) {
return err;
}

Expand Down Expand Up @@ -762,11 +766,11 @@ srs_error_t SrsDvrSegmentPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, S
return srs_success;
}

srs_error_t SrsDvrSegmentPlan::on_publish()
srs_error_t SrsDvrSegmentPlan::on_publish(SrsRequest* r)
duiniuluantanqin marked this conversation as resolved.
Show resolved Hide resolved
{
srs_error_t err = srs_success;

if ((err = SrsDvrPlan::on_publish()) != srs_success) {
if ((err = SrsDvrPlan::on_publish(r)) != srs_success) {
return err;
}

Expand Down Expand Up @@ -913,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 @@ -945,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 @@ -954,9 +959,12 @@ srs_error_t SrsDvr::on_publish()
return err;
}

if ((err = plan->on_publish()) != 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
8 changes: 4 additions & 4 deletions trunk/src/app/srs_app_dvr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class SrsDvrPlan : public ISrsReloadHandler
virtual ~SrsDvrPlan();
public:
virtual srs_error_t initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsRequest* r);
virtual srs_error_t on_publish();
virtual srs_error_t on_publish(SrsRequest* r);
virtual void on_unpublish();
virtual srs_error_t on_meta_data(SrsSharedPtrMessage* shared_metadata);
virtual srs_error_t on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format);
Expand All @@ -187,7 +187,7 @@ class SrsDvrSessionPlan : public SrsDvrPlan
SrsDvrSessionPlan();
virtual ~SrsDvrSessionPlan();
public:
virtual srs_error_t on_publish();
virtual srs_error_t on_publish(SrsRequest* r);
virtual void on_unpublish();
};

Expand All @@ -203,7 +203,7 @@ class SrsDvrSegmentPlan : public SrsDvrPlan
virtual ~SrsDvrSegmentPlan();
public:
virtual srs_error_t initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsRequest* r);
virtual srs_error_t on_publish();
virtual srs_error_t on_publish(SrsRequest* r);
virtual void on_unpublish();
virtual srs_error_t on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format);
virtual srs_error_t on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format);
Expand Down 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