00001 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- 00002 * 00003 * Copyright (c) Xerox Corporation 1997. All rights reserved. 00004 * 00005 * License is granted to copy, to use, and to make and to use derivative 00006 * works for research and evaluation purposes, provided that Xerox is 00007 * acknowledged in all documentation pertaining to any such copy or 00008 * derivative work. Xerox grants no other licenses expressed or 00009 * implied. The Xerox trade name should not be used in any advertising 00010 * without its written permission. 00011 * 00012 * XEROX CORPORATION MAKES NO REPRESENTATIONS CONCERNING EITHER THE 00013 * MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE 00014 * FOR ANY PARTICULAR PURPOSE. The software is provided "as is" without 00015 * express or implied warranty of any kind. 00016 * 00017 * These notices must be retained in any copies of any part of this 00018 * software. 00019 */ 00020 00021 #ifndef lint 00022 static const char rcsid[] = 00023 "@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/adc/adaptive-receiver.cc,v 1.7 2000/09/01 03:04:05 haoboy Exp $"; 00024 #endif 00025 00026 #include "config.h" 00027 #include "agent.h" 00028 #include "tclcl.h" 00029 #include "packet.h" 00030 #include "ip.h" 00031 #include "rtp.h" 00032 #include "adaptive-receiver.h" 00033 #include <math.h> 00034 00035 #define myabs(r) (r<0)?-r:r 00036 00037 AdaptiveRcvr::AdaptiveRcvr() : Agent(PT_NTYPE) 00038 { 00039 //bind("npkts_",&npkts_); 00040 //bind("ndelay_",&ndelay_); 00041 //bind("nvar_",&nvar_); 00042 } 00043 00044 void AdaptiveRcvr::recv(Packet *pkt,Handler*) 00045 { 00046 int delay; 00047 int seq_no; 00048 hdr_cmn* ch= hdr_cmn::access(pkt); 00049 hdr_rtp *rh = hdr_rtp::access(pkt); 00050 00051 seq_no= rh->seqno(); 00052 register u_int32_t send_time = (int)ch->timestamp(); 00053 00054 u_int32_t local_time= (u_int32_t)(Scheduler::instance().clock() * SAMPLERATE); 00055 delay=adapt(pkt,local_time); 00056 Tcl::instance().evalf("%s print-delay-stats %f %f %f",name(),send_time/SAMPLERATE,local_time/SAMPLERATE,(local_time+delay)/SAMPLERATE); 00057 Packet::free(pkt); 00058 } 00059
1.3.3