www.pudn.com > RTP通用开发库(for Linux).rar > rtcprr.c


/*-------------------------------------------------------------------------
 * rtcprr.c - rtcprr
 *-------------------------------------------------------------------------
 */

#include 
#include 
#include 

/*------------------------------------------------------------------------
 * rtcprr - process an incoming RTCP receiver report
 *------------------------------------------------------------------------
 */
int
rtcprr(struct session *psn, struct rtcp *prtcp)
{
  
	struct rr	*prr;
	struct stream	*pstm;

	if (prtcp->rtcp_type != RTCP_RR) 
		return -1;
 
	prr = (struct rr *) prtcp->rtcp_data;
	prr->rr_ssrc = ntohl(prr->rr_ssrc);

	pstm = rtpgetstream(psn, prr->rr_ssrc);
	if (pstm == NULL)
		if ((pstm = rtpnewstream(psn, prr->rr_ssrc)) == NULL)
			return ERROR;

	if (!RTP_INACTIVE(pstm->stm_inactive))
		pstm->stm_inactive = 0;
	else {
		rtpreleasestream(psn, pstm);
		return OK;
	}

	rtpreleasestream(psn, pstm);

	/*
	 * Post event with the receiver report as data.
	 */
	rtppostevent(psn, EVENT_RTCP_RR, prr->rr_ssrc,
		     (char *) prtcp, RTCP_LENGTH_BYTE(prtcp));
	return OK;
}