libgpac
Documentation of the core library of GPAC
JavaScript APIs

JavaScript API available in GPAC. More...

+ Collaboration diagram for JavaScript APIs:

Modules

 JS Core API for libgpac
 JavaScript API for libgpac core tools.
 
 JS Filter API
 JavaScript API for filters.
 
 XMLHttpRequest API
 XMLHttpRequest API.
 
 EVG JS API
 Embedded Vector Graphics JavaScript API.
 
 Compositor API
 GPAC Compositor and Scene API.
 
 Storage API
 Storage API.
 
 WebGL API
 WebGL API.
 
 JS FilterSession API
 JavaScript API for FilterSession.
 
 JS DASH Adaptation API
 JavaScript API for DASH client adaptation algorithm.
 
 JS HTTP output API
 JavaScript API for httpout filter.
 

Detailed Description

Parts of the GPAC code can be modified at run-time using JavaScript. This part of the documentation describes the various APIs used in GPAC.

For SVG and DOM scenegraph API, see https://www.w3.org/TR/SVGTiny12/svgudom.html.

For BIFS and VRML scenegraph, see https://www.web3d.org/documents/specifications/14772/V2.0/part1/javascript.html

SVG and BIFS APIs are automatically loaded when loading an SVG or BIFS scene with script nodes. They cannot be loaded in another way.

The JSFilter API is loaded through a dedicated filter, see gpac -h jsf.

All other APIs shall be loaded by the parent script (scene or JSFilter) as ECMAScript modules using the import directive.

GPAC uses the amazing QuickJS engine for JavaScript support: https://bellard.org/quickjs/quickjs.html. Although not JIT-enabled, it is small, fast and cross-platform which ensures the same behaviour on all devices.

The module loader is the same as the QuickJS libc module loader (https://bellard.org/quickjs/quickjs.html#Modules), except that it checks for .so, .dll or .dylib extensions for C modules.

This means that JS C modules as defined in QuickJS could also be used (https://bellard.org/quickjs/quickjs.html#C-Modules)

Warning
support for C modules is still not fully tested

There is currently no support for non-local modules (http, https ...).

The default GPAC compilation includes the following modules from QuickJS:

GPAC constants used in the API (error code, property types, specific flags for functions) are exported:

Unless indicated otherwise, all errors are handled through exceptions. An exception object contains a code (integer) attribute and optionally a message (string) attribute.

Types and interfaces are described using WebIDL, see https://heycam.github.io/webidl/, with some slight modifications.

Warning
These IDL files are only intended to document the APIs, and are likely useless for other purposes.

Notes on QuickJS 'os' module support: