⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jb_timer.cpp

📁 基于h323协议的软phone
💻 CPP
📖 第 1 页 / 共 3 页
字号:
//   arg.tq = jbCb.jbTq;
//   arg.timers = jbCb.jbTimers;
//   arg.tNum = connCb->connIndex;
//   cmRmvCbTq(&arg);

   RETVALUE(ROK);
} /* JbStopTimer */


/*
*
*       Fun:   jbProcessRxCodec
*
*       Desc:  This function is used to process and send an RX Codec event
*
*       Ret:   ROK on success and RFAILED on failure
*
*       Notes:
*
*       File:  jb_timer.c
*
*/
#ifdef ANSI
PUBLIC S16 jbProcessRxCodec
(
JbConnKey *conn         /* Connection Control Block Key */
)
#else
PUBLIC S16 jbProcessRxCodec(conn)
JbConnKey *conn         /* Connection Control Block Key */
#endif
{
//   JbConnCb *connCb;
   S16 ret;

//   TRC3(jbProcessRxCodec)

//   if (cmHashListFind(&jbCb.connHlCp, (U8*)(conn), sizeof(JbConnKey), 0,
//        (PTR*)&connCb) != ROK)
//   {
//          RETVALUE(RFAILED);
//   }

    /* slm: MR8849 changed to index based on line number */
    if (connCb.connIndex == jbCb.activeConn[connCb.key.lineNo]) /* Added - GTC */
    {


#ifdef DEBUG_JB
if( jbdbg_d_index < MAX_JBDBG )
{
//semTake(jbCb.sem, WAIT_FOREVER);
//jbCb.sem.lock();
   semTake(jbCb.sem, JB_MAX_TICKS);
if (errnoGet() == S_objLib_OBJ_TIMEOUT)
{
	errnoSet(0);
	break;
}

jbdbg_d[jbdbg_d_index].op = JB_PLAY_PACKET;
if( isT8300 )
    jbdbg_d[jbdbg_d_index].timestamp = *((volatile ULONG *) 0xE000060C);
jbdbg_d[jbdbg_d_index].state = connCb->jitter.state;
jbdbg_d[jbdbg_d_index].p = connCb->jitter.p;
jbdbg_d[jbdbg_d_index].q = connCb->jitter.q;
jbdbg_d[jbdbg_d_index].frames = 0;
jbdbg_d[jbdbg_d_index].length = 0;
jbdbg_d[jbdbg_d_index].seq = 0;
jbdbg_d[jbdbg_d_index].pkttimestamp = 0;
jbdbg_d[jbdbg_d_index].curtimestamp = connCb->jitter.curTimestamp;
jbdbg_d[jbdbg_d_index].numPackets = connCb->sts.numPackets;
jbdbg_d[jbdbg_d_index].jitterBufferSize = connCb->sts.jitterBufferSize;
jbdbg_d_index++;
semGive(jbCb.sem);
//jbCb.sem.unlock();
}
#endif /* DEBUG_JB */

       ret = JbFSM[JB_PLAY_PACKET][connCb.jitter.state](&connCb, NULLP, NULLP);

    }
    else    /* Added - GTC */
    {
        taskDelay(4);
        ret = ROK;
    }

   RETVALUE(ret);
} /* jbProcessRxCodec */


/*
*
*       Fun:   jbProcessTxCodec
*
*       Desc:  This function is used to retrieve data from DSP and send to RTP
*
*       Ret:   ROK on success and RFAILED on failure
*
*       Notes:
*
*       File:  jb_timer.c
*
*/

#ifdef ANSI
PUBLIC S16 jbProcessTxCodec
(
S32 sId,
JbConnKey *conn,        /* Connection Control Block Key */
U16 size,               /* frame size */
U16 num                 /* number of frames */
)
#else
PUBLIC S16 jbProcessTxCodec(conn, size, num)
JbConnKey *conn,        /* Connection Control Block Key */
U16 size,               /* frame size */
U16 num                 /* number of frames */
#endif
{
//   JbConnCb *connCb;
//   SpId spId;
   U8 rtpId;
/*
   static unsigned int CallCount=0;
*/

//   TRC3(jbProcessTxCodec)

//   if (cmHashListFind(&jbCb.connHlCp, (U8*)(conn), sizeof(JbConnKey), 0,
//        (PTR*)&connCb) != ROK)
//   {
//          RETVALUE(RFAILED);
//   }

   /* This should work: spId = connCb->key.spId;
    * OR, just do: (since conn == &connCb->key)
    */
//   spId = conn->spId;

/*
if(((CallCount%100) == 0) || ((CallCount%101) == 0))
    printf("jbProcessTxCodec for spId=%u\n",spId);
*/

   /* If in txPause state, just eat the outgoing packets */
/* FIXME? Do we need an equivalent for SIP? - GTC */
#ifdef HC
   if (_sap(spId).currConCb->h245Msg2 & NULLTCSPAUSE)
    {
/*
if(((CallCount%100) == 0) || ((CallCount%101) == 0))
    printf("Transmit for spId %u PAUSED, not sending\n",spId);
CallCount++;
*/
       return ROK;
    }
#endif

   /* sree: Send RTP Data only if the RTP is valid. This is introduced to take care of
      any time delays between disconnection of RTP and JB */
//   if(_sap(spId).currConCb)
//   {
//       rtpId = _sap(spId).currConCb->rtpId;
//       if (rtpId < 0xff)
//       {
	if (/*rptManager.isValid()*/1)
	{
/*
if(((CallCount%100) == 0) || ((CallCount%101) == 0))
    printf("Transmitting audio for spId %u\n",spId);
*/
#ifdef DEBUG_JB
if( jbdbg_e_index < MAX_JBDBG )
{
HrAccSess  *session;    /* test session */
HrAccUsr   *usr;     /* RTP user */
HrAccSrc   *src;  /* RTP source */
EXTERN HrAccSess hrTstSess[];
session = &hrTstSess[rtpId];
if ( (usr = session->usr) != NULLP)
{
src = &usr->src[0];
if( isT8300 )
    jbdbg_e[jbdbg_e_index].timestamp = *((volatile ULONG *) 0xE000060C);
jbdbg_e[jbdbg_e_index].frames = num;
jbdbg_e[jbdbg_e_index].length = size;
jbdbg_e[jbdbg_e_index].pkttimestamp = src->nxtRtpTimeStamp;
jbdbg_e_index++;
}
}
#endif
//            HrSendUDatReq(getBuf, (U32) size, rtpId, num);
//		printf("send data \n");
#ifndef INCLUDE_RV_RTP
		rtpManager->getSession(sId)->sendData((char*)getBuf, size);
#else

		
		rtpParam p;
		p.marker = 0;
	       semTake(rtpSem, WAIT_FOREVER);	
		switch (sendCodec)
		{
			case PCMU:
			case PCMA: 
				rtp_last_time += G711_TIMESTAMP_INTERVAL; break;
			case G729:
				rtp_last_time += G729_TIMESTAMP_INTERVAL; break;	
			case G7231:
				rtp_last_time += G723_TIMESTAMP_INTERVAL; break;
			default:
				rtp_last_time += G711_TIMESTAMP_INTERVAL; break;
		}
			
		p.timestamp = rtp_last_time;
		p.payload = sendCodec;
		p.sByte = 12;
/*rtpG729GetHeaderLength()
		char* tmpBuf;
		if(RvMemoryAlloc(NULL, (void**)&tmpBuf, size+p.sByte) != RV_OK)
		{
			printf("rvmemoryalloc in jbProcessTxCodec return error!\n");
			return -1;
		}
		memcpy(tmpBuf+p.sByte, getBuf, size);
*/
		
		if (wpCallInfo[sId].rtpSession == NULL)
		{
			semGive(rtpSem);
			return 0;
		}
		rtpWrite(wpCallInfo[sId].rtpSession, (void * )getBuf, size+p.sByte, &p);
		semGive(rtpSem);

/*		RvMemoryFree(tmpBuf);*/
#endif

/*
CallCount++;
*/
//        }
//    }
	}
} /* jbProcessTxCodec */


/*
*
*       Fun:   jbProcessLongSilence
*
*       Desc:  This function is used to process and send a LongSilence Event
*
*       Ret:   Nothing
*
*       Notes:
*
*       File:  jb_timer.c
*
*/
#ifdef ANSI
PUBLIC Void jbProcessLongSilence
(
PTR connCb,     /* Connection Control Block */
S16 event       /* Timer Event */
)
#else
PUBLIC Void jbProcessLongSilence(connCb, event)
PTR connCb;         /* Connection Control Block */
S16 event;      /* Timer Event */
#endif
{
   TRC3(jbProcessLongSilence)

   UNUSED(event);

   if (connCb)
   {
      if ( ((JbConnCb*)connCb)->jitter.state == JB_UNDERFLOW )
      {
#ifdef DEBUG_JB
if( jbdbg_d_index < MAX_JBDBG )
{
//semTake(jbCb.sem, WAIT_FOREVER);
//jbCb.sem.lock();
   semTake(jbCb.sem, JB_MAX_TICKS);
if (errnoGet() == S_objLib_OBJ_TIMEOUT)
{
	errnoSet(0);
	break;
}

jbdbg_d[jbdbg_d_index].op = JB_LONG_SILENCE;
if( isT8300 )
    jbdbg_d[jbdbg_d_index].timestamp = *((volatile ULONG *) 0xE000060C);
jbdbg_d[jbdbg_d_index].state = JB_UNDERFLOW;
jbdbg_d[jbdbg_d_index].p = ((JbConnCb*)connCb)->jitter.p;
jbdbg_d[jbdbg_d_index].q = ((JbConnCb*)connCb)->jitter.q;
jbdbg_d[jbdbg_d_index].frames = 0;
jbdbg_d[jbdbg_d_index].length = 0;
jbdbg_d[jbdbg_d_index].seq = 0;
jbdbg_d[jbdbg_d_index].pkttimestamp = 0;
jbdbg_d[jbdbg_d_index].curtimestamp = ((JbConnCb*)connCb)->jitter.curTimestamp;
jbdbg_d[jbdbg_d_index].numPackets = ((JbConnCb*)connCb)->sts.numPackets;
jbdbg_d[jbdbg_d_index].jitterBufferSize = ((JbConnCb*)connCb)->sts.jitterBufferSize;
jbdbg_d_index++;
semGive(jbCb.sem);
//jbCb.sem.unlock();
}
#endif
       JbFSM[JB_LONG_SILENCE][JB_UNDERFLOW]
                 ((JbConnCb*)connCb, NULLP, NULLP);
      }
   }
} /* jbProcessLongSilence */

#define TEST_VLAN_ID_DEF          0x5
#define TEST_VLAN_UP_DEF          0x7

#define TEST_L3QOS_DSCP           (0x2e)   /* Differentiated Services Code Point */
#define TEST_L3QOS_FC             (0x0)         /* Flow Control */

int bPortTagEnable = FALSE;
int blayer3QosEnable = FALSE;

/* slm: MR7049 Only Tornado 2.0.1 uses tag8021QLib functions */
#if ((__GNUC__ == 2) && ( __GNUC_MINOR__ == 7 ))
void check8021QPortTagEnable(int port)
{
    if (bPortTagEnable)
    {
        /* set the priority */
          tag8021QPortUPSet(port, TEST_VLAN_UP_DEF);

          /* set the VID */
          tag8021QPortVIDSet(port, TEST_VLAN_ID_DEF);

          /* enable port */
          tag8021QPortEnable(port);
    }
    else
    {
        tag8021QPortDisable(port);
    }
}
#endif /* GNUC */

/* For Layer 3 QOS testing only */
void layer3QosEnable(int socket)
{
    int TOSVal;
    int retval;
    if(!blayer3QosEnable)
        return;
    if(socket)
    {
        TOSVal= (TEST_L3QOS_DSCP << 2) | (TEST_L3QOS_FC & 3) ;
        retval = setsockopt(socket,
                        IPPROTO_IP,
                        IP_TOS,
                        (char *)&TOSVal,
                        sizeof(TOSVal));
#ifndef JB_TERSE
        if(retval == OK)
        {
            printf("layer3 QOS Enabled: IP_TOS Val: 0x%x  DSCP: 0x%x  FC: 0x%x\n",
                TOSVal,TEST_L3QOS_DSCP,TEST_L3QOS_FC);
        }
        else
        {
            printf("layer3 QOS NOT enabled: SetSockOpt failed\n");
        }
#endif
    } /* if socket */
#ifndef JB_TERSE
    else /* socket == NULL*/
    {
        printf("layer3 QOS NOT enabled: SetSockOpt failed\n");
    }
#endif
}

extern "C" {

void portTagOn(void)
{
    bPortTagEnable = TRUE;
}

void portTagOff(void)
{
    bPortTagEnable = FALSE;
}

/* for Layer3 QOS testing only */
void layer3QosOn(void)
{
    blayer3QosEnable = TRUE;
}
void layer3QosOff(void)
{
    blayer3QosEnable = FALSE;
}

} /* extern C */

/* end of file jb_timer.cpp */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -