⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtcpheader.c

📁 linux环境下用纯c写的RTP协议的通用开发库
💻 C
字号:
/*------------------------------------------------------------------------- * rtcpheader.c - rtcpheader *------------------------------------------------------------------------- */#include <rtp.h>#include <rtcp.h>/*------------------------------------------------------------------------ * rtcpheader - fill in an RTCP header in machine byte order and pad * for 32-bit alignment if necessary. Rtcpheader assumes that the caller  * has allocated the correct amount of memory to round up so that the * message is 32-bit aligned. *------------------------------------------------------------------------ */intrtcpheader(struct rtcp *prtcp, int count, unsigned char type, int bytelength){  	int		pad, i;  	if (count > (1 << 5) - 1)		return ERROR;	if (bytelength > 1 << 18)		return ERROR;	prtcp->rtcp_ver = RTP_CURRVERS;	prtcp->rtcp_count = count;	prtcp->rtcp_type = type;  	/*	 * RTCP acket length represented in 4-octet units minus one.	 */ 	prtcp->rtcp_length = (bytelength / 4) - 1;	/*	 * Determine if the packet must be padded so that it is	 * 32-bit aligned.	 */	pad = (bytelength % 4 > 0 ? 4 - (bytelength % 4) : 0);	if (pad > 0) {		prtcp->rtcp_length++;		prtcp->rtcp_pad = TRUE;		for (i = 0; i < pad - 1; i++) {			*((char *) prtcp + bytelength + i) = 0;      		}				/* 		 * The last byte of a padded RTCP packet		 * indicates the number of padding bytes		 * present.		 */		*((char *) prtcp + bytelength + pad - 1) = pad;	}	else		prtcp->rtcp_pad = FALSE;    	return OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -