# RTCSessionDescription

The session description of one end of a connection.

### *class* webrtc.models.rtc_session_description.RTCSessionDescription(type, sdp='')

A session description set on a connection, with its SDP and its role in the offer/answer exchange.

[`webrtc.RTCPeerConnection.local_description`](../interfaces/rtc_peer_connection.md#webrtc.interfaces.rtc_peer_connection.RTCPeerConnection.local_description) and the other description properties return it. The
methods that set a description take an [`webrtc.RTCSessionDescriptionInit`](rtc_session_description_init.md#webrtc.models.rtc_session_description_init.RTCSessionDescriptionInit) as well, so creating one
is rarely needed. The type is checked on creation, but the SDP is only parsed once the description is set.
Both are writable; a description already set on a connection doesn’t change.
See [MDN: RTCSessionDescription](https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription).

* **Parameters:**
  * **type** ([`webrtc.RTCSdpType`](../enums.md#webrtc.enums.RTCSdpType)) – The type of the description, or its value (like `'offer'`). An
    [`webrtc.RTCSessionDescriptionInit`](rtc_session_description_init.md#webrtc.models.rtc_session_description_init.RTCSessionDescriptionInit) is taken too, in which case `sdp` is ignored.
  * **sdp** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional) – The SDP of the description, empty by default.
* **Raises:**
  * [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If the type isn’t a member of [`webrtc.RTCSdpType`](../enums.md#webrtc.enums.RTCSdpType).
  * [**TypeError**](https://docs.python.org/3/builtins/exceptions.html#TypeError) – If the SDP is [`None`](https://docs.python.org/3/builtins/constants.html#None).

#### to_json()

Returns the description as a JSON-serializable dictionary, to send to the remote peer.

`webrtc.RTCSessionDescriptionInit.from_json()` reads it back.
See [MDN: RTCSessionDescription/toJSON](https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription/toJSON).

* **Returns:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict) – `type` (like `'offer'`) and `sdp`.
* **Return type:**
  [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### *property* type *: [webrtc.RTCSdpType](../enums.md#webrtc.enums.RTCSdpType)*

The role of the description in the offer/answer exchange.

It can be set with a member or its value. See [MDN: RTCSessionDescription/type](https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription/type).

* **Type:**
  [`webrtc.RTCSdpType`](../enums.md#webrtc.enums.RTCSdpType)

#### *property* sdp *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)*

The SDP of the description, which may be empty (like for a `rollback`).

See [MDN: RTCSessionDescription/sdp](https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription/sdp).

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
