RtpPacket
@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 |
|---|
class RtpPacket.BuilderBuilder class for an |
Constants |
|
|---|---|
const Int |
CSRC_SIZE = 4 |
const Int |
MAX_SEQUENCE_NUMBER = 65535 |
const Int |
MAX_SIZE = 65507 |
const Int |
MIN_HEADER_SIZE = 12 |
const Int |
|
const Int |
RTP_VERSION = 2 |
Public functions |
|
|---|---|
Boolean |
|
java-static Int |
getNextSequenceNumber(sequenceNumber: Int)Returns the next sequence number of the |
java-static Int |
getPreviousSequenceNumber(sequenceNumber: Int)Returns the previous sequence number from the |
Int |
hashCode() |
java-static RtpPacket? |
parse(packetBuffer: ParsableByteArray!)Creates an |
java-static RtpPacket? |
Creates an |
String! |
toString() |
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
Public functions
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.
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. |
parse
java-static fun parse(buffer: ByteArray!, length: Int): RtpPacket?
Creates an RtpPacket from a byte array.
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 |