WebRTC Video Chat 1.1.4
Loading...
Searching...
No Matches
Byn.Awrtc.ByteArrayBuffer Class Reference

This class is used to wrap a byte[] of any size and use it as a fixed size buffer. Main goal is to reuse byte[] objects multiple times as the automatic garbage collection of byte[] can cause unity games to stall or reduce framerate. More...

Inheritance diagram for Byn.Awrtc.ByteArrayBuffer:
Byn.Awrtc.MessageDataBuffer

Public Member Functions

 ByteArrayBuffer (byte[] arr)
 Creates a byte buffer without using the global bool / without reusing an existing byte[].
 
 ByteArrayBuffer (byte[] arr, int offset, int length)
 Creates a byte buffer without using the global bool / without reusing an existing byte[].
 
void CopyFrom (byte[] arr, int srcOffset, int len)
 Copies the data into the buffer. Offset and length are assumed to fit.
 
void Dispose ()
 Returns the buffer back to its pool if it was created via Get.
 

Static Public Member Functions

static ByteArrayBuffer Get (int size, bool enforceZeroOffset=false)
 Allocates a new buffer. It won't use the exact size but often a larger one to be able to reuse it later efficiently. Call Dispose after being done with the buffer.
 

Public Attributes

byte[] array
 Array used by this buffer.
 

Static Public Attributes

static bool LOG_GC_CALLS = false
 Debugging flag only.
 

Properties

int PositionWriteRelative [get, set]
 Used to keep track of the "end" position / length of the content in this buffer.
 
int PositionWriteAbsolute [get, set]
 Length + Offset of the buffer.
 
int PositionReadRelative [get]
 Keeps track of the current read position / length (relative to the offset)
 
int PositionReadAbsolute [get]
 Index of the read position starting on array[0] not array[offset].
 
int Offset [get]
 Offset of the content in this buffer. Can be used to truncate leading bytes without having to reallocate the whole byte array (not yet used. Always 0. This might change if more optimization is needed for some C# / C++ interaction)
 
byte[] Buffer [get]
 Returns a reference to the internal buffer.
 
int ContentLength [get, set]
 Length of the content in the buffer. Samme as PositionWriteRelative but used for MessageDataBuffer interface.
 
bool IsDisposed [get]
 Checks if the buffer was disposed. For debugging.
 

Detailed Description

This class is used to wrap a byte[] of any size and use it as a fixed size buffer. Main goal is to reuse byte[] objects multiple times as the automatic garbage collection of byte[] can cause unity games to stall or reduce framerate.

Watch out this class is being used to help with C# / C++ interaction and allow direct pointer access to the byte[]. Changes can easily cause crashes or very difficult to debug memory errors on different platforms.

Constructor & Destructor Documentation

◆ ByteArrayBuffer() [1/2]

Byn.Awrtc.ByteArrayBuffer.ByteArrayBuffer ( byte[] arr)

Creates a byte buffer without using the global bool / without reusing an existing byte[].

Parameters
arr

◆ ByteArrayBuffer() [2/2]

Byn.Awrtc.ByteArrayBuffer.ByteArrayBuffer ( byte[] arr,
int offset,
int length )

Creates a byte buffer without using the global bool / without reusing an existing byte[].

Parameters
arr
offset
length

Member Function Documentation

◆ CopyFrom()

void Byn.Awrtc.ByteArrayBuffer.CopyFrom ( byte[] arr,
int srcOffset,
int len )

Copies the data into the buffer. Offset and length are assumed to fit.

Parameters
arr
srcOffset
len

◆ Get()

static ByteArrayBuffer Byn.Awrtc.ByteArrayBuffer.Get ( int size,
bool enforceZeroOffset = false )
static

Allocates a new buffer. It won't use the exact size but often a larger one to be able to reuse it later efficiently. Call Dispose after being done with the buffer.

Parameters
size
enforceZeroOffset
Returns

Property Documentation

◆ Buffer

byte [] Byn.Awrtc.ByteArrayBuffer.Buffer
get

Returns a reference to the internal buffer.

Implements Byn.Awrtc.MessageDataBuffer.

◆ ContentLength

int Byn.Awrtc.ByteArrayBuffer.ContentLength
getset

Length of the content in the buffer. Samme as PositionWriteRelative but used for MessageDataBuffer interface.

Implements Byn.Awrtc.MessageDataBuffer.

◆ Offset

int Byn.Awrtc.ByteArrayBuffer.Offset
get

Offset of the content in this buffer. Can be used to truncate leading bytes without having to reallocate the whole byte array (not yet used. Always 0. This might change if more optimization is needed for some C# / C++ interaction)

Implements Byn.Awrtc.MessageDataBuffer.


The documentation for this class was generated from the following file: