src/jlibrtp/RtcpPktRR.java
author Da Risk <darisk972@gmail.com>
Tue, 14 Apr 2009 16:56:20 +0200
changeset 105 c6e4728ac9f7
parent 13 e684f11070d5
permissions -rw-r--r--
Passage sous cupcake :) Peu de modification de code, il faut juste creer des fichier aidl pour les classes parcelables. Sinon les fichier de build.xml ont ete completement modifiés, j'ai remplacé par les nouveaux. (il doit y avoir un manque de precision dans le fichier build.properties)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
     1
/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
     2
 * Java RTP Library (jlibrtp)
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
     3
 * Copyright (C) 2006 Arne Kepp
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
     4
 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
     5
 * This library is free software; you can redistribute it and/or
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
     6
 * modify it under the terms of the GNU Lesser General Public
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
     7
 * License as published by the Free Software Foundation; either
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
     8
 * version 2.1 of the License, or (at your option) any later version.
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
     9
 *
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    10
 * This library is distributed in the hope that it will be useful,
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    13
 * Lesser General Public License for more details.
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    14
 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    15
 * You should have received a copy of the GNU Lesser General Public
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    16
 * License along with this library; if not, write to the Free Software
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    18
 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    19
package jlibrtp;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    20
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    21
/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    22
 * RTCP packets for Receiver Reports 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    23
 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    24
 * @author Arne Kepp
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    25
 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    26
public class RtcpPktRR extends RtcpPkt {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    27
	/** Array of participants to send Receiver Reports to */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    28
	protected Participant[] reportees = null;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    29
	/** SSRC of participants the reports are for */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    30
	protected long[] reporteeSsrc = null;// -1; //32 bits
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    31
	/** Fraction (over 256) of packets lost */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    32
	protected int[] lossFraction = null;//-1; //8 bits
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    33
	/** Number of lost packets */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    34
	protected int[] lostPktCount = null;//-1; //24 bits
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    35
	/** Extended highest sequence received */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    36
	protected long[] extHighSeqRecv = null;//-1; //32 bits
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    37
	/** Interarrival jitter*/
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    38
	protected long[] interArvJitter = null;//-1; //32 bits
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    39
	/** Middle 32 bits of NTP when last SR was received */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    40
	protected long[] timeStampLSR = null;//-1; //32 bits
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    41
	/** Delay on last SRC */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    42
	protected long[] delaySR = null;//-1; //32 bits
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    43
	
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    44
	/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    45
	 * Constructor for a packet with receiver reports
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    46
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    47
	 * @param reportees the participants on which to generate reports
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    48
	 * @param ssrc the SSRC of the sender, from the RTPSession
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    49
	 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    50
	protected RtcpPktRR(Participant[] reportees, long ssrc) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    51
		super.packetType = 201;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    52
		// Fetch all the right stuff from the database
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    53
		super.ssrc = ssrc;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    54
		this.reportees = reportees;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    55
	}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    56
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    57
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    58
	/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    59
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    60
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    61
	 * If rcount < 0 we assume we have to parse the entire packet,
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    62
	 * otherwise we'll just parse the receiver report blocks
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    63
	 * (ie. the data came from a Sender Report packet)
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    64
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    65
	 * @param aRawPkt the byte[] with the report(s)
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    66
	 * @param start where in the raw packet to start reading
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    67
	 * @param rrCount the number of receiver reports, -1 if this does not come from an SR
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    68
	 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    69
	protected RtcpPktRR(byte[] aRawPkt, int start, int rrCount) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    70
		//System.out.println("RtcpPktRR: " + rrCount + "  start: " + start);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    71
		super.rawPkt = aRawPkt;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    72
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    73
		if(rrCount < 0 && (!super.parseHeaders(start) || packetType != 201 || super.length < 1)) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    74
			if(RTPSession.rtpDebugLevel > 2) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    75
				System.out.println(" <-> RtcpPktRR.parseHeaders() etc. problem: "+(!super.parseHeaders(start))+" "+packetType+" "+super.length);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    76
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    77
			super.problem = -201;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    78
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    79
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    80
		int base;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    81
		if(rrCount > 0) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    82
			base = start + 28;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    83
		} else {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    84
			base = start + 8;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    85
			rrCount = super.itemCount;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    86
			super.ssrc = StaticProcs.bytesToUIntLong(aRawPkt, start + 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    87
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    88
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    89
		if(rrCount > 0) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    90
			reporteeSsrc = new long[rrCount];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    91
			lossFraction = new int[rrCount];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    92
			lostPktCount = new int[rrCount];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    93
			extHighSeqRecv = new long[rrCount];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    94
			interArvJitter = new long[rrCount];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    95
			timeStampLSR = new long[rrCount];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    96
			delaySR = new long[rrCount];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    97
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    98
			for(int i=0; i<rrCount; i++ ) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    99
				int pos = base + i*24;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   100
				reporteeSsrc[i] = StaticProcs.bytesToUIntLong(aRawPkt, pos);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   101
				lossFraction[i] = (int) aRawPkt[pos + 4];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   102
				aRawPkt[pos + 4] = (byte) 0;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   103
				lostPktCount[i] = (int) StaticProcs.bytesToUIntLong(aRawPkt, pos + 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   104
				extHighSeqRecv[i] = StaticProcs.bytesToUIntLong(aRawPkt, pos + 8);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   105
				interArvJitter[i] = StaticProcs.bytesToUIntLong(aRawPkt, pos + 12);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   106
				timeStampLSR[i] = StaticProcs.bytesToUIntLong(aRawPkt, pos + 16);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   107
				delaySR[i] = StaticProcs.bytesToUIntLong(aRawPkt, pos + 20);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   108
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   109
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   110
	}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   111
	
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   112
	/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   113
	 * Encode the packet into a byte[], saved in .rawPkt
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   114
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   115
	 * CompRtcpPkt will call this automatically
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   116
	 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   117
	protected void encode() {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   118
		if(RTPSession.rtpDebugLevel > 9) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   119
			System.out.println("  -> RtcpPktRR.encode()");
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   120
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   121
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   122
		byte[] rRs = null;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   123
		//Gather up the actual receiver reports
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   124
		if(this.reportees != null) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   125
			rRs = this.encodeRR();
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   126
			super.rawPkt = new byte[rRs.length + 8];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   127
			System.arraycopy(rRs, 0, super.rawPkt, 8, rRs.length);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   128
			super.itemCount = reportees.length;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   129
		} else {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   130
			super.rawPkt = new byte[8];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   131
			super.itemCount = 0;	
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   132
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   133
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   134
		//Write the common header
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   135
		super.writeHeaders();
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   136
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   137
		//Add our SSRC (as sender)
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   138
		byte[] someBytes;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   139
		someBytes = StaticProcs.uIntLongToByteWord(super.ssrc);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   140
		System.arraycopy(someBytes, 0, super.rawPkt, 4, 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   141
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   142
		if(RTPSession.rtpDebugLevel > 9) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   143
			System.out.println("  <- RtcpPktRR.encode()");
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   144
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   145
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   146
	}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   147
	
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   148
	/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   149
	 * Encodes the individual Receiver Report blocks, 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   150
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   151
	 * so they can be used either in RR packets or appended to SR
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   152
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   153
	 * @return the encoded packets
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   154
	 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   155
	protected byte[] encodeRR() {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   156
		if(RTPSession.rtpDebugLevel > 10) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   157
			System.out.println("   -> RtcpPktRR.encodeRR()");
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   158
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   159
		//assuming we will always create complete reports:
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   160
		byte[] ret = new byte[24*reportees.length];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   161
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   162
		//Write SR stuff
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   163
		for(int i = 0; i<reportees.length; i++) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   164
			int offset = 24*i;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   165
			byte[] someBytes = StaticProcs.uIntLongToByteWord(reportees[i].ssrc);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   166
			System.arraycopy(someBytes, 0, ret, offset, 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   167
			
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   168
			//Cumulative number of packets lost
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   169
			someBytes = StaticProcs.uIntLongToByteWord(reportees[i].getLostPktCount());
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   170
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   171
			someBytes[0] = (byte) reportees[i].getFractionLost();
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   172
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   173
			//Write Cumulative number of packets lost and loss fraction to packet:
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   174
			System.arraycopy(someBytes, 0, ret, 4 + offset, 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   175
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   176
			// Extended highest sequence received
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   177
			someBytes = StaticProcs.uIntLongToByteWord(reportees[i].getExtHighSeqRecv());
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   178
			System.arraycopy(someBytes, 0, ret, 8 + offset, 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   179
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   180
			// Interarrival jitter
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   181
			if(reportees[i].interArrivalJitter >= 0) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   182
				someBytes = StaticProcs.uIntLongToByteWord((long)reportees[i].interArrivalJitter);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   183
			} else { 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   184
				someBytes = StaticProcs.uIntLongToByteWord((long) 0); 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   185
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   186
			System.arraycopy(someBytes, 0, ret, 12 + offset, 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   187
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   188
			// Timestamp last sender report received
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   189
			someBytes = StaticProcs.uIntLongToByteWord(reportees[i].timeStampLSR);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   190
			System.arraycopy(someBytes, 0, ret, 16 + offset, 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   191
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   192
			// Delay since last sender report received, in terms of 1/655536 s = 0.02 ms
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   193
			if(reportees[i].timeReceivedLSR > 0) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   194
				someBytes = StaticProcs.uIntLongToByteWord(reportees[i].delaySinceLastSR());
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   195
			} else {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   196
				someBytes = StaticProcs.uIntLongToByteWord(0);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   197
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   198
			System.arraycopy(someBytes, 0, ret, 20 + offset, 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   199
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   200
		if(RTPSession.rtpDebugLevel > 10) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   201
			System.out.println("   <- RtcpPktRR.encodeRR()");
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   202
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   203
		return ret;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   204
	}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   205
	
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   206
	/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   207
	 * Debug purposes only
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   208
	 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   209
	public void debugPrint() {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   210
		System.out.println("RtcpPktRR.debugPrint() ");
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   211
		if(reportees != null) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   212
			for(int i= 0; i<reportees.length; i++) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   213
				Participant part = reportees[i];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   214
				System.out.println("     part.ssrc: " + part.ssrc + "  part.cname: " + part.cname);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   215
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   216
		} else {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   217
			for(int i=0;i<reporteeSsrc.length; i++) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   218
				System.out.println("     reporteeSSRC: " + reporteeSsrc[i] + "  timeStampLSR: " + timeStampLSR[i]);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   219
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   220
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   221
	}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   222
}