mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Kickoff publisher when stream is idle, which means no players. v6.0.31, v5.0.144 (#3105)
For some use scenario, the publisher is invited when player want to view the stream: 1. Publisher connect to system, but does not publish any stream to SRS yet. 2. Player connect to system and start to request the stream. 3. System notifies publisher to publish stream to SRS. 4. Player play the stream from SRS. Please notice that `system` means your business system, not SRS. This is what we called `on-demand-live-streaming`, so when the last player stop to view the stream, what happends? 1. System needs to notify publisher to stop publish. 2. Or, SRS disconnect the publisher when idle(the last player stops playing). This PR is for the solution 2, so that the cleanup is very simple, your system does not need to notify publisher to stop publish, because SRS has already disconnected the publihser. --------- Co-authored-by: winlin <winlin@vip.126.com> Co-authored-by: chundonglinlin <chundonglinlin@163.com>
This commit is contained in:
parent
dc7be76bb1
commit
8fde0366fb
14 changed files with 125 additions and 19 deletions
|
@ -2559,7 +2559,7 @@ srs_error_t SrsConfig::check_normal_config()
|
|||
for (int j = 0; j < (int)conf->directives.size(); j++) {
|
||||
string m = conf->at(j)->name;
|
||||
if (m != "mr" && m != "mr_latency" && m != "firstpkt_timeout" && m != "normal_timeout"
|
||||
&& m != "parse_sps" && m != "try_annexb_first") {
|
||||
&& m != "parse_sps" && m != "try_annexb_first" && m != "kickoff_for_idle") {
|
||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal vhost.publish.%s of %s", m.c_str(), vhost->arg0().c_str());
|
||||
}
|
||||
}
|
||||
|
@ -2727,6 +2727,14 @@ srs_error_t SrsConfig::check_normal_config()
|
|||
}
|
||||
}
|
||||
|
||||
// Check forward dnd kickoff for publsher idle.
|
||||
for (int n = 0; n < (int)vhosts.size(); n++) {
|
||||
SrsConfDirective* vhost = vhosts[n];
|
||||
if (get_forward_enabled(vhost) && get_publish_kickoff_for_idle(vhost)) {
|
||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "vhost.forward conflicts with vhost.publish.kickoff_for_idle");
|
||||
}
|
||||
}
|
||||
|
||||
// check ingest id unique.
|
||||
for (int i = 0; i < (int)vhosts.size(); i++) {
|
||||
SrsConfDirective* vhost = vhosts[i];
|
||||
|
@ -5340,6 +5348,35 @@ srs_utime_t SrsConfig::get_publish_normal_timeout(string vhost)
|
|||
return (srs_utime_t)(::atoi(conf->arg0().c_str()) * SRS_UTIME_MILLISECONDS);
|
||||
}
|
||||
|
||||
srs_utime_t SrsConfig::get_publish_kickoff_for_idle(std::string vhost)
|
||||
{
|
||||
return get_publish_kickoff_for_idle(get_vhost(vhost));
|
||||
}
|
||||
|
||||
srs_utime_t SrsConfig::get_publish_kickoff_for_idle(SrsConfDirective* vhost)
|
||||
{
|
||||
SRS_OVERWRITE_BY_ENV_FLOAT_SECONDS("srs.vhost.publish.kickoff_for_idle"); // SRS_VHOST_PUBLISH_KICKOFF_FOR_IDLE
|
||||
|
||||
static srs_utime_t DEFAULT = 0 * SRS_UTIME_SECONDS;
|
||||
|
||||
SrsConfDirective* conf = vhost;
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("publish");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("kickoff_for_idle");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return (srs_utime_t)(::atof(conf->arg0().c_str()) * SRS_UTIME_SECONDS);
|
||||
}
|
||||
|
||||
int SrsConfig::get_global_chunk_size()
|
||||
{
|
||||
SRS_OVERWRITE_BY_ENV_INT("srs.vhost.chunk_size"); // SRS_VHOST_CHUNK_SIZE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue