示例#1
0
    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;
    }
示例#2
0
// Constructor
MpTopologyGraph::MpTopologyGraph(int samplesPerFrame, 
                                 int samplesPerSec,
                                 MpResourceTopology& initialResourceTopology,
                                 MpResourceFactory& resourceFactory,
                                 OsMsgDispatcher *pNotifDispatcher)
: MpFlowGraphBase(samplesPerFrame, samplesPerSec, pNotifDispatcher)
, mpResourceFactory(&resourceFactory)
{
    OsStatus result;

    // construct the new resources defined in the topology and add to the flowgraph
    UtlHashBag newResourcesAdded;
    addTopologyResources(initialResourceTopology, 
                         resourceFactory,
                         newResourcesAdded);

    // Add virtual ports defined in the topology
    addVirtualInputs(initialResourceTopology, newResourcesAdded);
    addVirtualOutputs(initialResourceTopology, newResourcesAdded);

    // Add the links for the resources in the topology
    linkTopologyResources(initialResourceTopology, newResourcesAdded);

    // ask the media processing task to manage the new flowgraph
    MpMediaTask* mediaTask = MpMediaTask::getMediaTask();
    result = mediaTask->manageFlowGraph(*this);
    assert(result == OS_SUCCESS);

    // start the flowgraph
    result = mediaTask->startFlowGraph(*this);
    if(result != OS_SUCCESS)
    {
        printf("MpTopologyGraph mediaTask->startFlowGraph failed: %d\n", result);
    }
    assert(result == OS_SUCCESS);
}
示例#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;
    }
示例#4
0
    void testStartAndStopFlowGraph()
    {

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

        // Test 1: Set the time limit to twice its original value
        pMediaTask = MpMediaTask::getMediaTask(10);

        pFlowGraph = new MpFlowGraphBase(30, 30);

        pMediaTask->numHandledMsgErrs(); // clear count
        // Test 1: Attempt to start a flow graph that is not being managed
        //CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numStartedFlowGraphs());
        res = pMediaTask->startFlowGraph(*pFlowGraph);
        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);
        // NOTE: Original test code had "1", not sure what's correct
        CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs());
        CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numStartedFlowGraphs());

        // Test 2: Start a flow graph that is managed
        pMediaTask->numHandledMsgErrs(); // clear the count

        res = pMediaTask->manageFlowGraph(*pFlowGraph);
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        res = pMediaTask->startFlowGraph(*pFlowGraph);
        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);
        CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numHandledMsgErrs());
        CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numStartedFlowGraphs());
        CPPUNIT_ASSERT(pFlowGraph->isStarted());

        // Test 3: Attempt to start the same flow graph again
        pMediaTask->numHandledMsgErrs(); // clear the count

        res = pMediaTask->startFlowGraph(*pFlowGraph);
        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);
        //CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numHandledMsgErrs());
        CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numStartedFlowGraphs());


        // Test 4: Stop the flow graph
        pMediaTask->numHandledMsgErrs(); // clear the count

        res = pMediaTask->stopFlowGraph(*pFlowGraph);
        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);
        CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numHandledMsgErrs());
        CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numStartedFlowGraphs());
        CPPUNIT_ASSERT(!pFlowGraph->isStarted());

        // Test 5: Attempt to stop the same flow graph again
        pMediaTask->numHandledMsgErrs(); // clear the count

        res = pMediaTask->stopFlowGraph(*pFlowGraph);
        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);
        //CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs());
        CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numStartedFlowGraphs());
        CPPUNIT_ASSERT(!pFlowGraph->isStarted());

        // Test 6: Attempt to stop a flow graph that is not being managed
        pMediaTask->numHandledMsgErrs(); // clear the count

        res = pMediaTask->unmanageFlowGraph(*pFlowGraph);
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        res = pMediaTask->stopFlowGraph(*pFlowGraph);
        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);
        CPPUNIT_ASSERT_EQUAL(1, pMediaTask->numHandledMsgErrs());
        CPPUNIT_ASSERT_EQUAL(0, pMediaTask->numStartedFlowGraphs());
        CPPUNIT_ASSERT(!pFlowGraph->isStarted());

        delete pFlowGraph;
    }