#include "Config.h" #include "Channel.h" #include "Json.h" #include #include #include QList channelList; Config::Config() { } void Config::loadConfig(QString path) { QFileInfo fileInfo(path); if (!fileInfo.exists()) { qDebug() << "config.json does not exist, exit"; exit(0); } // read the configuration QVariantMap config = Json::loadFile(path).toMap(); QVariantList list = config["interface"].toList(); for (int i = 0; i < list.count(); i++) { Channel* chn = new Channel(); QVariantMap cfg = list.at(i).toMap(); chn->channelName = cfg["name"].toString(); QVariantMap encV = cfg["encV"].toMap(); chn->videoEncoderParams = encV; QVariantMap encA = cfg["encA"].toMap(); chn->audioEncoderParams = encA; chn->pushCode = cfg["pushCode"].toString(); chn->init(); bool autoRecord = cfg["autoRecord"].toBool(); if (autoRecord) { // chn->startRecord(); } channelList.push_back(chn); } } /** * @brief find the channel from channel list by channel name * @param name * @return */ Channel* Config::findChannelByName(QString name) { for (Channel* chn : channelList) { if (chn->channelName == name) { return chn; } } return nullptr; }