www.pudn.com > streamrtp.rar > rtpnewstream.c


/*-------------------------------------------------------------------------
 * rtpnewstream.c - rtpnrestream
 *-------------------------------------------------------------------------
 */

#include 
#include 
#include 
#include 
#include 
#include 

/*------------------------------------------------------------------------
 * rtpnewstream - create state for newly detected stream
 * The refcount is initialized to 1. Thus the caller must release the
 * stream when finished with it.
 *------------------------------------------------------------------------
 */
struct stream *
rtpnewstream(struct session *psn, unsigned int ssrc)
{

	struct stream		*pstm;

	pstm = (struct stream *) malloc(sizeof(struct stream));
	if (pstm == NULL)
		return NULL;
	memset(pstm, 0, sizeof(struct stream));

	rtpqinit(&pstm->stm_queue);
	pthread_mutex_init(&pstm->stm_mutex, NULL);
	pstm->stm_ssrc = ssrc;
	pstm->stm_ip.sin_addr.s_addr = INADDR_ANY;
	pstm->stm_payload = RTP_PAYLOADUNINITIALIZED;
	pstm->stm_inactthresh = RTP_DEFAULT_INACTIVETHRESH;
	pstm->stm_probation = RTP_MINSEQUENTIAL;
	pstm->stm_refcnt = 1;
	htadd(psn->sn_ssrcs, ssrc, pstm);
	rtpcheckcollision(psn, ssrc);
	rtppostevent(psn, EVENT_PARTICIPANT_NEW, ssrc, NULL, 0);
  
	return pstm;
}