TsgcTURNClientMethods › SendChannelData

SendChannelData Method

Sends a datagram to a peer using a bound channel, producing a smaller ChannelData message.

Overloads

Overload 1

Syntax

procedure SendChannelData(const aChannelID: Word; const aData: string);

Parameters

NameTypeDescription
aChannelIDconst WordChannel number previously assigned by a successful ChannelBind (range 0x4000-0x7FFF).
aDataconst stringText payload to relay; converted to UTF-8 bytes before being framed as ChannelData.

Remarks

Sends a ChannelData message (RFC 5766 section 11.5). The 4-byte ChannelData header (2 bytes channel + 2 bytes length) is much smaller than the 36+ byte SEND Indication header, which makes channels the preferred option for high-rate media such as RTP or DTLS.

Example

oTURN.ChannelBind('203.0.113.25', 49200);
// Once OnTURNChannelBind fires with the assigned channel id:
oTURN.SendChannelData($4000, 'hello');

Overload 2

Syntax

procedure SendChannelData(const aChannelID: Word; const aData: TBytes);

Parameters

NameTypeDescription
aChannelIDconst WordChannel number previously assigned by a successful ChannelBind.
aDataconst TBytesRaw byte payload to relay; used verbatim inside the ChannelData frame.

Remarks

Binary-payload variant of ChannelData. Use this overload for media packets or any content where a text encoding round-trip would corrupt the data. The payload is padded to a 4-byte boundary on the wire as required by RFC 5766.

Example

var
  vRTP: TBytes;
begin
  // vRTP holds a serialized RTP packet.
  oTURN.SendChannelData($4000, vRTP);
end;

Back to Methods