mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix #84: unpublish source when edge stop, clear gop cache
This commit is contained in:
parent
7920348e5f
commit
8d99ef27cf
5 changed files with 67 additions and 21 deletions
|
@ -465,6 +465,7 @@ SrsSource::SrsSource(SrsRequest* req)
|
|||
|
||||
frame_rate = sample_rate = 0;
|
||||
_can_publish = true;
|
||||
_source_id = -1;
|
||||
|
||||
play_edge = new SrsPlayEdge();
|
||||
publish_edge = new SrsPublishEdge();
|
||||
|
@ -791,6 +792,24 @@ int SrsSource::on_dvr_request_sh()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int SrsSource::on_source_id_changed(int id)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if (_source_id == id) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
_source_id = id;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsSource::source_id()
|
||||
{
|
||||
return _source_id;
|
||||
}
|
||||
|
||||
bool SrsSource::can_publish()
|
||||
{
|
||||
return _can_publish;
|
||||
|
@ -1181,6 +1200,10 @@ int SrsSource::on_publish()
|
|||
|
||||
_can_publish = false;
|
||||
|
||||
// whatever, the publish thread is the source or edge source,
|
||||
// save its id to srouce id.
|
||||
on_source_id_changed(_srs_context->get_id());
|
||||
|
||||
// create forwarders
|
||||
if ((ret = create_forwarders()) != ERROR_SUCCESS) {
|
||||
srs_error("create forwarders failed. ret=%d", ret);
|
||||
|
@ -1239,6 +1262,7 @@ void SrsSource::on_unpublish()
|
|||
srs_trace("clear cache/metadata/sequence-headers when unpublish.");
|
||||
|
||||
_can_publish = true;
|
||||
_source_id = -1;
|
||||
}
|
||||
|
||||
int SrsSource::create_consumer(SrsConsumer*& consumer)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue