1

一旦我在两个对等方之间交换了会话描述。如何允许用户阻止音频和/或视频广播?我需要再次交换会话描述吗?

4

1 回答 1

2
  1. "Broadcast" is probably not the correct term since PeerConnections are always unicast peer-to-peer.
  2. To acquire an audio/video stream from the user's devices you call getUserMedia() and to send these to the other peer you call addStream() on the PeerConnection object.

So to allow the user to not send the acquired stream just let her choose whether to call addStream() or not. E.g. show a popup saying "Send Audio/Video to the other user?". If she chooses "Yes" call addStream() on the PeerConnection object, otherwise just don't call it.

EDIT to answer question in comment:

If you'd like to stop sending of audio and/or video just call removeStream() on the PeerConnection object with the stream to remove as parameter. This will per the API spec trigger a renegotiation.

See http://dev.w3.org/2011/webrtc/editor/webrtc.html#interface-definition for further details.

于 2013-06-24T11:54:06.350 回答