void testFocus() { MpFlowGraphBase* pFlowGraph = 0; MpMediaTask* pMediaTask = 0; OsStatus res; // Test 1: Attempt to setFocus to a flow graph that the media task // is not managing pMediaTask = MpMediaTask::getMediaTask(10); pFlowGraph = new MpFlowGraphBase(30, 30); res = pMediaTask->setFocus(pFlowGraph); // send the media task a CPPUNIT_ASSERT(res == OS_SUCCESS); // set_focus command and res = MpMediaTask::signalFrameStart(); // give it a chance to run CPPUNIT_ASSERT(res == OS_SUCCESS); OsTask::delay(20); CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs()); // Test 2: Set the focus to a flow graph that has not been started res = pMediaTask->manageFlowGraph(*pFlowGraph); CPPUNIT_ASSERT(res == OS_SUCCESS); // manage the flow graph and res = pMediaTask->setFocus(pFlowGraph); // send the media task a CPPUNIT_ASSERT(res == OS_SUCCESS); // set_focus command and res = MpMediaTask::signalFrameStart(); // give it a chance to run CPPUNIT_ASSERT(res == OS_SUCCESS); OsTask::delay(20); CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs()); // Test 3: Set the focus to a flow graph that has been started res = pMediaTask->startFlowGraph(*pFlowGraph); CPPUNIT_ASSERT(res == OS_SUCCESS); // start the flow graph and res = pMediaTask->setFocus(pFlowGraph); // send the media task a CPPUNIT_ASSERT(res == OS_SUCCESS); // set_focus command and res = MpMediaTask::signalFrameStart(); // give it a chance to run CPPUNIT_ASSERT(res == OS_SUCCESS); OsTask::delay(20); // 6/16/99, incompatible with new, real implementation of Focus: // CPPUNIT_ASSERT(pMediaTask->getFocus() == pFlowGraph); // Test 4: Set the focus to NULL res = pMediaTask->unmanageFlowGraph(*pFlowGraph); CPPUNIT_ASSERT(res == OS_SUCCESS); // unmanage the flow graph res = pMediaTask->setFocus(NULL); // and send the media task a CPPUNIT_ASSERT(res == OS_SUCCESS); // set_focus command and res = MpMediaTask::signalFrameStart(); // give it a chance to run CPPUNIT_ASSERT(res == OS_SUCCESS); CPPUNIT_ASSERT(pMediaTask->getFocus() == NULL); delete pFlowGraph; }
// (static) Displays information on the console about the media processing // task. MpFlowGraphBase* MpMediaTask::mediaInfo(void) { MpFlowGraphBase* flowGraphs[20]; int i; int numItems; MpMediaTask* pMediaTask; MpFlowGraphBase* pFlowGraph; OsStatus res; pMediaTask = MpMediaTask::getMediaTask(0); printf("\nMedia processing task information\n"); printf(" Debug mode: %s\n", pMediaTask->getDebugMode() ? "TRUE" : "FALSE"); printf(" Processed Frame Count: %d\n", pMediaTask->numProcessedFrames()); printf(" Processing Time Limit: %d usecs\n", pMediaTask->getTimeLimit()); printf(" Processing Limit Exceeded Count: %d\n", pMediaTask->getLimitExceededCnt()); i = pMediaTask->getWaitTimeout(); if (i < 0) printf(" Frame Start Wait Timeout: INFINITE\n"); else printf(" Frame Start Wait Timeout: %d\n", i); printf(" Wait Timeout Exceeded Count: %d\n", pMediaTask->getWaitTimeoutCnt()); printf("\n Flow Graph Information\n"); printf(" Managed: %d\n", pMediaTask->numManagedFlowGraphs()); printf(" Started: %d\n", pMediaTask->numStartedFlowGraphs()); pFlowGraph = pMediaTask->getFocus(); if (pFlowGraph == NULL) printf(" Focus: NULL\n"); else printf(" Focus: %p\n", pFlowGraph); res = pMediaTask->getManagedFlowGraphs(flowGraphs, 20, numItems); for (i=0; i < numItems; i++) printf(" FlowGraph[%d]: %p\n", i, flowGraphs[i]); return pFlowGraph; }
OsStatus CpPhoneMediaInterface::defocus() { if(mpFlowGraph) { MpMediaTask* mediaTask = MpMediaTask::getMediaTask(0); // There should probably be a lock here // take focus away from the flow graph if it is focus if(mpFlowGraph == (MpCallFlowGraph*) mediaTask->getFocus()) { mediaTask->setFocus(NULL); // osPrintf("Setting NULL focus for flow graph\n"); } } return OS_SUCCESS ; }
// (static) Displays information on the console about the specified flow // graph. void MpFlowGraphBase::flowGraphInfo(MpFlowGraphBase* pFlowGraph) { int i; MpResource* pResource; if (NULL == pFlowGraph) { MpMediaTask* pMediaTask = MpMediaTask::getMediaTask(0); pFlowGraph = pMediaTask->getFocus(); if (NULL == pFlowGraph) { pMediaTask->getManagedFlowGraphs(&pFlowGraph, 1, i); if (0 == i) pFlowGraph = NULL; } } if (NULL == pFlowGraph) { printf("No flowGraph to display!\n"); return; } printf("\nFlow graph information for %p\n", pFlowGraph); printf(" State: %s\n", pFlowGraph->isStarted() ? "STARTED" : "STOPPED"); printf(" Processed Frame Count: %d\n", pFlowGraph->numFramesProcessed()); printf(" Samples Per Frame: %d\n", pFlowGraph->getSamplesPerFrame()); printf(" Samples Per Second: %d\n", pFlowGraph->getSamplesPerSec()); pResource = pFlowGraph->mpResourceInProcess; if (pResource == NULL) printf(" Resource Being Processed: NULL\n"); else printf(" Resource Being Processed: %p\n", pResource); printf("\n Resource Information\n"); printf(" Resources: %d\n", pFlowGraph->numResources()); printf(" Links: %d\n", pFlowGraph->numLinks()); for (i=0; i < pFlowGraph->mResourceCnt; i++) { pResource = pFlowGraph->mUnsorted[i]; pResource->resourceInfo(pResource, i); } }
void testCreators() { MpMediaTask* pMediaTask = 0; OsStatus res; int numFramesAlready; // Call getMediaTask() which causes the task to get instantiated pMediaTask = MpMediaTask::getMediaTask(10); CPPUNIT_ASSERT(pMediaTask != NULL); // Check the initial state of the MpMediaTask object // **************************************************************************** // **** This is NOT THE INITIAL STATE UNLESS THE ABOVE CALL to getMediaTask() // **** is the very first call to that function. The problem with these // **** tests is that they were meant to be run separately, but that is not // **** the case with our self-starting singleton tasks. This one has been // **** around the track a few times already, we get whatever we get. // **************************************************************************** // Not anymore... CPPUNIT_ASSERT(pMediaTask->getDebugMode() == FALSE); // Good luck with the rest! CPPUNIT_ASSERT(pMediaTask->getFocus() == NULL); // Not anymore... CPPUNIT_ASSERT_EQUAL(0, pMediaTask->getLimitExceededCnt()); CPPUNIT_ASSERT(pMediaTask->getTimeLimit() == MpMediaTask::DEF_TIME_LIMIT_USECS); CPPUNIT_ASSERT(pMediaTask->getWaitTimeout() == MpMediaTask::DEF_SEM_WAIT_MSECS); // Not anymore... CPPUNIT_ASSERT_EQUAL(0, pMediaTask->getWaitTimeoutCnt()); CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numManagedFlowGraphs()); // Not anymore... CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numProcessedFrames()); numFramesAlready = pMediaTask->numProcessedFrames(); CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numStartedFlowGraphs()); // Verify that the task is actually running by: // enabling debug mode // calling signalFrameStart() // checking the processed frame count res = pMediaTask->setDebug(TRUE); CPPUNIT_ASSERT(res == OS_SUCCESS); res = MpMediaTask::signalFrameStart(); // send a signal to the task CPPUNIT_ASSERT(res == OS_SUCCESS); // and give it a chance to run OsTask::delay(20); // Not anymore... CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numProcessedFrames()); CPPUNIT_ASSERT_EQUAL((numFramesAlready+1), pMediaTask->numProcessedFrames()); }
// Destructor CpPhoneMediaInterface::~CpPhoneMediaInterface() { OsSysLog::add(FAC_CP, PRI_DEBUG, "CpPhoneMediaInterface::~CpPhoneMediaInterface deleting the CpMediaInterface %p", this); CpPhoneMediaConnection* mediaConnection = NULL; while ((mediaConnection = (CpPhoneMediaConnection*) mMediaConnections.get())) { doDeleteConnection(mediaConnection); delete mediaConnection; mediaConnection = NULL; } if(mpFlowGraph) { // Free up the resources used by tone generation ASAP stopTone(); // Stop the net in/out stuff before the sockets are deleted //mpMediaFlowGraph->stopReceiveRtp(); //mpMediaFlowGraph->stopSendRtp(); MpMediaTask* mediaTask = MpMediaTask::getMediaTask(0); // take focus away from the flow graph if it is focus if(mpFlowGraph == (MpCallFlowGraph*) mediaTask->getFocus()) { mediaTask->setFocus(NULL); } OsSysLog::add(FAC_CP, PRI_DEBUG, "CpPhoneMediaInterface::~CpPhoneMediaInterface deleting the MpCallFlowGraph %p", mpFlowGraph); delete mpFlowGraph; mpFlowGraph = NULL; } }
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; }