xref: /aosp_15_r20/external/openscreen/build/config/external_libraries.md (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
1# External Libraries in Open Screen
2
3Currently, external libraries are used exclusively by the standalone sender and
4receiver applications, for compiling in dependencies used for video decoding and
5playback.
6
7The decision to link external libraries is made manually by setting the GN args.
8For example, a developer wanting to link all the libraries for the standalone
9sender and receiver executables might add the following to `gn args out/Default`:
10
11```python
12is_debug=true
13have_ffmpeg=true
14have_libsdl2=true
15have_libopus=true
16have_libvpx=true
17```
18
19On some versions of Debian, the following apt-get command will install all of
20the necessary external libraries for Open Screen:
21
22```sh
23sudo apt-get install libsdl2-2.0 libsdl2-dev libavcodec libavcodec-dev
24                     libavformat libavformat-dev libavutil libavutil-dev
25                     libswresample libswresample-dev libopus0 libopus-dev
26                     libvpx5 libvpx-dev
27```
28
29Similarly, on some versions of Raspian, the following command will install the
30necessary external libraries, at least for the standalone receiver. Note that
31this command is based off of the packages linked in the [sysroot](sysroot.gni):
32
33```sh
34sudo apt-get install libavcodec58=7:4.1.4* libavcodec-dev=7:4.1.4*
35                     libsdl2-2.0-0=2.0.9* libsdl2-dev=2.0.9*
36                     libavformat-dev=7:4.1.4*
37```
38
39Note: release of these operating systems may require slightly different
40packages, so these `sh` commands are merely a potential starting point.
41
42Finally, note that generally the headers for packages must also be installed.
43In Debian Linux flavors, this usually means that the `*-dev` version of each
44package must also be installed. In the example above, this looks like having
45both `libavcodec` and `libavcodec-dev`.
46
47## Standalone Sender
48
49The standalone sender uses FFMPEG, LibOpus, and LibVpx for encoding video and
50audio for sending. When the build has determined that [have_external_libs](
51  ../../cast/standalone_sender/BUILD.gn
52) is set to true, meaning that all of these libraries are installed, then
53the VP8 and Opus encoders are enabled and actual video files can be sent
54to standalone receiver instances. Without these dependencies, the standalone
55sender cannot properly function (contrasted with the standalone receiver,
56which can use a dummy player).
57
58## Standalone Receiver
59
60The standalone receiver also uses FFMPEG, for decoding the video stream encoded
61by the sender, and also uses LibSDL2 to create a surface for decoding video.
62Unlike the sender, the standalone receiver can work without having
63its [have_external_libs](../.../cast/standalone_receiver/BUILD.gn) set to true,
64through the use of its
65[Dummy Player](../../cast/standalone_receiver/dummy_player.h).
66