mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #209, support cleanup when srs stop.
This commit is contained in:
parent
860d68e6e7
commit
4a80a5a71e
3 changed files with 52 additions and 6 deletions
|
@ -250,7 +250,7 @@ Compare SRS with other media server.
|
|||
| RTMP Edge | Stable | X | X | Stable | X |
|
||||
| RTMP Backup | Stable | X | X | X | X |
|
||||
| VHOST | Stable | X | X | Stable | Stable |
|
||||
| Reload | Stable | Stable | X | X | X |
|
||||
| Reload | Stable | X | X | X | X |
|
||||
| Forward | Stable | X | X | X | X |
|
||||
| ATC | Stable | X | X | X | X |
|
||||
|
||||
|
@ -312,6 +312,7 @@ Remark:
|
|||
1. HLS aonly: The HLS audio only streaming delivery.
|
||||
1. BW check: The bandwidth check.
|
||||
1. Security: To allow or deny stream publish or play.
|
||||
1. Reload: Nginx supports reload, but not nginx-rtmp.
|
||||
|
||||
## Releases
|
||||
|
||||
|
|
|
@ -292,6 +292,7 @@ SrsHlsMuxer::SrsHlsMuxer()
|
|||
|
||||
SrsHlsMuxer::~SrsHlsMuxer()
|
||||
{
|
||||
|
||||
std::vector<SrsHlsSegment*>::iterator it;
|
||||
for (it = segments.begin(); it != segments.end(); ++it) {
|
||||
SrsHlsSegment* segment = *it;
|
||||
|
@ -305,6 +306,40 @@ SrsHlsMuxer::~SrsHlsMuxer()
|
|||
srs_freep(context);
|
||||
}
|
||||
|
||||
void SrsHlsMuxer::dispose()
|
||||
{
|
||||
if (!should_write_file) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<SrsHlsSegment*>::iterator it;
|
||||
for (it = segments.begin(); it != segments.end(); ++it) {
|
||||
SrsHlsSegment* segment = *it;
|
||||
if (unlink(segment->full_path.c_str()) < 0) {
|
||||
srs_warn("dispose unlink path failed, file=%s.", segment->full_path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (current) {
|
||||
std::string path = current->full_path + ".tmp";
|
||||
if (unlink(path.c_str()) < 0) {
|
||||
srs_warn("dispose unlink path failed, file=%s", path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (unlink(m3u8.c_str()) < 0) {
|
||||
srs_warn("dispose unlink path failed. file=%s", m3u8.c_str());
|
||||
}
|
||||
srs_trace("gracefully dispose hls %s", req? req->get_stream_url().c_str() : "");
|
||||
}
|
||||
|
||||
int SrsHlsMuxer::cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
// TODO: FIXME: implements it.
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsHlsMuxer::sequence_no()
|
||||
{
|
||||
return _sequence_no;
|
||||
|
@ -720,6 +755,9 @@ int SrsHlsMuxer::segment_close(string log_desc)
|
|||
std::string tmp_file = current->full_path + ".tmp";
|
||||
if (should_write_file) {
|
||||
unlink(tmp_file.c_str());
|
||||
if (unlink(tmp_file.c_str()) < 0) {
|
||||
srs_warn("drop unlink path failed, file=%s.", tmp_file.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
srs_freep(current);
|
||||
|
@ -754,7 +792,9 @@ int SrsHlsMuxer::segment_close(string log_desc)
|
|||
SrsHlsSegment* segment = segment_to_remove[i];
|
||||
|
||||
if (hls_cleanup) {
|
||||
unlink(segment->full_path.c_str());
|
||||
if (unlink(segment->full_path.c_str()) < 0) {
|
||||
srs_warn("cleanup unlink path failed, file=%s.", segment->full_path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
srs_freep(segment);
|
||||
|
@ -1111,15 +1151,17 @@ SrsHls::~SrsHls()
|
|||
|
||||
void SrsHls::dispose()
|
||||
{
|
||||
if (hls_enabled) {
|
||||
on_unpublish();
|
||||
}
|
||||
|
||||
muxer->dispose();
|
||||
}
|
||||
|
||||
int SrsHls::cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
srs_info("hls cycle for source %d", source->source_id());
|
||||
|
||||
return ret;
|
||||
return muxer->cycle();
|
||||
}
|
||||
|
||||
int SrsHls::initialize(SrsSource* s, ISrsHlsHandler* h)
|
||||
|
|
|
@ -259,6 +259,9 @@ private:
|
|||
public:
|
||||
SrsHlsMuxer();
|
||||
virtual ~SrsHlsMuxer();
|
||||
public:
|
||||
virtual void dispose();
|
||||
virtual int cycle();
|
||||
public:
|
||||
virtual int sequence_no();
|
||||
virtual std::string ts_url();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue