MediaFramesnamespace
The MediaFrames namespace of detritus-client-socket.
On this page
import { MediaFrames } from 'detritus-client-socket';Classes
Classes you create or receive from the library.
Interfaces
Object shapes for options, payloads and events.
Enums
Named constants.
Functions
Standalone helpers.
depacketize()
function src/mediaframes.ts:263function depacketize(codec: string, payload: Buffer): DepacketizedPayload | nulldepacketizeH264()
function src/mediaframes.ts:204function depacketizeH264(payload: Buffer): DepacketizedPayload | nullRFC 6184 Section 5.6 - 5.8, single nal units, STAP-A and FU-A (the only modes discord uses) Returns the packet's nal units as annex b
depacketizeVP8()
function src/mediaframes.ts:88function depacketizeVP8(payload: Buffer): DepacketizedPayload | nullRFC 7741 Section 4.2
depacketizeVP9()
function src/mediaframes.ts:134function depacketizeVP9(payload: Buffer): DepacketizedPayload | nullRFC 9628 Section 4.2
isKeyframe()
function src/mediaframes.ts:285function isKeyframe(codec: string, frame: Buffer): booleanIf an encoded frame is a keyframe, works on e2e encrypted frames too (DAVE leaves these bytes unencrypted)
isSequenceNewer()
function src/mediaframes.ts:79function isSequenceNewer(a: number, b: number): booleanIf b comes after a, anything more than half the sequence space ahead is treated as behind
packetize()
function src/mediaframes.ts:387function packetize(
codec: string,
frame: Buffer,
options: PacketizeOptions,
): Buffer<ArrayBufferLike>[]Splits an encoded frame into rtp payloads, the inverse of depacketize
packetizeH264()
function src/mediaframes.ts:364function packetizeH264(frame: Buffer): Buffer<ArrayBufferLike>[]RFC 6184 Section 5.6/5.8, a single nal unit per packet when it fits, FU-A fragments when it doesn't. Takes annex b
packetizeVP8()
function src/mediaframes.ts:304function packetizeVP8(frame: Buffer, options: PacketizeOptions): Buffer<ArrayBufferLike>[]RFC 7741 Section 4.2, X=1 | S on a frame's first packet, I=1, then M=1 and a 15 bit picture id
packetizeVP9()
function src/mediaframes.ts:322function packetizeVP9(frame: Buffer, options: PacketizeOptions): Buffer<ArrayBufferLike>[]RFC 9628 Section 4.2, non-flexible mode without layers, I=1 | P on inter frames | B on the first packet | E on the last
sequenceDistance()
function src/mediaframes.ts:72function sequenceDistance(a: number, b: number): numberHow far b is ahead of a, 16-bit rtp sequence numbers wrap around
splitAnnexB()
function src/mediaframes.ts:339function splitAnnexB(frame: Buffer): Buffer<ArrayBufferLike>[]An annex b frame's nal units, without their start codes (3 or 4 bytes)
Variables
Exported values.
MAX_PAYLOAD_LENGTH
variable const src/mediaframes.ts:274const MAX_PAYLOAD_LENGTH: 1100 = 1100