Invoking sendStream():

1. If the stream parameter provided is invalid, sendStream() callback error is triggered.

2. Stops any attached Stream to replace with it with the new Stream.

3. Triggers mediaAccessStopped event if there is any Stream.

If MediaStream object is passed in sendStream(), proceed to step 6, else step 4.

4. Invoke getUserMedia() to retrieve Stream.

5. After Stream is successfully retrieved, both mediaAccessSuccess event and getUserMedia() callback success will be triggered.

5a. Event mediaAccessError state would trigger for the failed attempt of retrieving Stream. If audioFallback is set to true in the init(), proceed to step 5b, else step 5e.
5b. Invokes getUserMedia() again to retrieve audio only Stream.
5c. After audio only Stream successfully retrieved, both  mediaAccessSuccess event and getUserMedia() callback success will be triggered. Skip to step 6.
5d. Event mediaAccessError will be triggered for the failed attempt of retrieving audio only Stream.
5e. getUserMedia() callback error will be triggered.
5f. After getUserMedia() callback is triggered with an error,  sendStream() callback error will be triggered.

If there is Peer connected to self, proceed to step 6, else step 10.

6. Restarts all Peer connections. This works similarly to refreshConnection() method.

7. Event peerRestart is triggered for each Peer connection.

8. Event peerUpdated is triggered for self.

9. Waits for all Peer connections peerRestart event to be triggered.

10. sendStream()  callback success  is triggered.