Debian Codegraph @

README.md

raw symbols SCIP
1 # GStreamer
2
3 This is GStreamer, a framework for streaming media.
4
5 ## Where to start
6
7 We have a website at
8
9 https://gstreamer.freedesktop.org
10
11 Our documentation, including tutorials, API reference and FAQ can be found at
12
13 https://gstreamer.freedesktop.org/documentation/
14
15 You can ask questions on the GStreamer Discourse at
16
17 https://discourse.gstreamer.org/
18
19 We track bugs, feature requests and merge requests (patches) in GitLab at
20
21 https://gitlab.freedesktop.org/gstreamer/
22
23 You can join us on our Matrix room at
24
25 https://matrix.to/#/#gstreamer:gstreamer.org
26
27 This repository contains all official modules supported by the GStreamer
28 community which can be found in the `subprojects/` directory.
29
30 ## Getting started
31
32 ### Install git and python 3.8+
33
34 If you're on Linux, you probably already have these. On macOS, new versions of
35 Xcode ship Python 3 already. If you're on an older Xcode, you can use the
36 [official Python installer](https://www.python.org/downloads/mac-osx/).
37
38 You can find [instructions for Windows below](#windows-prerequisites-setup).
39
40 ### Install meson and ninja
41
42 Meson 1.1 or newer is required.
43
44 On Linux and macOS you can get meson through your package manager or using:
45
46 ```
47 $ pip3 install --user meson
48 ```
49
50 This will install meson into `~/.local/bin` which may or may not be included
51 automatically in your PATH by default.
52
53 You should get `ninja` using your package manager or download the [official
54 release](https://github.com/ninja-build/ninja/releases) and put the `ninja`
55 binary in your PATH.
56
57 You can find [instructions for Windows below](#windows-prerequisites-setup).
58
59
60 If you used the official Python installer on macOS instead of the Python
61 3 shipped with Xcode, you might need to execute "Install Certificates.command"
62 from the Python folder in the user Applications folder:
63
64 ```
65 $ /Applications/Python\ 3.*/Install\ Certificates.command
66 ```
67
68 Otherwise you will get this error when downloading meson wraps:
69
70 ```
71 urllib.error.URLError: urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
72 ```
73
74 ### Build GStreamer and its modules
75
76 You can get all GStreamer built running:
77
78 ```
79 meson setup builddir
80 meson compile -C builddir
81 ```
82
83 This will automatically create the `builddir` directory and build everything
84 inside it.
85
86 NOTE: On Windows, meson will automatically detect and use the latest Visual
87 Studio if GCC, clang, etc are not available in `PATH`. Use the `--vsenv`
88 argument to force the use of Visual Studio.
89
90 NOTE: Meson will not update subprojects automatically once a subproject has
91 been fetched. Remember to update subprojects if wrap files are updated.
92
93 ```
94 meson subprojects update
95 ```
96
97 ### External dependencies
98
99 All mandatory dependencies of GStreamer are included as [meson subprojects](https://mesonbuild.com/Subprojects.html):
100 libintl, zlib, libffi, glib. Some optional dependencies are also included as
101 subprojects, such as ffmpeg, x264, json-glib, graphene, openh264, orc, etc.
102
103 Mandatory dependencies will be automatically built if meson cannot find them on
104 your system using pkg-config. The same is true for optional dependencies that
105 are included as subprojects. You can find a full list by looking at the
106 `subprojects` directory.
107
108 Plugins that need optional dependencies that aren't included can only be built
109 if they are provided by the system. Instructions on how to build some common
110 ones such as Qt5/QML are listed below. If you do not know how to provide an
111 optional dependency needed by a plugin, you should use [Cerbero](https://gitlab.freedesktop.org/gstreamer/cerbero/#description)
112 which handles this for you automatically.
113
114 Plugins will be automatically enabled if possible, but you can ensure that
115 a particular plugin (especially if it has external dependencies) is built by
116 enabling the gstreamer repository that ships it and the plugin inside it. For
117 example, to enable the Qt5 plugin in the gst-plugins-good repository, you need
118 to run meson as follows:
119
120 ```
121 meson -Dgood=enabled -Dgst-plugins-good:qt5=enabled builddir
122 ```
123
124 This will cause Meson to error out if the plugin could not be enabled. You can
125 also flip the default and disable all plugins except those explicitly enabled
126 like so:
127
128 ```
129 meson -Dauto_features=disabled -Dgstreamer:tools=enabled -Dbad=enabled -Dgst-plugins-bad:openh264=enabled
130 ```
131
132 This will disable all optional features and then enable the `openh264` plugin
133 and the tools that ship with the core gstreamer repository: `gst-inspect-1.0`,
134 `gst-launch-1.0`, etc. As usual, you can change these values on a builddir that
135 has already been setup with `meson configure -Doption=value`.
136
137 ### Building the Qt5 QML plugin
138
139 If `qmake` is not in `PATH` and pkgconfig files are not available, you can
140 point the `QMAKE` env var to the Qt5 installation of your choosing before
141 running `meson` as shown above.
142
143 The plugin will be automatically enabled if possible, but you can ensure that
144 it is built by passing `-Dgood=enabled -Dgst-plugins-good:qt5=enabled` to `meson`.
145
146 ### Building the Intel MSDK plugin
147
148 On Linux, you need to have development files for `libmfx` installed. On
149 Windows, if you have the [Intel Media SDK](https://software.intel.com/en-us/media-sdk),
150 it will set the `INTELMEDIASDKROOT` environment variable, which will be used by
151 the build files to find `libmfx`.
152
153 The plugin will be automatically enabled if possible, but you can ensure it by
154 passing `-Dbad=enabled -Dgst-plugins-bad:msdk=enabled` to `meson`.
155
156 ### Building plugins with (A)GPL-licensed dependencies
157
158 Some plugins have GPL- or AGPL-licensed dependencies and will only be built
159 if you have explicitly opted in to allow (A)GPL-licensed dependencies by
160 passing `-Dgpl=enabled` to Meson.
161
162 List of plugins with (A)GPL-licensed dependencies (non-exhaustive) in gst-plugins-bad:
163 - dts (DTS audio decoder plugin)
164 - faad (Free AAC audio decoder plugin)
165 - iqa (Image quality assessment plugin based on dssim-c)
166 - mpeg2enc (MPEG-2 video encoder plugin)
167 - mplex (audio/video multiplexer plugin)
168 - ofa (Open Fingerprint Architecture library plugin)
169 - resindvd (Resin DVD playback plugin)
170 - x265 (HEVC/H.265 video encoder plugin)
171
172 List of plugins with (A)GPL-licensed dependencies (non-exhaustive) in gst-plugins-ugly:
173 - a52dec (Dolby Digital (AC-3) audio decoder plugin)
174 - cdio (CD audio source plugin based on libcdio)
175 - dvdread (DVD video source plugin based on libdvdread)
176 - mpeg2dec (MPEG-2 video decoder plugin based on libmpeg2)
177 - sidplay (Commodore 64 audio decoder plugin based on libsidplay)
178 - x264 (H.264 video encoder plugin based on libx264)
179
180 ### Static build
181
182 Since *1.18.0*, when doing a static build using `--default-library=static`,
183 a shared library `gstreamer-full-1.0`, in addition to a package config file,
184 will be produced and includes all enabled GStreamer plugins and libraries.
185 A list of libraries that needs to be exposed in `gstreamer-full-1.0`
186 ABI can be set using `gst-full-libraries` option.
187 glib-2.0, gobject-2.0 and gstreamer-1.0 are always included.
188
189 ```
190 meson setup --default-library=static -Dgst-full-libraries=gstreamer-app-1.0,gstreamer-video-1.0 builddir
191 ```
192
193 GStreamer *1.18* requires applications using gstreamer-full-1.0 to initialize
194 static plugins by calling `gst_init_static_plugins()` after `gst_init()`. That
195 function is defined in `gst/gstinitstaticplugins.h` header file.
196
197 Since *1.20.0*, `gst_init_static_plugins()` is called automatically by
198 `gst_init()` and applications don't have to call it manually any more.
199 The header file has been removed from public API.
200
201 One can use the `gst-full-version-script` option to pass a
202 [version script](https://www.gnu.org/software/gnulib/manual/html_node/LD-Version-Scripts.html)
203 to the linker. This can be used to control the exact symbols that are exported by
204 the `gstreamer-full` library, allowing the linker to garbage collect unused code
205 and so, reduce the total library size. A default script
206 `gstreamer-full-default.map` declares only glib/gstreamer symbols as public.
207
208 One can use the `gst-full-plugins` option to pass a list of plugins to be
209 registered in the `gstreamer-full` library. The default value is '*'
210 which means that all the plugins selected during the build process will be
211 registered statically.
212 An empty value will prevent any plugins to be registered.
213
214 One can select a specific set of features with `gst-full-elements`,
215 `gst-full-typefind-functions`, `gst-full-device-providers`
216 or `gst-full-dynamic-types` to select specific feature from a plugin.
217 When a feature has been listed in one of those options, the other features from
218 its plugin will no longer be automatically included, even if the plugin
219 is listed in `gst-full-plugins`.
220
221 The user must insure that all selected plugins and features (element,
222 typefind, etc.) have been enabled during the build configuration.
223
224 To register features, the syntax is the following:
225 plugins are separated by ';' and features from a plugin starts after ':'
226 and are ',' separated.
227
228 As an example:
229
230 * `-Dgst-full-plugins=coreelements;typefindfunctions;alsa;pbtypes`:
231 Enable only `coreelements`, `typefindfunctions`, `alsa`, `pbtypes` plugins.
232 * `-Dgst-full-elements=coreelements:filesrc,fakesink,identity;alsa:alsasrc`:
233 Enable only `filesrc`, `identity` and `fakesink` elements from `coreelements`
234 plugin and `alsasrc` element from `alsa` plugin.
235 * `-Dgst-full-typefind-functions=typefindfunctions:wav,flv`:
236 Enable only typefind func `wav` and `flv` from `typefindfunctions`
237 * `-Dgst-full-device-providers=alsa:alsadeviceprovider`:
238 Enable `alsadeviceprovider` from `alsa` plugin.
239 * `-Dgst-full-dynamic-types=pbtypes:video_multiview_flagset`:
240 Enable `video_multiview_flagset` from `pbtypes`.
241
242 All features from the `playback` plugin will be enabled and the other plugins
243 will be restricted to the specific features requested.
244
245 All the selected features will be registered into a dedicated `NULL`
246 plugin name.
247
248 This will cause the features/plugins that are not registered to not be included
249 in the final gstreamer-full library.
250
251 This is an experimental feature, backward incompatible changes could still be
252 made in the future.
253 Only linux-like platforms are currently well supported when Windows, MSVC
254 and MinGW, should be considered as *experimental* as the symbols export
255 is still under discussion.
256
257 Since 1.24.7, it is possible to disable the `gstreamer-full` library by passing
258 `-Dgst-full=disabled`. This can be useful in cases where you want a static
259 build of gstreamer, but you do not want to use gst-full, since linking the
260 static executables associated with it can be quite CPU/RAM intensive.
261
262
263 #### Full-static build
264
265 Since *1.24.0*, it is also possible to link an application with GStreamer
266 statically. It means that all the gstreamer libraries will be linked within
267 your library or application. However, it is important to note that even though
268 the `gstreamer-full` library can be statically built into the application,
269 it does not contain all of the code (core libraries and plugins).
270 Instead, it relies on all the other static libraries. Hence, while the
271 `gstreamer-full` library provides a cohesive access point, the actual
272 functionality is distributed across various static libraries.
273 You can enable this option using `-Dgst-full-target-type=static_library` which
274 is by default set to `shared_library`. The buildsystem will produce a set of
275 archives depending on your `gstreamer-full` configuration as explained above.
276 Your application can now check the `gstreamer-full` dependency within meson or
277 with the package config file.
278 In both case, the application can rely on the `gstreamer-full-1.0.pc` file
279 generated during the build process to retrieve all its dependencies.
280 In that configuration, the *features* selected during the build configuration
281 will be automatically registered during the call of `gst_init()`.
282
283
284 ### Building documentation
285
286 Documentation is not built by default because it is slow to generate. To build
287 the documentation, first ensure that `hotdoc` is installed and `doc` option is
288 enabled. For API documentation, gobject introspection must also be enabled.
289 The special target `gst-doc` can then be used to (re)generate the documentation.
290
291 ```sh
292 $ pip install hotdoc
293 $ meson setup -Ddoc=enabled -Dintrospection=enabled builddir
294 $ meson compile -C builddir gst-doc
295 ```
296
297 NOTE: To visualize the documentation, `devhelp` can be run inside the development
298 environment (see below).
299
300 # Development environment
301
302 ## Development environment target
303
304 GStreamer ships a script that drops you into a development environment where
305 all the plugins, libraries, and tools you just built are available:
306
307 ```
308 ./gst-env.py
309 ```
310
311 Or with a custom builddir (i.e., not `build`, `_build` or `builddir`):
312
313 ```
314 ./gst-env.py --builddir <BUILDDIR>
315 ```
316
317 You can also use `ninja devenv` inside your build directory to achieve the same
318 effect. However, this may not work on Windows if meson has auto-detected the
319 visual studio environment.
320
321 Alternatively, if you'd rather not start a shell in your workflow, you
322 can mutate the current environment into a suitable state like so:
323
324 ```
325 ./gst-env.py --only-environment
326 ```
327
328 This will print output suitable for an sh-compatible `eval` function,
329 just like `ssh-agent -s`.
330
331 An external script can be run in development environment with:
332
333 ```
334 ./gst-env.py external_script.sh
335 ```
336
337 NOTE: In the development environment, a fully usable prefix is also configured
338 in `gstreamer/prefix` where you can install any extra dependency/project.
339
340 For more extensive documentation about the development environment go to [the
341 documentation](https://gstreamer.freedesktop.org/documentation/installing/building-from-source-using-meson.html).
342
343 ## Windows Development Environment
344
345 ### Prerequisites
346
347 - **Visual Studio Community 2022** (or later) with:
348 - Desktop development with C++ workload
349 - Windows SDK
350 - **Python 3.8+** (required for build system and gst-env.py)
351 - **Meson 0.59.0+** (install via pip: `pip install meson`)
352
353 It is recommended to use Visual Studio Community 2022 and PowerShell terminal.
354
355 Meson 0.59.0+ automatically detects and activates the Visual Studio toolchain when no other compilers are found. GStreamer should be built in a PowerShell environment for a complete user experience.
356
357 NOTE: If you have other toolchains (MinGW, Clang, etc.) in your PATH, Meson may detect those instead of Visual Studio. To ensure Visual Studio is used:
358 - Remove conflicting toolchains from your Windows PATH, or
359 - Use the `--vsenv` flag: `meson setup --vsenv builddir`, or
360 - Run from a Developer PowerShell for VS 2022 which pre-configures the environment
361
362 ### Building with Visual Studio
363
364 ```powershell
365 meson setup builddir
366 meson compile -C builddir
367 ```
368
369 NOTE: You should verify that Visual Studio is being detected. Look for output similar to:
370
371 ```powershell
372 ...
373 Activating VS 17.x.x
374 ...
375 ```
376
377 ### Using the Development Environment in PowerShell
378
379 ```powershell
380 python.exe gst-env.py
381 ```
382
383 Or with a custom build directory:
384
385 ```powershell
386 python.exe gst-env.py --builddir builddir
387 ```
388
389 You can also use ninja directly:
390
391 ```powershell
392 ninja -C builddir devenv
393 ```
394
395 The development environment will configure all necessary paths (PATH, GST_PLUGIN_PATH, etc.) so you can immediately use GStreamer tools and test your changes:
396
397 ```powershell
398 gst-inspect-1.0.exe coreelements
399 gst-launch-1.0.exe videotestsrc ! autovideosink
400 ```
401
402 ## Custom subprojects
403
404 We also added a meson option, `custom_subprojects`, that allows the user
405 to provide a comma-separated list of meson subprojects that should be built
406 alongside the default ones.
407
408 To use it:
409
410 ```sh
411 # Clone into the subprojects directory
412 $ git -C subprojects clone my_subproject
413 # Wipe dependency detection state, in case you have an existing build dir
414 $ meson setup --wipe builddir -Dcustom_subprojects=my_subproject
415 $ meson compile -C builddir
416 ```
417
418 ## Run tests
419
420 You can easily run the test of all the components:
421
422 ```
423 meson test -C builddir
424 ```
425
426 To list all available tests:
427
428 ```
429 meson test -C builddir --list
430 ```
431
432 To run all the tests of a specific component:
433
434 ```
435 meson test -C builddir --suite gst-plugins-base
436 ```
437
438 Or to run a specific test file:
439
440 ```
441 meson test -C builddir --suite gstreamer gst_gstbuffer
442 ```
443
444 Run a specific test from a specific test file:
445
446 ```
447 GST_CHECKS=test_subbuffer meson test -C builddir --suite gstreamer gst_gstbuffer
448 ```
449
450 ## Optional Installation
451
452 You can also install everything that is built into a predetermined prefix like
453 so:
454
455 ```
456 meson setup --prefix=/path/to/install/prefix builddir
457 meson compile -C builddir
458 meson install -C builddir
459 ```
460
461 Note that the installed files have `RPATH` stripped, so you will need to set
462 `LD_LIBRARY_PATH`, `DYLD_LIBRARY_PATH`, or `PATH` as appropriate for your
463 platform for things to work.
464
465
466 ## Add information about GStreamer development environment in your prompt line
467
468 ### Bash prompt
469
470 We automatically handle `bash` and set `$PS1` accordingly.
471
472 If the automatic `$PS1` override is not desired (maybe you have a fancy custom
473 prompt), set the `$GST_BUILD_DISABLE_PS1_OVERRIDE` environment variable to
474 `TRUE` and use `$GST_ENV` when setting the custom prompt, for example with a
475 snippet like the following:
476
477 ```bash
478 ...
479 if [[ -n "${GST_ENV-}" ]];
480 then
481 PS1+="[ ${GST_ENV} ]"
482 fi
483 ...
484 ```
485
486 ### Using powerline
487
488 In your powerline theme configuration file (by default in
489 `{POWERLINE INSTALLATION DIR}/config_files/themes/shell/default.json`)
490 you should add a new environment segment as follow:
491
492 ```
493 {
494 "function": "powerline.segments.common.env.environment",
495 "args": { "variable": "GST_ENV" },
496 "priority": 50
497 },
498 ```
499
500 ## Windows Prerequisites Setup
501
502 On Windows, some of the components may require special care.
503
504 ### Git for Windows
505
506 Use the [Git for Windows](https://gitforwindows.org/) installer. It will
507 install a `bash` prompt with basic shell utils and up-to-date git binaries.
508
509 During installation, when prompted about `PATH`, you should select the
510 following option:
511
512 ![Select "Git from the command line and also from 3rd-party software"](/data/images/git-installer-PATH.png)
513
514 ### Python 3.8+ on Windows
515
516 Use the [official Python installer](https://www.python.org/downloads/windows/).
517 You must ensure that Python is installed into `PATH`:
518
519 ![Enable Add Python to PATH, then click Customize Installation](/data/images/py-installer-page1.png)
520
521 You may also want to customize the installation and install it into
522 a system-wide location such as `C:\PythonXY`, but this is not required.
523
524 ### Ninja on Windows
525
526 If you are using Visual Studio 2019 or newer, Ninja is already provided.
527
528 In other cases, the easiest way to install Ninja on Windows is with `pip3`,
529 which will download the compiled binary and place it into the `Scripts`
530 directory inside your Python installation:
531
532 ```
533 pip3 install ninja
534 ```
535
536 You can also download the [official release](https://github.com/ninja-build/ninja/releases)
537 and place it into `PATH`, or use MSYS2.
538
539 ### Meson on Windows
540
541 **IMPORTANT**: Do not use the Meson MSI installer since it is experimental and known to not
542 work with `GStreamer`.
543
544 You can use `pip3` to install Meson, same as Ninja above:
545
546 ```
547 pip3 install meson
548 ```
549
550 Note that Meson is written entirely in Python, so you can also run it as-is
551 from the [git repository](https://github.com/mesonbuild/meson/) if you want to
552 use the latest master branch for some reason.
553
554 ### Running Meson on Windows
555
556 Since version 0.59.0, Meson automatically activates the Visual Studio
557 environment on Windows if no other compilers (gcc, clang, etc) are found. To
558 force the use of Visual Studio in such cases, you can use:
559
560 ```
561 meson setup --vsenv builddir
562 ```
563
564 ### Setup a mingw/wine based development environment on linux
565
566 #### Install wine and mingw
567
568 ##### On fedora x64
569
570 ``` sh
571 sudo dnf install mingw64-gcc mingw64-gcc-c++ mingw64-pkg-config mingw64-winpthreads wine
572 ```
573
574 FIXME: Figure out what needs to be installed on other distros
575
576 #### Get meson from git
577
578 This simplifies the process and allows us to use the cross files
579 defined in meson itself.
580
581 ``` sh
582 git clone https://github.com/mesonbuild/meson.git
583 ```
584
585 #### Build and install
586
587 ```
588 BUILDDIR=$PWD/winebuild/
589 export WINEPREFIX=$BUILDDIR/wine-prefix/ && mkdir -p $WINEPREFIX
590 # Setting the prefix is mandatory as it is used to setup symlinks within the development environment
591 meson/meson.py $BUILDDIR --cross-file meson/cross/linux-mingw-w64-64bit.txt -Dgst-plugins-bad:vulkan=disabled -Dorc:gtk_doc=disabled --prefix=$BUILDDIR/wininstall/ -Djson-glib:gtk_doc=disabled
592 meson/meson.py install -C $BUILDDIR/
593 ```
594
595 > __NOTE__: You should use `meson install -C $BUILDDIR` each time you make a change
596 > instead of the usual `meson compile -C $BUILDDIR` as this is not in the
597 > development environment.
598
599 Alternatively, you can also use `mingw64-meson` on Fedora, which is a wrapper
600 script that sets things up to use Fedora's cross files and settings. However,
601 the wrapper script can be buggy in some cases.
602
603 #### cross-mingw development environment
604
605 You can get into the development environment as usual with the gst-env.py
606 script:
607
608 ```
609 ./gst-env.py
610 ```
611
612 See [above](#development-environment) for more details.
613
614 After setting up [binfmt] to use wine for windows binaries,
615 you can run GStreamer tools under wine by running:
616
617 ```
618 gst-launch-1.0.exe videotestsrc ! glimagesink
619 ```
620
621 [binfmt]: http://man7.org/linux/man-pages/man5/binfmt.d.5.html