Skip to main content

4.1.8. createOffer

4.1.8. createOffer

The createOffer method generates a blob of SDP that contains an offer per [RFC3264] with the supported configurations for the session, including descriptions of the media added to this PeerConnection, the codec, RTP, and RTCP options supported by this implementation, and any candidates that have been gathered by the ICE agent. An options parameter may be supplied to provide additional control over the generated offer. This options parameter allows an application to trigger an ICE restart, for the purpose of reestablishing connectivity.

In the initial offer, the generated SDP will contain all desired functionality for the session (functionality that is supported but not desired by default may be omitted); for each SDP line, the generation of the SDP will follow the process defined for generating an initial offer from the specification that defines the given SDP line. The exact handling of initial offer generation is detailed in Section 5.2.1 below.

In the event createOffer is called after the session is established, createOffer will generate an offer to modify the current session based on any changes that have been made to the session, e.g., adding or stopping RtpTransceivers, or requesting an ICE restart. For each existing stream, the generation of each SDP line MUST follow the process defined for generating an updated offer from the RFC that specifies the given SDP line. For each new stream, the generation of the SDP MUST follow the process of generating an initial offer, as mentioned above. If no changes have been made, or for SDP lines that are unaffected by the requested changes, the offer will only contain the parameters negotiated by the last offer/answer exchange. The exact handling of subsequent offer generation is detailed in Section 5.2.2 below.

Session descriptions generated by createOffer MUST be immediately usable by setLocalDescription; if a system has limited resources (e.g., a finite number of decoders), createOffer SHOULD return an offer that reflects the current state of the system, so that setLocalDescription will succeed when it attempts to acquire those resources.

Calling this method may do things such as generating new ICE credentials, but it does not change the PeerConnection state, trigger candidate gathering, or cause media to start or stop flowing. Specifically, the offer is not applied, and does not become the pending local description, until setLocalDescription is called.