savant_rs.utils.serialization

class savant_rs.utils.serialization.Message
as_end_of_stream()

Returns the message as EndOfStream type

Returns:

as_shutdown()

Returns the message as Shutdown type

Returns:

The message as Shutdown type

Return type:

py:class:savant_rs.primitives.Shutdown

as_unknown()

Returns the message as Unknown type

Returns:

  • str – The message as Unknown type

  • None – If the message is not of Unknown type

as_user_data()

Returns the message as Telemetry type

Returns:

  • savant_rs.primitives.Telemetry – The message as Telemetry type

  • None – If the message is not of Telemetry type

as_video_frame()

Returns the message as VideoFrame type

Returns:

as_video_frame_batch()

Returns the message as VideoFrameBatch type

Returns:

as_video_frame_update()

Returns the message as VideoFrameUpdate type

Returns:

static end_of_stream(eos)

Create a new end of stream message

Parameters:

eos (savant_rs.primitives.EndOfStream) – The end of stream message

Returns:

The message of EndOfStream type

Return type:

savant_rs.utils.serialization.Message

is_end_of_stream()

Checks if the message is of EndOfStream type

Returns:

True if the message is of EndOfStream type, False otherwise

Return type:

bool

is_shutdown()

Checks if the message is of Shutdown type

Returns:

True if the message is of Shutdown type, False otherwise

Return type:

bool

is_unknown()

Checks if the message is of Unknown type

Returns:

True if the message is of Unknown type, False otherwise

Return type:

bool

is_user_data()

Checks if the message is of Telemetry type

Returns:

True if the message is of Telemetry type, False otherwise

Return type:

bool

is_video_frame()

Checks if the message is of VideoFrame type

Returns:

True if the message is of VideoFrame type, False otherwise

Return type:

bool

is_video_frame_batch()

Checks if the message is of VideoFrameBatch type

Returns:

True if the message is of VideoFrameBatch type, False otherwise

Return type:

bool

is_video_frame_update()

Checks if the message is of VideoFrameUpdate type

Returns:

True if the message is of VideoFrameUpdate type, False otherwise

Return type:

bool

labels
static shutdown(shutdown)

Create a new shutdown message

Parameters:

shutdown (savant_rs.primitives.Shutdown) – The shutdown message

Returns:

The message of Shutdown type

Return type:

py:class:savant_rs.utils.serialization.Message

span_context
static unknown(s)

Create a new undefined message

Parameters:

s (str) – The message text

Returns:

The message of Unknown type

Return type:

savant_rs.utils.serialization.Message

static user_data(data)

Create a new unspecified message

Parameters:

t (savant_rs.primitives.UserData) – The unspecified message

Returns:

The message of EndOfStream type

Return type:

py:class:savant_rs.utils.serialization.Message

validate_seq_id()

Allows validating the sequence id of the message

Returns:

True if the sequence id is valid, False otherwise

Return type:

bool

static video_frame(frame)

Create a new video frame message

Parameters:

frame (savant_rs.primitives.VideoFrame) – The video frame

Returns:

The message of VideoFrame type

Return type:

savant_rs.utils.serialization.Message

static video_frame_batch(batch)

Create a new video frame batch message

Parameters:

batch (savant_rs.primitives.VideoFrameBatch) – The video frame batch

Returns:

The message of VideoFrameBatch type

Return type:

savant_rs.utils.serialization.Message

static video_frame_update(update)

Create a new video frame update message

Parameters:

update (savant_rs.primitives.VideoFrameUpdate) – The update struct

Returns:

The message of VideoFrameUpdate type

Return type:

savant_rs.utils.serialization.Message

savant_rs.utils.serialization.clear_source_seq_id(source)
savant_rs.utils.serialization.load_message(bytes, no_gil=True)

Loads a message from a byte array. The function is optionally GIL-free.

Parameters:
  • bytes (bytes) – The byte array to load the message from.

  • no_gil (bool) – Whether to release the GIL while loading the message.

Returns:

The loaded message.

Return type:

savant_rs.primitives.Message

savant_rs.utils.serialization.load_message_from_bytebuffer(buffer, no_gil=True)

Loads a message from a savant_rs.utils.ByteBuffer. The function is GIL-free.

Parameters:

bytes (savant_rs.utils.ByteBuffer) – The byte array to load the message from.

Returns:

The loaded message.

Return type:

savant_rs.primitives.Message

savant_rs.utils.serialization.load_message_from_bytes(buffer, no_gil=True)

Loads a message from a python bytes. The function is optionally GIL-free.

Parameters:
  • bytes (bytes) – The byte buffer to load the message from.

  • no_gil (bool) – Whether to release the GIL while loading the message.

Returns:

The loaded message.

Return type:

savant_rs.primitives.Message

savant_rs.utils.serialization.save_message(message, no_gil=True)

Save a message to a byte array. The function is optionally GIL-free.

Parameters:
  • message (savant_rs.primitives.Message) – The message to save

  • no_gil (bool) – Whether to release the GIL while saving the message

Returns:

The byte array containing the message

Return type:

bytes

savant_rs.utils.serialization.save_message_to_bytebuffer(message, with_hash=True, no_gil=True)

Save a message to a byte array. The function is optionally GIL-free.

Parameters:
  • message (savant_rs.primitives.Message) – The message to save

  • with_hash (bool) – Whether to include a hash of the message in the returned byte buffer

  • no_gil (bool) – Whether to release the GIL while saving the message

Returns:

The byte buffer containing the message

Return type:

ByteBuffer

savant_rs.utils.serialization.save_message_to_bytes(message, no_gil=True)

Save a message to python bytes. The function is optionally GIL-free.

Parameters:
  • message (savant_rs.primitives.Message) – The message to save

  • no_gil (bool) – Whether to release the GIL while saving the message

Returns:

The byte buffer containing the message

Return type:

bytes