src/jlibrtp/RtcpPktSDES.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
import java.net.InetSocketAddress;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    22
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    23
/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    24
 * RTCP packets for Source Descriptions
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    25
 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    26
 * @author Arne Kepp
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    27
 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    28
public class RtcpPktSDES extends RtcpPkt {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    29
	/** Whether the RTP Session object should be inclduded */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    30
	boolean reportSelf = true;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    31
	/** The parent RTP Session object, holds participant database */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    32
	RTPSession rtpSession = null;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    33
	/** The participants to create SDES packets for */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    34
	protected Participant[] participants = null;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    35
	
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    36
	/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    37
	 * Constructor to create a new SDES packet
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    38
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    39
	 * TODO:
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    40
	 * Currently the added participants are not actually encoded
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    41
	 * because the library lacks some support for acting as mixer or
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    42
	 * relay in other areas.
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    43
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    44
	 * @param reportThisSession include information from RTPSession as a participant
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    45
	 * @param rtpSession the session itself
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    46
	 * @param additionalParticipants additional participants to include
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    47
	 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    48
	protected RtcpPktSDES(boolean reportThisSession, RTPSession rtpSession, Participant[] additionalParticipants) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    49
		super.packetType = 202;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    50
		// Fetch all the right stuff from the database
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    51
		reportSelf = reportThisSession;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    52
		participants = additionalParticipants;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    53
		this.rtpSession = rtpSession; 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    54
	}
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
	 * Constructor that parses a received packet
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    58
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    59
	 * @param aRawPkt the byte[] containing the packet
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    60
	 * @param start where in the byte[] this packet starts
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    61
	 * @param socket the address from which the packet was received
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    62
	 * @param partDb the participant database
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    63
	 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    64
	protected RtcpPktSDES(byte[] aRawPkt,int start, InetSocketAddress socket, ParticipantDatabase partDb) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    65
		if(RTPSession.rtcpDebugLevel > 8) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    66
			System.out.println("  -> RtcpPktSDES(byte[], ParticipantDabase)");
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    67
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    68
		rawPkt = aRawPkt;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    69
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    70
		if(! super.parseHeaders(start) || packetType != 202 ) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    71
			if(RTPSession.rtpDebugLevel > 2) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    72
				System.out.println(" <-> RtcpPktSDES.parseHeaders() etc. problem");
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    73
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    74
			super.problem = -202;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    75
		} else {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    76
			//System.out.println(" DECODE SIZE: " + super.length + " itemcount " + itemCount );
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    77
			
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    78
			int curPos = 4 + start;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    79
			int curLength;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    80
			int curType;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    81
			long ssrc;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    82
			boolean endReached = false;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    83
			boolean newPart;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    84
			this.participants = new Participant[itemCount];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    85
			
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    86
			// Loop over SSRC SDES chunks
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    87
			for(int i=0; i< itemCount; i++) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    88
				ssrc = StaticProcs.bytesToUIntLong(aRawPkt, curPos);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    89
				Participant part = partDb.getParticipant(ssrc);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    90
				if(part == null) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    91
					if(RTPSession.rtcpDebugLevel > 1) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    92
						System.out.println("RtcpPktSDES(byte[], ParticipantDabase) adding new participant, ssrc:"+ssrc+" "+socket);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    93
					}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    94
					
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    95
					part = new Participant(socket, socket , ssrc);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    96
					newPart = true;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    97
				} else {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    98
					newPart = false;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
    99
				}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   100
				
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   101
				curPos += 4;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   102
							
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   103
				//System.out.println("PRE endReached " + endReached + " curPos: " + curPos + " length:" + this.length + (!endReached && (curPos/4) < this.length));
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   104
				
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   105
				while(!endReached && (curPos/4) <= this.length) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   106
					//System.out.println("endReached " + endReached + " curPos: " + curPos + " length:" + this.length);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   107
					curType = (int) aRawPkt[curPos];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   108
					
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   109
					if(curType == 0) {	
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   110
						curPos += 4 - (curPos % 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   111
						endReached = true;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   112
					} else {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   113
						curLength  = (int) aRawPkt[curPos + 1];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   114
						//System.out.println("curPos:"+curPos+" curType:"+curType+" curLength:"+curLength+" read from:"+(curPos + 1));
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   115
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   116
						if(curLength > 0) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   117
							byte[] item = new byte[curLength];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   118
							//System.out.println("curPos:"+curPos+" arawPkt.length:"+aRawPkt.length+" curLength:"+curLength);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   119
							System.arraycopy(aRawPkt, curPos + 2, item, 0, curLength);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   120
							
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   121
							switch(curType) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   122
							case 1:  part.cname = new String(item); break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   123
							case 2:  part.name = new String(item); break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   124
							case 3:  part.email = new String(item); break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   125
							case 4:  part.phone = new String(item); break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   126
							case 5:  part.loc = new String(item); break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   127
							case 6:  part.tool = new String(item); break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   128
							case 7:  part.note = new String(item); break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   129
							case 8:  part.priv = new String(item); break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   130
							}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   131
							//System.out.println("TYPE " + curType + " value:" + new String(item) );
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   132
							
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   133
						} else {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   134
							switch(curType) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   135
							case 1:  part.cname = null; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   136
							case 2:  part.name = null; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   137
							case 3:  part.email = null; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   138
							case 4:  part.phone = null; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   139
							case 5:  part.loc = null; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   140
							case 6:  part.tool = null; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   141
							case 7:  part.note = null; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   142
							case 8:  part.priv = null; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   143
							}
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
						curPos = curPos + curLength + 2;
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
				
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   150
				// Save the participant
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   151
				this.participants[i] = part;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   152
				if(newPart)
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   153
					partDb.addParticipant(2,part);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   154
				
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   155
				//System.out.println("HEPPPPPP " + participants[i].cname );
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   156
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   157
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   158
		if(RTPSession.rtcpDebugLevel > 8) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   159
			System.out.println("  <- RtcpPktSDES()");
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   160
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   161
	}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   162
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   163
	/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   164
	 * Encode the packet into a byte[], saved in .rawPkt
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   165
	 * 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   166
	 * CompRtcpPkt will call this automatically
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   167
	 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   168
	protected void encode() {	
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   169
		byte[] temp = new byte[1450];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   170
		byte[] someBytes = StaticProcs.uIntLongToByteWord(this.rtpSession.ssrc);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   171
		System.arraycopy(someBytes, 0, temp, 4, 4);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   172
		int pos = 8;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   173
	
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   174
		String tmpString = null;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   175
		for(int i=1; i<9;i++) {			
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   176
			switch(i) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   177
				case 1:  tmpString = this.rtpSession.cname; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   178
				case 2:  tmpString = this.rtpSession.name; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   179
				case 3:  tmpString = this.rtpSession.email; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   180
				case 4:  tmpString = this.rtpSession.phone; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   181
				case 5:  tmpString = this.rtpSession.loc; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   182
				case 6:  tmpString = this.rtpSession.tool; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   183
				case 7:  tmpString = this.rtpSession.note; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   184
				case 8:  tmpString = this.rtpSession.priv; break;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   185
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   186
			
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   187
			if(tmpString != null) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   188
				someBytes = tmpString.getBytes();
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   189
				temp[pos] = (byte) i;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   190
				temp[pos+1] = (byte) someBytes.length;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   191
				System.arraycopy(someBytes, 0, temp, pos + 2, someBytes.length);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   192
				//System.out.println("i: "+i+" pos:"+pos+" someBytes.length:"+someBytes.length);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   193
				pos = pos + someBytes.length + 2;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   194
				//if(i == 1 ) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   195
				//	System.out.println("trueeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + tmpString);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   196
				//}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   197
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   198
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   199
		int leftover = pos % 4;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   200
		if(leftover == 1) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   201
			temp[pos] = (byte) 0; 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   202
			temp[pos + 1] = (byte) 1; 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   203
			pos += 3;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   204
		} else if(leftover == 2) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   205
			temp[pos] = (byte) 0; 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   206
			temp[pos + 1] = (byte) 0; 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   207
			pos += 2;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   208
		} else if(leftover == 3) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   209
			temp[pos] = (byte) 0; 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   210
			temp[pos + 1] = (byte) 3; 
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   211
			pos += 5;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   212
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   213
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   214
		// TODO Here we ought to loop over participants, if we're doing SDES for other participants.
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   215
		
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   216
		super.rawPkt = new byte[pos];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   217
		itemCount = 1;
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   218
		//This looks wrong, but appears to be fine..
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   219
		System.arraycopy(temp, 0, super.rawPkt, 0, pos);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   220
		writeHeaders();
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   221
	}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   222
	
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   223
	/**
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   224
	 * Debug purposes only
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   225
	 */
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   226
	public void debugPrint() {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   227
		System.out.println("RtcpPktSDES.debugPrint() ");
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   228
		if(participants != null) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   229
			for(int i= 0; i<participants.length; i++) {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   230
				Participant part = participants[i];
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   231
				System.out.println("     part.ssrc: " + part.ssrc + "  part.cname: " + part.cname + " part.loc: " + part.loc);
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   232
			}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   233
		} else {
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   234
			System.out.println("     nothing to report (only valid for received packets)");
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   235
		}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   236
	}
e684f11070d5 ajout de jlibrtp
nikita@nikita-rack
parents:
diff changeset
   237
}