Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.transform.zrtp
Class ZrtpRawPacket

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.RawPacket
      extended by net.java.sip.communicator.impl.neomedia.transform.zrtp.ZrtpRawPacket

public class ZrtpRawPacket
extends RawPacket

ZRTP packet representation. This class extends the RawPacket class and adds some methods required by the ZRTP transformer.

Author:
Werner Dittmann

Field Summary
static byte[] zrtpMagic
          Each ZRTP packet contains this magic number.
 
Fields inherited from class net.java.sip.communicator.impl.neomedia.RawPacket
EXT_HEADER_SIZE, FIXED_HEADER_SIZE
 
Constructor Summary
ZrtpRawPacket(byte[] buf, int off, int len)
          Construct an output ZrtpRawPacket using specified value.
ZrtpRawPacket(RawPacket pkt)
          Construct an input ZrtpRawPacket using a received RTP raw packet.
 
Method Summary
protected  boolean checkCrc()
          Check if the CRC of this packet is ok.
protected  boolean hasMagic()
          Check if it is really a ZRTP packet.
(package private) static boolean isZrtpData(RawPacket pkt)
          Checks whether extension bit is set and if so is the extension header an zrtp one.
protected  boolean isZrtpPacket()
          Check if it could be a ZRTP packet.
protected  void setCrc()
          Set ZRTP CRC in this packet
protected  void setSeqNum(short seq)
          Set the sequence number in this packet.
protected  void setSSRC(int ssrc)
          Set SSRC in this packet
 
Methods inherited from class net.java.sip.communicator.impl.neomedia.RawPacket
addExtension, append, extractCsrcLevels, extractCsrcList, getBuffer, getCsrcCount, getExtensionBit, getExtensionLength, getHeaderExtensionType, getHeaderLength, getLength, getOffset, getPaddingSize, getPayload, getPayloadLength, getPayloadType, GetRTCPSSRC, getSequenceNumber, getSRTCPIndex, getSSRC, getTimestamp, grow, isPacketMarked, readByte, readInt, readRegion, readRegionToBuff, readShort, readTimeStampIntoByteArray, readUnsignedIntAsLong, readUnsignedShortAsInt, removeExtension, setBuffer, setCsrcList, setLength, setMarker, setOffset, setPayload, setTimestamp, shrink, writeByte, writeInt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

zrtpMagic

public static byte[] zrtpMagic
Each ZRTP packet contains this magic number.

Constructor Detail

ZrtpRawPacket

public ZrtpRawPacket(RawPacket pkt)
Construct an input ZrtpRawPacket using a received RTP raw packet.

Parameters:
pkt - a raw RTP packet as received

ZrtpRawPacket

public ZrtpRawPacket(byte[] buf,
                     int off,
                     int len)
Construct an output ZrtpRawPacket using specified value. Initialize this packet and set the ZRTP magic value to mark it as a ZRTP packet.

Parameters:
buf - Byte array holding the content of this Packet
off - Start offset of packet content inside buffer
len - Length of the packet's data
Method Detail

isZrtpPacket

protected boolean isZrtpPacket()
Check if it could be a ZRTP packet. The method checks if the first byte of the received data matches the defined ZRTP pattern 0x10

Returns:
true if could be a ZRTP packet, false otherwise.

isZrtpData

static boolean isZrtpData(RawPacket pkt)
Checks whether extension bit is set and if so is the extension header an zrtp one.

Parameters:
pkt - the packet to check.
Returns:
true if data is zrtp packet.

hasMagic

protected boolean hasMagic()
Check if it is really a ZRTP packet. The method checks if the packet contains the ZRTP magic number.

Returns:
true if packet contains the magic number, false otherwise.

setSeqNum

protected void setSeqNum(short seq)
Set the sequence number in this packet.

Parameters:
seq - sequence number

setSSRC

protected void setSSRC(int ssrc)
Set SSRC in this packet

Parameters:
ssrc - SSRC to set

checkCrc

protected boolean checkCrc()
Check if the CRC of this packet is ok.

Returns:
true if the CRC is valid, false otherwise

setCrc

protected void setCrc()
Set ZRTP CRC in this packet


Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.