void testMultipleManagedAndUnmanagedFlowgraph() { MpFlowGraphBase* pFlowGraph1 = 0; MpFlowGraphBase* pFlowGraph2 = 0; MpMediaTask* pMediaTask = 0; MpFlowGraphBase* flowGraphs[2]; int itemCnt; OsStatus res; pMediaTask = MpMediaTask::getMediaTask(10); pFlowGraph1 = new MpFlowGraphBase(30, 30); pFlowGraph2 = new MpFlowGraphBase(30, 30); // Test 1: Add one managed flow graph res = pMediaTask->manageFlowGraph(*pFlowGraph1); CPPUNIT_ASSERT(res == OS_SUCCESS); res = MpMediaTask::signalFrameStart(); // signal the media task and CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run // NOTE: original delay of 20 was tempermental, I increased // this to 100 to reduce the chance of this happening to // hopefully 0% - DLH OsTask::delay(100); flowGraphs[0] = flowGraphs[1] = NULL; res = pMediaTask->getManagedFlowGraphs(flowGraphs, 2, itemCnt); CPPUNIT_ASSERT(res == OS_SUCCESS); CPPUNIT_ASSERT_EQUAL(1, itemCnt); CPPUNIT_ASSERT(flowGraphs[0] == pFlowGraph1); // Test 2: Add a second managed flow graph res = pMediaTask->manageFlowGraph(*pFlowGraph2); CPPUNIT_ASSERT(res == OS_SUCCESS); res = MpMediaTask::signalFrameStart(); // signal the media task and CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run OsTask::delay(20); flowGraphs[0] = flowGraphs[1] = NULL; res = pMediaTask->getManagedFlowGraphs(flowGraphs, 2, itemCnt); CPPUNIT_ASSERT(res == OS_SUCCESS); CPPUNIT_ASSERT_EQUAL(2, itemCnt); CPPUNIT_ASSERT(flowGraphs[0] == pFlowGraph1 || flowGraphs[0] == pFlowGraph2); CPPUNIT_ASSERT(flowGraphs[1] == pFlowGraph1 || flowGraphs[1] == pFlowGraph2); CPPUNIT_ASSERT(flowGraphs[0] != flowGraphs[1]); res = pMediaTask->unmanageFlowGraph(*pFlowGraph1); CPPUNIT_ASSERT(res == OS_SUCCESS); res = pMediaTask->unmanageFlowGraph(*pFlowGraph2); CPPUNIT_ASSERT(res == OS_SUCCESS); res = MpMediaTask::signalFrameStart(); // signal the media task and CPPUNIT_ASSERT(res == OS_SUCCESS); // give it a chance to run OsTask::delay(20); delete pFlowGraph1; delete pFlowGraph2; }
//****************************************************************************** void showStatus() { MpMediaTask* pMediaTask = MpMediaTask::getMediaTask(); pMediaTask->mediaInfo(); const int MAX_GRAPHS = 16; int numGraphs; MpFlowGraphBase* pGraphs[MAX_GRAPHS]; OsStatus ret; ret = pMediaTask->getManagedFlowGraphs(pGraphs, MAX_GRAPHS, numGraphs); if (ret != OS_SUCCESS) { cerr << "***ERROR: Couldn't retrieve flow graph pointers!" << endl; return; } //cout << "Retrieved " << numGraphs << " flow graph pointers:" << endl; for (int i = 0; i < numGraphs; i++) { MpFlowGraphBase::flowGraphInfo(pGraphs[i]); } cout << endl; return; }
// (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; }
// (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); } }