Пример #1
0
//******************************************************************************
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;
}
Пример #2
0
OsStatus CpPhoneMediaInterface::giveFocus()
{
    if(mpFlowGraph)
    {
        // There should probably be a lock here
        // Set the flow graph to have the focus
        MpMediaTask* mediaTask = MpMediaTask::getMediaTask(0);
        mediaTask->setFocus(mpFlowGraph);
        // osPrintf("Setting focus for flow graph\n");
   }

   return OS_SUCCESS ;
}
Пример #3
0
    void testDebugMode()
    {

        MpMediaTask*     pMediaTask = 0;
        OsStatus         res;
        int              waitTimeoutCnt;

        // Test 1: Verify that wait for "frame start" timeouts are noticed
        //         only when the media task is not in debug mode
        pMediaTask = MpMediaTask::getMediaTask(10);
        res = pMediaTask->setDebug(FALSE);      // turn debug mode off
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        CPPUNIT_ASSERT(pMediaTask->getDebugMode() == FALSE);

        waitTimeoutCnt = pMediaTask->getWaitTimeoutCnt();
        res = MpMediaTask::signalFrameStart();  // send a signal to the task
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        OsTask::delay(1000);                    // and wait 1 second

        // $$$ Need to understand why the following test fails on vxWorks
        // WHAT THE #(*$&#(*&???  CPPUNIT_ASSERT(pMediaTask->getWaitTimeoutCnt() > waitTimeoutCnt);

        res = pMediaTask->setDebug(TRUE);       // turn debug mode on
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        CPPUNIT_ASSERT(pMediaTask->getDebugMode() == TRUE);

        res = MpMediaTask::signalFrameStart();  // send a signal to the task
        CPPUNIT_ASSERT(res == OS_SUCCESS);      // and give it a chance to run
        OsTask::delay(20);

        waitTimeoutCnt = pMediaTask->getWaitTimeoutCnt();
        OsTask::delay(1000);                     // wait 1 second
        CPPUNIT_ASSERT_EQUAL(waitTimeoutCnt, pMediaTask->getWaitTimeoutCnt());
    }
Пример #4
0
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 ;
}
Пример #5
0
// Destructor
MpTopologyGraph::~MpTopologyGraph()
{
    // unmanage the flowgraph
    MpMediaTask* mediaTask = MpMediaTask::getMediaTask();
    OsStatus result = mediaTask->unmanageFlowGraph(*this);
    assert(result == OS_SUCCESS);

    // wait until the flowgraph is unmanaged.
    while (mediaTask->isManagedFlowGraph(this))
    {
        OsTask::delay(20);   // wait 20 msecs before checking again
    }

    mVirtualInputs.destroyAll();
    mVirtualOutputs.destroyAll();
}
Пример #6
0
// (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);
   }
}
Пример #7
0
    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;
    }
Пример #8
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());
    }
Пример #9
0
// 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;
    }
}
Пример #10
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);
}
Пример #11
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;
}
Пример #12
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;
    }
Пример #13
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;
    }
Пример #14
0
    void testTimeLimitAndTimeout()
    {
        MpMediaTask*     pMediaTask = 0;
        OsStatus         res;
        int              oldValue;

        // Test 1: Set the time limit to twice its original value
        pMediaTask = MpMediaTask::getMediaTask(10);
        oldValue = pMediaTask->getTimeLimit();
        res = pMediaTask->setTimeLimit(oldValue * 2);
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        CPPUNIT_ASSERT_EQUAL(oldValue * 2, pMediaTask->getTimeLimit());

        // Test 2: Set the time limit back to its original value
        res = pMediaTask->setTimeLimit(oldValue);
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        CPPUNIT_ASSERT_EQUAL(oldValue, pMediaTask->getTimeLimit());

        // Test 3: Set the wait timeout to twice its original value
        oldValue = pMediaTask->getWaitTimeout();
        res = pMediaTask->setWaitTimeout(oldValue * 2);
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        CPPUNIT_ASSERT_EQUAL(oldValue * 2, pMediaTask->getWaitTimeout());

        // Test 4: Set the wait timeout to -1 (infinity)
        res = pMediaTask->setWaitTimeout(-1);
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        CPPUNIT_ASSERT_EQUAL(-1, pMediaTask->getWaitTimeout());

        // Test 5: Set the wait timeout back to its original value
        res = pMediaTask->setWaitTimeout(oldValue);
        CPPUNIT_ASSERT(res == OS_SUCCESS);
        CPPUNIT_ASSERT_EQUAL(oldValue, pMediaTask->getWaitTimeout());
    }
Пример #15
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;
    }
Пример #16
0
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;
}