With peer-to-peer streaming, two clients transmit audio-video streams directly to each other. With peer-to-peer streaming, there is no need for an intermediate video server.
By removing the server, peer-to-peer streaming decreases latency and improves quality.
Peer-to-peer streaming uses UDP. A firewall may block UDP and cause peer-to-peer streaming to fail. If peer-to-peer streaming fails, either when streams are initially published or during the course of a session, the session falls back to using the OpenTok servers for relaying streams.
When you create an OpenTok session, you can specify whether or not it will be a peer-to-peer session. See Session creation.
Peer-to-peer streaming is supported for sessions that have no more than two connected clients. For a session created with peer-to-peer streaming enabled, if a third client attempts to connect, the TB object on the additional client dispatches an exception event.
Sessions that are not peer-to-peer are known as multi-party sessions. In multi-party sessions, more than two clients can connect and audio-video streams are relayed via TokBox video servers.
Here are the differences between peer-to-peer and multi-party sessions:
| Peer-to-peer | Multi-party | |
|---|---|---|
| Maximum number of participants | 2 |
Unlimited *
* Note: While the OpenTok platform does not limit the number of participants in a multi-party session, the bandwidth and CPU available to an end-user affect performance. |
| Pricing | Free | See the Pricing page. |
| Benefits |
Better video quality
Less latency |
More than two participants per session
Interoperable with the OpenTok iOS SDK |
| Requirements |
End-user firewalls must be configured to allow UDP
Must have Adobe Flash Player |
Bandwidth to download multiple streams (average of 220 kbps per stream)
Must have Adobe Flash Player (except on iOS) |
| Limitations |
Does not work with applications built with the OpenTok iOS SDK
No more than two participants per session |