DvppSourceManager.cpp
1.04 KB
#include "DvppSourceManager.h"
#include "dvpp_headers.h"
#include "depend_headers.h"
using namespace std;
DvppSourceManager::~DvppSourceManager()
{
m_channelMap.clear();
// aclFinalize();
}
int DvppSourceManager::getChannel(int devId){
std::lock_guard<std::mutex> l(m_channelMap_mtx);
// channel 最大值暂定为32, 华为没有接口获取最大channel,只有文档说明
for(int iChannel = 0; iChannel < 32; iChannel++){
string channelKey = "channel_" + to_string(devId) + "_" + to_string(iChannel) ;
auto it = m_channelMap.find(channelKey);
if(it == m_channelMap.end()){
m_channelMap[channelKey] = iChannel;
return iChannel;
}
}
return -1;
}
void DvppSourceManager::releaseChannel(int devId, int iChannel){
std::lock_guard<std::mutex> l(m_channelMap_mtx);
string channelKey = "channel_" + to_string(devId) + "_" + to_string(iChannel) ;
auto it = m_channelMap.find(channelKey);
if(it != m_channelMap.end()){
m_channelMap.erase(channelKey);
}
}