📄 hust_rtcpsdes.c
字号:
/*------------------------------------------------------------------------- * rtcpsdes.c - rtcpsdes, rtcpprocesschunk, rtcpconsumechunk *------------------------------------------------------------------------- */#include <ipOS.h>#include <ipHAL.h>#include <ipStack.h>#include <ipEthernet.h>#include "hust_rtp.h"#include "hust_rtplibcommon.h"#include "hust_rtcp.h"#include "hust_event.h"#include "hust_hash.h"#include "hust_linux.h"///#include <hash.h>///#include <rtcp.h>///#include <rtp.h>///#include <string.h>///#include <strings.h>/*------------------------------------------------------------------------ * rtcpsdes - process an incoming source description message *------------------------------------------------------------------------ */intrtcpsdes(struct session *psn, struct rtcp *prtcp, struct netbuf *udpnb){/// struct sdchunk *pchunk; int i; if (prtcp->rtcp_type != RTCP_SDES) return ERROR; /* * Iterate over the source description's chunks. *//* pchunk = (struct sdchunk *)heap_alloc(sizeof(struct sdchunk)); prtcp->rtcp_data = pchunk; memset(pchunk, 0, sizeof(struct sdchunk));*/ for (i = 0; i < prtcp->rtcp_count ; i++) { rtcpprocesschunk(psn, udpnb); } return OK;}/*------------------------------------------------------------------------ * rtcpprocesschunk - process a single chunk of a source description * message.Rtcpprocesschunk returns a pointer to the next chunk. *------------------------------------------------------------------------ */voidrtcpprocesschunk(struct session *psn, struct netbuf *udpnb) { struct stream *pstm; struct sditem *psditem;/// struct sdchunk *nextchunk; u8_t temp,end=0,lencount=0; ssrc_t ssrc; /// pchunk->sdc_ssrc = netbuf_fwd_read_u32(udpnb); ssrc = netbuf_fwd_read_u32(udpnb); pstm = rtpgetstream(psn, ssrc); if (pstm == NULL) if ((pstm = rtpnewstream(psn, ssrc)) == NULL){ rtcpconsumechunk(udpnb); return ; } if (!RTP_INACTIVE(pstm->stm_inactive)) pstm->stm_inactive = 0; else { rtpreleasestream(psn, pstm); rtcpconsumechunk(udpnb); return ; } /* * Iterate over all items in the chunk. */ psditem = (struct sditem *) heap_alloc(sizeof(struct sditem));/// pchunk->sdc_data = psditem; memset(psditem, 0, sizeof(struct sditem)); /// nextchunk = NULL; while (!end) { psditem->sdi_type = netbuf_fwd_read_u8(udpnb); if(psditem->sdi_type != RTCP_ITEM_NULL) { psditem->sdi_len = netbuf_fwd_read_u8(udpnb); psditem->sdi_data = (char *)heap_alloc(psditem->sdi_len); netbuf_fwd_read_mem(udpnb,psditem->sdi_data,psditem->sdi_len); lencount+= ITEMHEADERSZ+psditem->sdi_len; } switch(psditem->sdi_type) { case RTCP_ITEM_NULL: /* * End of chunk; eat nulls until we reach * 32-bit alignmnet. */ while((++lencount)%4 ) { temp = netbuf_fwd_read_u8(udpnb); } end=1; break; /* * For all other items, record item in stream's state * and post an event with no data. */ case RTCP_ITEM_CNAME: if (pstm->stm_cname==NULL) { pstm->stm_cname = (char *)heap_alloc(psditem->sdi_len+1); } if (memcmp(pstm->stm_cname, psditem->sdi_data, psditem->sdi_len)) { strncpy(pstm->stm_cname, psditem->sdi_data, psditem->sdi_len); pstm->stm_cname[psditem->sdi_len] ='\0'; rtcpcnameadd(psn, pstm);/// rtppostevent(psn, EVENT_RTCP_SDES_CNAME,/// pstm->stm_ssrc, NULL, 0); } break; case RTCP_ITEM_NAME: if (pstm->stm_name==NULL) { pstm->stm_name= (char *)heap_alloc(psditem->sdi_len); } if (memcmp(pstm->stm_name, psditem->sdi_data, psditem->sdi_len)) { strncpy(pstm->stm_name, psditem->sdi_data, psditem->sdi_len); pstm->stm_name[psditem->sdi_len] = '\0';/// rtppostevent(psn, EVENT_RTCP_SDES_NAME,/// pstm->stm_ssrc, NULL, 0); } break; case RTCP_ITEM_EMAIL: if (pstm->stm_email==NULL) { pstm->stm_email= (char *)heap_alloc(psditem->sdi_len); } if (memcmp(pstm->stm_email, psditem->sdi_data, psditem->sdi_len)) { strncpy(pstm->stm_email, psditem->sdi_data, psditem->sdi_len); pstm->stm_email[psditem->sdi_len] = '\0';/// rtppostevent(psn, EVENT_RTCP_SDES_EMAIL,/// pstm->stm_ssrc, NULL, 0); } break; case RTCP_ITEM_PHONE: if (pstm->stm_phone==NULL) { pstm->stm_phone= (char *)heap_alloc(psditem->sdi_len); } if (memcmp(pstm->stm_phone, psditem->sdi_data, psditem->sdi_len)) { strncpy(pstm->stm_phone, psditem->sdi_data, psditem->sdi_len); pstm->stm_phone[psditem->sdi_len] = '\0';/// rtppostevent(psn, EVENT_RTCP_SDES_PHONE,/// pstm->stm_ssrc, NULL, 0); } break; case RTCP_ITEM_LOC: if (pstm->stm_loc==NULL) { pstm->stm_loc= (char *)heap_alloc(psditem->sdi_len); } if (memcmp(pstm->stm_loc, psditem->sdi_data, psditem->sdi_len)) { strncpy(pstm->stm_loc, psditem->sdi_data, psditem->sdi_len); pstm->stm_loc[psditem->sdi_len] = '\0';/// rtppostevent(psn, EVENT_RTCP_SDES_LOC,/// pstm->stm_ssrc, NULL, 0); } break; case RTCP_ITEM_TOOL: if (pstm->stm_tool==NULL) { pstm->stm_tool= (char *)heap_alloc(psditem->sdi_len); } if (memcmp(pstm->stm_tool, psditem->sdi_data, psditem->sdi_len)) { strncpy(pstm->stm_tool, psditem->sdi_data, psditem->sdi_len); pstm->stm_tool[psditem->sdi_len] = '\0';//// rtppostevent(psn, EVENT_RTCP_SDES_TOOL,//// pstm->stm_ssrc, NULL, 0); } break; case RTCP_ITEM_NOTE: if (pstm->stm_note==NULL) { pstm->stm_note= (char *)heap_alloc(psditem->sdi_len); } if (memcmp(pstm->stm_note, psditem->sdi_data, psditem->sdi_len)) { strncpy(pstm->stm_note, psditem->sdi_data, psditem->sdi_len); pstm->stm_note[psditem->sdi_len] = '\0';/// rtppostevent(psn, EVENT_RTCP_SDES_NOTE,/// pstm->stm_ssrc, NULL, 0); } break; case RTCP_ITEM_PRIV: if (pstm->stm_priv==NULL) { pstm->stm_priv= (char *)heap_alloc(psditem->sdi_len); } if (memcmp(pstm->stm_priv, psditem->sdi_data, psditem->sdi_len)) { strncpy(pstm->stm_priv, psditem->sdi_data, psditem->sdi_len); pstm->stm_note[psditem->sdi_len] = '\0';/// rtppostevent(psn, EVENT_RTCP_SDES_PRIV,/// pstm->stm_ssrc, NULL, 0); } break; } if(!end) heap_free(psditem->sdi_data); /* * Advance to next item. */ ///psditem = (struct sditem *) ((char *) psditem + 2 + psditem->sdi_len); }/* rtppostevent(psn, EVENT_RTCP_SDES_CHUNK, pstm->stm_ssrc, (char *) pchunk, (unsigned int) nextchunk - (unsigned int) pchunk);*/ heap_free(psditem); rtpreleasestream(psn, pstm); return ;}/*------------------------------------------------------------------------ * rtcpconsumechunk - quietly consume a source description chunk. * Rtcpconsumechunk is used to skip over chunks that relate to inactive * participants. *------------------------------------------------------------------------ */voidrtcpconsumechunk( struct netbuf *udpnb){ ///struct sdchunk *nextchunk; struct sditem *psditem; u8_t temp,end=0,lencount=0; /* * Iterate over items in the chunk. */ psditem = (struct sditem *) heap_alloc(sizeof(struct sditem)); memset(psditem, 0, sizeof(struct sditem)); while (!end) { psditem->sdi_type = netbuf_fwd_read_u8(udpnb); if (psditem->sdi_type != RTCP_ITEM_NULL) { psditem->sdi_len = netbuf_fwd_read_u8(udpnb); netbuf_advance_pos(udpnb,psditem->sdi_len); lencount+= ITEMHEADERSZ+psditem->sdi_len; } else{ /* * End of chunk; eat nulls until we * reach 32-bit alignmnet. */ while((++lencount)%4 ) { temp = netbuf_fwd_read_u8(udpnb); } end=1; } /* * Advance to next item. *//// psditem = (struct sditem *) ((char *) psditem + 2 + psditem->sdi_len); } heap_free(psditem); return ;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -