Exemple #1
0
UtlBoolean MprBridge::handleMessage(MpFlowGraphMsg& rMsg)
{
   UtlBoolean msgHandled = FALSE;

   switch (rMsg.getMsg()) {
   case SET_WEIGHTS_FOR_INPUT:
      {
         MpBridgeGain *pGains = (MpBridgeGain*)rMsg.getPtr1();
         msgHandled = handleSetMixWeightsForInput(rMsg.getInt1(), rMsg.getInt2(),
                                                  pGains);
         delete[] pGains;
      }
      break;

   case SET_WEIGHTS_FOR_OUTPUT:
      {
         MpBridgeGain *pGains = (MpBridgeGain*)rMsg.getPtr1();
         msgHandled = handleSetMixWeightsForOutput(rMsg.getInt1(), rMsg.getInt2(),
                                                   pGains);
         delete[] pGains;
      }
      break;

   default:
      msgHandled = MpAudioResource::handleMessage(rMsg);
      break;
   }
   return msgHandled;
}
Exemple #2
0
// Handle messages for this resource.
UtlBoolean MprFromStream::handleMessage(MpFlowGraphMsg& rMsg)
{
   UtlBoolean bHandled = FALSE ;

   switch (rMsg.getMsg())
   {
      case SOURCE_RENDER:
         bHandled = handleRender((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      case SOURCE_PLAY:
         bHandled = handlePlay((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      case SOURCE_REWIND:
         bHandled = handleRewind((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      case SOURCE_PAUSE:
         bHandled = handlePause((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      case SOURCE_STOP:
         bHandled = handleStop((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      case SOURCE_DESTROY:
         bHandled = handleDestroy((MpStreamFeeder*) rMsg.getPtr1()) ;
         break ;
      default:
         bHandled = MpResource::handleMessage(rMsg);
         break;
   }
   return bHandled ;
}
Exemple #3
0
// Handle messages for this resource.
UtlBoolean MprToNet::handleMessage(MpFlowGraphMsg& rMsg)
{

   if (rMsg.getMsg() == SET_SOCKETS)
   {
      mpRtpSocket  = (OsSocket*) rMsg.getPtr1();
      mpRtcpSocket = (OsSocket*) rMsg.getPtr2();
      return TRUE;
   }
   if (rMsg.getMsg() == RESET_SOCKETS)
   {
      mpRtpSocket  = NULL;
      mpRtcpSocket = NULL;
      return TRUE;
   }
   else
      return MpResource::handleMessage(rMsg);
}
Exemple #4
0
// Handle messages for this resource.
UtlBoolean MprDecode::handleMessage(MpFlowGraphMsg& rMsg)
{
   UtlBoolean ret = FALSE;

   switch (rMsg.getMsg()) {
   case DESELECT_CODECS:
      handleDeselectCodecs();
      ret = TRUE;
      break;
   case SELECT_CODECS:
      handleSelectCodecs((SdpCodec**) rMsg.getPtr1(), rMsg.getInt1());
      ret = TRUE;
      break;
   default:
      ret = MpResource::handleMessage(rMsg);
      break;
   }
   return ret;
}
UtlBoolean MprSimpleDtmfDetector::handleMessage(MpFlowGraphMsg& rMsg)
{
   switch (rMsg.getMsg())
   {
   case 0: // to make compiler stop complaining
   default:
      return MpAudioResource::handleMessage(rMsg);
      break;
   }
   return TRUE;
}
Exemple #6
0
// Handle messages for this resource.
UtlBoolean MprToneGen::handleMessage(MpFlowGraphMsg& fgMsg)
{
   int msgType;

   msgType = fgMsg.getMsg();
   switch (msgType)
   {
   case START_TONE:
      MpToneGen_startTone(mpToneGenState, fgMsg.getInt1());
      enable();
      break;
   case STOP_TONE:
      MpToneGen_stopTone(mpToneGenState);
      disable();
      break;
   default:
      return MpAudioResource::handleMessage(fgMsg);
      break;
   }
   return TRUE;
}
// Handle messages for this resource.
UtlBoolean MprSpeexPreprocess::handleMessage(MpFlowGraphMsg& rMsg)
{
   int msgType;

   msgType = rMsg.getMsg();
   switch (msgType)
   {
   case SET_AGC:
      return handleSetAGC(rMsg.getInt1());
      break;
   case SET_NOISE_REDUCTION:
      return handleSetNoiseReduction(rMsg.getInt1());
      break;
   case SET_VAD:
      return handleSetVAD(rMsg.getInt1());
      break;
   default:
      return MpAudioResource::handleMessage(rMsg);
      break;
   }
}
Exemple #8
0
UtlBoolean MprRecorder::handleMessage(MpFlowGraphMsg& rMsg)
{
   OsSysLog::add(FAC_MP, PRI_DEBUG, "MprRecorder::handleMessage(%d)\n", rMsg.getMsg());
   switch (rMsg.getMsg())
   {
   case SETUP:
      {
      //params:  Int1 = file descriptor,
      //         Int2 = time to record in millisecs,
      //         Ptr1 = OsEvent pointer
         int file = rMsg.getInt1();
         int iMSec = rMsg.getInt2();
         OsProtectedEvent* pEvent = (OsProtectedEvent*) rMsg.getPtr1();
         int silenceLength = (int) (intptr_t) rMsg.getPtr2();
         return handleSetup(file, iMSec, silenceLength, pEvent);
      }
      break;

   case BEGIN:
      return handleBegin();
      break;

   case STOP:
      return handleStop();
      break;
   }
   return MpResource::handleMessage(rMsg);
}
Exemple #9
0
// Handle messages for this resource.
UtlBoolean MprMixer::handleMessage(MpFlowGraphMsg& rMsg)
{
   UtlBoolean boolRes;
   int       msgType;
   int*      weights;

   msgType = rMsg.getMsg();
   switch (msgType)
   {
   case SET_WEIGHT:
      return handleSetWeight(rMsg.getInt1(), rMsg.getInt2());
      break;
   case SET_WEIGHTS:
      weights = (int*) rMsg.getPtr1();
      boolRes = handleSetWeights(weights, rMsg.getInt1());
      delete[] weights; // delete storage allocated in the setWeights() method
      return boolRes;
      break;
   default:
      return MpResource::handleMessage(rMsg);
      break;
   }
}
Exemple #10
0
// Handles an incoming message for the flow graph.
// Returns TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpFlowGraphBase::handleMessage(OsMsg& rMsg)
{
   MpFlowGraphMsg* pMsg = (MpFlowGraphMsg*) &rMsg ;
   UtlBoolean retCode;
   MpResource* ptr1;
   MpResource* ptr2;
   int         int1;
   int         int2;

   retCode = FALSE;

   ptr1 = (MpResource*) pMsg->getPtr1();    // get the parameters out of
   ptr2 = (MpResource*) pMsg->getPtr2();    // the message
   int1 = pMsg->getInt1();
   int2 = pMsg->getInt2();

   switch (pMsg->getMsg())
   {
   case MpFlowGraphMsg::FLOWGRAPH_ADD_LINK:
      retCode = handleAddLink(ptr1, int1, ptr2, int2);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_ADD_RESOURCE:
      retCode = handleAddResource(ptr1, int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_DESTROY_RESOURCES:
      retCode = handleDestroyResources();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_DISABLE:
      retCode = handleDisable();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_ENABLE:
      retCode = handleEnable();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_REMOVE_LINK:
      retCode = handleRemoveLink(ptr1, int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_REMOVE_RESOURCE:
      retCode = handleRemoveResource(ptr1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_SET_SAMPLES_PER_FRAME:
      retCode = handleSetSamplesPerFrame(int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_SET_SAMPLES_PER_SEC:
      retCode = handleSetSamplesPerSec(int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_START:
      retCode = handleStart();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_STOP:
      retCode = handleStop();
      break;
   default:
      break;
   }

   return retCode;
}
Exemple #11
0
// Handles an incoming flowgraph message for this media processing object.
// Returns TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpResource::handleMessage(MpFlowGraphMsg& fgMsg)
{
   UtlBoolean msgHandled = FALSE;

   msgHandled = TRUE; // assume we'll handle the msg
   switch (fgMsg.getMsg())
   {
   case MpFlowGraphMsg::RESOURCE_DISABLE:   // disable this resource
      msgHandled = handleDisable();
      break;
   case MpFlowGraphMsg::RESOURCE_ENABLE:    // enable this resource
      msgHandled = handleEnable();
      break;
   default:
      msgHandled = FALSE; // we didn't handle the msg after all
      break;
   }
   
   return msgHandled;
}
Exemple #12
0
// Processes all of the messages currently queued for this flow graph.
// For now, this method always returns OS_SUCCESS.
OsStatus MpFlowGraphBase::processMessages(void)
{
   OsWriteLock     lock(mRWMutex);

   UtlBoolean       done;
   UtlBoolean       handled;
   static MpFlowGraphMsg* pStopMsg = NULL;
   MpResource*     pMsgDest;

   OsStatus        res;

   // First, we send ourselves a FLOWGRAPH_PROCESS_FRAME message.
   // This message serves as a "stopper" in the message queue.  When we
   // handle that message, we know that we have processed all of the messages
   // for the flowgraph (and its resources) that had arrived prior to the
   // start of this frame processing interval.

   if (NULL == pStopMsg) {
      pStopMsg = new MpFlowGraphMsg(MpFlowGraphMsg::FLOWGRAPH_PROCESS_FRAME);
      pStopMsg->setReusable(TRUE);
   }

   res = postMessage(*pStopMsg);
   assert(res == OS_SUCCESS);

   done = FALSE;
   while (!done)
   {
      // get the next message
      OsMsg* pMsg ;

      res = mMessages.receive(pMsg, OsTime::NO_WAIT);

      assert(res == OS_SUCCESS);

      if (pMsg->getMsgType() == OsMsg::MP_FLOWGRAPH_MSG)
      {
         MpFlowGraphMsg* pRcvdMsg = (MpFlowGraphMsg*) pMsg ;
         // determine if this message is intended for a resource in the
         // flow graph (as opposed to a message for the flow graph itself)
         pMsgDest = pRcvdMsg->getMsgDest();


         if (pMsgDest != NULL)
         {
            // deliver the message if the resource is still part of this graph
            if (pMsgDest->getFlowGraph() == this)
            {
               handled = pMsgDest->handleMessage(*pRcvdMsg);
               assert(handled);
            }
         }
         else
         {
            // since pMsgDest is NULL, this msg is intended for the flow graph
            switch (pRcvdMsg->getMsg())
            {
            case MpFlowGraphMsg::FLOWGRAPH_PROCESS_FRAME:
               done = TRUE;    // "stopper" message encountered -- we are done
               break;          //  processing messages for this frame interval

            default:
               handled = handleMessage(*pRcvdMsg);
               assert(handled);
               break;
            }
         }
         pRcvdMsg->releaseMsg();    // free the msg
      }
      else
      {
         handled = handleMessage(*pMsg);
         assert(handled);
         pMsg->releaseMsg() ;
      }

   }

   return OS_SUCCESS;
}