xref: /aosp_15_r20/external/webrtc/api/g3doc/index.md (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker<?% config.freshness.owner = 'hta' %?>
2*d9f75844SAndroid Build Coastguard Worker<?% config.freshness.reviewed = '2021-04-12' %?>
3*d9f75844SAndroid Build Coastguard Worker
4*d9f75844SAndroid Build Coastguard Worker# The WebRTC API
5*d9f75844SAndroid Build Coastguard Worker
6*d9f75844SAndroid Build Coastguard WorkerThe public API of the WebRTC library consists of the api/ directory and
7*d9f75844SAndroid Build Coastguard Workerits subdirectories. No other files should be depended on by webrtc users.
8*d9f75844SAndroid Build Coastguard Worker
9*d9f75844SAndroid Build Coastguard WorkerBefore starting to code against the API, it is important to understand
10*d9f75844SAndroid Build Coastguard Workersome basic concepts, such as:
11*d9f75844SAndroid Build Coastguard Worker
12*d9f75844SAndroid Build Coastguard Worker* Memory management, including webrtc's reference counted objects
13*d9f75844SAndroid Build Coastguard Worker* [Thread management](threading_design.md)
14*d9f75844SAndroid Build Coastguard Worker
15*d9f75844SAndroid Build Coastguard Worker## Using WebRTC through the PeerConnection class
16*d9f75844SAndroid Build Coastguard Worker
17*d9f75844SAndroid Build Coastguard WorkerThe
18*d9f75844SAndroid Build Coastguard Worker[PeerConnectionInterface](https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/api/peer_connection_interface.h?q=webrtc::PeerConnectionInterface)
19*d9f75844SAndroid Build Coastguard Workerclass is the recommended way to use the WebRTC library.
20*d9f75844SAndroid Build Coastguard Worker
21*d9f75844SAndroid Build Coastguard WorkerIt is closely modeled after the Javascript API documented in the [WebRTC
22*d9f75844SAndroid Build Coastguard Workerspecification](https://w3c.github.io/webrtc-pc/).
23*d9f75844SAndroid Build Coastguard Worker
24*d9f75844SAndroid Build Coastguard WorkerPeerConnections are created using the [PeerConnectionFactoryInterface](https://source.chromium.org/search?q=webrtc::PeerConnectionFactoryInterface).
25*d9f75844SAndroid Build Coastguard Worker
26*d9f75844SAndroid Build Coastguard WorkerThere are two levels of customization available:
27*d9f75844SAndroid Build Coastguard Worker
28*d9f75844SAndroid Build Coastguard Worker*   Pass a PeerConnectionFactoryDependencies object to the function that creates
29*d9f75844SAndroid Build Coastguard Worker    a PeerConnectionFactory. This object defines factories for a lot of internal
30*d9f75844SAndroid Build Coastguard Worker    objects inside the PeerConnection, so that users can override them.
31*d9f75844SAndroid Build Coastguard Worker    All PeerConnections using this interface will have the same options.
32*d9f75844SAndroid Build Coastguard Worker*   Pass a PeerConnectionInterface::RTCConfiguration object to the
33*d9f75844SAndroid Build Coastguard Worker    CreatePeerConnectionOrError() function on the
34*d9f75844SAndroid Build Coastguard Worker    PeerConnectionFactoryInterface. These customizations will apply only to a
35*d9f75844SAndroid Build Coastguard Worker    single PeerConnection.
36*d9f75844SAndroid Build Coastguard Worker
37*d9f75844SAndroid Build Coastguard WorkerMost functions on the PeerConnection interface are asynchronous, and take a
38*d9f75844SAndroid Build Coastguard Workercallback that is executed when the function is finished. The callbacks are
39*d9f75844SAndroid Build Coastguard Workermostly called on the thread that is passed as the "signaling thread" field of
40*d9f75844SAndroid Build Coastguard Workerthe PeerConnectionFactoryDependencies, or the thread that called
41*d9f75844SAndroid Build Coastguard WorkerPeerConnectionFactory::CreatePeerConnectionOrError() if no thread is given.
42*d9f75844SAndroid Build Coastguard Worker
43*d9f75844SAndroid Build Coastguard WorkerSee each class' module documentation for details.
44*d9f75844SAndroid Build Coastguard Worker
45*d9f75844SAndroid Build Coastguard Worker## Using WebRTC components without the PeerConnection class
46*d9f75844SAndroid Build Coastguard Worker
47*d9f75844SAndroid Build Coastguard WorkerThis needs to be done carefully, and in consultation with the WebRTC team. There
48*d9f75844SAndroid Build Coastguard Workerare non-obvious dependencies between many of the components.
49*d9f75844SAndroid Build Coastguard Worker
50*d9f75844SAndroid Build Coastguard Worker
51*d9f75844SAndroid Build Coastguard Worker
52