@UnstableApi
class RtpPacket


Represents the header and the payload of an RTP packet.

Not supported parsing at the moment: header extension and CSRC.

Structure of an RTP header (RFC3550, Section 5.1).

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P|X|  CC   |M|     PT      |       sequence number         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           timestamp                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           synchronization source (SSRC) identifier            |
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
|            contributing source (CSRC) identifiers             |
|                             ....                              |
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
| Profile-specific extension ID |   Extension header length     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Extension header                        |
|                             ....                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   3                   2                   1
 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0

Summary

Nested types

Builder class for an RtpPacket

Constants

const Int
const Int
const Int
MAX_SIZE = 65507
const Int
const Int
const Int

Public functions

Boolean
equals(o: Any?)
java-static Int
getNextSequenceNumber(sequenceNumber: Int)

Returns the next sequence number of the sequenceNumber.

java-static Int
getPreviousSequenceNumber(sequenceNumber: Int)

Returns the previous sequence number from the sequenceNumber.

Int
java-static RtpPacket?
parse(packetBuffer: ParsableByteArray!)

Creates an RtpPacket from a ParsableByteArray.

java-static RtpPacket?
parse(buffer: ByteArray!, length: Int)

Creates an RtpPacket from a byte array.

String!
Int
writeToBuffer(target: ByteArray!, offset: Int, length: Int)

Writes the data in an RTP packet to a target buffer.

Public properties

ByteArray<Byte>!

The RTP CSRC fields (Optional, up to 15 items).

Byte

The RTP CSRC count field (Word 0, bits 4-7).

Boolean

The RTP extension bit (Word 0, bit 3).

Boolean

The RTP marker bit (Word 0, bit 8).

Boolean

The RTP padding bit (Word 0, bit 2).

ByteArray<Byte>!
Byte

The RTP CSRC count field (Word 0, bits 9-15).

Int

The RTP sequence number field (Word 0, bits 16-31).

Int

The RTP SSRC field (Word 2).

Long

The RTP timestamp field (Word 1).

Byte

The RTP version field (Word 0, bits 0-1), should always be 2.

Constants

CSRC_SIZE

const val CSRC_SIZE = 4: Int

MAX_SEQUENCE_NUMBER

const val MAX_SEQUENCE_NUMBER = 65535: Int

MAX_SIZE

const val MAX_SIZE = 65507: Int

MIN_HEADER_SIZE

const val MIN_HEADER_SIZE = 12: Int

MIN_SEQUENCE_NUMBER

const val MIN_SEQUENCE_NUMBER = 0: Int

RTP_VERSION

const val RTP_VERSION = 2: Int

Public functions

equals

fun equals(o: Any?): Boolean

getNextSequenceNumber

java-static fun getNextSequenceNumber(sequenceNumber: Int): Int

Returns the next sequence number of the sequenceNumber.

getPreviousSequenceNumber

java-static fun getPreviousSequenceNumber(sequenceNumber: Int): Int

Returns the previous sequence number from the sequenceNumber.

hashCode

fun hashCode(): Int

parse

java-static fun parse(packetBuffer: ParsableByteArray!): RtpPacket?

Creates an RtpPacket from a ParsableByteArray.

Parameters
packetBuffer: ParsableByteArray!

The buffer that contains the RTP packet data.

Returns
RtpPacket?

The built RtpPacket.

parse

java-static fun parse(buffer: ByteArray!, length: Int): RtpPacket?

Creates an RtpPacket from a byte array.

Parameters
buffer: ByteArray!

The buffer that contains the RTP packet data.

length: Int

The length of the RTP packet.

Returns
RtpPacket?

The built RtpPacket.

toString

fun toString(): String!

writeToBuffer

fun writeToBuffer(target: ByteArray!, offset: Int, length: Int): Int

Writes the data in an RTP packet to a target buffer.

The size of the target buffer and the length argument should be big enough so that the entire RTP packet could fit. That is, if there is not enough space to store the entire RTP packet, no bytes will be written. The maximum size of an RTP packet is defined as MAX_SIZE.

Parameters
target: ByteArray!

A target byte buffer to which the packet data is copied.

offset: Int

The offset into the target array at which to write.

length: Int

The maximum number of bytes that can be written.

Returns
Int

The number of bytes written, or LENGTH_UNSET if there is not enough space to write the packet.

Public properties

csrc

val csrcByteArray<Byte>!

The RTP CSRC fields (Optional, up to 15 items).

csrcCount

val csrcCountByte

The RTP CSRC count field (Word 0, bits 4-7).

extension

val extensionBoolean

The RTP extension bit (Word 0, bit 3).

marker

val markerBoolean

The RTP marker bit (Word 0, bit 8).

padding

val paddingBoolean

The RTP padding bit (Word 0, bit 2).

payloadData

val payloadDataByteArray<Byte>!

payloadType

val payloadTypeByte

The RTP CSRC count field (Word 0, bits 9-15).

sequenceNumber

val sequenceNumberInt

The RTP sequence number field (Word 0, bits 16-31).

ssrc

val ssrcInt

The RTP SSRC field (Word 2).

timestamp

val timestampLong

The RTP timestamp field (Word 1).

version

val versionByte

The RTP version field (Word 0, bits 0-1), should always be 2.