Skip to content

Commit

Permalink
DVR: fix loop fault when configure dvr_plan segment.(ossrs#2717)
Browse files Browse the repository at this point in the history
  • Loading branch information
chundonglinlin committed Dec 31, 2021
1 parent 8bc2759 commit 8ba4e8c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion trunk/src/app/srs_app_dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ srs_error_t SrsDvrSegmenter::open()
if ((err = fragment->create_dir()) != srs_success) {
return srs_error_wrap(err, "create dir");
}

// set fragment duration zero.
fragment->set_duration(0);

// create jitter.
srs_freep(jitter);
Expand All @@ -100,7 +103,8 @@ srs_error_t SrsDvrSegmenter::open()
return srs_error_wrap(err, "open encoder");
}

srs_trace("dvr stream %s to file %s", req->stream.c_str(), path.c_str());
srs_trace("dvr stream %s to file %s dur=%.2f", req->stream.c_str(), path.c_str(),
(double)srsu2ms(fragment->duration()) / 1000.0);
return err;
}

Expand Down
6 changes: 6 additions & 0 deletions trunk/src/app/srs_app_fragment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ srs_utime_t SrsFragment::duration()
return dur;
}

void SrsFragment::set_duration(srs_utime_t d)
{
// when reopen file, need set duration
dur = d;
}

bool SrsFragment::is_sequence_header()
{
return sequence_header;
Expand Down
2 changes: 2 additions & 0 deletions trunk/src/app/srs_app_fragment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class SrsFragment
virtual void append(int64_t dts);
// Get the duration of fragment in srs_utime_t.
virtual srs_utime_t duration();
// Set the duration of fragment in srs_utime_t.
void set_duration(srs_utime_t d);
// Whether the fragment contains any sequence header.
virtual bool is_sequence_header();
// Set whether contains sequence header.
Expand Down

0 comments on commit 8ba4e8c

Please sign in to comment.