-
-
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: restore HLS information when republish stream.(#3088) #3126
base: develop
Are you sure you want to change the base?
HLS: restore HLS information when republish stream.(#3088) #3126
Conversation
14b8d86
to
4126c42
Compare
55dce2c
to
bc381a0
Compare
4ae67f1
to
badf33c
Compare
500d8fc
to
498ce72
Compare
c056094
to
2ac9eb8
Compare
13261d9
to
1668ba7
Compare
Due to the HLS state recovery, it is necessary to parse the m3u8 files on the disk, which also involves the recovery of various states of HLS. From a broader perspective, it is not suitable for SRS to do, which is very similar to DVR. Of course, SRS has also implemented DVR FLV and MP4, because sometimes it is necessary to have various basic functions and capabilities for convenience. Unfortunately, it is not possible to implement a more complete capability in SRS, because SRS is a C++ server, and it is difficult to customize the business. The best solution is to use Go with SRS in the SRS Stack, just like the recording we implemented in the SRS Stack, which includes recording to local disk, DVR to cloud storage, and even a VoD cloud on-demand system. In summary: HLS status recovery can be implemented in SRS, but only basic recovery capabilities are implemented to keep it simple, and full coverage testing is required. Complete HLS recovery capabilities are implemented in the SRS Stack.
|
@@ -17,5 +17,6 @@ vhost __defaultVhost__ { | |||
hls_path ./objs/nginx/html; | |||
hls_fragment 10; | |||
hls_window 60; | |||
hls_continuous on; |
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.
Change to: hls_recover
would be better, corresponding to the panic-recover concept in Go.
TRANS_BY_GPT4
@@ -383,6 +383,167 @@ srs_error_t SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, | |||
return err; | |||
} | |||
|
|||
srs_error_t SrsHlsMuxer::restore_stream() |
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.
The logic of this exception recovery, because it is a very commonly used path, must be verified and ensured for correctness through utest, otherwise it is very easy to make mistakes.
From the perspective of utest, it would be best to split this function into two functions, making it easier to mock fr
, that is, to read the m3u8 content from memory instead of from the actual file. It's somewhat like this:
srs_error_t SrsHlsMuxer::restore_stream() {
SrsFileReader fr;
if ((err = fr.open(m3u8)) != srs_success) {
return srs_error_wrap(err, "open file");
}
return do_restore_stream(&fr);
In this way, a mock can be used in utest to avoid reading the actual file.
VOID TEST() {
MOCKFileReader fr;
SrsHlsMuxer muxer;
muxer.do_restore_stream(&fr);
The above is just an example, you can refer to the Config section, which also requires mocking file reading.
TRANS_BY_GPT4
int nb_fbuf = fr.filesize(); | ||
char* fbuf = new char[nb_fbuf]; | ||
SrsAutoFreeA(char, fbuf); | ||
if ((err = fr.read(fbuf, nb_fbuf, NULL)) != srs_success) { |
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 seem to remember there is an auxiliary function like srs read all
, which can read all the content of a certain Reader until EOF.
It's a bit like the ioutil.ReadAll(io.Reader)
function in Go.
TRANS_BY_GPT4
0bb9637
to
2e211f6
Compare
Feature
HLS continuous mode: In this mode HLS sequence number is started from where it stopped last time. Old fragments are kept. Default is on.
Configuration