📄 jb_timer.cpp
字号:
sendCodec = GetSendCodec(sId);
/*if (p.payload != PCMU || p.len != 252)
printf("receive packet:sByte %d, len %d, payload:%d\n", p.sByte, p.len, p.payload);*/
if(p.payload != sendCodec)
{
return;
}
HrRtpHdr rtpHdr(&p);
JbDatInd(sId, &rtpHdr, (Data *)(dBuf+p.sByte));
#endif
/* for UDP, it is possible to receive
* a 0 byte datagram, in this case just continue */
// if ((sockFd->type == CM_INET_DGRAM) && (recvLen == 0))
// {
// continue;
// }
/* Check length */
// if((recvLen <= 0) || (recvLen > sizeof(dBuf)))
// {
//#ifndef JB_TERSE
// printf("jbReadSocket: Invalid Receive length = %d\n", recvLen);
//#endif /* JB_TERSE */
// return;
// }
/* clear the structure */
// cmMemset((U8*)&fromAddr, 0, sizeof(CmTptAddr));
//#ifdef HI_REL_1_3
// /* hi009.104 - fillup with all 0's */
// cmMemset((U8*)&destAddr,0, sizeof(CmTptAddr));
// cmMemset((U8*)&ipHdrParm, 0, sizeof(CmIpHdrParm));
// destAddr.type = CM_TPTADDR_NOTPRSNT;
//#endif /* HI_REL_1_3 */
// fromAddr.type = CM_INET_IPV4ADDR_TYPE;
// fromAddr.u.ipv4TptAddr.port = CM_INET_NTOH_U16(remAddr->sin_port);
// fromAddr.u.ipv4TptAddr.address = CM_INET_NTOH_U32(remAddr->sin_addr.s_addr);
// cmMemcpy((U8*)&jbUdpConCb[spId]->peerAddr, (U8*)&fromAddr, sizeof(CmTptAddr));
/* copy data to a message structure */
// ret = SGetMsg(DFLT_REGION, DFLT_POOL, &mBuf);
// if (ret != ROK)
// {
//#ifndef JB_TERSE
// printf("jbReadSocket: SGetMsg() failed\n");
//#endif /* JB_TERSE */
// return;
// }
/* slm: need to pass in the actual rcv pkt length so we can determine
** the number of voice frames received, based on the size of the packet
*/
// SAddPstMsgMult(dBuf);//, (MsgLen)recvLen, mBuf);
// if(jbUdpConCb[spId])
// {
//#ifdef HI_REL_1_3
// HiUiHitUDatInd(&((jbUdpConCb[spId]->sap)->uiPst), (jbUdpConCb[spId]->sap)->suId,
// jbUdpConCb[spId]->suConId, &fromAddr,&destAddr, &ipHdrParm, mBuf);
//#else
// HiUiHitUDatInd(&((jbUdpConCb[spId]->sap)->uiPst), (jbUdpConCb[spId]->sap)->suId,
// jbUdpConCb[spId]->suConId, &fromAddr, mBuf);
//#endif
// }
// else
// SPutMsg(dBuf);
#ifndef INCLUDE_RV_RTP
}
#endif
} /* jbReadSocket */
/*
*
* Fun: jbDspGetManager
*
* Desc: This task is spawned by jbActvInit and
* is responsible for getting and putting
* Dsp Buffers
*
* Ret: ROK on success and RFAILED on failure
*
* Notes:
*
* File: jb_timer.c
*
*/
#ifdef INCLUDE_RV_RTP
RvUint32 rtp_last_time;
RvUint8 GetSendCodec(int callId);
#endif
//extern "C"
//{
//void modDSP();
//}
//extern int codecIndex;
#ifdef ANSI
PUBLIC VOID jbDspGetManager
(
//JbConnKey **conn, /* Connection Control Block Key */
S8 num, /* Number of frames to capture */
U8 connIndex
)
#else
PUBLIC VOID jbDspGetManager(conn, num, connIndex)
JbConnKey **conn; /* Connection Control Block Key */
S8 num; /* Number of frames to capture */
U8 connIndex;
#endif
{
S16 ret;
U16 size;
U16 nframes;
S32 sessionId;
S16 sId;
// SpId spId;
JbConnKey *key;
extern int fRequestGetMgrTaskStop[];
sId = jbCb.conn[connIndex]->sessionId;
sessionId = sId % MAX_RTP_SESSION;
/* slm: MR7049 Only Tornado 2.0.1 uses tag8021QLib functions */
#if ((__GNUC__ == 2) && ( __GNUC_MINOR__ == 7 ))
/* Determine if we need to want 802.1q tagging on this port. */
// check8021QPortTagEnable(jbPeerAddr[sessionId].u.ipv4TptAddr.port);
check8021QPortTagEnable(port);
#endif /* __GNUC__ */
#ifdef INCLUDE_RV_RTP
rtp_last_time = 0;
sendCodec = GetSendCodec(sId);
#endif
while ((key = jbCb.conn[connIndex]) != (JbConnKey *) NULL )
{
// printf("sId (get) is %d\n", sId);
// printf("sessionId (get) is %d\n", sessionId);
/* If we are exitting, stop the task
*
* 0 - normal operation
* 1 - Request outstanding that the timer task stop
*/
if(fRequestGetMgrTaskStop[sessionId])
{
fRequestGetMgrTaskStop[sessionId] = 0;
break;
}
/* If this task is not for the active channel, then we do NOT want
* it to eat up any of the encoded (transmit) bytes of audio!
*/
/* slm: MR8849 changed to index based on line number */
if(connIndex != jbCb.activeConn[key->lineNo]) /* Added - GTC */
{
taskDelay(4); /* rather than chewing lots of CPU cycles, */
continue; /* sleep for a bit before checking again */
}
/* slm: MR8849 changed to index based on line number */
// if(codecIndex != -1 && dspApiEncoder[codecIndex])
if (dspApiEncoder[key->lineNo])
{
#ifndef INCLUDE_RV_RTP
/* slm: MR4213 reset number of frames so that getBuffer can return value */
nframes = num;
dspApiEncoder[key->lineNo]->getBuffer((char*)getBuf, &nframes, &size);
#else
static int prtc = 0;
/* slm: MR4213 reset number of frames so that getBuffer can return value */
nframes = num;
// dspApiEncoder[codecIndex]->getBuffer((char*)(getBuf+12), &nframes, &size);
dspApiEncoder[key->lineNo]->getBuffer((char*)(getBuf+12), &nframes, &size);
if (prtc++ == 0)
{
printf("getBuffer first packet size:%d, frames:%d!\n", size, nframes);
for (int i = 0; i < size; i++)
{
printf("%02x", getBuf[i]);
if ((i+1) % 10 == 0)
printf("\n");
}
}
/*else if (size != 240)
printf("getBuffer first packet size:%d, frames:%d!\n", size, nframes);*/
#endif
#ifdef CHECKDSP
if (nframes == 0)
{
checkDSP(sId);
continue;
}
#endif
if (size <= 0)
{
//printf("getBuffer packet size:%d, frames:%d!\n", size, nframes);
continue;
}
if ( ((sendCodec == PCMA || sendCodec == PCMU) && size != num*80)
|| (sendCodec == G7231 && (!(size == 24 || size == 4)))
|| (sendCodec == G729 && size != num*10)
)
{
printf("get size is %d, incorrect and continue\n", size);
continue;
}
/* else if (sendCodec == G7231)
{
if (!(size == 24 || size == 4))
continue;
}
else if (sendCodec == G729)
{
if (size != num*10)
continue;
}*/
jbProcessTxCodec(sId, key, size, nframes);
}
} /* while (*conn) */
} /* jbDspGetManager */
/*
*
* Fun: jbDspPutManager
*
* Desc: This task is spawned by jbActvInit and
* is responsible for getting and putting
* Dsp Buffers
*
* Ret: ROK on success and RFAILED on failure
*
* Notes:
*
* File: jb_timer.c
*
*/
#ifdef ANSI
PUBLIC VOID jbDspPutManager
(
//JbConnKey **conn, /* Connection Control Block Key */
U8 connIndex
)
#else
PUBLIC VOID jbDspPutManager(conn,connIndex)
JbConnKey **conn; /* Connection Control Block Key */
U8 connIndex;
#endif
{
S16 ret;
// SpId spId;
S32 sId;
S32 sessionId;
extern int fRequestPutMgrTaskStop[];
sId = jbCb.conn[connIndex]->sessionId;
sessionId = sId % MAX_RTP_SESSION;
while (jbCb.conn[connIndex])
{
// printf("sId (put) is %d\n", sId);
// printf("sessionId (put) is %d\n", sessionId);
/* If we are exitting, stop the task
*
* 0 - normal operation
* 1 - Request outstanding that the timer task stop
*/
if(fRequestPutMgrTaskStop[sessionId])
{
fRequestPutMgrTaskStop[sessionId] = 0;
break;
}
/*
** slm: MR3768 must check return code and break if failure
** otherwise, we could hit a case where we are disconnecting
** and jbDspPutManager preempts the disconnect routine in
** between the time where conn is deleted from the hash list
** but before conn is zero'd. In this case jbProcessRxCodec
** will return failed because it can't find conn on the hashlist.
** Breaking this while will allow the disconnect task to resume.
*/
if(jbProcessRxCodec(jbCb.conn[connIndex]) == RFAILED)
{
break;
}
}
} /* jbDspManager */
/*
*
* Fun: jbActvTmr
*
* Desc: This function is called by system services
* periodically to handle timer events
*
* Ret: ROK on success and RFAILED on failure
*
* Notes:
*
* File: jb_timer.c
*
*/
//#ifdef ANSI
//PUBLIC S16 jbActvTmr
//(
//)
//#else
//PUBLIC S16 jbActvTmr()
//#endif
//{
// S16 i;
// S16 j;
// JbConnKey **conn;
//
// TRC3(jbActvTmr)
//
// cmPrcTmr(&jbCb.jbTqCp, jbCb.jbTq, jbProcessLongSilence);
//
// RETVALUE(ROK);
//} /* jbActvTmr */
/*
*
* Fun: JbStartTimer
*
* Desc: This function is used to start a long silence timer
*
* Ret: ROK on success and RFAILED on failure
*
* Notes:
*
* File: jb_timer.c
*
*/
#ifdef ANSI
PUBLIC S16 JbStartTimer
(
JbConnCb *connCb /* Connection Control Block */
)
#else
PUBLIC S16 JbStartTimer(connCb)
JbConnCb *connCb /* Connection Control Block */
#endif
{
// CmTmrArg arg;
TRC3(JbStartTimer)
// arg.tqCp = &jbCb.jbTqCp;
// arg.tq = jbCb.jbTq;
// arg.timers = jbCb.jbTimers;
// arg.cb = (PTR)connCb;
// arg.evnt = 0;
// arg.wait = jbCb.jitCfg.longSilenceTimer.val;
// arg.tNum = connCb->connIndex;
// arg.max = jbCb.genCfg.maxConnections;
// cmPlcCbTq(&arg);
RETVALUE(ROK);
} /* JbStartTimer */
/*
*
* Fun: JbStopTimer
*
* Desc: This function is used to stop a long silence timer
*
* Ret: ROK on success and RFAILED on failure
*
* Notes:
*
* File: jb_timer.c
*
*/
#ifdef ANSI
PUBLIC S16 JbStopTimer
(
JbConnCb *connCb /* Connection Control Block */
)
#else
PUBLIC S16 JbStopTimer(connCb)
JbConnCb *connCb /* Connection Control Block */
#endif
{
// CmTmrArg arg;
TRC3(JbStopTimer)
// arg.tqCp = &jbCb.jbTqCp;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -