RTCPeerConnection 方法 addTransceiver() creates a new RTCRtpTransceiver and adds it to the set of transceivers associated with the RTCPeerConnection . Each transceiver represents a bidirectional stream, with both an RTCRtpSender RTCRtpReceiver associated with it.

句法

rtpTransceiver = RTCPeerConnection.addTransceiver(trackOrKind, init);
					

参数

trackOrKind
MediaStreamTrack to associate with the transceiver, or a DOMString which is used as the kind of the receiver's track , and by extension of the RTCRtpReceiver 本身。
init 可选
An object that conforms to the RTCRtpTransceiverInit dictionary which provides any options that you may wish to specify when creating the new transceiver. Possible values are:
direction 可选
The new transceiver's preferred directionality. This value is used to initialize the new RTCRtpTransceiver 对象的 RTCRtpTransceiver.direction 特性。
sendEncodings 可选
A list of encodings to allow when sending RTP media from the RTCRtpSender . Each entry is of type RTCRtpEncodingParameters .
可选
列表化的 MediaStream objects to add to the transceiver's RTCRtpReceiver ; when the remote peer's RTCPeerConnection 's track event occurs, these are the streams that will be specified by that event.

异常

TypeError
A string was specified as trackOrKind which is not valid. The string must be either "audio" or "video" .

规范

规范 状态 注释
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCPeerConnection.addTransceiver()' in that specification.
候选推荐

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
addTransceiver Chrome 69 Edge 79 Firefox 59 IE 不支持 No Opera 不支持 No Safari 11 WebView Android 69 Chrome Android 69 Firefox Android 59 Opera Android 不支持 No Safari iOS Yes Samsung Internet Android 10.0

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改:
  1. WebRTC API
  2. RTCPeerConnection
  3. 构造函数
    1. RTCPeerConnection()
  4. 特性
    1. canTrickleIceCandidates
    2. connectionState
    3. currentLocalDescription
    4. currentRemoteDescription
    5. getDefaultIceServers()
    6. iceConnectionState
    7. iceGatheringState
    8. localDescription
    9. onaddstream
    10. onconnectionstatechange
    11. ondatachannel
    12. onicecandidate
    13. oniceconnectionstatechange
    14. onicegatheringstatechange
    15. onidentityresult
    16. onidpassertionerror
    17. onidpvalidationerror
    18. onnegotiationneeded
    19. onpeeridentity
    20. onremovestream
    21. onsignalingstatechange
    22. ontrack
    23. peerIdentity
    24. pendingLocalDescription
    25. pendingRemoteDescription
    26. remoteDescription
    27. sctp
    28. signalingState
  5. 方法
    1. addIceCandidate()
    2. addStream()
    3. addTrack()
    4. close()
    5. createAnswer()
    6. createDataChannel()
    7. createOffer()
    8. generateCertificate()
    9. getConfiguration()
    10. getIdentityAssertion()
    11. getReceivers()
    12. getSenders()
    13. getStats()
    14. getStreamById()
    15. getTransceivers()
    16. removeStream()
    17. removeTrack()
    18. restartIce()
    19. setConfiguration()
    20. setIdentityProvider()
    21. setLocalDescription()
    22. setRemoteDescription()
  6. 事件
    1. addstream
    2. identityresult
    3. negotiationneeded
    4. removestream
    5. signalingstatechange
  7. 继承:
    1. EventTarget
  8. Related pages for WebRTC
    1. MediaDevices.getUserMedia()
    2. Navigator.mediaDevices
    3. RTCCertificate
    4. RTCDTMFSender
    5. RTCDTMFToneChangeEvent
    6. RTCDataChannel
    7. RTCDataChannelEvent
    8. RTCDtlsTransport
    9. RTCErrorEvent
    10. RTCIceCandidate
    11. RTCIceTransport
    12. RTCPeerConnectionIceErrorEvent
    13. RTCPeerConnectionIceEvent
    14. RTCRtpReceiver
    15. RTCRtpSender
    16. RTCRtpTransceiver
    17. RTCSctpTransport
    18. RTCSessionDescription
    19. RTCStatsEvent
    20. RTCStatsReport
    21. RTCTrackEvent

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1