DiscordPHP Documentation

VoicePacket
in package

A voice packet received from Discord.

Huge thanks to Austin and Michael from JDA for the constants and audio packets. Check out their repo: https://github.com/DV8FromTheWorld/JDA

Tags
since
3.2.0

Table of Contents

RTP_HEADER_BYTE_LENGTH  = 12
RTP_PAYLOAD_INDEX  = 1
RTP_PAYLOAD_TYPE  = 0x78
RTP_VERSION_PAD_EXTEND  = 0x80
RTP_VERSION_PAD_EXTEND_INDEX  = 0
SEQ_INDEX  = 2
SSRC_INDEX  = 8
TIMESTAMP_INDEX  = 4
$buffer  : Buffer
The voice packet buffer.
$seq  : int
The packet sequence.
$ssrc  : int
The client SSRC.
$timestamp  : int
The packet timestamp.
__construct()  : mixed
Constructs the voice packet.
__toString()  : string
Handles to string casting of object.
getData()  : string
Returns the data.
getHeader()  : string
Returns the header.
getSequence()  : int
Returns the sequence.
getSSRC()  : int
Returns the SSRC.
getTimestamp()  : int
Returns the timestamp.
make()  : VoicePacket
Creates a voice packet from data sent from Discord.
setBuffer()  : $this
Sets the buffer.
buildHeader()  : Buffer
Builds the header.
initBufferEncryption()  : void
Initilizes the buffer with encryption.
initBufferNoEncryption()  : void
Initilizes the buffer with no encryption.

Constants

RTP_HEADER_BYTE_LENGTH

public mixed RTP_HEADER_BYTE_LENGTH = 12

RTP_PAYLOAD_INDEX

public mixed RTP_PAYLOAD_INDEX = 1

RTP_PAYLOAD_TYPE

public mixed RTP_PAYLOAD_TYPE = 0x78

RTP_VERSION_PAD_EXTEND

public mixed RTP_VERSION_PAD_EXTEND = 0x80

RTP_VERSION_PAD_EXTEND_INDEX

public mixed RTP_VERSION_PAD_EXTEND_INDEX = 0

Properties

$seq

The packet sequence.

protected int $seq

The packet sequence.

$ssrc

The client SSRC.

protected int $ssrc

The client SSRC.

$timestamp

The packet timestamp.

protected int $timestamp

The packet timestamp.

Methods

__construct()

Constructs the voice packet.

public __construct(string $data, int $ssrc, int $seq, int $timestamp[, bool $encryption = false ][, string|null $key = null ]) : mixed
Parameters
$data : string

The Opus data to encode.

$ssrc : int

The client SSRC value.

$seq : int

The packet sequence.

$timestamp : int

The packet timestamp.

$encryption : bool = false

Whether the packet should be encrypted.

$key : string|null = null

The encryption key.

Return values
mixed

__toString()

Handles to string casting of object.

public __toString() : string
Return values
string

getData()

Returns the data.

public getData() : string
Return values
string

The packet data.

getHeader()

Returns the header.

public getHeader() : string
Return values
string

The packet header.

getSequence()

Returns the sequence.

public getSequence() : int
Return values
int

The packet sequence.

getSSRC()

Returns the SSRC.

public getSSRC() : int
Return values
int

The packet SSRC.

getTimestamp()

Returns the timestamp.

public getTimestamp() : int
Return values
int

The packet timestamp.

make()

Creates a voice packet from data sent from Discord.

public static make(string $data) : VoicePacket
Parameters
$data : string

Data from Discord.

Return values
VoicePacket

A voice packet.

setBuffer()

Sets the buffer.

public setBuffer(Buffer $buffer) : $this
Parameters
$buffer : Buffer

The buffer to set.

Return values
$this

initBufferEncryption()

Initilizes the buffer with encryption.

protected initBufferEncryption(string $data, string $key) : void
Parameters
$data : string

The Opus data to encode.

$key : string

The encryption key.

Return values
void

initBufferNoEncryption()

Initilizes the buffer with no encryption.

protected initBufferNoEncryption(string $data) : void
Parameters
$data : string

The Opus data to encode.

Return values
void

Search results