ExSRTP.Backend behaviour (ExSRTP v0.4.1)

View Source

The behaviour or SRTP backends.

Summary

Callbacks

Initializes the SRTP backend state based on the given policy.

Protects an RTP packet, returning the protected binary and updated state.

Protects an RTCP compound packet, returning the protected binary and updated state.

Unprotects a protected RTP packet, returning the unprotected packet and updated state.

Unprotects a protected RTCP compound packet, returning the unprotected packets and updated state.

Types

protect_return()

@type protect_return() :: {:ok, iodata(), state()} | {:error, term()}

state()

@type state() :: term()

Callbacks

init(t)

@callback init(ExSRTP.Policy.t()) :: {:ok, state()} | {:error, term()}

Initializes the SRTP backend state based on the given policy.

protect(t, state)

@callback protect(ExRTP.Packet.t(), state()) :: protect_return()

Protects an RTP packet, returning the protected binary and updated state.

protect_rtcp(list, state)

@callback protect_rtcp([ExRTCP.Packet.packet()], state()) :: protect_return()

Protects an RTCP compound packet, returning the protected binary and updated state.

unprotect(binary, state)

@callback unprotect(binary(), state()) ::
  {:ok, ExRTP.Packet.t(), state()} | {:error, term()}

Unprotects a protected RTP packet, returning the unprotected packet and updated state.

unprotect_rtcp(binary, state)

@callback unprotect_rtcp(binary(), state()) ::
  {:ok, [ExRTCP.Packet.packet()], state()} | {:error, term()}

Unprotects a protected RTCP compound packet, returning the unprotected packets and updated state.