/** * This is a simplified version with this limit of the algorithm described in * the appendix A.7 of RFC3550. */ void compute_rtcp_interval(RtpSession *session) { float t; float rtcp_min_time; float rtcp_bw; if (session->target_upload_bandwidth == 0) return; /* Compute target RTCP bandwidth in bits/s. */ rtcp_bw = 0.05f * session->target_upload_bandwidth; if (rtp_session_avpf_enabled(session) == TRUE) { session->rtcp.send_algo.T_rr_interval = rtp_session_get_avpf_rr_interval(session); rtcp_min_time = (float)session->rtcp.send_algo.Tmin; } else { rtcp_min_time = (float)session->rtcp.send_algo.T_rr_interval; if (session->rtcp.send_algo.initial == TRUE) { rtcp_min_time /= 2.; } } t = ((session->rtcp.send_algo.avg_rtcp_size * 8 * 2) / rtcp_bw) * 1000; if (t < rtcp_min_time) t = rtcp_min_time; t = rtcp_rand(t); t = t / (2.71828f - 1.5f); /* Compensation */ session->rtcp.send_algo.T_rr = (uint32_t)t; }
static void rtp_session_reschedule(RtpSession *session, uint64_t tc) { OrtpRtcpSendAlgorithm *sa = &session->rtcp.send_algo; if (rtp_session_avpf_enabled(session) == TRUE) { sa->tp = tc; sa->tn = tc + sa->T_rr; } }
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); } }
void rtp_session_send_rtcp_fb_generic_nack(RtpSession *session, uint16_t pid, uint16_t blp) { mblk_t *m; if ((rtp_session_avpf_enabled(session) == TRUE) && (rtp_session_avpf_feature_enabled(session, ORTP_AVPF_FEATURE_GENERIC_NACK) == TRUE)) { m = make_rtcp_fb_generic_nack(session, pid, blp); rtp_session_add_fb_packet_to_send(session, m); rtp_session_send_fb_rtcp_packet_and_reschedule(session); } }
void rtp_session_send_rtcp_fb_rpsi(RtpSession *session, uint8_t *bit_string, uint16_t bit_string_len) { mblk_t *m; if ((rtp_session_avpf_enabled(session) == TRUE) && (rtp_session_avpf_payload_type_feature_enabled(session, PAYLOAD_TYPE_AVPF_RPSI) == TRUE)) { m = make_rtcp_fb_rpsi(session, bit_string, bit_string_len); rtp_session_add_fb_packet_to_send(session, m); if (is_fb_packet_to_be_sent_immediately(session) == TRUE) { rtp_session_send_fb_rtcp_packet_and_reschedule(session); } } }
void rtp_session_send_rtcp_fb_tmmbn(RtpSession *session, uint32_t ssrc) { mblk_t *m; if ((rtp_session_avpf_enabled(session) == TRUE) && (rtp_session_avpf_feature_enabled(session, ORTP_AVPF_FEATURE_TMMBR) == TRUE)) { m = make_rtcp_fb_tmmbn(session, ssrc); if (m) { rtp_session_add_fb_packet_to_send(session, m); session->rtcp.send_algo.tmmbn_scheduled = TRUE; } rtp_session_send_fb_rtcp_packet_and_reschedule(session); } }
void rtp_session_send_rtcp_fb_tmmbr(RtpSession *session, uint64_t mxtbr) { mblk_t *m; if ((rtp_session_avpf_enabled(session) == TRUE) && (rtp_session_avpf_feature_enabled(session, ORTP_AVPF_FEATURE_TMMBR) == TRUE)) { if ((rtp_session_rtcp_rtpfb_scheduled(session, RTCP_RTPFB_TMMBR) != TRUE) && (rtp_session_get_recv_ssrc(session) != 0)) { uint16_t overhead = (session->rtp.gs.sockfamily == AF_INET6) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD; m = make_rtcp_fb_tmmbr(session, mxtbr, overhead); rtp_session_add_fb_packet_to_send(session, m); session->rtcp.send_algo.tmmbr_scheduled = TRUE; } rtp_session_send_fb_rtcp_packet_and_reschedule(session); } }
void rtp_session_send_rtcp_fb_fir(RtpSession *session) { mblk_t *m; if ((rtp_session_avpf_enabled(session) == TRUE) && (rtp_session_avpf_payload_type_feature_enabled(session, PAYLOAD_TYPE_AVPF_FIR) == TRUE)) { if (rtp_session_rtcp_psfb_scheduled(session, RTCP_PSFB_FIR) != TRUE) { m = make_rtcp_fb_fir(session); rtp_session_add_fb_packet_to_send(session, m); } if (is_fb_packet_to_be_sent_immediately(session) == TRUE) { rtp_session_send_fb_rtcp_packet_and_reschedule(session); } } }
void rtp_session_send_rtcp_fb_sli(RtpSession *session, uint16_t first, uint16_t number, uint8_t picture_id) { mblk_t *m; if (rtp_session_avpf_enabled(session) == TRUE) { /* Only send SLI if SLI and RPSI features have been enabled. SLI without RPSI is not really useful. */ if ((rtp_session_avpf_payload_type_feature_enabled(session, PAYLOAD_TYPE_AVPF_SLI) == TRUE) && (rtp_session_avpf_payload_type_feature_enabled(session, PAYLOAD_TYPE_AVPF_RPSI) == TRUE)) { m = make_rtcp_fb_sli(session, first, number, picture_id); rtp_session_add_fb_packet_to_send(session, m); if (is_fb_packet_to_be_sent_immediately(session) == TRUE) { rtp_session_send_fb_rtcp_packet_and_reschedule(session); } } else { // Try to fallback to sending a PLI if the SLI feature has not been enabled. rtp_session_send_rtcp_fb_pli(session); } } }
bool_t media_stream_avpf_enabled(const MediaStream *stream) { return rtp_session_avpf_enabled(stream->sessions.rtp_session); }