mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #179, add dvr plan append.
This commit is contained in:
parent
95b4baee7c
commit
7077b74d03
4 changed files with 57 additions and 4 deletions
|
@ -86,7 +86,7 @@ bool SrsFlvSegment::is_overflow(int64_t max_duration)
|
|||
return duration >= max_duration;
|
||||
}
|
||||
|
||||
int SrsFlvSegment::open()
|
||||
int SrsFlvSegment::open(bool use_tmp_file)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -113,7 +113,7 @@ int SrsFlvSegment::open()
|
|||
}
|
||||
|
||||
// generate the tmp flv path.
|
||||
if (!fresh_flv_file) {
|
||||
if (!fresh_flv_file || !use_tmp_file) {
|
||||
// when path exists, always append to it.
|
||||
// so we must use the target flv path as output flv.
|
||||
tmp_flv_file = path;
|
||||
|
@ -546,8 +546,11 @@ SrsDvrPlan* SrsDvrPlan::create_plan(string vhost)
|
|||
return new SrsDvrSegmentPlan();
|
||||
} else if (plan == SRS_CONF_DEFAULT_DVR_PLAN_SESSION) {
|
||||
return new SrsDvrSessionPlan();
|
||||
} else if (plan == SRS_CONF_DEFAULT_DVR_PLAN_APPEND) {
|
||||
return new SrsDvrAppendPlan();
|
||||
} else {
|
||||
return new SrsDvrSessionPlan();
|
||||
srs_error("invalid dvr plan=%s, vhost=%s", plan.c_str(), vhost.c_str());
|
||||
srs_assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,6 +604,40 @@ void SrsDvrSessionPlan::on_unpublish()
|
|||
dvr_enabled = false;
|
||||
}
|
||||
|
||||
SrsDvrAppendPlan::SrsDvrAppendPlan()
|
||||
{
|
||||
}
|
||||
|
||||
SrsDvrAppendPlan::~SrsDvrAppendPlan()
|
||||
{
|
||||
}
|
||||
|
||||
int SrsDvrAppendPlan::on_publish()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// support multiple publish.
|
||||
if (dvr_enabled) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!_srs_config->get_dvr_enabled(req->vhost)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = segment->open(false)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
dvr_enabled = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SrsDvrAppendPlan::on_unpublish()
|
||||
{
|
||||
}
|
||||
|
||||
SrsDvrSegmentPlan::SrsDvrSegmentPlan()
|
||||
{
|
||||
segment_duration = -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue