Esempio n. 1
0
/**
 * Sends a RTCP bye packet.
 *@param session RtpSession
 *@param reason the reason phrase.
**/
int rtp_session_bye(RtpSession *session, const char *reason) {
    mblk_t *cm;
    mblk_t *sdes = NULL;
    mblk_t *bye = NULL;
    int ret;

    /* Make a BYE packet (will be on the end of the compund packet). */
    bye = rtcp_create_simple_bye_packet(session->snd.ssrc, reason);

    /* SR or RR is determined by the fact whether stream was sent*/
    if (session->stats.packet_sent>0)
    {
        cm = allocb(sizeof(rtcp_sr_t), 0);
        cm->b_wptr += rtcp_sr_init(session,cm->b_wptr, sizeof(rtcp_sr_t));
        /* make a SDES packet */
        sdes = rtp_session_create_rtcp_sdes_packet(session, TRUE);
        /* link them */
        concatb(concatb(cm, sdes), bye);
    } else if (session->stats.packet_recv>0){
        /* make a RR packet */
        cm = allocb(sizeof(rtcp_rr_t), 0);
        cm->b_wptr += rtcp_rr_init(session, cm->b_wptr, sizeof(rtcp_rr_t));
        /* link them */
        cm->b_cont = bye;
    }else cm=bye;

    /* Send compound packet. */
    ret = rtp_session_rtcp_send(session, cm);

    return ret;
}
Esempio n. 2
0
static void rtp_session_create_and_send_rtcp_packet(RtpSession *session, bool_t full) {
	mblk_t *m=NULL;
	bool_t is_sr = FALSE;

	if (session->rtp.last_rtcp_packet_count < session->stats.packet_sent) {
		m = make_sr(session);
		session->rtp.last_rtcp_packet_count = (uint32_t)session->stats.packet_sent;
		is_sr = TRUE;
	} else if (session->stats.packet_recv > 0) {
		/* Don't send RR when no packet are received yet */
		m = make_rr(session);
		is_sr = FALSE;
	}
	if (m != NULL) {
		append_sdes(session, m, full);
		if ((full == TRUE) && (session->rtcp.xr_conf.enabled == TRUE)) {
			append_xr_packets(session, m);
		}
		if (rtp_session_avpf_enabled(session) == TRUE) {
			append_fb_packets(session, m);
		}
		/* Send the compound packet */
		notify_sent_rtcp(session, m);
		ortp_message("Sending RTCP %s compound message on session [%p].",(is_sr ? "SR" : "RR"), session);
		rtp_session_rtcp_send(session, m);
	}
}
Esempio n. 3
0
void rtp_session_send_rtcp_APP(RtpSession *session, uint8_t subtype, const char *name, const uint8_t *data, int datalen){
	mblk_t *h=allocb(sizeof(rtcp_app_t),0);
	mblk_t *d;
	h->b_wptr+=rtcp_app_init(session,h->b_wptr,subtype,name,datalen+sizeof(rtcp_app_t));
	d=esballoc((uint8_t*)data,datalen,0,NULL);
	d->b_wptr+=datalen;
	h->b_cont=d;
	rtp_session_rtcp_send(session,h);
}
Esempio n. 4
0
void rtp_session_remove_contributing_source(RtpSession *session, uint32_t ssrc) {
	queue_t *q=&session->contributing_sources;
	mblk_t *tmp;
	for (tmp=qbegin(q); !qend(q,tmp); tmp=qnext(q,tmp)){
		uint32_t csrc=sdes_chunk_get_ssrc(tmp);
		if (csrc==ssrc) {
			remq(q,tmp);
			break;
		}
	}
	tmp=rtcp_create_simple_bye_packet(ssrc, NULL);
	rtp_session_rtcp_send(session,tmp);
}
Esempio n. 5
0
void rtp_session_rtcp_process_send(RtpSession *session){
	RtpStream *st=&session->rtp;
	RtcpStream *rtcp_st=&session->rtcp;
	mblk_t *m;
	if (st->rcv_last_app_ts - rtcp_st->last_rtcp_report_snt_r > rtcp_st->rtcp_report_snt_interval_r 
		|| st->snd_last_ts - rtcp_st->last_rtcp_report_snt_s > rtcp_st->rtcp_report_snt_interval_s){
		rtcp_st->last_rtcp_report_snt_r=st->rcv_last_app_ts;
		rtcp_st->last_rtcp_report_snt_s=st->snd_last_ts;
		m=make_sr(session);
		/* send the compound packet */
		notify_sent_rtcp(session,m);
		rtp_session_rtcp_send(session,m);
		ortp_debug("Rtcp compound message sent.");
	}
}
Esempio n. 6
0
void rtp_session_rtcp_process_recv(RtpSession *session){
	RtpStream *st=&session->rtp;
	RtcpStream *rtcp_st=&session->rtcp;
	mblk_t *m=NULL;
	if (st->rcv_last_app_ts - rtcp_st->last_rtcp_report_snt_r > rtcp_st->rtcp_report_snt_interval_r 
		|| st->snd_last_ts - rtcp_st->last_rtcp_report_snt_s > rtcp_st->rtcp_report_snt_interval_s){
		rtcp_st->last_rtcp_report_snt_r=st->rcv_last_app_ts;
		rtcp_st->last_rtcp_report_snt_s=st->snd_last_ts;

		if (session->rtp.last_rtcp_packet_count<session->rtp.stats.packet_sent){
			m=make_sr(session);
			session->rtp.last_rtcp_packet_count=session->rtp.stats.packet_sent;
		}else if (session->rtp.stats.packet_recv>0){
			/*don't send RR when no packet are received yet*/
			m=make_rr(session);
		}
		if (m!=NULL){
			/* send the compound packet */
			notify_sent_rtcp(session,m);
			rtp_session_rtcp_send(session,m);
			ortp_debug("Rtcp compound message sent.");
		}
	}
}