Home

setLocalDescription

setLocalDescription is a method of the RTCPeerConnection interface in the WebRTC API. It sets the local session description for the connection, typically an SDP offer or answer produced by createOffer or createAnswer. The local description defines the parameters for the local endpoint and is used during signaling to negotiate media capabilities with the remote peer.

Usage generally follows the offer/answer flow. You create an offer with createOffer, then set it as the

The call is asynchronous. In modern browsers it returns a Promise that resolves once the local description

The description argument is an RTCSessionDescriptionInit (or RTCSessionDescription) object and must include a type ('offer' or

See also: setRemoteDescription, createOffer, createAnswer, RTCPeerConnection.

local
description
with
setLocalDescription,
and
send
the
offer
to
the
remote
peer
via
your
signaling
channel.
The
remote
peer
applies
the
offer
with
setRemoteDescription
and
may
reply
with
an
answer,
which
you
apply
using
setRemoteDescription.
The
actual
transmission
of
the
local
description
to
the
remote
party
is
handled
by
your
signaling
layer;
setLocalDescription
itself
does
not
send
data
over
the
network.
has
been
installed,
and
it
can
reject
with
errors
such
as
InvalidStateError
if
the
connection
is
closed
or
not
in
a
suitable
state.
Using
asynchronous
syntax,
for
example:
const
offer
=
await
pc.createOffer();
await
pc.setLocalDescription(offer).
'answer')
and
an
sdp
string.
Setting
the
local
description
may
affect
the
connection’s
signalingState
and
can
trigger
negotiation-needed
events
depending
on
the
browser’s
implementation
and
current
state.