コード例 #1
0
int MpTopologyGraph::linkTopologyResources(MpResourceTopology& resourceTopology,
                                           UtlHashBag& newResources,
                                           UtlBoolean replaceNumInName,
                                           int resourceNum)
{
    // Link the resources
    int connectionIndex = 0;
    UtlString outputResourceName;
    UtlString inputResourceName;
    int outputResourcePortIndex;
    int inputResourcePortIndex;
    MpResource* outputResource = NULL;
    MpResource* inputResource = NULL;
    OsStatus result;
    UtlHashMap newConnectionIds;

#ifdef TEST_PRINT
    osPrintf("%d new resources in the list\n", newResources.entries());
    UtlHashBagIterator iterator(newResources);
    MpResource* containerResource = NULL;
    while(containerResource = (MpResource*) iterator())
    {
        osPrintf("found list resource: \"%s\" value: \"%s\"\n",
                 containerResource->getName().data(), containerResource->data());
    }
#endif

    while(resourceTopology.getConnection(connectionIndex,
                                         outputResourceName,
                                         outputResourcePortIndex,
                                         inputResourceName,
                                         inputResourcePortIndex) == OS_SUCCESS)
    {
        if(replaceNumInName)
        {
            resourceTopology.replaceNumInName(outputResourceName, resourceNum);
            resourceTopology.replaceNumInName(inputResourceName, resourceNum);
        }

        // Look in the container of new resources first as this is more 
        // efficient and new resources are not added immediately to a running
        // flowgraph
        outputResource = (MpResource*) newResources.find(&outputResourceName);
        if(outputResource == NULL)
        {
            result = lookupResource(outputResourceName, outputResource);
            if(result != OS_SUCCESS)
            {
                int virtPortIdx = outputResourcePortIndex>=0?outputResourcePortIndex:-1;
                int realPortIdx;
                result = lookupVirtualOutput(outputResourceName, virtPortIdx,
                                             outputResource, realPortIdx);
                if (result == OS_SUCCESS && outputResourcePortIndex>=0)
                {
                   outputResourcePortIndex = realPortIdx;
                }
            }
            assert(result == OS_SUCCESS);
        }
        inputResource = (MpResource*) newResources.find(&inputResourceName);
        if(inputResource == NULL)
        {
            result = lookupResource(inputResourceName, inputResource);
            if(result != OS_SUCCESS)
            {
                int virtPortIdx = inputResourcePortIndex>=0?inputResourcePortIndex:-1;
                int realPortIdx;
                result = lookupVirtualInput(inputResourceName, virtPortIdx,
                                            inputResource, realPortIdx);
                if (result == OS_SUCCESS && inputResourcePortIndex>=0)
                {
                   inputResourcePortIndex = realPortIdx;
                }
            }
            assert(result == OS_SUCCESS);
        }
        assert(outputResource);
        assert(inputResource);

        if(outputResource && inputResource)
        {
            if(outputResourcePortIndex == MpResourceTopology::MP_TOPOLOGY_NEXT_AVAILABLE_PORT)
            {
                outputResourcePortIndex = outputResource->reserveFirstUnconnectedOutput();
                assert(outputResourcePortIndex >= 0);
            }
            else if(outputResourcePortIndex < MpResourceTopology::MP_TOPOLOGY_NEXT_AVAILABLE_PORT)
            {
                // First see if a real port is already in the dictionary
                UtlInt searchKey(outputResourcePortIndex);
                UtlInt* foundValue = NULL;
                if((foundValue = (UtlInt*) newConnectionIds.findValue(&searchKey)))
                {
                    // Use the mapped index
                    outputResourcePortIndex = foundValue->getValue();
                }
                else
                {
                    // Find an available port and add it to the map
                    int realPortNum = outputResource->reserveFirstUnconnectedOutput();
                    assert(realPortNum >= 0);
                    UtlInt* portKey = new UtlInt(outputResourcePortIndex);
                    UtlInt* portValue = new UtlInt(realPortNum);
                    newConnectionIds.insertKeyAndValue(portKey, portValue);
                    outputResourcePortIndex = realPortNum;
                }
            }

            if(inputResourcePortIndex == MpResourceTopology::MP_TOPOLOGY_NEXT_AVAILABLE_PORT)
            {
                inputResourcePortIndex = inputResource->reserveFirstUnconnectedInput();
                assert(inputResourcePortIndex >= 0);
            }
            else if(inputResourcePortIndex < MpResourceTopology::MP_TOPOLOGY_NEXT_AVAILABLE_PORT)
            {
                // First see if a real port is already in the dictionary
                UtlInt searchKey(inputResourcePortIndex);
                UtlInt* foundValue = NULL;
                if((foundValue = (UtlInt*) newConnectionIds.findValue(&searchKey)))
                {
                    // Use the mapped index
                    inputResourcePortIndex = foundValue->getValue();
                }
                else
                {
                    // Find an available port and add it to the map
                    int realPortNum = inputResource->reserveFirstUnconnectedInput();
                    assert(realPortNum >= 0);
                    UtlInt* portKey = new UtlInt(inputResourcePortIndex);
                    UtlInt* portValue = new UtlInt(realPortNum);
                    newConnectionIds.insertKeyAndValue(portKey, portValue);
                    inputResourcePortIndex = realPortNum;
                }
            }


            result = addLink(*outputResource, outputResourcePortIndex, *inputResource, inputResourcePortIndex);
            assert(result == OS_SUCCESS);
        }
        connectionIndex++;
    }

    newConnectionIds.destroyAll();
    return(connectionIndex);
}
コード例 #2
0
ファイル: sipXtapiExt.cpp プロジェクト: Konnekt/lib-sipx
SIPXTAPI_API SIPX_RESULT sipxQOSDebug(SIPX_INST phInst, CStdString& txt) {
	CStdString buff;

#ifdef INCLUDE_RTCP
	IRTCPControl* ic = CRTCManager::getRTCPControl();
	IRTCPSession* sess = ic->GetFirstSession();
	while (sess) {
		buff.Format("Sess: %d ", sess->GetSessionID());
		txt += buff;
		IRTCPConnection* conn = sess->GetFirstConnection();
		while (conn) {
			txt += "Conn\n";
			CRTCPRender* render = (CRTCPRender*)((CRTCPConnection*)conn)->GetRenderInterface();
			IGetSrcDescription* statDesc;
			IGetSenderStatistics* statSender;
			IGetReceiverStatistics* statRcvr;
			IGetByeInfo* statBye;
			render->GetStatistics(&statDesc, &statSender, &statRcvr, &statBye);
			char appName [255];
			statDesc->GetAppName((unsigned char*)appName);
			unsigned long packetCount, octetCount;
			statSender->GetSenderStatistics(&packetCount, &octetCount);
			unsigned long fractionalLoss, cumulativeLoss, highestSeq, interarrivalJitter, SRtimestamp, packetDelay;
			statRcvr->GetReceiverStatistics(&fractionalLoss, &cumulativeLoss, &highestSeq, &interarrivalJitter, &SRtimestamp, &packetDelay);

			buff.Format("app=%s, packet=%d, octet=%d, loss=%d, cLoss=%d, seq=%d, jitt=%d, SR=%d, delay=%d", appName, packetCount, octetCount, fractionalLoss, cumulativeLoss, highestSeq, interarrivalJitter, SRtimestamp, packetDelay);
			txt += buff + "\n";
			conn = sess->GetNextConnection();
		}

		sess = ic->GetNextSession();
	}
#endif 

	MpMediaTask* mtask = MpMediaTask::getMediaTask(32);
	MpFlowGraphBase* flowGraph = mtask->getFocus();
	if (flowGraph) {
		for (int i=0; i < flowGraph->mResourceCnt; i++) {
			MpResource* r = flowGraph->mExecOrder[i];
			if (strstr(r->getName(), "Dejitter")) {
				/*
				MprDejitter* dejj = (MprDejitter*) r;
				buff.Format("<u>%s</u>:: ave=%d, buff=%d, pull=%d, push=%d, " 
					//"lmax=%d, lmin=%d, " 
					"disc=%d, packs=%d ", dejj->getName().data(), dejj->getAveBufferLength(), dejj->mBufferLength, dejj->mLastPulled, dejj->mLastPushed 
					//, dejj->mLatencyMax, dejj->mLatencyMin
					, dejj->mNumDiscarded, dejj->mNumPackets);
				txt += buff + "<br/>";
				*/
			} else if (strstr(r->getName(), "Decode")) {
				/*
				MprDecode* decode = (MprDecode*) r;

				for (int c=0; c < decode->mNumCurrentCodecs; c++) {
					MpDecoderBase* mpd = decode->mpCurrentCodecs[c];
					if (mpd->getInfo()->getCodecType() == SdpCodec::SDP_CODEC_PCMU || mpd->getInfo()->getCodecType() == SdpCodec::SDP_CODEC_PCMA) {
						MpdSipxPcma* pcma = (MpdSipxPcma*)mpd;
						MpJitterBuffer* jb = (MpJitterBuffer*)pcma->pJBState;
						buff.Format("Codec::%d tci=%d, pull=%d, wait=%d, under=%d, seq=%d, few=%d, many=%d, last=%d", pcma->getInfo()->getCodecType(), pcma->mTimerCountIncrement, pcma->mNextPullTimerCount, pcma->mWaitTimeInFrames, pcma->mUnderflowCount, pcma->mLastSeqNo, pcma->mTooFewPacketsInBuffer, pcma->mTooManyPacketsInBuffer, pcma->mLastReportSize);
						txt += buff + ", JB:";
						buff.Format("avail=%d, qc=%d, qi=%d, qo=%d", jb->JbPacketsAvail, jb->JbQCount, jb->JbQIn, jb->JbQOut);
						txt += buff + "<br/>";
					}
				}
*/
			}/* else if (stristr(r->getName(), "FromNet")) {
				MprFromNet* fromNet = (MprFromNet*) r;
			}*/
		}
	}

	int rating = 0;
	sipxQOSRating(phInst, rating);
	buff.Format("Rating: <b>%d</b>", rating);
	txt += buff;

/*
MprDejitter::getAveBufferLength -> MprDejitter -> MprDecode::getMyDejitter / MprFromNet::getMyDejitter()
MpdSipxPcmu -> MpConnection::mapPayloadType  MpCodecFactory::createDecoder 
MpdSipxPcma (MpDecoderBase)
MpJitterBuffer -> MpConnection::getJBinst

MpCallFlowGraph::getConnectionPtr
*/
	return SIPX_RESULT_SUCCESS;
}
コード例 #3
0
int MpTopologyGraph::addTopologyResources(MpResourceTopology& resourceTopology,
                                          MpResourceFactory& resourceFactory,
                                          UtlHashBag& newResources,
                                          UtlBoolean replaceNumInName,
                                          int resourceNum)
{
    // Add the resources
    int resourceIndex = 0;
    MpResource* resourcePtr = NULL;
    MpResource* resourceArray[MAX_CONSTRUCTED_RESOURCES];
    UtlString resourceType;
    UtlString resourceName;
    MpConnectionID resourceConnId;
    int resourceStreamId;
    OsStatus result;
    while(resourceTopology.getResource(resourceIndex, resourceType, resourceName,
                                       resourceConnId, resourceStreamId) == OS_SUCCESS)
    {
        if(replaceNumInName)
        {
           MpResourceTopology::replaceNumInName(resourceName, resourceNum);
        }

        int numConstructorResources;
        OsStatus status;
        status = resourceFactory.newResource(resourceType, resourceName, MAX_CONSTRUCTED_RESOURCES,
                                             numConstructorResources, resourceArray);        
        if(status == OS_SUCCESS)
        {
           assert(numConstructorResources > 0);
           int arrayIndex;
           // We now can potentially get more than one resource back from the
           // constructor
           for(arrayIndex = 0; arrayIndex < numConstructorResources; arrayIndex++)
           {
              resourcePtr = resourceArray[arrayIndex];
              assert(resourcePtr);
              if(resourcePtr)
              {
#ifdef TEST_PRINT
                  printf("constructed and adding resource name: %s type: %s\n",
                         resourcePtr->getName().data(),
                         resourceType.data());
#endif
                  if(replaceNumInName && resourceConnId == MP_INVALID_CONNECTION_ID)
                  {
                     resourcePtr->setConnectionId(resourceNum);
                  }
                  else
                  {
                     resourcePtr->setConnectionId(resourceConnId);
                  }
                  resourcePtr->setStreamId(resourceStreamId);
                  newResources.insert(resourcePtr);
                  result = addResource(*resourcePtr, FALSE);
                  assert(result == OS_SUCCESS);
               }
           }
        }
        else
        {
           OsSysLog::add(FAC_MP, PRI_ERR, 
              "Failed to create resource type: %s name: %s status: %d",
              resourceType.data(), resourceName.data(), status);
        }
        resourceIndex++;
    }
    return(resourceIndex);
}