Exemple #1
0
UtlBoolean MprToneGen::doProcessFrame(MpBufPtr inBufs[],
                                    MpBufPtr outBufs[],
                                    int inBufsSize,
                                    int outBufsSize,
                                    UtlBoolean isEnabled,
                                    int samplesPerFrame,
                                    int samplesPerSecond)
{
   MpBufPtr out = NULL;
   int16_t *outbuf;
   int count;
   OsStatus ret;

   if (0 == outBufsSize) return FALSE;
   *outBufs = NULL;
   if (0 == samplesPerFrame) return FALSE;
   if (isEnabled) {
      out = MpBuf_getBuf(MpMisc.UcbPool, samplesPerFrame, 0, MP_FMT_T12);
      assert(NULL != out);
      count = min(samplesPerFrame, MpBuf_getNumSamples(out));
      MpBuf_setNumSamples(out, count);
      outbuf = (int16_t*)MpBuf_getSamples(out);
      ret = MpToneGen_getNextBuff(mpToneGenState, outbuf, count);
      switch (ret) {
      case OS_WAIT_TIMEOUT: /* one-shot tone completed */
         ((MpCallFlowGraph*)getFlowGraph())->stopTone();
         MpBuf_setSpeech(out, MP_SPEECH_TONE);
         break;
      case OS_NO_MORE_DATA: /* silent */
         MpBuf_delRef(out);
         out = NULL;      // Will replace with silence before returning...
         break;
      case OS_SUCCESS:
      default:
         MpBuf_setSpeech(out, MP_SPEECH_TONE);
         break;
      }
   } else {
      if (0 < inBufsSize) out = *inBufs;
      *inBufs = NULL;
   }

   if (NULL == out) {
      out = MpBuf_getFgSilence();
   }
   *outBufs = out;

   return (NULL != mpToneGenState);
}
Exemple #2
0
OsStatus MpResource::sendNotification(MpResNotificationMsg& msg)
{
   OsStatus stat = OS_SUCCESS;
   // Only send a notification if notifications are enabled.
   if (areNotificationsEnabled() == TRUE)
   {
      MpFlowGraphBase* pFg = getFlowGraph();
      assert(pFg != NULL);

      msg.setConnectionId(mConnectionId);
      msg.setStreamId(mStreamId);

      stat = pFg->postNotification(msg);
   }
   return stat;
}
Exemple #3
0
// Initialize the media task, phone task, and a flow graph
void MpTestConfig::initializeMediaSystem()
{
   OsConfigDb configDb;

   mpStartUp(8000, 80, 64, &configDb, sgNumCodecPaths, sgCodecPaths);

   mMediaTask = MpMediaTask::getMediaTask(); OsTask::delay(150) ;
//   mPhoneTask = PsPhoneTask::getPhoneTask();   OsTask::delay(150) ;

   mpStartTasks() ;      OsTask::delay(150) ;

   mFlowGraph = new MpCallFlowGraph();

   mMediaTask->setFocus(getFlowGraph());
//   mPhoneTask->activateGroup(PtComponentGroup::SOUND);

   OsTask::delay(1000) ;
}
Exemple #4
0
UtlBoolean MprToneGen::doProcessFrame(MpBufPtr inBufs[],
                                      MpBufPtr outBufs[],
                                      int inBufsSize,
                                      int outBufsSize,
                                      UtlBoolean isEnabled,
                                      int samplesPerFrame,
                                      int samplesPerSecond)
{
   MpAudioBufPtr out;
   MpAudioSample *outbuf;
   int count;
   OsStatus ret;

   // We have one output
   if (outBufsSize != 1)
       return FALSE;

   // Don't waste the time if output is not connected
   if (!isOutputConnected(0))
       return TRUE;

   // Avoid division by zero
   if (samplesPerFrame == 0)
       return FALSE;

   if (isEnabled) {
      // Get new buffer
      out = MpMisc.RawAudioPool->getBuffer();
      if (!out.isValid())
         return FALSE;
      out->setSamplesNumber(samplesPerFrame);
      count = out->getSamplesNumber();

      // Generate new portion of tone
      outbuf = out->getSamplesWritePtr();
      ret = MpToneGen_getNextBuff(mpToneGenState, outbuf, count);

      // See what we get...
      switch (ret) {
      case OS_WAIT_TIMEOUT: /* one-shot tone completed */
        ////////////////////////////////////////////////////////////////////////
        // This is the only reason this file needs MpCallFlowGraph.h
          if(getFlowGraph()->getType() == MpFlowGraphBase::CALL_FLOWGRAPH)
          {
            ((MpCallFlowGraph*)getFlowGraph())->stopTone();
          }
          else
        ////////////////////////////////////////////////////////////////////////
          {
             MprToneGen::stopTone(*this, *getFlowGraph()->getMsgQ()); 
          }
          out->setSpeechType(MP_SPEECH_TONE);
          break;

      case OS_NO_MORE_DATA: /* silent */
         out.release();
         break;

      case OS_SUCCESS:
      default:
         out->setSpeechType(MP_SPEECH_TONE);
         break;
      }
   } else {
      // If disabled just push input buffer downstream
      if (inBufsSize > 0)
          out = inBufs[0];
   }

   // Set output
   outBufs[0] = out;
   
   return (mpToneGenState != NULL);
}