bool CheckConnectivityVia( TestNrSocket *from, TestNrSocket *to, const nr_transport_addr &via, nr_transport_addr *sender_external_address = nullptr) { MOZ_ASSERT(from); if (!WaitForWriteable(from)) { return false; } int result = 0; sts_->Dispatch(WrapRunnableRet(this, &TestNrSocketTest::SendData_s, from, via, &result), NS_DISPATCH_SYNC); if (result) { return false; } if (!WaitForReadable(to)) { return false; } nr_transport_addr dummy_outparam; if (!sender_external_address) { sender_external_address = &dummy_outparam; } MOZ_ASSERT(to); sts_->Dispatch(WrapRunnableRet(this, &TestNrSocketTest::RecvData_s, to, sender_external_address, &result), NS_DISPATCH_SYNC); return !result; }
nsRefPtr<TestNat> CreatePrivateAddrs(size_t size, const char* ip_str = "127.0.0.1") { nsRefPtr<TestNat> result; sts_->Dispatch( WrapRunnableRet(this, &TestNrSocketTest::CreatePrivateAddrs_s, size, ip_str, &result), NS_DISPATCH_SYNC); return result; }
int GetAddress(TestNrSocket *sock, nr_transport_addr_ *address) { MOZ_ASSERT(sock); MOZ_ASSERT(address); int r; sts_->Dispatch(WrapRunnableRet(this, &TestNrSocketTest::GetAddress_s, sock, address, &r), NS_DISPATCH_SYNC); return r; }
int32_t WebrtcGmpVideoDecoder::Decode(const webrtc::EncodedImage& aInputImage, bool aMissingFrames, const webrtc::RTPFragmentationHeader* aFragmentation, const webrtc::CodecSpecificInfo* aCodecSpecificInfo, int64_t aRenderTimeMs) { int32_t ret; MOZ_ASSERT(mGMPThread); MOZ_ASSERT(!NS_IsMainThread()); // Would be really nice to avoid this sync dispatch, but it would require a // copy of the frame, since it doesn't appear to actually have a refcount. mozilla::SyncRunnable::DispatchToThread(mGMPThread, WrapRunnableRet(&ret, this, &WebrtcGmpVideoDecoder::Decode_g, aInputImage, aMissingFrames, aFragmentation, aCodecSpecificInfo, aRenderTimeMs)); return ret; }
nsresult PeerConnectionMedia::Init(const std::vector<NrIceStunServer>& stun_servers) { // TODO([email protected]): need some way to set not offerer later // Looks like a bug in the NrIceCtx API. mIceCtx = NrIceCtx::Create("PC:" + mParent->GetHandle(), true); if(!mIceCtx) { CSFLogError(logTag, "%s: Failed to create Ice Context", __FUNCTION__); return NS_ERROR_FAILURE; } nsresult rv; if (NS_FAILED(rv = mIceCtx->SetStunServers(stun_servers))) { CSFLogError(logTag, "%s: Failed to set stun servers", __FUNCTION__); return rv; } if (NS_FAILED(rv = mDNSResolver->Init())) { CSFLogError(logTag, "%s: Failed to initialize dns resolver", __FUNCTION__); return rv; } if (NS_FAILED(rv = mIceCtx->SetResolver(mDNSResolver->AllocateResolver()))) { CSFLogError(logTag, "%s: Failed to get dns resolver", __FUNCTION__); return rv; } mIceCtx->SignalGatheringCompleted.connect(this, &PeerConnectionMedia::IceGatheringCompleted); mIceCtx->SignalCompleted.connect(this, &PeerConnectionMedia::IceCompleted); // Create three streams to start with. // One each for audio, video and DataChannel // TODO: this will be re-visited RefPtr<NrIceMediaStream> audioStream = mIceCtx->CreateStream("stream1", 2); RefPtr<NrIceMediaStream> videoStream = mIceCtx->CreateStream("stream2", 2); RefPtr<NrIceMediaStream> dcStream = mIceCtx->CreateStream("stream3", 2); if (!audioStream) { CSFLogError(logTag, "%s: audio stream is NULL", __FUNCTION__); return NS_ERROR_FAILURE; } else { mIceStreams.push_back(audioStream); } if (!videoStream) { CSFLogError(logTag, "%s: video stream is NULL", __FUNCTION__); return NS_ERROR_FAILURE; } else { mIceStreams.push_back(videoStream); } if (!dcStream) { CSFLogError(logTag, "%s: datachannel stream is NULL", __FUNCTION__); return NS_ERROR_FAILURE; } else { mIceStreams.push_back(dcStream); } // TODO([email protected]): This is not connected to the PCCimpl. // Will need to do that later. for (std::size_t i=0; i<mIceStreams.size(); i++) { mIceStreams[i]->SignalReady.connect(this, &PeerConnectionMedia::IceStreamReady); } // Start gathering nsresult res; mIceCtx->thread()->Dispatch(WrapRunnableRet( mIceCtx, &NrIceCtx::StartGathering, &res), NS_DISPATCH_SYNC ); if (NS_FAILED(res)) { CSFLogError(logTag, "%s: StartGathering failed: %u", __FUNCTION__, static_cast<uint32_t>(res)); return res; } return NS_OK; }