1
0
Fork 0
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:
MarkCao 2023-03-06 09:09:27 +08:00 committed by GitHub
parent dc7be76bb1
commit 8fde0366fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 125 additions and 19 deletions

View file

@ -533,17 +533,20 @@ private:
private:
// Whether source is avaiable for publishing.
bool _can_publish;
// The last die time, when all consumers quit and no publisher,
// We will remove the source when source die.
srs_utime_t die_at;
// The last die time, while die means neither publishers nor players.
srs_utime_t stream_die_at_;
// The last idle time, while idle means no players.
srs_utime_t publisher_idle_at_;
public:
SrsLiveSource();
virtual ~SrsLiveSource();
public:
virtual void dispose();
virtual srs_error_t cycle();
// Remove source when expired.
virtual bool expired();
// Whether stream is dead, which is no publisher or player.
virtual bool stream_is_dead();
// Whether publisher is idle for a period of timeout.
bool publisher_is_idle_for(srs_utime_t timeout);
public:
// Initialize the hls with handlers.
virtual srs_error_t initialize(SrsRequest* r, ISrsLiveSourceHandler* h);