mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 19:31:53 +00:00
SquashSRS4: Refine the init of global objects
This commit is contained in:
parent
276bd2223e
commit
3256c7c2fa
20 changed files with 412 additions and 153 deletions
|
@ -182,6 +182,7 @@ The ports used by SRS:
|
|||
|
||||
## V4 changes
|
||||
|
||||
* v4.0, 2021-05-08, Refine global or thread-local variables initialize. 4.0.104
|
||||
* v4.0, 2021-05-07, RTC: Support circuit breaker. 4.0.103
|
||||
* v4.0, 2021-05-07, RTC: Refine play stream find track. 4.0.102
|
||||
* v4.0, 2021-05-07, RTC: Refine FastTimer to fixed interval. 4.0.101
|
||||
|
|
|
@ -38,10 +38,10 @@ using namespace std;
|
|||
|
||||
#include <srs_protocol_kbps.hpp>
|
||||
|
||||
SrsPps* _srs_pps_ids = new SrsPps();
|
||||
SrsPps* _srs_pps_fids = new SrsPps();
|
||||
SrsPps* _srs_pps_fids_level0 = new SrsPps();
|
||||
SrsPps* _srs_pps_dispose = new SrsPps();
|
||||
SrsPps* _srs_pps_ids = NULL;
|
||||
SrsPps* _srs_pps_fids = NULL;
|
||||
SrsPps* _srs_pps_fids_level0 = NULL;
|
||||
SrsPps* _srs_pps_dispose = NULL;
|
||||
|
||||
ISrsDisposingHandler::ISrsDisposingHandler()
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ using namespace std;
|
|||
|
||||
#include <srs_protocol_kbps.hpp>
|
||||
|
||||
SrsPps* _srs_pps_timer = new SrsPps();
|
||||
SrsPps* _srs_pps_timer = NULL;
|
||||
|
||||
extern SrsPps* _srs_pps_clock_15ms;
|
||||
extern SrsPps* _srs_pps_clock_20ms;
|
||||
|
|
|
@ -44,10 +44,10 @@ extern unsigned long long _st_stat_recvfrom;
|
|||
extern unsigned long long _st_stat_recvfrom_eagain;
|
||||
extern unsigned long long _st_stat_sendto;
|
||||
extern unsigned long long _st_stat_sendto_eagain;
|
||||
SrsPps* _srs_pps_recvfrom = new SrsPps();
|
||||
SrsPps* _srs_pps_recvfrom_eagain = new SrsPps();
|
||||
SrsPps* _srs_pps_sendto = new SrsPps();
|
||||
SrsPps* _srs_pps_sendto_eagain = new SrsPps();
|
||||
SrsPps* _srs_pps_recvfrom = NULL;
|
||||
SrsPps* _srs_pps_recvfrom_eagain = NULL;
|
||||
SrsPps* _srs_pps_sendto = NULL;
|
||||
SrsPps* _srs_pps_sendto_eagain = NULL;
|
||||
|
||||
extern unsigned long long _st_stat_read;
|
||||
extern unsigned long long _st_stat_read_eagain;
|
||||
|
@ -55,30 +55,30 @@ extern unsigned long long _st_stat_readv;
|
|||
extern unsigned long long _st_stat_readv_eagain;
|
||||
extern unsigned long long _st_stat_writev;
|
||||
extern unsigned long long _st_stat_writev_eagain;
|
||||
SrsPps* _srs_pps_read = new SrsPps();
|
||||
SrsPps* _srs_pps_read_eagain = new SrsPps();
|
||||
SrsPps* _srs_pps_readv = new SrsPps();
|
||||
SrsPps* _srs_pps_readv_eagain = new SrsPps();
|
||||
SrsPps* _srs_pps_writev = new SrsPps();
|
||||
SrsPps* _srs_pps_writev_eagain = new SrsPps();
|
||||
SrsPps* _srs_pps_read = NULL;
|
||||
SrsPps* _srs_pps_read_eagain = NULL;
|
||||
SrsPps* _srs_pps_readv = NULL;
|
||||
SrsPps* _srs_pps_readv_eagain = NULL;
|
||||
SrsPps* _srs_pps_writev = NULL;
|
||||
SrsPps* _srs_pps_writev_eagain = NULL;
|
||||
|
||||
extern unsigned long long _st_stat_recvmsg;
|
||||
extern unsigned long long _st_stat_recvmsg_eagain;
|
||||
extern unsigned long long _st_stat_sendmsg;
|
||||
extern unsigned long long _st_stat_sendmsg_eagain;
|
||||
SrsPps* _srs_pps_recvmsg = new SrsPps();
|
||||
SrsPps* _srs_pps_recvmsg_eagain = new SrsPps();
|
||||
SrsPps* _srs_pps_sendmsg = new SrsPps();
|
||||
SrsPps* _srs_pps_sendmsg_eagain = new SrsPps();
|
||||
SrsPps* _srs_pps_recvmsg = NULL;
|
||||
SrsPps* _srs_pps_recvmsg_eagain = NULL;
|
||||
SrsPps* _srs_pps_sendmsg = NULL;
|
||||
SrsPps* _srs_pps_sendmsg_eagain = NULL;
|
||||
|
||||
extern unsigned long long _st_stat_epoll;
|
||||
extern unsigned long long _st_stat_epoll_zero;
|
||||
extern unsigned long long _st_stat_epoll_shake;
|
||||
extern unsigned long long _st_stat_epoll_spin;
|
||||
SrsPps* _srs_pps_epoll = new SrsPps();
|
||||
SrsPps* _srs_pps_epoll_zero = new SrsPps();
|
||||
SrsPps* _srs_pps_epoll_shake = new SrsPps();
|
||||
SrsPps* _srs_pps_epoll_spin = new SrsPps();
|
||||
SrsPps* _srs_pps_epoll = NULL;
|
||||
SrsPps* _srs_pps_epoll_zero = NULL;
|
||||
SrsPps* _srs_pps_epoll_shake = NULL;
|
||||
SrsPps* _srs_pps_epoll_spin = NULL;
|
||||
|
||||
extern unsigned long long _st_stat_sched_15ms;
|
||||
extern unsigned long long _st_stat_sched_20ms;
|
||||
|
@ -89,26 +89,26 @@ extern unsigned long long _st_stat_sched_40ms;
|
|||
extern unsigned long long _st_stat_sched_80ms;
|
||||
extern unsigned long long _st_stat_sched_160ms;
|
||||
extern unsigned long long _st_stat_sched_s;
|
||||
SrsPps* _srs_pps_sched_15ms = new SrsPps();
|
||||
SrsPps* _srs_pps_sched_20ms = new SrsPps();
|
||||
SrsPps* _srs_pps_sched_25ms = new SrsPps();
|
||||
SrsPps* _srs_pps_sched_30ms = new SrsPps();
|
||||
SrsPps* _srs_pps_sched_35ms = new SrsPps();
|
||||
SrsPps* _srs_pps_sched_40ms = new SrsPps();
|
||||
SrsPps* _srs_pps_sched_80ms = new SrsPps();
|
||||
SrsPps* _srs_pps_sched_160ms = new SrsPps();
|
||||
SrsPps* _srs_pps_sched_s = new SrsPps();
|
||||
SrsPps* _srs_pps_sched_15ms = NULL;
|
||||
SrsPps* _srs_pps_sched_20ms = NULL;
|
||||
SrsPps* _srs_pps_sched_25ms = NULL;
|
||||
SrsPps* _srs_pps_sched_30ms = NULL;
|
||||
SrsPps* _srs_pps_sched_35ms = NULL;
|
||||
SrsPps* _srs_pps_sched_40ms = NULL;
|
||||
SrsPps* _srs_pps_sched_80ms = NULL;
|
||||
SrsPps* _srs_pps_sched_160ms = NULL;
|
||||
SrsPps* _srs_pps_sched_s = NULL;
|
||||
#endif
|
||||
|
||||
SrsPps* _srs_pps_clock_15ms = new SrsPps();
|
||||
SrsPps* _srs_pps_clock_20ms = new SrsPps();
|
||||
SrsPps* _srs_pps_clock_25ms = new SrsPps();
|
||||
SrsPps* _srs_pps_clock_30ms = new SrsPps();
|
||||
SrsPps* _srs_pps_clock_35ms = new SrsPps();
|
||||
SrsPps* _srs_pps_clock_40ms = new SrsPps();
|
||||
SrsPps* _srs_pps_clock_80ms = new SrsPps();
|
||||
SrsPps* _srs_pps_clock_160ms = new SrsPps();
|
||||
SrsPps* _srs_pps_timer_s = new SrsPps();
|
||||
SrsPps* _srs_pps_clock_15ms = NULL;
|
||||
SrsPps* _srs_pps_clock_20ms = NULL;
|
||||
SrsPps* _srs_pps_clock_25ms = NULL;
|
||||
SrsPps* _srs_pps_clock_30ms = NULL;
|
||||
SrsPps* _srs_pps_clock_35ms = NULL;
|
||||
SrsPps* _srs_pps_clock_40ms = NULL;
|
||||
SrsPps* _srs_pps_clock_80ms = NULL;
|
||||
SrsPps* _srs_pps_clock_160ms = NULL;
|
||||
SrsPps* _srs_pps_timer_s = NULL;
|
||||
|
||||
#if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS)
|
||||
extern int _st_active_count;
|
||||
|
@ -116,10 +116,10 @@ extern unsigned long long _st_stat_thread_run;
|
|||
extern unsigned long long _st_stat_thread_idle;
|
||||
extern unsigned long long _st_stat_thread_yield;
|
||||
extern unsigned long long _st_stat_thread_yield2;
|
||||
SrsPps* _srs_pps_thread_run = new SrsPps();
|
||||
SrsPps* _srs_pps_thread_idle = new SrsPps();
|
||||
SrsPps* _srs_pps_thread_yield = new SrsPps();
|
||||
SrsPps* _srs_pps_thread_yield2 = new SrsPps();
|
||||
SrsPps* _srs_pps_thread_run = NULL;
|
||||
SrsPps* _srs_pps_thread_idle = NULL;
|
||||
SrsPps* _srs_pps_thread_yield = NULL;
|
||||
SrsPps* _srs_pps_thread_yield2 = NULL;
|
||||
#endif
|
||||
|
||||
extern SrsPps* _srs_pps_objs_rtps;
|
||||
|
@ -139,10 +139,11 @@ ISrsHybridServer::~ISrsHybridServer()
|
|||
|
||||
SrsHybridServer::SrsHybridServer()
|
||||
{
|
||||
// Note that the timer depends on other global variables,
|
||||
// so we MUST never create it in constructor.
|
||||
timer20ms_ = NULL;
|
||||
timer5s_ = NULL;
|
||||
// Create global shared timer.
|
||||
timer20ms_ = new SrsFastTimer("hybrid", 20 * SRS_UTIME_MILLISECONDS);
|
||||
timer100ms_ = new SrsFastTimer("hybrid", 100 * SRS_UTIME_MILLISECONDS);
|
||||
timer1s_ = new SrsFastTimer("hybrid", 1 * SRS_UTIME_SECONDS);
|
||||
timer5s_ = new SrsFastTimer("hybrid", 5 * SRS_UTIME_SECONDS);
|
||||
|
||||
clock_monitor_ = new SrsClockWallMonitor();
|
||||
}
|
||||
|
@ -150,7 +151,10 @@ SrsHybridServer::SrsHybridServer()
|
|||
SrsHybridServer::~SrsHybridServer()
|
||||
{
|
||||
srs_freep(clock_monitor_);
|
||||
|
||||
srs_freep(timer20ms_);
|
||||
srs_freep(timer100ms_);
|
||||
srs_freep(timer1s_);
|
||||
srs_freep(timer5s_);
|
||||
|
||||
vector<ISrsHybridServer*>::iterator it;
|
||||
|
@ -170,17 +174,6 @@ srs_error_t SrsHybridServer::initialize()
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// init st
|
||||
if ((err = srs_st_init()) != srs_success) {
|
||||
return srs_error_wrap(err, "initialize st failed");
|
||||
}
|
||||
|
||||
// Create global shared timer.
|
||||
timer20ms_ = new SrsFastTimer("hybrid", 20 * SRS_UTIME_MILLISECONDS);
|
||||
timer100ms_ = new SrsFastTimer("hybrid", 100 * SRS_UTIME_MILLISECONDS);
|
||||
timer1s_ = new SrsFastTimer("hybrid", 1 * SRS_UTIME_SECONDS);
|
||||
timer5s_ = new SrsFastTimer("hybrid", 5 * SRS_UTIME_SECONDS);
|
||||
|
||||
// Start the timer first.
|
||||
if ((err = timer20ms_->start()) != srs_success) {
|
||||
return srs_error_wrap(err, "start timer");
|
||||
|
@ -409,5 +402,5 @@ srs_error_t SrsHybridServer::on_timer(srs_utime_t interval)
|
|||
return err;
|
||||
}
|
||||
|
||||
SrsHybridServer* _srs_hybrid = new SrsHybridServer();
|
||||
SrsHybridServer* _srs_hybrid = NULL;
|
||||
|
||||
|
|
|
@ -45,11 +45,11 @@ using namespace std;
|
|||
|
||||
#include <srs_protocol_kbps.hpp>
|
||||
|
||||
SrsPps* _srs_pps_rpkts = new SrsPps();
|
||||
SrsPps* _srs_pps_addrs = new SrsPps();
|
||||
SrsPps* _srs_pps_fast_addrs = new SrsPps();
|
||||
SrsPps* _srs_pps_rpkts = NULL;
|
||||
SrsPps* _srs_pps_addrs = NULL;
|
||||
SrsPps* _srs_pps_fast_addrs = NULL;
|
||||
|
||||
SrsPps* _srs_pps_spkts = new SrsPps();
|
||||
SrsPps* _srs_pps_spkts = NULL;
|
||||
|
||||
// set the max packet size.
|
||||
#define SRS_UDP_MAX_PACKET_SIZE 65535
|
||||
|
|
|
@ -193,7 +193,7 @@ bool SrsAlonePithyPrint::can_print()
|
|||
}
|
||||
|
||||
// The global stage manager for pithy print, multiple stages.
|
||||
static SrsStageManager* _srs_stages = new SrsStageManager();
|
||||
SrsStageManager* _srs_stages = NULL;
|
||||
|
||||
SrsPithyPrint::SrsPithyPrint(int _stage_id)
|
||||
{
|
||||
|
|
|
@ -61,15 +61,15 @@ using namespace std;
|
|||
|
||||
#include <srs_protocol_kbps.hpp>
|
||||
|
||||
SrsPps* _srs_pps_sstuns = new SrsPps();
|
||||
SrsPps* _srs_pps_srtcps = new SrsPps();
|
||||
SrsPps* _srs_pps_srtps = new SrsPps();
|
||||
SrsPps* _srs_pps_sstuns = NULL;
|
||||
SrsPps* _srs_pps_srtcps = NULL;
|
||||
SrsPps* _srs_pps_srtps = NULL;
|
||||
|
||||
SrsPps* _srs_pps_pli = new SrsPps();
|
||||
SrsPps* _srs_pps_twcc = new SrsPps();
|
||||
SrsPps* _srs_pps_rr = new SrsPps();
|
||||
SrsPps* _srs_pps_pub = new SrsPps();
|
||||
SrsPps* _srs_pps_conn = new SrsPps();
|
||||
SrsPps* _srs_pps_pli = NULL;
|
||||
SrsPps* _srs_pps_twcc = NULL;
|
||||
SrsPps* _srs_pps_rr = NULL;
|
||||
SrsPps* _srs_pps_pub = NULL;
|
||||
SrsPps* _srs_pps_conn = NULL;
|
||||
|
||||
extern SrsPps* _srs_pps_snack;
|
||||
extern SrsPps* _srs_pps_snack2;
|
||||
|
|
|
@ -46,9 +46,9 @@ using namespace std;
|
|||
#include <srs_protocol_utility.hpp>
|
||||
|
||||
extern SrsPps* _srs_pps_rpkts;
|
||||
SrsPps* _srs_pps_rstuns = new SrsPps();
|
||||
SrsPps* _srs_pps_rrtps = new SrsPps();
|
||||
SrsPps* _srs_pps_rrtcps = new SrsPps();
|
||||
SrsPps* _srs_pps_rstuns = NULL;
|
||||
SrsPps* _srs_pps_rrtps = NULL;
|
||||
SrsPps* _srs_pps_rrtcps = NULL;
|
||||
extern SrsPps* _srs_pps_addrs;
|
||||
extern SrsPps* _srs_pps_fast_addrs;
|
||||
|
||||
|
@ -132,10 +132,10 @@ void SrsRtcBlackhole::sendto(void* data, int len)
|
|||
srs_sendto(blackhole_stfd, data, len, (sockaddr*)blackhole_addr, sizeof(sockaddr_in), SRS_UTIME_NO_TIMEOUT);
|
||||
}
|
||||
|
||||
SrsRtcBlackhole* _srs_blackhole = new SrsRtcBlackhole();
|
||||
SrsRtcBlackhole* _srs_blackhole = NULL;
|
||||
|
||||
// @global dtls certficate for rtc module.
|
||||
SrsDtlsCertificate* _srs_rtc_dtls_certificate = new SrsDtlsCertificate();
|
||||
SrsDtlsCertificate* _srs_rtc_dtls_certificate = NULL;
|
||||
|
||||
// TODO: Should support error response.
|
||||
// For STUN packet, 0x00 is binding request, 0x01 is binding success response.
|
||||
|
@ -777,5 +777,5 @@ void RtcServerAdapter::stop()
|
|||
{
|
||||
}
|
||||
|
||||
SrsResourceManager* _srs_rtc_manager = new SrsResourceManager("RTC", true);
|
||||
SrsResourceManager* _srs_rtc_manager = NULL;
|
||||
|
||||
|
|
|
@ -52,17 +52,17 @@
|
|||
#include <srs_protocol_kbps.hpp>
|
||||
|
||||
// The NACK sent by us(SFU).
|
||||
SrsPps* _srs_pps_snack = new SrsPps();
|
||||
SrsPps* _srs_pps_snack2 = new SrsPps();
|
||||
SrsPps* _srs_pps_snack3 = new SrsPps();
|
||||
SrsPps* _srs_pps_snack4 = new SrsPps();
|
||||
SrsPps* _srs_pps_sanack = new SrsPps();
|
||||
SrsPps* _srs_pps_svnack = new SrsPps();
|
||||
SrsPps* _srs_pps_snack = NULL;
|
||||
SrsPps* _srs_pps_snack2 = NULL;
|
||||
SrsPps* _srs_pps_snack3 = NULL;
|
||||
SrsPps* _srs_pps_snack4 = NULL;
|
||||
SrsPps* _srs_pps_sanack = NULL;
|
||||
SrsPps* _srs_pps_svnack = NULL;
|
||||
|
||||
SrsPps* _srs_pps_rnack = new SrsPps();
|
||||
SrsPps* _srs_pps_rnack2 = new SrsPps();
|
||||
SrsPps* _srs_pps_rhnack = new SrsPps();
|
||||
SrsPps* _srs_pps_rmnack = new SrsPps();
|
||||
SrsPps* _srs_pps_rnack = NULL;
|
||||
SrsPps* _srs_pps_rnack2 = NULL;
|
||||
SrsPps* _srs_pps_rhnack = NULL;
|
||||
SrsPps* _srs_pps_rmnack = NULL;
|
||||
|
||||
extern SrsPps* _srs_pps_aloss2;
|
||||
|
||||
|
@ -249,7 +249,7 @@ void SrsRtcConsumer::on_stream_change(SrsRtcStreamDescription* desc)
|
|||
|
||||
SrsRtcStreamManager::SrsRtcStreamManager()
|
||||
{
|
||||
lock = NULL;
|
||||
lock = srs_mutex_new();
|
||||
}
|
||||
|
||||
SrsRtcStreamManager::~SrsRtcStreamManager()
|
||||
|
@ -261,11 +261,6 @@ srs_error_t SrsRtcStreamManager::fetch_or_create(SrsRequest* r, SrsRtcStream** p
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// Lazy create lock, because ST is not ready in SrsRtcStreamManager constructor.
|
||||
if (!lock) {
|
||||
lock = srs_mutex_new();
|
||||
}
|
||||
|
||||
// Use lock to protect coroutine switch.
|
||||
// @bug https://github.com/ossrs/srs/issues/1230
|
||||
SrsLocker(lock);
|
||||
|
@ -315,7 +310,7 @@ SrsRtcStream* SrsRtcStreamManager::fetch(SrsRequest* r)
|
|||
return source;
|
||||
}
|
||||
|
||||
SrsRtcStreamManager* _srs_rtc_sources = new SrsRtcStreamManager();
|
||||
SrsRtcStreamManager* _srs_rtc_sources = NULL;
|
||||
|
||||
ISrsRtcPublishStream::ISrsRtcPublishStream()
|
||||
{
|
||||
|
|
|
@ -1684,17 +1684,18 @@ srs_error_t SrsMetaCache::update_vsh(SrsSharedPtrMessage* msg)
|
|||
return vformat->on_video(msg);
|
||||
}
|
||||
|
||||
SrsSourceManager* _srs_sources = new SrsSourceManager();
|
||||
SrsSourceManager* _srs_sources = NULL;
|
||||
|
||||
SrsSourceManager::SrsSourceManager()
|
||||
{
|
||||
lock = NULL;
|
||||
timer_ = NULL;
|
||||
lock = srs_mutex_new();
|
||||
timer_ = new SrsHourGlass("sources", this, 1 * SRS_UTIME_SECONDS);
|
||||
}
|
||||
|
||||
SrsSourceManager::~SrsSourceManager()
|
||||
{
|
||||
srs_mutex_destroy(lock);
|
||||
srs_freep(timer_);
|
||||
}
|
||||
|
||||
srs_error_t SrsSourceManager::initialize()
|
||||
|
@ -1706,11 +1707,6 @@ srs_error_t SrsSourceManager::fetch_or_create(SrsRequest* r, ISrsSourceHandler*
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// Lazy create lock, because ST is not ready in SrsSourceManager constructor.
|
||||
if (!lock) {
|
||||
lock = srs_mutex_new();
|
||||
}
|
||||
|
||||
// Use lock to protect coroutine switch.
|
||||
// @bug https://github.com/ossrs/srs/issues/1230
|
||||
// TODO: FIXME: Use smaller lock.
|
||||
|
@ -1778,9 +1774,6 @@ srs_error_t SrsSourceManager::setup_ticks()
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
srs_freep(timer_);
|
||||
timer_ = new SrsHourGlass("sources", this, 1 * SRS_UTIME_SECONDS);
|
||||
|
||||
if ((err = timer_->tick(1, 1 * SRS_UTIME_SECONDS)) != srs_success) {
|
||||
return srs_error_wrap(err, "tick");
|
||||
}
|
||||
|
|
|
@ -27,17 +27,146 @@
|
|||
#include <srs_app_hybrid.hpp>
|
||||
#include <srs_app_utility.hpp>
|
||||
#include <srs_kernel_utility.hpp>
|
||||
#include <srs_app_rtc_source.hpp>
|
||||
#include <srs_app_source.hpp>
|
||||
#include <srs_app_pithy_print.hpp>
|
||||
#include <srs_app_rtc_server.hpp>
|
||||
#include <srs_app_rtc_dtls.hpp>
|
||||
#include <srs_app_rtc_conn.hpp>
|
||||
#include <srs_app_log.hpp>
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
extern ISrsLog* _srs_log;
|
||||
extern ISrsContext* _srs_context;
|
||||
extern SrsConfig* _srs_config;
|
||||
|
||||
extern SrsStageManager* _srs_stages;
|
||||
extern SrsRtcBlackhole* _srs_blackhole;
|
||||
extern SrsResourceManager* _srs_rtc_manager;
|
||||
|
||||
extern SrsRtpObjectCacheManager<SrsRtpPacket2>* _srs_rtp_cache;
|
||||
extern SrsRtpObjectCacheManager<SrsRtpRawPayload>* _srs_rtp_raw_cache;
|
||||
extern SrsRtpObjectCacheManager<SrsRtpFUAPayload2>* _srs_rtp_fua_cache;
|
||||
|
||||
extern SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_buffers;
|
||||
extern SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_objs;
|
||||
|
||||
extern SrsResourceManager* _srs_rtc_manager;
|
||||
extern SrsDtlsCertificate* _srs_rtc_dtls_certificate;
|
||||
|
||||
#include <srs_protocol_kbps.hpp>
|
||||
|
||||
extern SrsPps* _srs_pps_snack2;
|
||||
extern SrsPps* _srs_pps_snack3;
|
||||
extern SrsPps* _srs_pps_snack4;
|
||||
|
||||
SrsPps* _srs_pps_aloss2 = new SrsPps();
|
||||
SrsPps* _srs_pps_aloss2 = NULL;
|
||||
|
||||
extern SrsPps* _srs_pps_ids;
|
||||
extern SrsPps* _srs_pps_fids;
|
||||
extern SrsPps* _srs_pps_fids_level0;
|
||||
extern SrsPps* _srs_pps_dispose;
|
||||
|
||||
extern SrsPps* _srs_pps_timer;
|
||||
|
||||
extern SrsPps* _srs_pps_snack;
|
||||
extern SrsPps* _srs_pps_snack2;
|
||||
extern SrsPps* _srs_pps_snack3;
|
||||
extern SrsPps* _srs_pps_snack4;
|
||||
extern SrsPps* _srs_pps_sanack;
|
||||
extern SrsPps* _srs_pps_svnack;
|
||||
|
||||
extern SrsPps* _srs_pps_rnack;
|
||||
extern SrsPps* _srs_pps_rnack2;
|
||||
extern SrsPps* _srs_pps_rhnack;
|
||||
extern SrsPps* _srs_pps_rmnack;
|
||||
|
||||
#if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS)
|
||||
extern SrsPps* _srs_pps_recvfrom;
|
||||
extern SrsPps* _srs_pps_recvfrom_eagain;
|
||||
extern SrsPps* _srs_pps_sendto;
|
||||
extern SrsPps* _srs_pps_sendto_eagain;
|
||||
|
||||
extern SrsPps* _srs_pps_read;
|
||||
extern SrsPps* _srs_pps_read_eagain;
|
||||
extern SrsPps* _srs_pps_readv;
|
||||
extern SrsPps* _srs_pps_readv_eagain;
|
||||
extern SrsPps* _srs_pps_writev;
|
||||
extern SrsPps* _srs_pps_writev_eagain;
|
||||
|
||||
extern SrsPps* _srs_pps_recvmsg;
|
||||
extern SrsPps* _srs_pps_recvmsg_eagain;
|
||||
extern SrsPps* _srs_pps_sendmsg;
|
||||
extern SrsPps* _srs_pps_sendmsg_eagain;
|
||||
|
||||
extern SrsPps* _srs_pps_epoll;
|
||||
extern SrsPps* _srs_pps_epoll_zero;
|
||||
extern SrsPps* _srs_pps_epoll_shake;
|
||||
extern SrsPps* _srs_pps_epoll_spin;
|
||||
|
||||
extern SrsPps* _srs_pps_sched_15ms;
|
||||
extern SrsPps* _srs_pps_sched_20ms;
|
||||
extern SrsPps* _srs_pps_sched_25ms;
|
||||
extern SrsPps* _srs_pps_sched_30ms;
|
||||
extern SrsPps* _srs_pps_sched_35ms;
|
||||
extern SrsPps* _srs_pps_sched_40ms;
|
||||
extern SrsPps* _srs_pps_sched_80ms;
|
||||
extern SrsPps* _srs_pps_sched_160ms;
|
||||
extern SrsPps* _srs_pps_sched_s;
|
||||
#endif
|
||||
|
||||
extern SrsPps* _srs_pps_clock_15ms;
|
||||
extern SrsPps* _srs_pps_clock_20ms;
|
||||
extern SrsPps* _srs_pps_clock_25ms;
|
||||
extern SrsPps* _srs_pps_clock_30ms;
|
||||
extern SrsPps* _srs_pps_clock_35ms;
|
||||
extern SrsPps* _srs_pps_clock_40ms;
|
||||
extern SrsPps* _srs_pps_clock_80ms;
|
||||
extern SrsPps* _srs_pps_clock_160ms;
|
||||
extern SrsPps* _srs_pps_timer_s;
|
||||
|
||||
#if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS)
|
||||
extern SrsPps* _srs_pps_thread_run;
|
||||
extern SrsPps* _srs_pps_thread_idle;
|
||||
extern SrsPps* _srs_pps_thread_yield;
|
||||
extern SrsPps* _srs_pps_thread_yield2;
|
||||
#endif
|
||||
|
||||
extern SrsPps* _srs_pps_rpkts;
|
||||
extern SrsPps* _srs_pps_addrs;
|
||||
extern SrsPps* _srs_pps_fast_addrs;
|
||||
|
||||
extern SrsPps* _srs_pps_spkts;
|
||||
|
||||
extern SrsPps* _srs_pps_sstuns;
|
||||
extern SrsPps* _srs_pps_srtcps;
|
||||
extern SrsPps* _srs_pps_srtps;
|
||||
|
||||
extern SrsPps* _srs_pps_pli;
|
||||
extern SrsPps* _srs_pps_twcc;
|
||||
extern SrsPps* _srs_pps_rr;
|
||||
extern SrsPps* _srs_pps_pub;
|
||||
extern SrsPps* _srs_pps_conn;
|
||||
|
||||
extern SrsPps* _srs_pps_rstuns;
|
||||
extern SrsPps* _srs_pps_rrtps;
|
||||
extern SrsPps* _srs_pps_rrtcps;
|
||||
|
||||
extern SrsPps* _srs_pps_aloss2;
|
||||
|
||||
extern SrsPps* _srs_pps_cids_get;
|
||||
extern SrsPps* _srs_pps_cids_set;
|
||||
|
||||
extern SrsPps* _srs_pps_objs_msgs;
|
||||
|
||||
extern SrsPps* _srs_pps_objs_rtps;
|
||||
extern SrsPps* _srs_pps_objs_rraw;
|
||||
extern SrsPps* _srs_pps_objs_rfua;
|
||||
extern SrsPps* _srs_pps_objs_rbuf;
|
||||
extern SrsPps* _srs_pps_objs_rothers;
|
||||
extern SrsPps* _srs_pps_objs_drop;
|
||||
|
||||
SrsCircuitBreaker::SrsCircuitBreaker()
|
||||
{
|
||||
|
@ -83,12 +212,12 @@ srs_error_t SrsCircuitBreaker::initialize()
|
|||
|
||||
bool SrsCircuitBreaker::hybrid_high_water_level()
|
||||
{
|
||||
return enabled_ && hybrid_critical_water_level() || hybrid_high_water_level_;
|
||||
return enabled_ && (hybrid_critical_water_level() || hybrid_high_water_level_);
|
||||
}
|
||||
|
||||
bool SrsCircuitBreaker::hybrid_critical_water_level()
|
||||
{
|
||||
return enabled_ && hybrid_dying_water_level() || hybrid_critical_water_level_;
|
||||
return enabled_ && (hybrid_dying_water_level() || hybrid_critical_water_level_);
|
||||
}
|
||||
|
||||
bool SrsCircuitBreaker::hybrid_dying_water_level()
|
||||
|
@ -133,7 +262,7 @@ srs_error_t SrsCircuitBreaker::on_timer(srs_utime_t interval)
|
|||
// The hybrid thread cpu and memory.
|
||||
float thread_percent = stat->percent * 100;
|
||||
|
||||
if (enabled_ && hybrid_high_water_level() || hybrid_critical_water_level() || _srs_pps_snack2->r10s()) {
|
||||
if (enabled_ && (hybrid_high_water_level() || hybrid_critical_water_level() || _srs_pps_snack2->r10s())) {
|
||||
srs_trace("CircuitBreaker: cpu=%.2f%%,%dMB, break=%d,%d,%d, cond=%.2f%%, snk=%d,%d,%d",
|
||||
u->percent * 100, memory,
|
||||
hybrid_high_water_level(), hybrid_critical_water_level(), hybrid_dying_water_level(), // Whether Circuit-Break is enable.
|
||||
|
@ -145,5 +274,150 @@ srs_error_t SrsCircuitBreaker::on_timer(srs_utime_t interval)
|
|||
return err;
|
||||
}
|
||||
|
||||
SrsCircuitBreaker* _srs_circuit_breaker = new SrsCircuitBreaker();
|
||||
SrsCircuitBreaker* _srs_circuit_breaker = NULL;
|
||||
|
||||
srs_error_t srs_thread_initialize()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// Root global objects.
|
||||
_srs_log = new SrsFileLog();
|
||||
_srs_context = new SrsThreadContext();
|
||||
_srs_config = new SrsConfig();
|
||||
|
||||
// The clock wall object.
|
||||
_srs_clock = new SrsWallClock();
|
||||
|
||||
// The pps cids depends by st init.
|
||||
_srs_pps_cids_get = new SrsPps();
|
||||
_srs_pps_cids_set = new SrsPps();
|
||||
|
||||
// Initialize ST, which depends on pps cids.
|
||||
if ((err = srs_st_init()) != srs_success) {
|
||||
return srs_error_wrap(err, "initialize st failed");
|
||||
}
|
||||
|
||||
// The global objects which depends on ST.
|
||||
_srs_hybrid = new SrsHybridServer();
|
||||
_srs_rtc_sources = new SrsRtcStreamManager();
|
||||
_srs_sources = new SrsSourceManager();
|
||||
_srs_stages = new SrsStageManager();
|
||||
_srs_blackhole = new SrsRtcBlackhole();
|
||||
_srs_rtc_manager = new SrsResourceManager("RTC", true);
|
||||
_srs_circuit_breaker = new SrsCircuitBreaker();
|
||||
|
||||
_srs_rtp_cache = new SrsRtpObjectCacheManager<SrsRtpPacket2>(sizeof(SrsRtpPacket2));
|
||||
_srs_rtp_raw_cache = new SrsRtpObjectCacheManager<SrsRtpRawPayload>(sizeof(SrsRtpRawPayload));
|
||||
_srs_rtp_fua_cache = new SrsRtpObjectCacheManager<SrsRtpFUAPayload2>(sizeof(SrsRtpFUAPayload2));
|
||||
|
||||
_srs_rtp_msg_cache_buffers = new SrsRtpObjectCacheManager<SrsSharedPtrMessage>(sizeof(SrsSharedPtrMessage) + kRtpPacketSize);
|
||||
_srs_rtp_msg_cache_objs = new SrsRtpObjectCacheManager<SrsSharedPtrMessage>(sizeof(SrsSharedPtrMessage));
|
||||
|
||||
_srs_rtc_manager = new SrsResourceManager("RTC", true);
|
||||
_srs_rtc_dtls_certificate = new SrsDtlsCertificate();
|
||||
|
||||
// Initialize global pps, which depends on _srs_clock
|
||||
_srs_pps_ids = new SrsPps();
|
||||
_srs_pps_fids = new SrsPps();
|
||||
_srs_pps_fids_level0 = new SrsPps();
|
||||
_srs_pps_dispose = new SrsPps();
|
||||
|
||||
_srs_pps_timer = new SrsPps();
|
||||
|
||||
_srs_pps_snack = new SrsPps();
|
||||
_srs_pps_snack2 = new SrsPps();
|
||||
_srs_pps_snack3 = new SrsPps();
|
||||
_srs_pps_snack4 = new SrsPps();
|
||||
_srs_pps_sanack = new SrsPps();
|
||||
_srs_pps_svnack = new SrsPps();
|
||||
|
||||
_srs_pps_rnack = new SrsPps();
|
||||
_srs_pps_rnack2 = new SrsPps();
|
||||
_srs_pps_rhnack = new SrsPps();
|
||||
_srs_pps_rmnack = new SrsPps();
|
||||
|
||||
#if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS)
|
||||
_srs_pps_recvfrom = new SrsPps();
|
||||
_srs_pps_recvfrom_eagain = new SrsPps();
|
||||
_srs_pps_sendto = new SrsPps();
|
||||
_srs_pps_sendto_eagain = new SrsPps();
|
||||
|
||||
_srs_pps_read = new SrsPps();
|
||||
_srs_pps_read_eagain = new SrsPps();
|
||||
_srs_pps_readv = new SrsPps();
|
||||
_srs_pps_readv_eagain = new SrsPps();
|
||||
_srs_pps_writev = new SrsPps();
|
||||
_srs_pps_writev_eagain = new SrsPps();
|
||||
|
||||
_srs_pps_recvmsg = new SrsPps();
|
||||
_srs_pps_recvmsg_eagain = new SrsPps();
|
||||
_srs_pps_sendmsg = new SrsPps();
|
||||
_srs_pps_sendmsg_eagain = new SrsPps();
|
||||
|
||||
_srs_pps_epoll = new SrsPps();
|
||||
_srs_pps_epoll_zero = new SrsPps();
|
||||
_srs_pps_epoll_shake = new SrsPps();
|
||||
_srs_pps_epoll_spin = new SrsPps();
|
||||
|
||||
_srs_pps_sched_15ms = new SrsPps();
|
||||
_srs_pps_sched_20ms = new SrsPps();
|
||||
_srs_pps_sched_25ms = new SrsPps();
|
||||
_srs_pps_sched_30ms = new SrsPps();
|
||||
_srs_pps_sched_35ms = new SrsPps();
|
||||
_srs_pps_sched_40ms = new SrsPps();
|
||||
_srs_pps_sched_80ms = new SrsPps();
|
||||
_srs_pps_sched_160ms = new SrsPps();
|
||||
_srs_pps_sched_s = new SrsPps();
|
||||
#endif
|
||||
|
||||
_srs_pps_clock_15ms = new SrsPps();
|
||||
_srs_pps_clock_20ms = new SrsPps();
|
||||
_srs_pps_clock_25ms = new SrsPps();
|
||||
_srs_pps_clock_30ms = new SrsPps();
|
||||
_srs_pps_clock_35ms = new SrsPps();
|
||||
_srs_pps_clock_40ms = new SrsPps();
|
||||
_srs_pps_clock_80ms = new SrsPps();
|
||||
_srs_pps_clock_160ms = new SrsPps();
|
||||
_srs_pps_timer_s = new SrsPps();
|
||||
|
||||
#if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS)
|
||||
_srs_pps_thread_run = new SrsPps();
|
||||
_srs_pps_thread_idle = new SrsPps();
|
||||
_srs_pps_thread_yield = new SrsPps();
|
||||
_srs_pps_thread_yield2 = new SrsPps();
|
||||
#endif
|
||||
|
||||
_srs_pps_rpkts = new SrsPps();
|
||||
_srs_pps_addrs = new SrsPps();
|
||||
_srs_pps_fast_addrs = new SrsPps();
|
||||
|
||||
_srs_pps_spkts = new SrsPps();
|
||||
|
||||
_srs_pps_sstuns = new SrsPps();
|
||||
_srs_pps_srtcps = new SrsPps();
|
||||
_srs_pps_srtps = new SrsPps();
|
||||
|
||||
_srs_pps_pli = new SrsPps();
|
||||
_srs_pps_twcc = new SrsPps();
|
||||
_srs_pps_rr = new SrsPps();
|
||||
_srs_pps_pub = new SrsPps();
|
||||
_srs_pps_conn = new SrsPps();
|
||||
|
||||
_srs_pps_rstuns = new SrsPps();
|
||||
_srs_pps_rrtps = new SrsPps();
|
||||
_srs_pps_rrtcps = new SrsPps();
|
||||
|
||||
_srs_pps_aloss2 = new SrsPps();
|
||||
|
||||
_srs_pps_objs_msgs = new SrsPps();
|
||||
|
||||
_srs_pps_objs_rtps = new SrsPps();
|
||||
_srs_pps_objs_rraw = new SrsPps();
|
||||
_srs_pps_objs_rfua = new SrsPps();
|
||||
_srs_pps_objs_rbuf = new SrsPps();
|
||||
_srs_pps_objs_rothers = new SrsPps();
|
||||
_srs_pps_objs_drop = new SrsPps();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,5 +63,8 @@ private:
|
|||
|
||||
extern SrsCircuitBreaker* _srs_circuit_breaker;
|
||||
|
||||
// Initialize global or thread-local variables.
|
||||
extern srs_error_t srs_thread_initialize();
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -26,6 +26,6 @@
|
|||
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 103
|
||||
#define VERSION_REVISION 104
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,7 +43,7 @@ using namespace std;
|
|||
|
||||
#include <srs_kernel_kbps.hpp>
|
||||
|
||||
SrsPps* _srs_pps_objs_msgs = new SrsPps();
|
||||
SrsPps* _srs_pps_objs_msgs = NULL;
|
||||
|
||||
SrsMessageHeader::SrsMessageHeader()
|
||||
{
|
||||
|
|
|
@ -61,7 +61,7 @@ void srs_pps_update(SrsRateSample& sample, int64_t nn, srs_utime_t now)
|
|||
|
||||
SrsPps::SrsPps()
|
||||
{
|
||||
clk_ = NULL;
|
||||
clk_ = _srs_clock;
|
||||
sugar = 0;
|
||||
}
|
||||
|
||||
|
@ -69,11 +69,6 @@ SrsPps::~SrsPps()
|
|||
{
|
||||
}
|
||||
|
||||
void SrsPps::set_clock(SrsWallClock* clk)
|
||||
{
|
||||
clk_ = clk;
|
||||
}
|
||||
|
||||
void SrsPps::update()
|
||||
{
|
||||
update(sugar);
|
||||
|
@ -81,10 +76,7 @@ void SrsPps::update()
|
|||
|
||||
void SrsPps::update(int64_t nn)
|
||||
{
|
||||
// Lazy setup the clock.
|
||||
if (!clk_) {
|
||||
clk_ = _srs_clock;
|
||||
}
|
||||
srs_assert(clk_);
|
||||
|
||||
srs_utime_t now = clk_->now();
|
||||
|
||||
|
@ -129,5 +121,5 @@ srs_utime_t SrsWallClock::now()
|
|||
return srs_get_system_time();
|
||||
}
|
||||
|
||||
SrsWallClock* _srs_clock = new SrsWallClock();
|
||||
SrsWallClock* _srs_clock = NULL;
|
||||
|
||||
|
|
|
@ -64,8 +64,6 @@ public:
|
|||
SrsPps();
|
||||
virtual ~SrsPps();
|
||||
public:
|
||||
// Setup the clock, use global clock if not set.
|
||||
void set_clock(SrsWallClock* clk);
|
||||
// Update with the nn which is target.
|
||||
void update();
|
||||
// Update with the nn.
|
||||
|
|
|
@ -36,12 +36,12 @@ using namespace std;
|
|||
|
||||
#include <srs_kernel_kbps.hpp>
|
||||
|
||||
SrsPps* _srs_pps_objs_rtps = new SrsPps();
|
||||
SrsPps* _srs_pps_objs_rraw = new SrsPps();
|
||||
SrsPps* _srs_pps_objs_rfua = new SrsPps();
|
||||
SrsPps* _srs_pps_objs_rbuf = new SrsPps();
|
||||
SrsPps* _srs_pps_objs_rothers = new SrsPps();
|
||||
SrsPps* _srs_pps_objs_drop = new SrsPps();
|
||||
SrsPps* _srs_pps_objs_rtps = NULL;
|
||||
SrsPps* _srs_pps_objs_rraw = NULL;
|
||||
SrsPps* _srs_pps_objs_rfua = NULL;
|
||||
SrsPps* _srs_pps_objs_rbuf = NULL;
|
||||
SrsPps* _srs_pps_objs_rothers = NULL;
|
||||
SrsPps* _srs_pps_objs_drop = NULL;
|
||||
|
||||
/* @see https://tools.ietf.org/html/rfc1889#section-5.1
|
||||
0 1 2 3
|
||||
|
@ -1081,12 +1081,12 @@ bool SrsRtpPacket2::is_keyframe()
|
|||
return false;
|
||||
}
|
||||
|
||||
SrsRtpObjectCacheManager<SrsRtpPacket2>* _srs_rtp_cache = new SrsRtpObjectCacheManager<SrsRtpPacket2>(sizeof(SrsRtpPacket2));
|
||||
SrsRtpObjectCacheManager<SrsRtpRawPayload>* _srs_rtp_raw_cache = new SrsRtpObjectCacheManager<SrsRtpRawPayload>(sizeof(SrsRtpRawPayload));
|
||||
SrsRtpObjectCacheManager<SrsRtpFUAPayload2>* _srs_rtp_fua_cache = new SrsRtpObjectCacheManager<SrsRtpFUAPayload2>(sizeof(SrsRtpFUAPayload2));
|
||||
SrsRtpObjectCacheManager<SrsRtpPacket2>* _srs_rtp_cache = NULL;
|
||||
SrsRtpObjectCacheManager<SrsRtpRawPayload>* _srs_rtp_raw_cache = NULL;
|
||||
SrsRtpObjectCacheManager<SrsRtpFUAPayload2>* _srs_rtp_fua_cache = NULL;
|
||||
|
||||
SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_buffers = new SrsRtpObjectCacheManager<SrsSharedPtrMessage>(sizeof(SrsSharedPtrMessage) + kRtpPacketSize);
|
||||
SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_objs = new SrsRtpObjectCacheManager<SrsSharedPtrMessage>(sizeof(SrsSharedPtrMessage));
|
||||
SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_buffers = NULL;
|
||||
SrsRtpObjectCacheManager<SrsSharedPtrMessage>* _srs_rtp_msg_cache_objs = NULL;
|
||||
|
||||
SrsRtpRawPayload::SrsRtpRawPayload()
|
||||
{
|
||||
|
|
|
@ -70,10 +70,10 @@ srs_error_t run_hybrid_server();
|
|||
void show_macro_features();
|
||||
|
||||
// @global log and context.
|
||||
ISrsLog* _srs_log = new SrsFileLog();
|
||||
ISrsContext* _srs_context = new SrsThreadContext();
|
||||
ISrsLog* _srs_log = NULL;
|
||||
ISrsContext* _srs_context = NULL;
|
||||
// @global config object for app module.
|
||||
SrsConfig* _srs_config = new SrsConfig();
|
||||
SrsConfig* _srs_config = NULL;
|
||||
|
||||
// @global version of srs, which can grep keyword "XCORE"
|
||||
extern const char* _srs_version;
|
||||
|
@ -87,7 +87,15 @@ SrsServer* _srs_server = NULL;
|
|||
srs_error_t do_main(int argc, char** argv)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
||||
// Initialize global or thread-local variables.
|
||||
if ((err = srs_thread_initialize()) != srs_success) {
|
||||
return srs_error_wrap(err, "thread init");
|
||||
}
|
||||
|
||||
// For background context id.
|
||||
_srs_context->set_id(_srs_context->generate_id());
|
||||
|
||||
// TODO: support both little and big endian.
|
||||
srs_assert(srs_is_little_endian());
|
||||
|
||||
|
@ -215,10 +223,8 @@ srs_error_t do_main(int argc, char** argv)
|
|||
return err;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// For background context id.
|
||||
_srs_context->set_id(_srs_context->generate_id());
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
srs_error_t err = do_main(argc, argv);
|
||||
|
||||
if (err != srs_success) {
|
||||
|
|
|
@ -35,8 +35,8 @@ using namespace std;
|
|||
|
||||
#include <srs_protocol_kbps.hpp>
|
||||
|
||||
SrsPps* _srs_pps_cids_get = new SrsPps();
|
||||
SrsPps* _srs_pps_cids_set = new SrsPps();
|
||||
SrsPps* _srs_pps_cids_get = NULL;
|
||||
SrsPps* _srs_pps_cids_set = NULL;
|
||||
|
||||
#define SRS_BASIC_LOG_SIZE 8192
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_app_config.hpp>
|
||||
#include <srs_app_log.hpp>
|
||||
#include <srs_app_rtc_dtls.hpp>
|
||||
#include <srs_app_threads.hpp>
|
||||
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
@ -41,10 +42,10 @@ int _srs_tmp_port = 11935;
|
|||
srs_utime_t _srs_tmp_timeout = (100 * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
// kernel module.
|
||||
ISrsLog* _srs_log = new MockEmptyLog(SrsLogLevelDisabled);
|
||||
ISrsContext* _srs_context = new SrsThreadContext();
|
||||
ISrsLog* _srs_log = NULL;
|
||||
ISrsContext* _srs_context = NULL;
|
||||
// app module.
|
||||
SrsConfig* _srs_config = new SrsConfig();
|
||||
SrsConfig* _srs_config = NULL;
|
||||
SrsServer* _srs_server = NULL;
|
||||
bool _srs_in_docker = false;
|
||||
|
||||
|
@ -54,10 +55,13 @@ bool _srs_in_docker = false;
|
|||
srs_error_t prepare_main() {
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
if ((err = srs_st_init()) != srs_success) {
|
||||
if ((err = srs_thread_initialize()) != srs_success) {
|
||||
return srs_error_wrap(err, "init st");
|
||||
}
|
||||
|
||||
srs_freep(_srs_log);
|
||||
_srs_log = new MockEmptyLog(SrsLogLevelDisabled);
|
||||
|
||||
if ((err = _srs_rtc_dtls_certificate->initialize()) != srs_success) {
|
||||
return srs_error_wrap(err, "rtc dtls certificate initialize");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue