webrtc/api/g3doc/index.md
Harald Alvestrand df1edc9ae0 API description: PeerConnection description
Since we want most users to use the PeerConnection API, this is the
part that we should document.

If we want people to use other APIs, we can add to the file.

Bug: webrtc:12674
Change-Id: Icf14f218cf51c640e6f846f10b49dff84106dc21
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215066
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33707}
2021-04-13 12:51:47 +00:00

2.2 KiB

The WebRTC API

The public API of the WebRTC library consists of the api/ directory and its subdirectories. No other files should be depended on by webrtc users.

Before starting to code against the API, it is important to understand some basic concepts, such as:

Using WebRTC through the PeerConnection class

The PeerConnectionInterface class is the recommended way to use the WebRTC library.

It is closely modeled after the Javascript API documented in the WebRTC specification.

PeerConnections are created using the PeerConnectionFactoryInterface.

There are two levels of customization available:

  • Pass a PeerConnectionFactoryDependencies object to the function that creates a PeerConnectionFactory. This object defines factories for a lot of internal objects inside the PeerConnection, so that users can override them. All PeerConnections using this interface will have the same options.
  • Pass a PeerConnectionInterface::RTCConfiguration object to the CreatePeerConnectionOrError() function on the PeerConnectionFactoryInterface. These customizations will apply only to a single PeerConnection.

Most functions on the PeerConnection interface are asynchronous, and take a callback that is executed when the function is finished. The callbacks are mostly called on the thread that is passed as the "signaling thread" field of the PeerConnectionFactoryDependencies, or the thread that called PeerConnectionFactory::CreatePeerConnectionOrError() if no thread is given.

See each class' module documentation for details.

Using WebRTC components without the PeerConnection class

This needs to be done carefully, and in consultation with the WebRTC team. There are non-obvious dependencies between many of the components.