Artem Titov | a617867 | 2023-01-30 10:51:01 | [diff] [blame] | 1 | <!-- go/cmark --> |
| 2 | <!--* freshness: {owner: 'hta' reviewed: '2021-04-12'} *--> |
Harald Alvestrand | 4af6f2b | 2021-04-12 11:47:56 | [diff] [blame] | 3 | |
| 4 | # The WebRTC API |
| 5 | |
| 6 | The public API of the WebRTC library consists of the api/ directory and |
| 7 | its subdirectories. No other files should be depended on by webrtc users. |
| 8 | |
| 9 | Before starting to code against the API, it is important to understand |
| 10 | some basic concepts, such as: |
| 11 | |
| 12 | * Memory management, including webrtc's reference counted objects |
| 13 | * [Thread management](threading_design.md) |
Harald Alvestrand | df1edc9 | 2021-04-13 12:31:20 | [diff] [blame] | 14 | |
| 15 | ## Using WebRTC through the PeerConnection class |
| 16 | |
| 17 | The |
Tony Herre | b0ed120 | 2021-07-22 15:40:44 | [diff] [blame] | 18 | [PeerConnectionInterface](https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/api/peer_connection_interface.h?q=webrtc::PeerConnectionInterface) |
Harald Alvestrand | df1edc9 | 2021-04-13 12:31:20 | [diff] [blame] | 19 | class is the recommended way to use the WebRTC library. |
| 20 | |
| 21 | It is closely modeled after the Javascript API documented in the [WebRTC |
| 22 | specification](https://w3c.github.io/webrtc-pc/). |
| 23 | |
| 24 | PeerConnections are created using the [PeerConnectionFactoryInterface](https://source.chromium.org/search?q=webrtc::PeerConnectionFactoryInterface). |
| 25 | |
| 26 | There are two levels of customization available: |
| 27 | |
| 28 | * Pass a PeerConnectionFactoryDependencies object to the function that creates |
| 29 | a PeerConnectionFactory. This object defines factories for a lot of internal |
| 30 | objects inside the PeerConnection, so that users can override them. |
| 31 | All PeerConnections using this interface will have the same options. |
| 32 | * Pass a PeerConnectionInterface::RTCConfiguration object to the |
| 33 | CreatePeerConnectionOrError() function on the |
| 34 | PeerConnectionFactoryInterface. These customizations will apply only to a |
| 35 | single PeerConnection. |
| 36 | |
| 37 | Most functions on the PeerConnection interface are asynchronous, and take a |
| 38 | callback that is executed when the function is finished. The callbacks are |
| 39 | mostly called on the thread that is passed as the "signaling thread" field of |
| 40 | the PeerConnectionFactoryDependencies, or the thread that called |
| 41 | PeerConnectionFactory::CreatePeerConnectionOrError() if no thread is given. |
| 42 | |
| 43 | See each class' module documentation for details. |
| 44 | |
| 45 | ## Using WebRTC components without the PeerConnection class |
| 46 | |
| 47 | This needs to be done carefully, and in consultation with the WebRTC team. There |
| 48 | are non-obvious dependencies between many of the components. |
| 49 | |
| 50 | |
| 51 | |