webrtc_turn_stream (webrtc v0.1.0)

View Source

Framing of TURN over a stream transport (TCP, TLS over TCP, RFC 8656 §3.1, §12.5): the messages on the stream are STUN messages and ChannelData, each self-delimiting, ChannelData padded to a multiple of four bytes.

  {ok, Messages, Rest} = webrtc_turn_stream:split(<<Buffer/binary, Received/binary>>)

Messages are complete STUN messages and ChannelData frames (with their padding removed), in order; Rest is the start of the next one. Bytes that start neither a STUN message nor ChannelData mean the stream is out of step: {error, bad_frame}, the connection must be closed (§3.1). Rest never exceeds one maximum size message. Messages sent on the stream need no extra framing: webrtc_turn_channel:encode/2 already pads ChannelData.

Summary

Functions

split(Buf)

-spec split(binary()) -> {ok, [binary()], binary()} | {error, bad_frame}.