• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# WebRTC development
2
3The currently supported platforms are Windows, Mac OS X, Linux, Android and
4iOS. See the [Android][webrtc-android-development] and [iOS][webrtc-ios-development]
5pages for build instructions and example applications specific to these mobile platforms.
6
7
8## Before You Start
9
10First, be sure to install the [prerequisite software][webrtc-prerequisite-sw].
11
12[webrtc-prerequisite-sw]: https://webrtc.googlesource.com/src/+/refs/heads/master/docs/native-code/development/prerequisite-sw/index.md
13
14
15## Getting the Code
16
17For desktop development:
18
191. Create a working directory, enter it, and run `fetch webrtc`:
20
21```
22$ mkdir webrtc-checkout
23$ cd webrtc-checkout
24$ fetch --nohooks webrtc
25$ gclient sync
26```
27
28NOTICE: During your first sync, you'll have to accept the license agreement of the Google Play Services SDK.
29
30The checkout size is large due the use of the Chromium build toolchain and many dependencies. Estimated size:
31
32* Linux: 6.4 GB.
33* Linux (with Android): 16 GB (of which ~8 GB is Android SDK+NDK images).
34* Mac (with iOS support): 5.6GB
35
362. Optionally you can specify how new branches should be tracked:
37
38```
39$ git config branch.autosetupmerge always
40$ git config branch.autosetuprebase always
41```
42
433. Alternatively, you can create new local branches like this (recommended):
44
45```
46$ cd src
47$ git checkout master
48$ git new-branch your-branch-name
49```
50
51See the [Android][webrtc-android-development] and [iOS][webrtc-ios-development] pages for separate instructions.
52
53**NOTICE:** if you get `Remote: Daily bandwidth rate limit exceeded for <ip>`,
54make sure you're logged in. The quota is much larger for logged in users.
55
56## Updating the Code
57
58Update your current branch with:
59
60```
61$ git checkout master
62$ git pull origin master
63$ gclient sync
64$ git checkout my-branch
65$ git merge master
66```
67
68## Building
69
70[Ninja][ninja] is the default build system for all platforms.
71
72See the [Android][webrtc-android-development] and [iOS][webrtc-ios-development] pages for build
73instructions specific to those platforms.
74
75## Generating Ninja project files
76
77[Ninja][ninja] project files are generated using [GN][gn]. They're put in a
78directory of your choice, like `out/Debug` or `out/Release`, but you can
79use any directory for keeping multiple configurations handy.
80
81To generate project files using the defaults (Debug build), run (standing in
82the src/ directory of your checkout):
83
84```
85$ gn gen out/Default
86```
87
88To generate ninja project files for a Release build instead:
89
90```
91$ gn gen out/Default --args='is_debug=false'
92```
93
94To clean all build artifacts in a directory but leave the current GN
95configuration untouched (stored in the args.gn file), do:
96
97```
98$ gn clean out/Default
99```
100
101See the [GN][gn-doc] documentation for all available options. There are also more
102platform specific tips on the [Android][webrtc-android-development] and
103[iOS][webrtc-ios-development] instructions.
104
105## Compiling
106
107When you have Ninja project files generated (see previous section), compile
108(standing in `src/`) using:
109
110For [Ninja][ninja] project files generated in `out/Default`:
111
112```
113$ ninja -C out/Default
114```
115
116
117## Using Another Build System
118
119Other build systems are **not supported** (and may fail), such as Visual
120Studio on Windows or Xcode on OSX. GN supports a hybrid approach of using
121[Ninja][ninja] for building, but Visual Studio/Xcode for editing and driving
122compilation.
123
124To generate IDE project files, pass the `--ide` flag to the [GN][gn] command.
125See the [GN reference][gn-doc] for more details on the supported IDEs.
126
127
128## Working with Release Branches
129
130To see available release branches, run:
131
132```
133$ git branch -r
134```
135
136To create a local branch tracking a remote release branch (in this example,
137the 43 branch):
138
139```
140$ git checkout -b my_branch refs/remotes/branch-heads/43
141$ gclient sync
142```
143
144**NOTICE**: depot_tools are not tracked with your checkout, so it's possible gclient
145sync will break on sufficiently old branches. In that case, you can try using
146an older depot_tools:
147
148```
149which gclient
150$ # cd to depot_tools dir
151$ # edit update_depot_tools; add an exit command at the top of the file
152$ git log  # find a hash close to the date when the branch happened
153$ git checkout <hash>
154$ cd ~/dev/webrtc/src
155$ gclient sync
156$ # When done, go back to depot_tools, git reset --hard, run gclient again and
157$ # verify the current branch becomes REMOTE:origin/master
158```
159
160The above is untested and unsupported, but it might help.
161
162Commit log for the branch: [https://webrtc.googlesource.com/src/+log/branch-heads/43][m43-log]
163To browse it: [https://webrtc.googlesource.com/src/+/branch-heads/43][m43]
164
165For more details, read Chromium's [Working with Branches][chromium-work-branches] and
166[Working with Release Branches][chromium-work-release-branches] pages.
167
168
169## Contributing Patches
170
171Please see [Contributing Fixes][webrtc-contributing] for information on how to run
172`git cl upload`, getting your patch reviewed, and getting it submitted. You can also
173find info on how to run trybots and applying for try rights.
174
175## Chromium Committers
176
177Many WebRTC committers are also Chromium committers. To make sure to use the
178right account for pushing commits to WebRTC, use the `user.email` Git config
179setting. The recommended way is to have the chromium.org account set globally
180as described at the [depot tools setup page][depot-tools] and then set `user.email`
181locally for the WebRTC repos using (change to your webrtc.org address):
182
183```
184$ cd /path/to/webrtc/src
185$ git config user.email yourname@webrtc.org
186```
187
188## Example Applications
189
190WebRTC contains several example applications, which can be found under
191`src/webrtc/examples`. Higher level applications are listed first.
192
193
194### Peerconnection
195
196Peerconnection consist of two applications using the WebRTC Native APIs:
197
198* A server application, with target name `peerconnection_server`
199* A client application, with target name `peerconnection_client` (not currently supported on Mac/Android)
200
201The client application has simple voice and video capabilities. The server
202enables client applications to initiate a call between clients by managing
203signaling messages generated by the clients.
204
205
206#### Setting up P2P calls between peerconnection_clients
207
208Start `peerconnection_server`. You should see the following message indicating
209that it is running:
210
211```
212Server listening on port 8888
213```
214
215Start any number of `peerconnection_clients` and connect them to the server.
216The client UI consists of a few parts:
217
218**Connecting to a server:** When the application is started you must specify
219which machine (by IP address) the server application is running on. Once that
220is done you can press **Connect** or the return button.
221
222**Select a peer:** Once successfully connected to a server, you can connect to
223a peer by double-clicking or select+press return on a peer's name.
224
225**Video chat:** When a peer has been successfully connected to, a video chat
226will be displayed in full window.
227
228**Ending chat session:** Press **Esc**. You will now be back to selecting a
229peer.
230
231**Ending connection:** Press **Esc** and you will now be able to select which
232server to connect to.
233
234
235#### Testing peerconnection_server
236
237Start an instance of `peerconnection_server` application.
238
239Open `src/webrtc/examples/peerconnection/server/server_test.html` in your
240browser. Click **Connect**. Observe that the `peerconnection_server` announces
241your connection. Open one more tab using the same page. Connect it too (with a
242different name). It is now possible to exchange messages between the connected
243peers.
244
245### STUN Server
246
247Target name `stunserver`. Implements the STUN protocol for Session Traversal
248Utilities for NAT as documented in [RFC 5389][rfc-5389].
249
250
251### TURN Server
252
253Target name `turnserver`. Used for unit tests.
254
255
256[ninja]: https://ninja-build.org/
257[gn]: https://gn.googlesource.com/gn/+/master/README.md
258[gn-doc]: https://gn.googlesource.com/gn/+/master/docs/reference.md#IDE-options
259[webrtc-android-development]: https://webrtc.googlesource.com/src/+/refs/heads/master/docs/native-code/android/index.md
260[webrtc-ios-development]: https://webrtc.googlesource.com/src/+/refs/heads/master/docs/native-code/ios/index.md
261[chromium-work-branches]: https://www.chromium.org/developers/how-tos/get-the-code/working-with-branches
262[chromium-work-release-branches]: https://www.chromium.org/developers/how-tos/get-the-code/working-with-release-branches
263[webrtc-contributing]: https://webrtc.org/support/contributing/
264[depot-tools]: http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
265[rfc-5389]: https://tools.ietf.org/html/rfc5389
266[rfc-5766]: https://tools.ietf.org/html/rfc5766
267[m43-log]: https://webrtc.googlesource.com/src/+log/branch-heads/43
268[m43]: https://webrtc.googlesource.com/src/+/branch-heads/43
269