RTCRtpSender

RTCRtpSender interface provides the ability to control and obtain details about how a particular MediaStreamTrack is encoded and sent to a remote peer. With it, you can configure the encoding used for the corresponding track, get information about the device's media capabilities, and so forth. You can also obtain access to an RTCDTMFSender which can be used to send DTMF codes (to simulate the user pressing buttons on a telephone's dial pad) to the remote peer.

特性

RTCRtpSender.dtmf 只读
An RTCDTMFSender which can be used to send DTMF tones using telephone-event payloads on the RTP session represented by the RTCRtpSender object. If null , the track and/or the connection doesn't support DTMF. Only audio tracks can support DTMF.
RTCRtpSender.track 只读
MediaStreamTrack which is being handled by the RTCRtpSender 。若 track is null RTCRtpSender doesn't transmit anything.
RTCRtpSender.transport 只读
RTCDtlsTransport over which the sender is exchanging the RTP and RTCP packets used to manage transmission of media and control data. This value is null until the transport is established. When bundling is in use, more than transceiver may be sharing the same transport object.

过时特性

rtcpTransport
This property has been removed; the RTP and RTCP transports have been combined into a single transport. Use the transport property instead.

方法

RTCRtpSender.getParameters()
返回 RTCRtpParameters object describing the current configuration for the encoding and transmission of media on the track .
RTCRtpSender.getStats()
返回 Promise which is fulfilled with a RTCStatsReport which provides statistics data for all outbound streams being sent using this RTCRtpSender .
RTCRtpSender.setParameters()
Applies changes to parameters which configure how the track is encoded and transmitted to the remote peer.
RTCRtpSender.setStreams()
设置 MediaStream (s) associated with the track being transmitted by this sender.
RTCRtpSender.replaceTrack()
Attempts to replace the track currently being sent by the RTCRtpSender with another track, without performing renegotiation. This method can be used, for example, to toggle between the front- and rear-facing cameras on a device.

静态方法

RTCRtpSender.getCapabilities()
Returns an RTCRtpCapabilities object describing the system's capabilities for sending a specified kind of media data.

规范

规范 状态 Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCRtpSender' in that specification.
候选推荐

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
RTCRtpSender Chrome Yes Edge ≤18 Firefox 34 IE 不支持 No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
dtmf Chrome Yes Edge ≤18 Firefox 52 IE 不支持 No Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android 52 Opera Android Yes Safari iOS ? Samsung Internet Android Yes
getCapabilities() Chrome Yes Edge 12 Firefox ? IE 不支持 No Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android ? Opera Android Yes Safari iOS ? Samsung Internet Android Yes
getParameters() Chrome 67 Edge ≤79 Firefox Yes IE 不支持 No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
getStats() Chrome 67 Edge ≤18 Firefox 55 IE 不支持 No Opera 54 Safari ? WebView Android 67 Chrome Android 67 Firefox Android 55 Opera Android 48 Safari iOS ? Samsung Internet Android 9.0
replaceTrack() Chrome 65 Edge ≤18 Firefox Yes IE 不支持 No Opera Yes Safari Yes WebView Android 65 Chrome Android 65 Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android 9.0
rtcpTransport Chrome 不支持 No Edge 不支持 12 — 79 Firefox 34 IE 不支持 No Opera ? Safari ? WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 34 Opera Android ? Safari iOS ? Samsung Internet Android 不支持 No
setParameters() Chrome Yes Edge ≤79 Firefox 64
注意事项
64
注意事项
Changes to parameters that should update live now do so starting in Firefox 64.
46
IE 不支持 No Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android 64
注意事项
64
注意事项
Changes to parameters that should update live now do so starting in Firefox 64.
46
Opera Android Yes Safari iOS ? Samsung Internet Android Yes
track Chrome Yes Edge 12 Firefox 34 IE 不支持 No Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
transport Chrome 不支持 No Edge 不支持 12 — 79 Firefox 34 IE 不支持 No Opera ? Safari ? WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 34 Opera Android ? Safari iOS ? Samsung Internet Android 不支持 No

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
见实现注意事项。

另请参阅