示例#1
0
// (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;
}
示例#2
0
    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());
    }
示例#3
0
    void testManagedAndUnmanagedFlowGraph()
    {

        MpFlowGraphBase* pFlowGraph = 0;
        MpMediaTask*     pMediaTask = 0;
        OsStatus         res;

        // Test 1: Create an empty flow graph and manage it
        pMediaTask = MpMediaTask::getMediaTask(10);
        pFlowGraph = new MpFlowGraphBase(30, 30);
        res = pMediaTask->manageFlowGraph(*pFlowGraph);
        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

        // 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);

        CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numManagedFlowGraphs());

        // Test 2: Invoke manageFlowGraph() with the same flow graph
        //         (will increment the numHandledMsgErrs() count for that
        //         frame processing interval but should otherwise have no
        //         effect)
        res = pMediaTask->manageFlowGraph(*pFlowGraph);
        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);

        CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numManagedFlowGraphs());
        CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs());

        // Test 3: Unmanage the flow graph
        res = pMediaTask->unmanageFlowGraph(*pFlowGraph);
        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);

        CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numManagedFlowGraphs());
        // Test 4: Unmanage a flow graph which is not currently managed
        //         (will increment the numHandledMsgErrs() count for that
        //         frame processing interval but should otherwise have no
        //         effect)
        res = pMediaTask->unmanageFlowGraph(*pFlowGraph);
        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);

        CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numManagedFlowGraphs());
        CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs());

        // Test 5: Attempt to manage a flow graph that is not in the
        //         MpFlowGraphBase::STOPPED state
        res = pFlowGraph->start();              // send the flow graph a start
        CPPUNIT_ASSERT(res == OS_SUCCESS);      // command and a signal to
        res = pFlowGraph->processNextFrame();   // process its messages
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pMediaTask->manageFlowGraph(*pFlowGraph);
        CPPUNIT_ASSERT(res == OS_INVALID_ARGUMENT);

        res = pFlowGraph->stop();               // send the flow graph a stop
        CPPUNIT_ASSERT(res == OS_SUCCESS);      // command and a signal to
        res = pFlowGraph->processNextFrame();   // process its messages
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        // Test 6: Unmanage a flow graph that is "started"
        res = pMediaTask->manageFlowGraph(*pFlowGraph);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pMediaTask->startFlowGraph(*pFlowGraph); // start the flow graph
        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);

        res = pMediaTask->unmanageFlowGraph(*pFlowGraph);
        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);

        // verify that the flow graph has been stopped and is unmanaged
        CPPUNIT_ASSERT(pFlowGraph->getState() == MpFlowGraphBase::STOPPED);
        CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numManagedFlowGraphs());
        CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numStartedFlowGraphs());

        delete pFlowGraph;
    }