createSender

open fun createSender(kind: String, stream_id: String): RtpSender

Creates an RtpSender without a track.

This method allows an application to cause the PeerConnection to negotiate sending/receiving a specific media type, but without having a track to send yet.

When the application does want to begin sending a track, it can call RtpSender.setTrack, which doesn't require any additional SDP negotiation.

Example use:


audioSender = pc.createSender("audio", "stream1");
videoSender = pc.createSender("video", "stream1");
// Do normal SDP offer/answer, which will kick off ICE/DTLS and negotiate
// media parameters....
// Later, when the endpoint is ready to actually begin sending:
audioSender.setTrack(audioTrack, false);
videoSender.setTrack(videoTrack, false);

Note: This corresponds most closely to "addTransceiver" in the official WebRTC API, in that it creates a sender without a track. It was implemented before addTransceiver because it provides useful functionality, and properly implementing transceivers would have required a great deal more work.

Note: This is only available with SdpSemantics.PLAN_B specified. Please use addTransceiver instead.

Return

A new RtpSender object if successful, or null otherwise.

Parameters

kind

Corresponds to MediaStreamTrack kinds (must be "audio" or "video").

stream_id

The ID of the MediaStream that this sender's track will be associated with when SDP is applied to the remote PeerConnection. If createSender is used to create an audio and video sender that should be synchronized, they should use the same stream ID.