You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
971 B

package com.inspect.tcpserver.sip.stream;
public class RtpPacket {
public static final int HEADER_SIZE = 12;
public byte[] buffer;
public int length;
public RtpPacket(int payloadSize) {
buffer = new byte[HEADER_SIZE + payloadSize];
}
public void setHeader(
int payloadType,
int seq,
long timestamp,
int ssrc,
boolean marker
) {
buffer[0] = (byte) 0x80;
buffer[1] = (byte) (payloadType & 0x7F);
if (marker) buffer[1] |= 0x80;
buffer[2] = (byte) (seq >> 8);
buffer[3] = (byte) (seq);
buffer[4] = (byte) (timestamp >> 24);
buffer[5] = (byte) (timestamp >> 16);
buffer[6] = (byte) (timestamp >> 8);
buffer[7] = (byte) (timestamp);
buffer[8] = (byte) (ssrc >> 24);
buffer[9] = (byte) (ssrc >> 16);
buffer[10] = (byte) (ssrc >> 8);
buffer[11] = (byte) (ssrc);
}
}