/* * MIT License * * Copyright (c) 2016-2019 xiongziliang <771730766@qq.com> * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "Common/config.h" #include "Util/util.h" #include "Util/logger.h" #include "Util/onceToken.h" #include "Util/NoticeCenter.h" #include "Network/sockutil.h" using namespace toolkit; namespace mediakit { bool loadIniConfig(const char *ini_path){ string ini; if(ini_path && ini_path[0] != '\0'){ ini = ini_path; }else{ ini = exePath() + ".ini"; } try{ mINI::Instance().parseFile(ini); NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastReloadConfig); return true; }catch (std::exception &ex) { InfoL << "dump ini file to:" << ini; mINI::Instance().dumpFile(ini); return false; } } ////////////广播名称/////////// namespace Broadcast { const string kBroadcastMediaChanged = "kBroadcastMediaChanged"; const string kBroadcastRecordMP4 = "kBroadcastRecordMP4"; const string kBroadcastHttpRequest = "kBroadcastHttpRequest"; const string kBroadcastHttpAccess = "kBroadcastHttpAccess"; const string kBroadcastOnGetRtspRealm = "kBroadcastOnGetRtspRealm"; const string kBroadcastOnRtspAuth = "kBroadcastOnRtspAuth"; const string kBroadcastMediaPlayed = "kBroadcastMediaPlayed"; const string kBroadcastMediaPublish = "kBroadcastMediaPublish"; const string kBroadcastFlowReport = "kBroadcastFlowReport"; const string kBroadcastReloadConfig = "kBroadcastReloadConfig"; const string kBroadcastShellLogin = "kBroadcastShellLogin"; const string kBroadcastNotFoundStream = "kBroadcastNotFoundStream"; const string kBroadcastStreamNoneReader = "kBroadcastStreamNoneReader"; } //namespace Broadcast //通用配置项目 namespace General{ #define GENERAL_FIELD "general." const string kFlowThreshold = GENERAL_FIELD"flowThreshold"; const string kStreamNoneReaderDelayMS = GENERAL_FIELD"streamNoneReaderDelayMS"; const string kMaxStreamWaitTimeMS = GENERAL_FIELD"maxStreamWaitMS"; const string kEnableVhost = GENERAL_FIELD"enableVhost"; const string kUltraLowDelay = GENERAL_FIELD"ultraLowDelay"; const string kAddMuteAudio = GENERAL_FIELD"addMuteAudio"; const string kResetWhenRePlay = GENERAL_FIELD"resetWhenRePlay"; onceToken token([](){ mINI::Instance()[kFlowThreshold] = 1024; mINI::Instance()[kStreamNoneReaderDelayMS] = 5 * 1000; mINI::Instance()[kMaxStreamWaitTimeMS] = 5 * 1000; mINI::Instance()[kEnableVhost] = 1; mINI::Instance()[kUltraLowDelay] = 1; mINI::Instance()[kAddMuteAudio] = 1; mINI::Instance()[kResetWhenRePlay] = 1; },nullptr); }//namespace General ////////////HTTP配置/////////// namespace Http { #define HTTP_FIELD "http." //http 文件发送缓存大小 const string kSendBufSize = HTTP_FIELD"sendBufSize"; //http 最大请求字节数 const string kMaxReqSize = HTTP_FIELD"maxReqSize"; //http keep-alive秒数 const string kKeepAliveSecond = HTTP_FIELD"keepAliveSecond"; //http keep-alive最大请求数 const string kMaxReqCount = HTTP_FIELD"maxReqCount"; //http 字符编码 const string kCharSet = HTTP_FIELD"charSet"; //http 服务器根目录 const string kRootPath = HTTP_FIELD"rootPath"; //http 404错误提示内容 const string kNotFound = HTTP_FIELD"notFound"; onceToken token([](){ mINI::Instance()[kSendBufSize] = 64 * 1024; mINI::Instance()[kMaxReqSize] = 4*1024; mINI::Instance()[kKeepAliveSecond] = 15; mINI::Instance()[kMaxReqCount] = 100; #if defined(_WIN32) mINI::Instance()[kCharSet] = "gb2312"; #else mINI::Instance()[kCharSet] ="utf-8"; #endif mINI::Instance()[kRootPath] = "./httpRoot"; mINI::Instance()[kNotFound] = "" "