rtcpbye.c
来自「linux环境下用纯c写的RTP协议的通用开发库」· C语言 代码 · 共 70 行
C
70 行
/*------------------------------------------------------------------------- * rtcpbye.c - rtcpbye *------------------------------------------------------------------------- */#include <hash.h>#include <rtcp.h>#include <rtp.h>#include <unistd.h>#include <stdlib.h>#include <strings.h>/*------------------------------------------------------------------------ * rtcpbye - process an incoming RTCP bye message *------------------------------------------------------------------------ */intrtcpbye(struct session *psn, struct rtcp *prtcp){ struct stream *pstm; ssrc_t *p, ssrc; int i, eventdatalen; char eventdata[sizeof(ssrc_t) + 256]; struct byereason *preason; if (prtcp->rtcp_type != RTCP_BYE) return ERROR; /* * Look for a reason string. */ if (prtcp->rtcp_length > prtcp->rtcp_count) { preason = (struct byereason *) (prtcp->rtcp_data + prtcp->rtcp_count * sizeof(ssrc_t)); eventdatalen = preason->bye_length + 1; memcpy(eventdata, preason->bye_reason, preason->bye_length); eventdata[preason->bye_length] = '\0'; } else eventdatalen = 0; /* * Iterate through list of synchronization * source identifiers in the bye message. */ for (i = 0, p = (unsigned int *) prtcp->rtcp_data; i < prtcp->rtcp_count; i++, p++) { ssrc = ntohl(*p); pstm = rtpgetstream(psn, ssrc); if (pstm != NULL) { if (!RTP_INACTIVE(pstm->stm_inactive)) { /* * Mark the stream as inactive, * cleanup if necessary, and post * event informing of the stream's * exit containing the reason string * as data. */ pstm->stm_inactive = RTP_BYERECEIVED; rtpstreamcleanup(psn, pstm); rtppostevent(psn, EVENT_RTCP_BYE, ssrc, eventdata, eventdatalen); } rtpreleasestream(psn, pstm); } } return OK;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?