RTCPeerConnection: localDescription プロパティ
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2017年9月.
RTCPeerConnection.localDescription は読み取り専用プロパティで、接続のローカル側のセッションを説明する RTCSessionDescription を返します。
まだ設定されていない場合は null となります。
構文
js
const sessionDescription = peerConnection.localDescription
より基本的なレベルでは、 RTCPeerConnection.pendingLocalDescription のプロパティが null でない場合、その値が返されます。
それ以外の場合は、 RTCPeerConnection.currentLocalDescription の値が返されます。
このアルゴリズムの詳細と使用理由については、 WebRTC Connectivity ページの Pending and current descriptions を参照してください。
例
この例では localDescription を見て、RTCSessionDescription オブジェクトの type と sdp フィールドを含むアラートを表示します。
js
const pc = new RTCPeerConnection();
// ...
const sd = pc.localDescription;
if (sd) {
alert(`Local session: type='${sd.type}'; sdp description='${sd.sdp}'`);
} else {
alert("No local session yet.");
}
仕様書
| Specification |
|---|
| WebRTC: Real-Time Communication in Browsers> # dom-peerconnection-localdescription> |
ブラウザーの互換性
Loading…