nsresult PeerConnectionMedia::Init(const std::vector<NrIceStunServer>& stun_servers, const std::vector<NrIceTurnServer>& turn_servers, NrIceCtx::Policy policy) { nsresult rv = InitProxy(); NS_ENSURE_SUCCESS(rv, rv); #if !defined(MOZILLA_EXTERNAL_LINKAGE) bool ice_tcp = Preferences::GetBool("media.peerconnection.ice.tcp", false); #else bool ice_tcp = false; #endif bool default_address_only = GetPrefDefaultAddressOnly(); // TODO([email protected]): need some way to set not offerer later // Looks like a bug in the NrIceCtx API. mIceCtxHdlr = NrIceCtxHandler::Create("PC:" + mParentName, true, // Offerer mParent->GetAllowIceLoopback(), ice_tcp, mParent->GetAllowIceLinkLocal(), default_address_only, policy); if(!mIceCtxHdlr) { CSFLogError(logTag, "%s: Failed to create Ice Context", __FUNCTION__); return NS_ERROR_FAILURE; } if (NS_FAILED(rv = mIceCtxHdlr->ctx()->SetStunServers(stun_servers))) { CSFLogError(logTag, "%s: Failed to set stun servers", __FUNCTION__); return rv; } // Give us a way to globally turn off TURN support #if !defined(MOZILLA_EXTERNAL_LINKAGE) bool disabled = Preferences::GetBool("media.peerconnection.turn.disable", false); #else bool disabled = false; #endif if (!disabled) { if (NS_FAILED(rv = mIceCtxHdlr->ctx()->SetTurnServers(turn_servers))) { CSFLogError(logTag, "%s: Failed to set turn servers", __FUNCTION__); return rv; } } else if (turn_servers.size() != 0) { CSFLogError(logTag, "%s: Setting turn servers disabled", __FUNCTION__); } if (NS_FAILED(rv = mDNSResolver->Init())) { CSFLogError(logTag, "%s: Failed to initialize dns resolver", __FUNCTION__); return rv; } if (NS_FAILED(rv = mIceCtxHdlr->ctx()->SetResolver(mDNSResolver->AllocateResolver()))) { CSFLogError(logTag, "%s: Failed to get dns resolver", __FUNCTION__); return rv; } ConnectSignals(mIceCtxHdlr->ctx().get()); return NS_OK; }
nsresult PeerConnectionMedia::Init(const std::vector<NrIceStunServer>& stun_servers, const std::vector<NrIceTurnServer>& turn_servers, NrIceCtx::Policy policy) { nsresult rv = InitProxy(); NS_ENSURE_SUCCESS(rv, rv); bool ice_tcp = Preferences::GetBool("media.peerconnection.ice.tcp", false); // setup the stun local addresses IPC async call InitLocalAddrs(); // TODO([email protected]): need some way to set not offerer later // Looks like a bug in the NrIceCtx API. mIceCtxHdlr = NrIceCtxHandler::Create("PC:" + mParentName, mParent->GetAllowIceLoopback(), ice_tcp, mParent->GetAllowIceLinkLocal(), policy); if(!mIceCtxHdlr) { CSFLogError(LOGTAG, "%s: Failed to create Ice Context", __FUNCTION__); return NS_ERROR_FAILURE; } if (NS_FAILED(rv = mIceCtxHdlr->ctx()->SetStunServers(stun_servers))) { CSFLogError(LOGTAG, "%s: Failed to set stun servers", __FUNCTION__); return rv; } // Give us a way to globally turn off TURN support bool disabled = Preferences::GetBool("media.peerconnection.turn.disable", false); if (!disabled) { if (NS_FAILED(rv = mIceCtxHdlr->ctx()->SetTurnServers(turn_servers))) { CSFLogError(LOGTAG, "%s: Failed to set turn servers", __FUNCTION__); return rv; } } else if (!turn_servers.empty()) { CSFLogError(LOGTAG, "%s: Setting turn servers disabled", __FUNCTION__); } if (NS_FAILED(rv = mDNSResolver->Init())) { CSFLogError(LOGTAG, "%s: Failed to initialize dns resolver", __FUNCTION__); return rv; } if (NS_FAILED(rv = mIceCtxHdlr->ctx()->SetResolver(mDNSResolver->AllocateResolver()))) { CSFLogError(LOGTAG, "%s: Failed to get dns resolver", __FUNCTION__); return rv; } ConnectSignals(mIceCtxHdlr->ctx().get()); return NS_OK; }
std::string CPeraIceWs::savePlanByByteXpdl(std::string strJsonInfo, ByteSeq byteSeq) { std::string strResult; if (!InitProxy()) { return strResult; } try { strResult = m_pPrx->savePlanByByteXpdl(strJsonInfo, byteSeq); } catch(const Ice::Exception& ex) { ZTools::WriteZToolsFormatLog("ICE异常:%s", ex.ice_name().c_str()); } return strResult; }
std::string CPeraIceWs::InvokeWsMethodOrignal( std::string strMethod, std::string strJson ) { std::string strResult; if (!InitProxy()) { return strResult; } try { strResult = m_pPrx->invokeWsMethod(strMethod, strJson); } catch(const Ice::Exception& ex) { ZTools::WriteZToolsFormatLog("ICE异常:%s", ex.ice_name().c_str()); } return strResult; }
BOOL CPeraIceWs::amiRunRobotFinished(std::string strTaskId, std::string strOutxml, std::string strRunType) { BOOL bResult = FALSE; if (!InitProxy()) { return bResult; } try { bResult = m_pPrx->runRobotFinished_async(new AMI_WsICEService_runRobotFinished_I, strTaskId, strOutxml, strRunType); } catch(const Ice::Exception& ex) { ZTools::WriteZToolsFormatLog("ICE异常:%s", ex.ice_name().c_str()); bResult = FALSE; } return bResult; }
std::string CPeraIceWs::runRobotFinished(std::string strTaskId, std::string strOutxml, std::string strRunType) { std::string strResult; if (!InitProxy()) { return strResult; } try { strResult = m_pPrx->runRobotFinished(strTaskId, strOutxml, strRunType); } catch(const Ice::Exception& ex) { ZTools::WriteZToolsFormatLog("ICE异常:%s", ex.ice_name().c_str()); } return strResult; return ""; }
BOOL CPeraIceWs::runRobotRate(std::string strRate) { BOOL bResult = FALSE; if (!InitProxy()) { return bResult; } try { m_pPrx->runRobotRate(strRate); bResult = TRUE; } catch(const Ice::Exception& ex) { ZTools::WriteZToolsFormatLog("ICE异常:%s", ex.ice_name().c_str()); bResult = FALSE; } return bResult; }