std::shared_ptr<DCameraProvider> provider = DCameraProvider::GetInstance(); //获取一个分布式相机服务提供者的实例
if (provider == nullptr) {
DHLOGE("Get distributed camera provider instance is null.");
return CamRetCode:EVICE_ERROR;
}
DCamRetCode ret = provider->OpenSession(dhBase_); //打开一个分布式相机控制会话
if (ret != DCamRetCode::SUCCESS) {
DHLOGE("Open distributed camera control session failed, ret = %d.", ret);
return MapToExternalRetCode(ret);
}
unique_lock<mutex> lock(openSesslock_);
auto st = openSessCV_.wait_for(lock, chrono::seconds(WAIT_OPEN_TIMEOUT_SEC)); //等待分布式相机会话的连接
if (st == cv_status::timeout) {
DHLOGE("Wait for distributed camera session open timeout.");
return CamRetCode:EVICE_ERROR;
}
{
unique_lock<mutex> lock(isOpenSessFailedlock_);
if (isOpenSessFailed_) {
DHLOGE("Open distributed camera session failed.");
return CamRetCode:EVICE_ERROR;
}
}
ret = CreateDStreamOperator(); //创建分布式相机流操作
if (ret != SUCCESS) {
DHLOGE("Create distributed camera stream operator failed.");
return MapToExternalRetCode(ret);
}
isOpened_ = true;