mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
添加mk_env_init1接口
This commit is contained in:
parent
15fbb3d087
commit
0b8c4e75e1
@ -71,6 +71,24 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
API_EXPORT void API_CALL mk_env_init(const mk_config *cfg);
|
API_EXPORT void API_CALL mk_env_init(const mk_config *cfg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础类型参数版本的mk_env_init,为了方便其他语言调用
|
||||||
|
*/
|
||||||
|
API_EXPORT void API_CALL mk_env_init1( // 线程数
|
||||||
|
int thread_num,
|
||||||
|
// 日志级别,支持0~4
|
||||||
|
int log_level,
|
||||||
|
// 配置文件是内容还是路径
|
||||||
|
int ini_is_path,
|
||||||
|
// 配置文件内容或路径,可以为NULL
|
||||||
|
const char *ini,
|
||||||
|
// ssl证书是内容还是路径
|
||||||
|
int ssl_is_path,
|
||||||
|
// ssl证书内容或路径,可以为NULL
|
||||||
|
const char *ssl,
|
||||||
|
// 证书密码,可以为NULL
|
||||||
|
const char *ssl_pwd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置配置项
|
* 设置配置项
|
||||||
* @param key 配置项名
|
* @param key 配置项名
|
||||||
|
@ -53,25 +53,42 @@ static TcpServer::Ptr tcpRtpServer(new TcpServer());
|
|||||||
//////////////////////////environment init///////////////////////////
|
//////////////////////////environment init///////////////////////////
|
||||||
API_EXPORT void API_CALL mk_env_init(const mk_config *cfg) {
|
API_EXPORT void API_CALL mk_env_init(const mk_config *cfg) {
|
||||||
assert(cfg);
|
assert(cfg);
|
||||||
|
mk_env_init1(cfg->thread_num,
|
||||||
|
cfg->log_level,
|
||||||
|
cfg->ini_is_path,
|
||||||
|
cfg->ini,
|
||||||
|
cfg->ssl_is_path,
|
||||||
|
cfg->ssl,
|
||||||
|
cfg->ssl_pwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
API_EXPORT void API_CALL mk_env_init1( int thread_num,
|
||||||
|
int log_level,
|
||||||
|
int ini_is_path,
|
||||||
|
const char *ini,
|
||||||
|
int ssl_is_path,
|
||||||
|
const char *ssl,
|
||||||
|
const char *ssl_pwd) {
|
||||||
|
|
||||||
static onceToken token([&]() {
|
static onceToken token([&]() {
|
||||||
Logger::Instance().add(std::make_shared<ConsoleChannel>("console", (LogLevel) cfg->log_level));
|
Logger::Instance().add(std::make_shared<ConsoleChannel>("console", (LogLevel) log_level));
|
||||||
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
|
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
|
||||||
|
|
||||||
EventPollerPool::setPoolSize(cfg->thread_num);
|
EventPollerPool::setPoolSize(thread_num);
|
||||||
WorkThreadPool::setPoolSize(cfg->thread_num);
|
WorkThreadPool::setPoolSize(thread_num);
|
||||||
|
|
||||||
if (cfg->ini) {
|
if (ini && ini[0]) {
|
||||||
//设置配置文件
|
//设置配置文件
|
||||||
if (cfg->ini_is_path) {
|
if (ini_is_path) {
|
||||||
mINI::Instance().parseFile(cfg->ini);
|
mINI::Instance().parseFile(ini);
|
||||||
} else {
|
} else {
|
||||||
mINI::Instance().parse(cfg->ini);
|
mINI::Instance().parse(ini);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg->ssl) {
|
if (ssl && ssl[0]) {
|
||||||
//设置ssl证书
|
//设置ssl证书
|
||||||
SSL_Initor::Instance().loadCertificate(cfg->ssl, true, cfg->ssl_pwd ? cfg->ssl_pwd : "", cfg->ssl_is_path);
|
SSL_Initor::Instance().loadCertificate(ssl, true, ssl_pwd ? ssl_pwd : "", ssl_is_path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user