void RTPPacket::Dump() { int i; printf("Payload type: %d\n",(int)GetPayloadType()); printf("Extended sequence number: 0x%08x\n",GetExtendedSequenceNumber()); printf("Timestamp: 0x%08x\n",GetTimestamp()); printf("SSRC: 0x%08x\n",GetSSRC()); printf("Marker: %s\n",HasMarker()?"yes":"no"); printf("CSRC count: %d\n",GetCSRCCount()); for (i = 0 ; i < GetCSRCCount() ; i++) printf(" CSRC[%02d]: 0x%08x\n",i,GetCSRC(i)); printf("Payload: %s\n",GetPayloadData()); printf("Payload length: %d\n",GetPayloadLength()); printf("Packet length: %d\n",GetPacketLength()); printf("Extension: %s\n",HasExtension()?"yes":"no"); if (HasExtension()) { printf(" Extension ID: 0x%04x\n",GetExtensionID()); printf(" Extension data: %s\n",GetExtensionData()); printf(" Extension length: %d\n",GetExtensionLength()); } }
int cache_att_to_svr(iclock_options_t *opt,PPostAttLog attlog) { FILE *iSvrResp = NULL; FILE *fStream = NULL; unsigned char head[20480]; unsigned char postbuf[2048]; int size = 0; int len=0; int j=0; int i=0; int fdatt=-1; unsigned char checkcode[4]; unsigned int macsum; unsigned char registerlen[3]={0x00,0x00,0x00}; unsigned int leftcount=0; //剩余流水数量 TYMIP_HEAD recv_head; TYMIP_HEAD post_head; unsigned char attcount; unsigned int transinfolen=0; unsigned short tmplem=0; unsigned int return_len; unsigned char data_return[512]; BOOL checkFN=FALSE; int error_code = -1; unsigned int writevalue[2]; //写入BsAtt.dat记录内容 memset(postbuf,0,sizeof(postbuf)); transinfolen=8+11+1+attlog->reclenght+4+4; fdatt=open(BS_TRANS_ATT_FILE,O_RDWR|O_NONBLOCK); tmplem=htons(transinfolen); memcpy(registerlen+1,&tmplem,2); incFN(); ymip_head_format(&post_head,LICENSEVERSION,registerlen,FramNumber,UPLOADATTDATA); attcount=(0xFF) & ((attlog->reclenght)/25); //一个字节来存储发送的数量 if((attlog->maxrec)>(attlog->currec+attcount)) { leftcount=htonl(attlog->maxrec-(attlog->currec+attcount)); } else { leftcount=0x00000000; } memcpy(&gLastAttRec, attlog->attbuffer+attlog->reclenght-4, 4); printf("\ngLastAttRec=%d\n", ntohl(gLastAttRec)); memcpy(postbuf,&post_head,sizeof(TYMIP_HEAD)); //head memcpy(postbuf+8,DevNumber,11); //devnumber memcpy(postbuf+8+11,&attcount,1); memcpy(postbuf+8+12,attlog->attbuffer,attlog->reclenght); //att memcpy(postbuf+8+12+attlog->reclenght,&leftcount,4); //leftcount //MAC check: printf("[PUSHSDK] [%s]__Commkey:\n", __FUNCTION__); for(i=0; i<16; i++) printf("%02x ", commkey[i]); printf("\ttranslen=%d\n", transinfolen-4); MACCAL_KEY16(commkey, pRadom, 0, postbuf, transinfolen-4, checkcode); memcpy(postbuf+transinfolen-4, checkcode, 4); //MAC //end /*如果发送数据后,没有收到服务器确认信息,将重发,三次都失败后,认为发送失败*/ printf("opt->websvr_time_out=%d\n",opt->websvr_time_out); // opt->websvr_time_out=10; //only test while(j<opt->reposttime){ // for (j=0; j<3; j++) { j++; iSvrResp = ymip_att_proc(opt->svrip,opt->svrport, (char *)&recv_head, postbuf, NULL, NULL, opt->error_intval, transinfolen); if(iSvrResp==NULL) { printf("[PUSH SDK] TRANS ATTLOG (%d)TIMES FAILED\n\n",j); continue; } return_len = svr_return_proc(iSvrResp, data_return, opt->websvr_time_out); if((return_len+8) != GetPacketLength(&recv_head)) { gErrorCode = 0x000a; fclose(iSvrResp); return -1; } if(return_len<=0) { printf("[PUSH SDK] TRANS ATTLOG (%d)TIMES FAILED\n\n",j); continue; } checkFN=IsRightFN(post_head.FrameNum,recv_head.FrameNum);//帧号检验 error_code = ProcessService(&recv_head, data_return, opt); if ((error_code < 0)/*||(checkFN==FALSE)*/) { printf("[PUSH SDK] TRANS ATTLOG (%d)TIMES FAILED\n\n",j); } else { memset(attlog->attbuffer,0,1024); //发送成功之后,重置数据 attlog->currec+=attcount; attlog->reclenght=0; writevalue[0]=attlog->currec; writevalue[1]=attlog->curfp; printf("\n[%s]currec=%d,attcount=%d,maxrec=%d\n",__FUNCTION__,attlog->currec,attcount, attlog->maxrec); write_file_with_offset(fdatt,0,(char *)&(writevalue),sizeof(writevalue)); if(attlog->maxrec<=attlog->currec) { opt->stat.post_interval = 1; } printf("[PUSH SDK] TRANS ATTLOG SUCCESS\n\n"); break; } } if (fStream) { fclose(fStream); } if(fdatt>0) { close(fdatt); } if (j >= opt->reposttime) { pipe_write_to_parent_cmd(CHILD_CMD_OFFLINE); return 0; } else { return 1; } }