This PR introduces a Web Worker for transmuxing resolving https://github.com/shaka-project/shaka-player/issues/1735 - The worker bundle is compiled separately - The build output is embedded as a string constant and then wrapped in a Blob to create an inline Worker URL (HLS.js does this very similarly) - `TransmuxerProxy` is created wrapping a real transmuxer, but no worker is started yet - on the first `transmux()` call, it checks if the device supports worker transmuxing - For each transmux() call: the buffer is copied, then zero-copy transferred to the worker. A PublicPromise is stored under a reqId with a timeout timer, and the main thread awaits it. - The worker transmuxes and posts back transmuxed (or error). The shared message listener routes the response to the right proxy instance by id, which resolves the promise and cancels the timer. - When the last proxy instance is destroyed, the worker is terminated and the blob URL is revoked. loaded inside the worker. - Some low-end devices have been excluded since their Worker support is questionable There most likely is a better way to do this - please let me know
This directory contains the scripts used to build and test Shaka Player. These scripts can run on any platform that supports Python v3.5 and Java 21+.
all.pysimply runsgendeps.py,check.py,docs.py, andbuild.py. It will forward--forcetobuild.py.build.pybuilds the compiled library. This will fail if there are syntax or type errors.check.pywill check all the files for style violations and will check the tests for type errors (but will not produce any compiled output).checkversion.pyis used internally as part of our release process.docs.pywill build the documentation. The output will be indocs/api.gendeps.pywill createdeps.jswhich is required to use the uncompiled library.shakaBuildHelpers.pyis a utility library used by these scripts.stats.pywill read the compiled library and source map to get information about the size of the compiled library.test.pywill run the unit/integration tests.
All the scripts here use two environment variables:
PRINT_ARGUMENTSif set, will print the command-line to subprocesses.RAISE_INTERRUPTif set, will raise interrupts rather than swallowing them.
$ PRINT_ARGUMENTS=1 build.py
git -C /path/to/shaka describe --tags --dirty
Compiling the library...
java -jar /path/to/shaka/node_modules/.../compiler.jar --language_in ...
Configurable Build
build.py is used to compile the library and can also be used to produce
customized builds that contain only the features that your app requires.
build.py accepts an optional argument --name which will set the name of the
build, defaulting to ui. All other arguments are treated as commands
describing what to include in the build. If nothing is given, it will use
+@complete.
A command is either an addition or a subtraction. An addition is prefixed with
a +; a subtraction with a -. An addition will add the JavaScript file (or
build file) to the resulting library while a subtraction will remove it. After
the first character, there is either the path to a JavaScript file, or a @
followed by the name of a build file.
Build files are the files found in build/types/. These files are simply a
newline separated list of commands to execute. So if the +@complete command
is given, it will open the complete file and run it (which may in turn open
other build files). Subtracting a build file will reverse all actions applied
by the given file. So -@networking will remove all the networking plugins.
# Examples:
build.py +@complete
build.py +@complete -@networking
build.py --name custom +@manifests +@networking +../my_plugin.js
Test
test.py accepts some arguments, but mostly will forward them to karma. You
can run karma start --help to get more info about the karma test runner. If
you don't have karma installed, it will be installed by npm install and will
be found in node_modules/.bin.
test.py has two arguments that it handles directly. --force will cause
the build to run even if there are no changes detected to the source code.
--no-build will not build the library even if it does not exist. Note that
some integration tests will not run without the compiled library present.
There are also several custom arguments that are handled in JavaScript by
karma.conf.js or the tests themselves (via getClientArg).
These arguments can be passed in using test.py or using karma start
directly:
--quickwill only run unit tests, skipping integration tests.--enable-loggingwill enable console logging. Logs will be printed to the console. It accepts the enum for the log level--enable-logging=v2, defaulting toinfo. See lib/debug/log.js for the log levels.--externalwill run integration tests against external assets. This will take an extremely long time to run, and requires a fast and reliable internet connection.--no-drmwill skip integration tests against DRM license servers. Not specifying this flag requires a connection to the open internet.--uncompiledwill run integration tests using the uncompiled library instead of the compiled version.--randomwill run the tests in a random order to isolate test dependencies.--seedwill seed the random test order so that the same order can be reproduced across runs. Specify any value--seed=xyz.--runsallows running the tests multiple times in succession. This parameter must be specified with a positive integer value, for example--runs 5.--use-xvfbwill launch the browsers in a virtual display (only on Linux).--filteris used to filter a specific test or set of tests. This parameter is specified as a RegExp string--filter="DataUriPlugin .*\d".
The karma argument --browsers will set the browsers used to run the tests
(e.g. --browsers Chrome,Firefox). If you don't pass any arguments, test.py
will choose a defaults based on your platform. However, if you pass any
arguments to test.py, it will not choose browsers and you must pass
--browsers.
Stats
stats.py is used to print various stats about the compiled library. This is
used internally to determine dependencies and to determine the size of the
compiled library.
Before running the script, you have to compile it first. Then you need to pass
either the name of the build (e.g. ui) or the path to the .map file.
You will also need to pass some arguments to determine the output you want.
You must pass exactly one of the following:
-cor--class-depswill print dependencies between classes.-for--function-depswill print dependencies between functions.-sor--function-sizeswill print the compiled size of the functions.-tor--all-tokenswill print all the tokens in the source map.
For --class-deps and --function-deps you can also output in DOT format.
This format can be used to produce visual graphs of the dependencies. Passing
in -d or --dot-format will output in DOT format. Then the output can be
piped into another program to produce the output. For example using graphviz:
stats.py -c -d | fdb -Goverlap=prism | neato -n2 -Tsvg > out.svg