rtcp_utils.c

Go to the documentation of this file.
00001 /* * 
00002  * This file is part of libnemesi
00003  *
00004  * Copyright (C) 2007 by LScube team <team@streaming.polito.it>
00005  * See AUTHORS for more details
00006  * 
00007  * libnemesi is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * libnemesi is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with libnemesi; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  *  
00021  * */
00022 
00027 #include "rtcp.h"
00028 
00029 #define RTCP_MIN_TIME 5.0
00030 #define RTCP_SENDER_BW_FRACTION 0.25
00031 #define RTCP_RCVR_BW_FRACTION 0.75
00032 #define COMPENSATION 1.21828    /* e - 1.5 */
00033 
00044 double rtcp_interval(int members, int senders, double rtcp_bw, int we_sent,
00045              double avg_rtcp_size, int initial)
00046 {
00047     double t;
00048     double rtcp_min_time = RTCP_MIN_TIME;
00049     int n;
00050 
00051     if (initial)
00052         rtcp_min_time /= 2;
00053 
00054     n = members;
00055     if (senders > 0 && senders < members * RTCP_SENDER_BW_FRACTION) {
00056         if (we_sent) {
00057             rtcp_bw *= RTCP_SENDER_BW_FRACTION;
00058             n = senders;
00059         } else {
00060             rtcp_bw *= RTCP_RCVR_BW_FRACTION;
00061             n -= senders;
00062         }
00063     }
00064     if ((t = avg_rtcp_size * n / rtcp_bw) < rtcp_min_time)
00065         t = rtcp_min_time;
00066     t = (t * (drand48() + 0.5)) / COMPENSATION;
00067     return t;
00068 }

Generated on Tue Feb 3 03:10:02 2009 for libnemesi by  doxygen 1.5.4