mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Support reload the object cache pool
This commit is contained in:
parent
a29d6cba68
commit
36f55247a3
2 changed files with 44 additions and 1 deletions
|
@ -248,10 +248,14 @@ SrsRtcServer::SrsRtcServer()
|
||||||
handler = NULL;
|
handler = NULL;
|
||||||
hijacker = NULL;
|
hijacker = NULL;
|
||||||
timer = new SrsHourGlass("server", this, 1 * SRS_UTIME_SECONDS);
|
timer = new SrsHourGlass("server", this, 1 * SRS_UTIME_SECONDS);
|
||||||
|
|
||||||
|
_srs_config->subscribe(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcServer::~SrsRtcServer()
|
SrsRtcServer::~SrsRtcServer()
|
||||||
{
|
{
|
||||||
|
_srs_config->unsubscribe(this);
|
||||||
|
|
||||||
srs_freep(timer);
|
srs_freep(timer);
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
|
@ -301,6 +305,42 @@ srs_error_t SrsRtcServer::initialize()
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srs_error_t SrsRtcServer::on_reload_rtc_server()
|
||||||
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
bool rtp_cache_enabled = _srs_config->get_rtc_server_rtp_cache_enabled();
|
||||||
|
uint64_t rtp_cache_pkt_size = _srs_config->get_rtc_server_rtp_cache_pkt_size();
|
||||||
|
uint64_t rtp_cache_payload_size = _srs_config->get_rtc_server_rtp_cache_payload_size();
|
||||||
|
if (_srs_rtp_cache->enabled() != rtp_cache_enabled) {
|
||||||
|
_srs_rtp_cache->setup(rtp_cache_enabled, rtp_cache_pkt_size);
|
||||||
|
_srs_rtp_raw_cache->setup(rtp_cache_enabled, rtp_cache_payload_size);
|
||||||
|
_srs_rtp_fua_cache->setup(rtp_cache_enabled, rtp_cache_payload_size);
|
||||||
|
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rtp_msg_cache_enabled = _srs_config->get_rtc_server_rtp_msg_cache_enabled();
|
||||||
|
uint64_t rtp_msg_cache_msg_size = _srs_config->get_rtc_server_rtp_msg_cache_msg_size();
|
||||||
|
uint64_t rtp_msg_cache_buffer_size = _srs_config->get_rtc_server_rtp_msg_cache_buffer_size();
|
||||||
|
if (_srs_rtp_msg_cache_buffers->enabled() != rtp_msg_cache_enabled) {
|
||||||
|
_srs_rtp_msg_cache_buffers->setup(rtp_msg_cache_enabled, rtp_msg_cache_buffer_size);
|
||||||
|
_srs_rtp_msg_cache_objs->setup(rtp_msg_cache_enabled, rtp_msg_cache_msg_size);
|
||||||
|
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
srs_trace("RTC: Object cache reload, rtp-cache=(enabled:%d,pkt:%dm-%dw,payload:%dm-%dw-%dw), msg-cache=(enabled:%d,obj:%dm-%dw,buf:%dm-%dw)",
|
||||||
|
rtp_cache_enabled, (int)(rtp_cache_pkt_size/1024/1024), _srs_rtp_cache->capacity()/10000,
|
||||||
|
(int)(rtp_cache_payload_size/1024/1024), _srs_rtp_raw_cache->capacity()/10000, _srs_rtp_fua_cache->capacity()/10000,
|
||||||
|
rtp_msg_cache_enabled, (int)(rtp_msg_cache_msg_size/1024/1024), _srs_rtp_msg_cache_objs->capacity()/10000,
|
||||||
|
(int)(rtp_msg_cache_buffer_size/1024/1024), _srs_rtp_msg_cache_buffers->capacity()/10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return srs_success;
|
||||||
|
}
|
||||||
|
|
||||||
void SrsRtcServer::set_handler(ISrsRtcServerHandler* h)
|
void SrsRtcServer::set_handler(ISrsRtcServerHandler* h)
|
||||||
{
|
{
|
||||||
handler = h;
|
handler = h;
|
||||||
|
|
|
@ -85,7 +85,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// The RTC server instance, listen UDP port, handle UDP packet, manage RTC connections.
|
// The RTC server instance, listen UDP port, handle UDP packet, manage RTC connections.
|
||||||
class SrsRtcServer : virtual public ISrsUdpMuxHandler, virtual public ISrsHourGlass
|
class SrsRtcServer : virtual public ISrsUdpMuxHandler, virtual public ISrsHourGlass, virtual public ISrsReloadHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsHourGlass* timer;
|
SrsHourGlass* timer;
|
||||||
|
@ -97,6 +97,9 @@ public:
|
||||||
virtual ~SrsRtcServer();
|
virtual ~SrsRtcServer();
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t initialize();
|
virtual srs_error_t initialize();
|
||||||
|
// interface ISrsReloadHandler
|
||||||
|
public:
|
||||||
|
virtual srs_error_t on_reload_rtc_server();
|
||||||
public:
|
public:
|
||||||
// Set the handler for server events.
|
// Set the handler for server events.
|
||||||
void set_handler(ISrsRtcServerHandler* h);
|
void set_handler(ISrsRtcServerHandler* h);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue