static mblk_t *rtcp_create_simple_bye_packet(uint32_t ssrc, const char *reason) { int packet_size; int strsize = 0; int strpadding = 0; mblk_t *mp; rtcp_bye_t *rtcp; packet_size = RTCP_BYE_HEADER_SIZE; if (reason!=NULL) { strsize=(int)MIN(strlen(reason),RTCP_BYE_REASON_MAX_STRING_SIZE); if (strsize > 0) { strpadding = 3 - (strsize % 4); packet_size += 1 + strsize + strpadding; } } mp = allocb(packet_size, 0); rtcp = (rtcp_bye_t*)mp->b_rptr; rtcp_common_header_init(&rtcp->ch,NULL,RTCP_BYE,1,packet_size); rtcp->ssrc[0] = htonl(ssrc); mp->b_wptr += RTCP_BYE_HEADER_SIZE; /* append the reason if any*/ if (reason!=NULL) { const char pad[] = {0, 0, 0}; unsigned char strsize_octet = (unsigned char)strsize; appendb(mp, (const char*)&strsize_octet, 1, FALSE); appendb(mp, reason,strsize, FALSE); appendb(mp, pad,strpadding, FALSE); } return mp; }
static mblk_t * sdes_chunk_append_item(mblk_t *m, rtcp_sdes_type_t sdes_type, const char *content) { if ( content ) { sdes_item_t si; si.item_type=sdes_type; si.len=(uint8_t) MIN(strlen(content),RTCP_SDES_MAX_STRING_SIZE); m=appendb(m,(char*)&si,RTCP_SDES_ITEM_HEADER_SIZE,FALSE); m=appendb(m,content,si.len,FALSE); } return m; }
mblk_t *rtcp_create_simple_bye_packet(guint32 ssrc, const gchar *reason) { gint strsize=0; gint packet_size; mblk_t *mp; rtcp_bye_t *rtcp; packet_size = RTCP_BYE_HEADER_SIZE + 1 + strsize; if (reason!=NULL) strsize=MIN(strlen(reason),RTCP_BYE_REASON_MAX_STRING_SIZE); mp = allocb(packet_size, 0); rtcp = (rtcp_bye_t*)mp->b_rptr; rtcp_common_header_init(&rtcp->ch,NULL,RTCP_BYE,1,packet_size); rtcp->ssrc[0] = htonl(ssrc); mp->b_wptr += packet_size; /* append the reason if any*/ if (reason!=NULL) appendb(mp,reason,strsize,FALSE); return mp; }
void msgappend(mblk_t *mp, const char *data, int size, bool_t pad){ while(mp->b_cont!=NULL) mp=mp->b_cont; appendb(mp,data,size,pad); }
static mblk_t * sdes_chunk_pad(mblk_t *m){ return appendb(m,"",1,TRUE); }
mblk_t * sdes_chunk_pad(mblk_t *m){ return appendb(m,NULL,0,TRUE); }