Esempio n. 1
0
MpBufPtr MpBuf_allowMods(MpBufPtr b)
{
   MpBufPtr t;

   if (NULL == b) {
      return NULL;
   }

   if (MpBuf_invalid(b, FALSE, TRUE)) {
      Zprintf("MpBuf_allowMod(0x%X): invalid!\n", (int) b, 0,0,0,0,0);
      return NULL;
   }

   if (1 == b->refCnt) {
      return b;
   }

   t = MpBuf_getBuf(b->pPool, MpBuf_getNumSamples(b),
                    MpBuf_getOffset(b), MpBuf_getFormat(b));

   if (NULL == t) {
      return NULL;
   }

   memcpy((void*) MpBuf_getSamples(t),
          (void*) MpBuf_getSamples(b),
          MpBuf_getByteLen(t));

   MpBuf_setOsTC(t, MpBuf_getOsTC(b));
   MpBuf_setContentLen(t, MpBuf_getContentLen(b));
   MpBuf_delRef(b);
   return t;

} /* MpBuf_allowMods */
Esempio n. 2
0
int MpdGIPSPCMA::decodeIn(MpBufPtr pPacket)
{
   int thisLen;
   unsigned char* pHeader;

   thisLen = MpBuf_getContentLen(pPacket);
   pHeader = (unsigned char*)MpBuf_getStorage(pPacket);

   if (invalidLen(thisLen, pHeader)) {

    /* DISCARD AN ODD LENGTH PACKET */

      osPrintf("MpdGIPSPCMU::decodeIn - BAD packet, SEQ#%d,"
      " payload is %d bytes\n", MprDejitter::getSeqNum(pPacket), thisLen);
      return OS_SUCCESS; /* (nobody cares, don't rock the boat!) */
      thisLen = 0;
   }
   return thisLen;
}
Esempio n. 3
0
int MpdPtAVT::decodeIn(MpBufPtr pPacket)
{
   struct avtPacket* pAvt;
   unsigned int samples;
   unsigned int ts;

   pAvt = (struct avtPacket*) MpBuf_getStorage(pPacket);

   dumpRawAvtPacket(pAvt, this);

   ts = pAvt->rh.timestamp;

   if (-1 != mCurrentToneKey) { // if previous tone still active
      if (mCurrentToneSignature != ts) { // and we have not seen this
         if (0 != mToneDuration) { // and its duration > 0
            OsSysLog::add(FAC_MP, PRI_INFO,
               "++++ MpdPtAVT(%p) SYNTHESIZING KEYUP for old key (%d)"
               " duration=%d ++++\n", this,
               mCurrentToneKey, mToneDuration);
            signalKeyUp(pPacket);
         }
      }
   }

   // Key Down (start of tone)
   if ((0x80 == (0x80 & (pAvt->rh.mpt))) && (ts != mCurrentToneSignature)) {
     // start bit marked
      OsSysLog::add(FAC_MP, PRI_INFO, "++++ MpdPtAVT(%p) RECEIVED KEYDOWN"
         " (marker bit set), duration=%d, TSs: old=0x%08x, new=0x%08x,"
         " delta=%d; mCurrentToneKey=%d ++++",
         this, mToneDuration, ntohl(mPrevToneSignature), ntohl(ts),
         ntohl(ts) - ntohl(mPrevToneSignature), mCurrentToneKey);
      signalKeyDown(pPacket);
      samples = pAvt->samplesSwapped;
      mToneDuration = (ntohs(samples) & 0xffff);
   } else if ((mPrevToneSignature != ts) && (-1 == mCurrentToneKey)) {
     // key up interpreted as key down if no previous start tone received
      OsSysLog::add(FAC_MP, PRI_INFO, "++++ MpdPtAVT(%p) RECEIVED KEYDOWN"
         " (lost packets?) duration=%d; TSs: old=0x%08x, new=0x%08x,"
         " delta=%d; ++++\n",
         this, mToneDuration, ntohl(mPrevToneSignature), ntohl(ts),
         ntohl(ts) - ntohl(mPrevToneSignature));
      signalKeyDown(pPacket);
      samples = pAvt->samplesSwapped;
      mToneDuration = (ntohs(samples) & 0xffff);
   }
   else
   {
      samples = pAvt->samplesSwapped;
      mToneDuration = (ntohs(samples) & 0xffff);
      if (mToneDuration && (0x80 != (0x80 & (pAvt->dB))))
      {
         OsSysLog::add(FAC_MP, PRI_INFO, "++++ MpdPtAVT(%p) RECEIVED packet, not KEYDOWN, set duration to zero"
              " duration=%d; TSs: old=0x%08x, new=0x%08x,"
              " delta=%d; ++++\n",
              this, mToneDuration, ntohl(mPrevToneSignature), ntohl(ts),
              ntohl(ts) - ntohl(mPrevToneSignature));
	      mToneDuration = 0;
      }
   }

   // Key Up (end of tone)
   if (0x80 == (0x80 & (pAvt->dB))) {
      OsSysLog::add(FAC_MP, PRI_INFO, "++++ MpdPtAVT(%p) RECEIVED KEYUP"
      " duration=%d, TS=0x%08x ++++\n", this, mToneDuration, ntohl(ts));
      signalKeyUp(pPacket);
   }

   return MpBuf_getContentLen(pPacket);
}