This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

addStream

Summary

Adds a new stream to the RTCPeerConnection.

Method of apis/webrtc/RTCPeerConnectionapis/webrtc/RTCPeerConnection

Syntax

 element.addStream();

Return Value

No return value

Examples

/*
 * This examples assumes that the browser supports WebRTC API and
 * attaches to the peerconnection the stream that gets from the
 * user's media interfaces
 */

var connection, constraints, peerconnection; // Peerconnection related
var success, error; //Callback functions

connection = { iceServers: [{url: '...', credential: '...'} ,{...}] };
constraints = { optional: [...] };
peerconnection = RTCPeerConnection(connection, constraints);

success = function(stream){
  //Attach the stream to the connection.
  //Sidenote: This will trigger 'negotiationneeded' event
  peerconnection.addStream(stream);
};

error = function(err){
  console.log(err);
};

navigator.getUserMedia({audio: true, video: true}, success, error);

Usage

 If the RTCPeerConnection object's readyState is closed, throws an INVALID_STATE exception.

Otherwise, destroys the ICE agent, abruptly ending any active ICE processing, any active streaming, and releasing any relevant resources (e.g. TURN permissions); then sets the readyState to closed.