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
|
@ -985,6 +985,7 @@ srs_error_t SrsRtmpConn::do_publishing(SrsLiveSource* source, SrsPublishRecvThre
|
|||
// initialize the publish timeout.
|
||||
publish_1stpkt_timeout = _srs_config->get_publish_1stpkt_timeout(req->vhost);
|
||||
publish_normal_timeout = _srs_config->get_publish_normal_timeout(req->vhost);
|
||||
srs_utime_t publish_kickoff_for_idle = _srs_config->get_publish_kickoff_for_idle(req->vhost);
|
||||
|
||||
// set the sock options.
|
||||
set_sock_options();
|
||||
|
@ -1008,6 +1009,11 @@ srs_error_t SrsRtmpConn::do_publishing(SrsLiveSource* source, SrsPublishRecvThre
|
|||
return srs_error_wrap(err, "rtmp: thread quit");
|
||||
}
|
||||
|
||||
// Kick off the publisher when idle for a period of timeout.
|
||||
if (source->publisher_is_idle_for(publish_kickoff_for_idle)) {
|
||||
return srs_error_new(ERROR_KICKOFF_FOR_IDLE, "kicked for idle, url=%s, timeout=%ds", req->tcUrl.c_str(), srsu2si(publish_kickoff_for_idle));
|
||||
}
|
||||
|
||||
pprint->elapse();
|
||||
|
||||
// cond wait for timeout.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue