Пример #1
0
    void testStartAndStop()
    {
        MpFlowGraphBase*    pFlowGraph = 0;
        OsStatus        res;

        pFlowGraph = new MpFlowGraphBase(80, 8000);

        CPPUNIT_ASSERT(!pFlowGraph->isStarted());  // verify the flow graph is not STARTED
        CPPUNIT_ASSERT(MpFlowGraphBase::STOPPED == pFlowGraph->getState());

        res = pFlowGraph->start();         // now start it
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        res = pFlowGraph->processNextFrame();
        CPPUNIT_ASSERT((res == OS_SUCCESS) && pFlowGraph->isStarted());
        CPPUNIT_ASSERT(MpFlowGraphBase::STARTED == pFlowGraph->getState());

        res = pFlowGraph->stop();          // now stop it again
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        res = pFlowGraph->processNextFrame();
        CPPUNIT_ASSERT((res == OS_SUCCESS) && !pFlowGraph->isStarted());
        CPPUNIT_ASSERT(MpFlowGraphBase::STOPPED == pFlowGraph->getState());

        delete pFlowGraph;
    }
Пример #2
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;
    }
Пример #3
0
    /**
     * FAILS : Segmention fault
     */
    void testProcessNextFrame()
    {
       // Set up a flow graph with two resources (resource1 and resource2). Both
       // resources have 4 inputs and 4 outputs.  All four outputs of resource1
       // are connected to the corresponding inputs of resource2.  The resources
       // are further configured to behave as follows for each frame processing
       // interval.
       //
       // Resource 1:                   |   Resource 2:
       //   Creates output buffers on   |     Processes input buffers received on
       //   output ports 0, 2 and 3.    |     input ports 0, 1 and 2.
       //
       //   resource1   Output 0        -->   Input 0
       //   ignores     Output 1 (NULL) -->   Input 1
       //   its         Output 2        -->   Input 2
       //   inputs      Output 3        -->   Input 3 (not processed)
       //
       // The net result is that each frame time, resource2 should receive
       // non-NULL buffers on input ports 0, 2 and 3.  Since resource2 is not
       // processing input buffers on input port 3, for each frame, the old
       // buffer on input port 3 will be discarded to make way for a new buffer.
        MpFlowGraphBase*    pFlowGraph = 0;
        MpTestResource* pResource1 = 0;
        MpTestResource* pResource2 = 0;
        OsStatus        res;

        mpStartUp(8000, 80, 6*10, 0);

        pFlowGraph = new MpFlowGraphBase(80, 8000);
        pResource1 = new MpTestResource("resource1", 4, 4, 4, 4);
        pResource2 = new MpTestResource("resource2", 4, 4, 4, 4);

        res = pFlowGraph->addResource(*pResource1);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pFlowGraph->addResource(*pResource2);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pFlowGraph->addLink(*pResource1, 0, *pResource2, 0);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pFlowGraph->addLink(*pResource1, 1, *pResource2, 1);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pFlowGraph->addLink(*pResource1, 2, *pResource2, 2);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        res = pFlowGraph->addLink(*pResource1, 3, *pResource2, 3);
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        // For resource1, create new buffers on output ports 0, 2 and 3 and
        // ignore all input buffers (Note: there shouldn't be any)
        pResource1->setGenOutBufMask(0xd);
        pResource1->setProcessInBufMask(0x0);

        // For resource2, process input buffers that arrive input ports 0, 1 and 2.
        pResource2->setGenOutBufMask(0x0);
        pResource2->setProcessInBufMask(0x7);

        CPPUNIT_ASSERT(pResource1->numFramesProcessed() == 0);
        CPPUNIT_ASSERT(pResource2->numFramesProcessed() == 0);

        // Enable the flow graph
        res = pFlowGraph->enable();
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        // Start the flow graph
        res = pFlowGraph->start();
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        // Process two frames
        res = pFlowGraph->processNextFrame();
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        res = pFlowGraph->processNextFrame();
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        for (int i = 0; i < 3; i++)
        {
            CPPUNIT_ASSERT((pResource1->mLastDoProcessArgs.inBufs[i]  == NULL) &&
                           (pResource1->mLastDoProcessArgs.outBufs[i] == NULL) &&
                           (pResource2->mLastDoProcessArgs.inBufs[i] == NULL) &&
                           (pResource2->mLastDoProcessArgs.outBufs[i] == NULL));
        }
        CPPUNIT_ASSERT((pResource1->numFramesProcessed() == 2) &&
                       (pResource1->mLastDoProcessArgs.inBufsSize == 4) &&
                       (pResource1->mLastDoProcessArgs.outBufsSize == 4) &&
                       (pResource2->numFramesProcessed() == 2));

        // Stop the flow graph
        res = pFlowGraph->stop();
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        // Request processing of another frame so that the STOP_FLOWGRAPH
        // message gets handled
        res = pFlowGraph->processNextFrame();
        CPPUNIT_ASSERT(res == OS_SUCCESS);

        delete pFlowGraph;
    }