Skip to content

Commit

Permalink
fix: Add missing documentation for RTCSessionDescriptionInit, RTCLoca…
Browse files Browse the repository at this point in the history
…lSessionDescriptionInit

Add missing documentation for RTCSessionDescriptionInit,
RTCLocalSessionDescriptionInit interfaces. Also correct several links
referencing those interfaces. Also add a clear explanation of the
relationship between RTCSessionDescription, RTCSessionDescriptionInit,
and RTCLocalSessionDescriptionInit interfaces.

Fixes mdn#33962
  • Loading branch information
bc-lee committed Jun 6, 2024
1 parent a80ebc0 commit 64eec53
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 10 deletions.
29 changes: 29 additions & 0 deletions files/en-us/web/api/rtclocalsessiondescriptioninit/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: RTCLocalSessionDescriptionInit
slug: Web/API/RTCLocalSessionDescriptionInit
page-type: web-api-interface
browser-compat: api.RTCSessionDescription
---

{{APIRef("WebRTC")}}

The **`RTCLocalSessionDescriptionInit`** dictionary is used to provide {{Glossary("SDP")}} values in {{domxref("RTCPeerConnection.setLocalDescription")}}. Especially, empty object(`{}`) conforms the `RTCLocalSessionDescriptionInit` dictionary.

### Properties

- `type`
- : A string which is used to set the `type` property of the new `RTCSessionDescription` object. For more information, see documentation for the {{domxref("RTCSessionDescription.type")}} property.
- `sdp`
- : A string containing the {{Glossary("SDP")}} describing the session. If `type` is `"rollback"`, this member is unused.


## Specifications

https://w3c.github.io/webrtc-pc/#dom-rtclocalsessiondescriptioninit

## See also

- [WebRTC](/en-US/docs/Web/API/WebRTC_API)
- {{domxref("RTCSessionDescription")}}
- {{domxref("RTCSessionDescriptionInit")}}
- {{domxref("RTCPeerConnection.setLocalDescription")}}
4 changes: 2 additions & 2 deletions files/en-us/web/api/rtcpeerconnection/createoffer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The parameters for the older form of `createOffer()` are described below, to aid

### Return value

A {{jsxref("Promise")}} whose fulfillment handler will receive an object conforming to the [RTCSessionDescriptionInit](/en-US/docs/Web/API/RTCSessionDescription/RTCSessionDescription#rtcsessiondescriptioninit) dictionary which contains the SDP describing the generated offer.
A {{jsxref("Promise")}} whose fulfillment handler will receive an object conforming to the {{domxref("RTCSessionDescriptionInit")}} dictionary which contains the SDP describing the generated offer.
That received offer should be delivered through the signaling server to a remote peer.

### Exceptions
Expand Down Expand Up @@ -98,7 +98,7 @@ myPeerConnection
});
```

In this code, the offer is created, and once successful, the local end of the {{domxref("RTCPeerConnection")}} is configured to match by passing the offer (which is represented using an object conforming to [RTCSessionDescriptionInit](/en-US/docs/Web/API/RTCSessionDescription/RTCSessionDescription#rtcsessiondescriptioninit)) into {{domxref("RTCPeerConnection.setLocalDescription", "setLocalDescription()")}}.
In this code, the offer is created, and once successful, the local end of the {{domxref("RTCPeerConnection")}} is configured to match by passing the offer (which is represented using an object conforming to {{domxref("RTCSessionDescriptionInit")}} into {{domxref("RTCPeerConnection.setLocalDescription", "setLocalDescription()")}}.
Once that's done, the offer is sent to the remote system over the signaling channel; in this case, by using a custom function called `sendToServer()`.
The implementation of the signaling server is independent from the WebRTC specification, so it doesn't matter how the offer is sent as long as both the caller and potential receiver are using the same one.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ setLocalDescription(sessionDescription, successCallback, errorCallback) // depre
### Parameters

- `sessionDescription` {{optional_inline}}
- : An {{domxref("RTCSessionDescriptionInit")}} or {{domxref("RTCSessionDescription")}} which specifies the configuration to be applied to the local end of the connection.
- : An {{domxref("RTCLocalSessionDescriptionInit")}} or {{domxref("RTCSessionDescription")}} which specifies the configuration to be applied to the local end of the connection.
If the description is omitted, the WebRTC runtime tries to automatically do the right thing.

### Return value
Expand All @@ -47,7 +47,7 @@ Otherwise, `setLocalDescription()` creates an answer, which becomes the new loca

#### Type of the description parameter

The description is of type `RTCSessionDescriptionInit`, which is a serialized version of a {{domxref("RTCSessionDescription")}} browser object. They're interchangeable:
The description is of type `RTCLocalSessionDescriptionInit`, which is a serialized version of a {{domxref("RTCSessionDescription")}} browser object. They're interchangeable:

```js
myPeerConnection
Expand Down Expand Up @@ -90,7 +90,7 @@ When using the deprecated callback-based version of `setLocalDescription()`, the
- `InvalidStateError` {{domxref("DOMException")}} {{deprecated_inline}}
- : Thrown if the connection's {{domxref("RTCPeerConnection.signalingState", "signalingState")}} is `"closed"`, indicating that the connection is not currently open, so negotiation cannot take place.
- `InvalidSessionDescriptionError` {{domxref("DOMException")}} {{deprecated_inline}}
- : Thrown if the {{domxref("RTCSessionDescription")}} specified by the `sessionDescription` parameter is invalid.
- : Thrown if the {{domxref("RTCLocalSessionDescriptionInit")}} specified by the `sessionDescription` parameter is invalid.

## Examples

Expand Down Expand Up @@ -140,3 +140,4 @@ called `signalRemotePeer()`.
## See also

- [WebRTC API](/en-US/docs/Web/API/WebRTC_API)
- {{domxref("RTCLocalSessionDescriptionInit")}}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ When using the deprecated callback-based version of `setRemoteDescription()`, th
- `InvalidStateError` {{deprecated_inline}}
- : The connection's {{domxref("RTCPeerConnection.signalingState", "signalingState")}} is `"closed"`, indicating that the connection is not currently open, so negotiation cannot take place.
- `InvalidSessionDescriptionError` {{deprecated_inline}}
- : The {{domxref("RTCSessionDescription")}} specified by the `sessionDescription` parameter is invalid.
- : The {{domxref("RTCSessionDescriptionInit")}} specified by the `sessionDescription` parameter is invalid.

## Examples

Expand Down Expand Up @@ -168,4 +168,5 @@ When our promise fulfillment handler is called, indicating that this has been do
- [WebRTC](/en-US/docs/Web/API/WebRTC_API)
- {{domxref("RTCPeerConnection.remoteDescription")}},
{{domxref("RTCPeerConnection.pendingRemoteDescription")}},
{{domxref("RTCPeerConnection.currentRemoteDescription")}}
{{domxref("RTCPeerConnection.currentRemoteDescription")}}
- {{domxref("RTCSessionDescriptionInit")}}
14 changes: 13 additions & 1 deletion files/en-us/web/api/rtcsessiondescription/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ _The `RTCSessionDescription` interface doesn't inherit any properties._
_The `RTCSessionDescription` doesn't inherit any methods._

- {{domxref("RTCSessionDescription.RTCSessionDescription", "RTCSessionDescription()")}} {{deprecated_inline}}
- : This constructor returns a new `RTCSessionDescription`. The parameter is a `RTCSessionDescriptionInit` dictionary containing the values to assign the two properties.
- : This constructor returns a new `RTCSessionDescription`. The parameter is a {{domxref("RTCSessionDescriptionInit")}} dictionary containing the values to assign the two properties.
- {{domxref("RTCSessionDescription.toJSON()")}}
- : Returns a {{Glossary("JSON")}} description of the object. The values of both properties, {{domxref("RTCSessionDescription.type", "type")}} and {{domxref("RTCSessionDescription.sdp", "sdp")}}, are contained in the generated JSON.

Expand Down Expand Up @@ -57,6 +57,16 @@ signalingChannel.onmessage = (evt) => {
};
```

## RTCSessionDescription, RTCSessionDescriptionInit, and RTCLocalSessionDescriptionInit

There are other similar interfaces that are used to provide the SDP values for `RTCSessionDescription` objects. These are:
- {{domxref("RTCSessionDescriptionInit")}}
- {{domxref("RTCLocalSessionDescriptionInit")}}

These interfaces are used in several methods of the {{domxref("RTCPeerConnection")}} interface utilize these interfaces, including {{domxref("RTCPeerConnection.createOffer")}}, {{domxref("RTCPeerConnection.createAnswer")}}, {{domxref("RTCPeerConnection.setLocalDescription")}}, and {{domxref("RTCPeerConnection.setRemoteDescription")}}.

In essence, `RTCSessionDescriptionInit` and `RTCLocalSessionDescriptionInit` are defined as dictionaries, enabling users to provide necessary values without creating a full `RTCSessionDescription` object. Also, `RTCPeerConnection.setLocalDescription()` accepts `RTCLocalSessionDescriptionInit` as an argument, allowing users to omit this argument altogether. This eliminates the need for separate calls to `RTCPeerConnection.createOffer()` and `RTCPeerConnection.setLocalDescription()`. (For more information, see [Implicit description in RTCPeerConnection.setLocalDescription()](/en-US/docs/Web/API/RTCPeerConnection/setLocalDescription#implicit_description)).

## Specifications

{{Specifications}}
Expand All @@ -69,3 +79,5 @@ signalingChannel.onmessage = (evt) => {

- [WebRTC](/en-US/docs/Web/API/WebRTC_API)
- {{domxref("RTCPeerConnection.setLocalDescription()")}} and {{domxref("RTCPeerConnection.setRemoteDescription()")}}
- {{domxref("RTCSessionDescriptionInit")}}
- {{domxref("RTCLocalSessionDescriptionInit")}}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ specified object.
> **Note:** This constructor has been deprecated because
> {{domxref("RTCPeerConnection.setLocalDescription()")}} and other methods which take
> SDP as input now directly accept an object conforming to the
> `RTCSessionDescriptionInit` dictionary, so you don't have to instantiate an
> {{domxref("RTCSessionDescriptionInit")}} dictionary, so you don't have to instantiate an
> `RTCSessionDescription` yourself.
## Syntax
Expand All @@ -31,7 +31,7 @@ new RTCSessionDescription(options)
- `options` {{optional_inline}}

- : An object providing the default values for the session description; the object
conforms to the `RTCSessionDescriptionInit` dictionary. That dictionary has
conforms to the {{domxref("RTCSessionDescriptionInit")}} dictionary. That dictionary has
the following properties:

- `type`
Expand Down
30 changes: 30 additions & 0 deletions files/en-us/web/api/rtcsessiondescriptioninit/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: RTCSessionDescriptionInit
slug: Web/API/RTCSessionDescriptionInit
page-type: web-api-interface
browser-compat: api.RTCSessionDescription
---

{{APIRef("WebRTC")}}

The **`RTCSessionDescriptionInit`** dictionary is used to provide {{Glossary("SDP")}} values in several methods of the {{domxref("RTCPeerConnection")}} interface, such as {{domxref("RTCPeerConnection.createOffer")}}, {{domxref("RTCPeerConnection.createAnswer")}}, and {{domxref("RTCPeerConnection.setRemoteDescription")}}. Also it can be used to create new `RTCSessionDescription` objects, though this is less common.

### Properties

- `type`
- : A string which is used to set the `type` property of the new `RTCSessionDescription` object. This is a required property. For more information, see documentation for the {{domxref("RTCSessionDescription.type")}} property.
- `sdp`
- : A string containing the {{Glossary("SDP")}} describing the session. If `type` is `"rollback"`, this member is unused.

## Specifications

https://w3c.github.io/webrtc-pc/#dom-rtcsessiondescriptioninit

## See also

- [WebRTC](/en-US/docs/Web/API/WebRTC_API)
- {{domxref("RTCSessionDescription")}}
- {{domxref("RTCLocalSessionDescriptionInit")}}
- {{domxref("RTCPeerConnection.createOffer")}}
- {{domxref("RTCPeerConnection.createAnswer")}}
- {{domxref("RTCPeerConnection.setRemoteDescription")}}

0 comments on commit 64eec53

Please sign in to comment.