Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SrsLiveSource cleanup is different to SrsSrtSource #4093

Closed
lizhongjie9999 opened this issue Jun 17, 2024 · 3 comments · Fixed by #4097
Closed

SrsLiveSource cleanup is different to SrsSrtSource #4093

lizhongjie9999 opened this issue Jun 17, 2024 · 3 comments · Fixed by #4097
Assignees
Labels
EnglishNative This issue is conveyed exclusively in English. Enhancement Improvement or enhancement.

Comments

@lizhongjie9999
Copy link

lizhongjie9999 commented Jun 17, 2024

Release v6.0-d5

The original code:

void SrsLiveSource::on_consumer_destroy(SrsLiveConsumer* consumer)
{
    ...
    if (consumers.empty()) {
        play_edge->on_all_client_stop();

        // For edge server, the stream die when the last player quit, because the edge stream is created by player
        // activities, so it should die when all players quit.
        if (_srs_config->get_vhost_is_edge(req->vhost)) {
            stream_die_at_ = srs_get_system_time();
        }

        // When no players, the publisher is idle now.
        publisher_idle_at_ = srs_get_system_time();
    }
}

Code that should be changed, Similar to SrsSrtSource::on_consumer_destroy():

void SrsLiveSource::on_consumer_destroy(SrsLiveConsumer* consumer)
{
    ...
    if (consumers.empty()) {
        play_edge->on_all_client_stop();

        // For edge server, the stream die when the last player quit, because the edge stream is created by player
        // activities, so it should die when all players quit.
        if (_srs_config->get_vhost_is_edge(req->vhost)) {
            stream_die_at_ = srs_get_system_time();
        } else if (_can_publish) {  // should die when no publishers and consumers.
            stream_die_at_ = srs_get_system_time();
        }

        // When no players, the publisher is idle now.
        publisher_idle_at_ = srs_get_system_time();
    }
}
@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Jun 17, 2024
@winlinvip
Copy link
Member

winlinvip commented Jun 17, 2024

LiveSource is designed for scheduled cleanup, which differs from the cleanup method used by SrtSource. In the future, it will be modified for consistency.

TRANS_BY_GPT4

@winlinvip winlinvip changed the title stop the push first, then stop the pull, without cleaning the SrsLiveSource SrsLiveSource cleanup is different to SrsSrtSource Jun 17, 2024
@winlinvip winlinvip self-assigned this Jun 17, 2024
@winlinvip winlinvip added the Enhancement Improvement or enhancement. label Jun 17, 2024
@winlinvip
Copy link
Member

LiveSource use a timer to cleanup, because we need to dispose HLS files while disposing source. So SRTSource should follow the same rule to LiveSource.

@lizhongjie9999
Copy link
Author

Call the SrsLiveSource::on_consumer_destroy(), both the consumer and publisher are gone, stream_die_at_ needs to be set, or the timer will not clean up the SrsLiveSource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EnglishNative This issue is conveyed exclusively in English. Enhancement Improvement or enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants