mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
refine code:优化edge模式回源播放线程启动流程
This commit is contained in:
parent
5f77724021
commit
a5a9f7c8c5
4 changed files with 10 additions and 26 deletions
|
@ -1210,15 +1210,6 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph)
|
||||||
srs_trace("hstrs: source url=%s, is_edge=%d, source_id=%d[%d]",
|
srs_trace("hstrs: source url=%s, is_edge=%d, source_id=%d[%d]",
|
||||||
r->get_stream_url().c_str(), vhost_is_edge, s->source_id(), s->source_id());
|
r->get_stream_url().c_str(), vhost_is_edge, s->source_id(), s->source_id());
|
||||||
|
|
||||||
// TODO: FIXME: disconnect when all connection closed.
|
|
||||||
if (vhost_is_edge) {
|
|
||||||
// notice edge to start for the first client.
|
|
||||||
if ((ret = s->on_edge_start_play()) != ERROR_SUCCESS) {
|
|
||||||
srs_error("notice edge start play stream failed. ret=%d", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -537,14 +537,6 @@ int SrsRtmpConn::playing(SrsSource* source)
|
||||||
SrsAutoFree(SrsConsumer, consumer);
|
SrsAutoFree(SrsConsumer, consumer);
|
||||||
srs_verbose("consumer created success.");
|
srs_verbose("consumer created success.");
|
||||||
|
|
||||||
if (_srs_config->get_vhost_is_edge(req->vhost)) {
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// use isolate thread to recv,
|
// use isolate thread to recv,
|
||||||
// @see: https://github.com/simple-rtmp-server/srs/issues/217
|
// @see: https://github.com/simple-rtmp-server/srs/issues/217
|
||||||
SrsQueueRecvThread trd(consumer, rtmp, SRS_PERF_MW_SLEEP);
|
SrsQueueRecvThread trd(consumer, rtmp, SRS_PERF_MW_SLEEP);
|
||||||
|
@ -835,7 +827,6 @@ int SrsRtmpConn::acquire_publish(SrsSource* source, bool is_edge)
|
||||||
if ((ret = source->on_edge_start_publish()) != ERROR_SUCCESS) {
|
if ((ret = source->on_edge_start_publish()) != ERROR_SUCCESS) {
|
||||||
srs_error("notice edge start publish stream failed. ret=%d", ret);
|
srs_error("notice edge start publish stream failed. ret=%d", ret);
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
} else {
|
} else {
|
||||||
if ((ret = source->on_publish()) != ERROR_SUCCESS) {
|
if ((ret = source->on_publish()) != ERROR_SUCCESS) {
|
||||||
srs_error("notify publish failed. ret=%d", ret);
|
srs_error("notify publish failed. ret=%d", ret);
|
||||||
|
|
|
@ -765,7 +765,7 @@ SrsSource* SrsSource::fetch(SrsRequest* r)
|
||||||
SrsSource* SrsSource::fetch(std::string vhost, std::string app, std::string stream)
|
SrsSource* SrsSource::fetch(std::string vhost, std::string app, std::string stream)
|
||||||
{
|
{
|
||||||
SrsSource* source = NULL;
|
SrsSource* source = NULL;
|
||||||
string stream_url = srs_generate_stream_url(vhost, app, stream);
|
string stream_url = srs_generate_stream_url(vhost, app, stream);
|
||||||
|
|
||||||
if (pool.find(stream_url) == pool.end()) {
|
if (pool.find(stream_url) == pool.end()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2135,6 +2135,15 @@ int SrsSource::create_consumer(SrsConsumer*& consumer, bool ds, bool dm, bool dg
|
||||||
} else {
|
} else {
|
||||||
srs_trace("create consumer, ignore gop cache, jitter=%d", jitter_algorithm);
|
srs_trace("create consumer, ignore gop cache, jitter=%d", jitter_algorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for edge, when play edge stream, check the state
|
||||||
|
if (_srs_config->get_vhost_is_edge(_req->vhost)) {
|
||||||
|
// notice edge to start for the first client.
|
||||||
|
if ((ret = play_edge->on_client_play()) != ERROR_SUCCESS) {
|
||||||
|
srs_error("notice edge start play stream failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2163,11 +2172,6 @@ SrsRtmpJitterAlgorithm SrsSource::jitter()
|
||||||
return jitter_algorithm;
|
return jitter_algorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsSource::on_edge_start_play()
|
|
||||||
{
|
|
||||||
return play_edge->on_client_play();
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsSource::on_edge_start_publish()
|
int SrsSource::on_edge_start_publish()
|
||||||
{
|
{
|
||||||
return publish_edge->on_client_publish();
|
return publish_edge->on_client_publish();
|
||||||
|
|
|
@ -574,8 +574,6 @@ public:
|
||||||
virtual SrsRtmpJitterAlgorithm jitter();
|
virtual SrsRtmpJitterAlgorithm jitter();
|
||||||
// internal
|
// internal
|
||||||
public:
|
public:
|
||||||
// for edge, when play edge stream, check the state
|
|
||||||
virtual int on_edge_start_play();
|
|
||||||
// for edge, when publish edge stream, check the state
|
// for edge, when publish edge stream, check the state
|
||||||
virtual int on_edge_start_publish();
|
virtual int on_edge_start_publish();
|
||||||
// for edge, proxy the publish
|
// for edge, proxy the publish
|
||||||
|
|
Loading…
Reference in a new issue