Exemple #1
0
int MpBuf_getTotalBufferCount(void)
{
   int count = 0;
   if (NULL != MpMisc.UcbPool) {
       count += MpBufPool_getNumBufs(MpMisc.UcbPool);
   }

   if (NULL != MpMisc.RtpPool) {
       count += MpBufPool_getNumBufs(MpMisc.RtpPool);
   }

   if (NULL != MpMisc.RtcpPool) {
       count += MpBufPool_getNumBufs(MpMisc.RtcpPool);
   }

   if (NULL != MpMisc.DMAPool) {
       count += MpBufPool_getNumBufs(MpMisc.DMAPool);
   }
   return count;
}
Exemple #2
0
OsStatus mpStartUp(int sampleRate, int samplesPerFrame,
      int numAudioBuffers, OsConfigDb* pConfigDb)
{
#ifdef _VXWORKS
        int defSilenceSuppressLevel = 10000;
#else
        int defSilenceSuppressLevel = 0;
#endif
        OsStatus  resCode;
        UtlBoolean silenceSuppressFlag;
        UtlString  silenceSuppressEnable;
        int       silenceSuppressLevel;

        if (samplesPerFrame < 8) samplesPerFrame = 80;
        samplesPerFrame = min(samplesPerFrame, FRAME_SAMPS);

        showMpMisc(TRUE);
        MpMisc.micMuteStatus = MpMisc.spkrMuteStatus = 0;

#ifdef _VXWORKS /* [ */
        /* Rashly assumes page size is a power of two */
        MpMisc.mem_page_size = goGetThePageSize();
        MpMisc.mem_page_mask = MpMisc.mem_page_size - 1;
#endif /* _VXWORKS ] */

        MpMisc.sampleBytes = sizeof(short);
        MpMisc.frameSamples = samplesPerFrame;
        MpMisc.frameBytes = MpMisc.sampleBytes * MpMisc.frameSamples;
        MpMisc.rtpMaxBytes = /* sizeof(struct rtpHeader) */ 12 +
            (((sampleRate + 24) / 25) * MpMisc.sampleBytes);

        MpMisc.audio_on = 0;

        if (OS_SUCCESS != MpBuf_init(samplesPerFrame, numAudioBuffers)) {
            return OS_UNSPECIFIED;
        }

        // Use the config database to determine the silence supression level
        silenceSuppressFlag  = FALSE;
        silenceSuppressLevel = defSilenceSuppressLevel;
        if (pConfigDb)
        {
           resCode = pConfigDb->get("PHONESET_SILENCE_SUPPRESSION",
                                    silenceSuppressEnable);
           if (resCode == OS_SUCCESS)
           {
              silenceSuppressFlag =
                (silenceSuppressEnable.compareTo("enable",
                                                 UtlString::ignoreCase) == 0);
           }

           resCode = pConfigDb->get("PHONESET_SILENCE_SUPPRESSION_LEVEL",
                                    silenceSuppressLevel);
           if ((resCode != OS_SUCCESS) ||
               (silenceSuppressLevel < 0) ||
               (silenceSuppressLevel > 20000))
           {
              silenceSuppressLevel = defSilenceSuppressLevel;
           }
        }

        if (silenceSuppressFlag)
           MpBuf_setMVE(silenceSuppressLevel);
        else
           MpBuf_setMVE(0);

#ifdef WIN32 /* [ */
        // Adjust initial audio latency if specified in config files:
        if (pConfigDb)
        {
           UtlString  latency;
           static const int MS_PER_FRAME = 10;
           int frames;
           resCode = pConfigDb->get("PHONESET_INITIAL_OUTPUT_LATENCY_MS",
                                    latency);
           if (resCode == OS_SUCCESS)
           {
              frames = atoi(latency.data()) / MS_PER_FRAME;
              DmaTask_setSpkrQPreload(frames);
           }
           resCode = pConfigDb->get("PHONESET_INITIAL_INPUT_LATENCY_MS",
                                    latency);
           if (resCode == OS_SUCCESS)
           {
              frames = atoi(latency.data()) / MS_PER_FRAME;
              DmaTask_setMicQPreload(frames);
           }
        }
#endif /* WIN32 ] */

#ifdef _VXWORKS /* [ */
        if (OS_SUCCESS != MpCodecOpen(sampleRate, START_GAIN, START_VOLUME)) {
            return OS_UNSPECIFIED;
        }
#endif /* _VXWORKS ] */

        if (NULL != MpMisc.pMicQ) {
            OsMsgQ* q = MpMisc.pMicQ;
            MpMisc.pMicQ = NULL;
            delete q;
        }
        if (NULL != MpMisc.pSpkQ) {
            OsMsgQ* q = MpMisc.pSpkQ;
            MpMisc.pSpkQ = NULL;
            delete q;
        }
        if (NULL != MpMisc.pEchoQ) {
            OsMsgQ* q = MpMisc.pEchoQ;
            MpMisc.pEchoQ = NULL;
            delete q;
        }
#ifdef _VXWORKS /* [ */
        if (NULL != MpMisc.pLoopBackQ) {
            OsMsgQ* q = MpMisc.pLoopBackQ;
            MpMisc.pLoopBackQ = NULL;
            delete q;
        }
#endif /* _VXWORKS ] */
        assert(
            (MIC_BUFFER_Q_LEN+SPK_BUFFER_Q_LEN+MIC_BUFFER_Q_LEN) <
                               (MpBufPool_getNumBufs(MpMisc.UcbPool)-3));
        MpMisc.pMicQ = new OsMsgQ("mpStartUp::MpMisc.pMicQ", MIC_BUFFER_Q_LEN);
        MpMisc.pSpkQ = new OsMsgQ("mpStartUp::MpMisc.pSpkQ", SPK_BUFFER_Q_LEN);
        MpMisc.pEchoQ = new OsMsgQ("mpStartUp::MpMisc.pEchoQ", MIC_BUFFER_Q_LEN);
#ifdef _VXWORKS /* [ */
        MpMisc.doLoopBack = 0;
        MpMisc.pLoopBackQ = new OsMsgQ("mpStartUp::MpMisc.pLoopBackQ", MIC_BUFFER_Q_LEN);
#endif /* _VXWORKS ] */

        assert(MprFromMic::MAX_MIC_BUFFERS > 0);
        assert(MprToSpkr::MAX_SPKR_BUFFERS > 0);
        assert(MprDecode::MIN_RTP_PACKETS > 0);

        setMaxMic(MprFromMic::MAX_MIC_BUFFERS - 1);
        setMaxSpkr(MprToSpkr::MAX_SPKR_BUFFERS);
        setMinRtp(MprDecode::MIN_RTP_PACKETS);
        mpStopSawTooth();

        return OS_SUCCESS;
}