代码拉取完成,页面将自动刷新
同步操作将从 广州灵派科技有限公司/Encoder 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "Intercom.h"
#include <QFile>
#include "Json.h"
Intercom::Intercom(QObject *parent) : QObject(parent),timer(this)
{
connect(&timer,SIGNAL(timeout()),this,SLOT(onTimer()));
}
void Intercom::init()
{
if(!QFile::exists("/link/config/intercom.json"))
return;
QVariantMap data;
ai=Link::create("InputAlsa");
data["path"] = "-1";
data["id"]="0d8c:0014|12d1:0010";
ai->start(data);
ao=Link::create("OutputAlsa");
ao->start(data);
res1=Link::create("Resample");
data.clear();
data["num"]=200;
data["channels"]=1;
data["samplerate"]=8000;
res1->start(data);
res2=Link::create("Resample");
res2->start();
intercom=Link::create("Intercom");
gain=Link::create("Gain");
gain->start();
ai->linkA(res1)->linkA(gain)->linkA(intercom)->linkA(res2)->linkA(ao);
server=Link::create("IntercomServer");
vmix=Link::create("VMix");
tally=Link::create("Tally");
vmix->linkE(intercom);
connect(intercom,SIGNAL(newEvent(QString,QVariant)),this,SLOT(onNewEvent(QString,QVariant)));
update(Json::loadFile("/link/config/intercom.json").toMap());
}
bool Intercom::update(QVariantMap cfg)
{
QVariantMap cfgIntercom=cfg["intercom"].toMap();
if(cfgIntercom["vad"].toInt()>0)
{
cfgIntercom["vad"]=cfgIntercom["vad"].toInt()+cfgIntercom["gain"].toInt();
}
if(cfgIntercom["enable"].toBool())
intercom->start(cfgIntercom);
else
intercom->stop();
QVariantMap cfgGain;
cfgGain["gain"]=cfgIntercom["gain"].toInt();
gain->start(cfgGain);
QVariantMap cfgServer=cfg["server"].toMap();
if(cfgServer["enable"].toBool())
server->start();
else
server->stop();
QVariantMap cfgVMix=cfg["vmix"].toMap();
if(cfgVMix["enable"].toBool())
vmix->start(cfgVMix);
else
vmix->stop();
QVariantMap cfgTally=cfg["tally"].toMap();
if(cfgTally["enable"].toBool())
{
timer.start(1000);
tally->start(cfgTally);
}
else
{
timer.stop();
tally->stop();
}
Json::saveFile(cfg,"/link/config/intercom.json");
return true;
}
bool Intercom::setTally(QVariantList list)
{
tally->invoke("setTally",list);
tallyInfo=list;
return true;
}
QVariantMap Intercom::getState()
{
QVariantMap state;
QVariantMap map=intercom->invoke("getState").toMap();
state["intercom"]=map["list"].toList();
state["talking"]=map["talking"].toBool();
state["tally"]=tallyInfo;
return state;
}
void Intercom::onTimer()
{
if(tallyInfo.isValid())
{
tally->invoke("setTally",tallyInfo);
}
}
void Intercom::onNewEvent(QString type, QVariant info)
{
if(type=="TALLY")
{
tallyInfo=info;
// qDebug()<<info;
tally->invoke("setTally",info);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。