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
|
@ -271,7 +271,7 @@ int SrsRtmpConn::stream_service_cycle()
|
|||
srs_error("set chunk_size=%d failed. ret=%d", chunk_size, ret);
|
||||
return ret;
|
||||
}
|
||||
srs_trace("set chunk_size=%d success", chunk_size);
|
||||
srs_info("set chunk_size=%d success", chunk_size);
|
||||
|
||||
// find a source to serve.
|
||||
SrsSource* source = NULL;
|
||||
|
@ -296,16 +296,16 @@ int SrsRtmpConn::stream_service_cycle()
|
|||
}
|
||||
|
||||
bool enabled_cache = _srs_config->get_gop_cache(req->vhost);
|
||||
srs_trace("source found, ip=%s, url=%s, enabled_cache=%d, edge=%d",
|
||||
ip.c_str(), req->get_stream_url().c_str(), enabled_cache, vhost_is_edge);
|
||||
srs_trace("source url=%s, ip=%s, cache=%d, is_edge=%d, id=%d",
|
||||
req->get_stream_url().c_str(), ip.c_str(), enabled_cache, vhost_is_edge, source->source_id());
|
||||
source->set_cache(enabled_cache);
|
||||
|
||||
switch (type) {
|
||||
case SrsRtmpConnPlay: {
|
||||
srs_verbose("start to play stream %s.", req->stream.c_str());
|
||||
|
||||
// notice edge to start for the first client.
|
||||
if (vhost_is_edge) {
|
||||
// notice edge to start for the first client.
|
||||
if ((ret = source->on_edge_start_play()) != ERROR_SUCCESS) {
|
||||
srs_error("notice edge start play stream failed. ret=%d", ret);
|
||||
return ret;
|
||||
|
@ -568,15 +568,18 @@ int SrsRtmpConn::fmle_publish(SrsSource* source)
|
|||
|
||||
SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER);
|
||||
|
||||
// notify the hls to prepare when publish start.
|
||||
if ((ret = source->on_publish()) != ERROR_SUCCESS) {
|
||||
srs_error("fmle hls on_publish failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("fmle hls on_publish success.");
|
||||
|
||||
bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost);
|
||||
|
||||
// when edge, ignore the publish event, directly proxy it.
|
||||
if (vhost_is_edge) {
|
||||
// notify the hls to prepare when publish start.
|
||||
if ((ret = source->on_publish()) != ERROR_SUCCESS) {
|
||||
srs_error("fmle hls on_publish failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("fmle hls on_publish success.");
|
||||
}
|
||||
|
||||
while (true) {
|
||||
// switch to other st-threads.
|
||||
st_usleep(0);
|
||||
|
@ -644,15 +647,18 @@ int SrsRtmpConn::flash_publish(SrsSource* source)
|
|||
|
||||
SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER);
|
||||
|
||||
// notify the hls to prepare when publish start.
|
||||
if ((ret = source->on_publish()) != ERROR_SUCCESS) {
|
||||
srs_error("flash hls on_publish failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("flash hls on_publish success.");
|
||||
|
||||
bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost);
|
||||
|
||||
// when edge, ignore the publish event, directly proxy it.
|
||||
if (vhost_is_edge) {
|
||||
// notify the hls to prepare when publish start.
|
||||
if ((ret = source->on_publish()) != ERROR_SUCCESS) {
|
||||
srs_error("flash hls on_publish failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("flash hls on_publish success.");
|
||||
}
|
||||
|
||||
while (true) {
|
||||
// switch to other st-threads.
|
||||
st_usleep(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue