123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /*
- evrcPacketDecode
- rtp语音包语音内容解密
- */
- #include "evrc2Pcm.h"
- #include <string.h>
- unsigned short evrcPacketDecode(unsigned char *outBuf,unsigned char *playload, unsigned char playlen)
- {
- T_BOOL fullRate;
- unsigned char index;
- unsigned char offset=0;
- unsigned char offsetN=VOICE_DATA_INDEX;
- int i;
- unsigned short retLen;
- if(playload[CNT_EVRC_FRAME_INDEX]==HAS_AMRNB_RATE){
- retLen=playlen-16;
- for(i=0;i<retLen;i++)
- outBuf[i]=playload[VOICE_DATA_INDEX+i]^playload[VOICE_MAGIC_INDEX];
- return retLen;
- }else if(playload[CNT_EVRC_FRAME_INDEX]==ALL_FULL_RATE){
- for(index = 0; index < (UDP_VOICE_PKT_FRAME_CNT*FULL_FRAME_SIZE); index++)
- playload[VOICE_DATA_INDEX+index] = (playload[VOICE_DATA_INDEX+index] ^ playload[VOICE_MAGIC_INDEX]);
- for(index = 0; index < UDP_VOICE_PKT_FRAME_CNT; index++){
- outBuf[offset++] = FULL_FRAME_I;
- outBuf[offset++] = FULL_FRAME_SIZE;
- memcpy(&outBuf[offset],&playload[offsetN], FULL_FRAME_SIZE);
- offsetN += FULL_FRAME_SIZE;
- offset += FULL_FRAME_SIZE;
- }
- return offset;
- }else{
- if(HAS_FULL_RATE==playload[CNT_EVRC_FRAME_INDEX]){
- fullRate=TRUE;
- for(index = 0; index < (FULL_FRAME_SIZE+ (UDP_VOICE_PKT_FRAME_CNT-1)*HALF_FRAME_SIZE); index++)
- playload[VOICE_DATA_INDEX+index] = (playload[VOICE_DATA_INDEX+index] ^ playload[VOICE_MAGIC_INDEX]);
- }else{
- fullRate=FALSE;
- for(index = 0; index < UDP_VOICE_PKT_FRAME_CNT*HALF_FRAME_SIZE; index++){
- playload[VOICE_DATA_INDEX+index] = (playload[VOICE_DATA_INDEX+index] ^ playload[VOICE_MAGIC_INDEX]);
- }
- }
- outBuf[0]=(fullRate ? FULL_FRAME_I : HALF_FRAME_I);
- outBuf[1] = (fullRate ? FULL_FRAME_SIZE : HALF_FRAME_SIZE);
- memcpy(&outBuf[2],&playload[VOICE_DATA_INDEX], (fullRate ? FULL_FRAME_SIZE : HALF_FRAME_SIZE));
- offset += (2+(fullRate ? FULL_FRAME_SIZE : HALF_FRAME_SIZE));
- offsetN += (fullRate ? FULL_FRAME_SIZE : HALF_FRAME_SIZE);
- for(index = 0; index < (UDP_VOICE_PKT_FRAME_CNT-1); index++){
- outBuf[offset++] = HALF_FRAME_I;
- outBuf[offset++] = HALF_FRAME_SIZE;
- memcpy(&outBuf[offset],&playload[offsetN], HALF_FRAME_SIZE);
- offsetN += HALF_FRAME_SIZE;
- offset += HALF_FRAME_SIZE;
- }
- return offset;
- }
- }
|