-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
HLS: Added delay cleanup old expired ts files #3001
base: develop
Are you sure you want to change the base?
Conversation
trunk/src/app/srs_app_fragment.cpp
Outdated
|
||
for (int i = (int)expired_fragments.size() - 1; i >= 0; i--) { | ||
SrsFragment* fragment = expired_fragments[i]; | ||
duration += fragment->duration(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, duration is used as the time for scheduled cleaning, which is difficult to understand, and there are too many if-else statements, making it very challenging for future maintenance.
A better solution is to send the task of deleting slice files to an asynchronous worker, which will handle recording the time and performing the cleaning.
It's something like this:
void SrsFragmentWindow::clear_expired(bool delete_files, srs_utime_t delay_time)
{
for (it = expired_fragments.begin(); it != expired_fragments.end(); ++it) {
SrsFragment* fragment = *it;
if (!delete_files) {
continue;
}
if (delay_time) {
err = cleanup_worker->unlink_file(filename);
} else {
err = fragment->unlink_file();
}
if (err != srs_success) {
srs_warn("Unlink ts failed, %s", srs_error_desc(err).c_str());
srs_freep(err);
}
You can use a global cleanup_worker
, which is relatively simple.
TRANS_BY_GPT3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an asynchronous clock to handle expired ts files. If you have time, please take a look. Thank you.
TRANS_BY_GPT3
5126fad
to
34ad906
Compare
Codecov Report
@@ Coverage Diff @@
## develop #3001 +/- ##
===========================================
- Coverage 56.10% 56.06% -0.05%
===========================================
Files 153 153
Lines 57561 57609 +48
===========================================
+ Hits 32294 32296 +2
- Misses 25267 25313 +46 | Impacted Files | Coverage Δ | |' Translated to English while maintaining the markdown structure: '| Impacted Files | Coverage Δ | | Translated to English while maintaining the markdown structure: '| trunk/src/app/srs_app_config.hpp | Translated to English while maintaining the markdown structure: '| trunk/src/app/srs_app_hls.cpp | Continue to review full report at Codecov.
Translated to English while maintaining the markdown structure: |
|
32b58dd
to
03c3a1f
Compare
4395ee1
to
06e8680
Compare
f2495c9
to
d4e5138
Compare
9c7a9d0
to
38c3d9f
Compare
991fdb5
to
02d47c5
Compare
55dce2c
to
bc381a0
Compare
4ae67f1
to
badf33c
Compare
500d8fc
to
498ce72
Compare
c056094
to
2ac9eb8
Compare
0bb9637
to
2e211f6
Compare
Some player start to play from the first ts file, which might be cleanup.
It's better to delay cleanup the ts files. issues #2999