![]() |
libgpac
Documentation of the core library of GPAC
|
JSGPACCoreSystem API. More...
import <core.idl;
Public Member Functions | |
| void | gc () |
| void | set_arg_used (unsigned int arg_idx, boolean arg_used) |
| DOMString | error_string (GF_Err e) |
| DOMString | prompt_input () |
| DOMString | prompt_string () |
| void | prompt_echo_off (boolean echo_off) |
| void | prompt_code (unsigned long code) |
| WinRect | prompt_size () |
| Array | enum_directory (DOMString dir, optional DOMString filter=null, optional bool go_up=false) |
| unsigned long | clock_ms () |
| unsigned long long | clock_us () |
| void | sleep (optional unsigned long sleep=0) |
| void | exit (optional unsigned long ret_code=0) |
| DOMString | fcc_to_str (unsigned long value) |
| void | rand_init (optional boolean reset=false) |
| unsigned long | rand () |
| unsigned long long | rand64 () |
| DOMString | getenv (DOMString var_name) |
| unsigned long long | get_utc () |
| unsigned long long | get_utc (unsigned long year, unsigned long month, unsigned long day, unsigned long hour, unsigned long min, unsigned long sec) |
| unsigned long long | get_utc (DOMString date) |
| Fraction | get_ntp () |
| Fraction | ntp_shift (Fraction ntp, long microseconds) |
| unsigned long | crc32 (ArrayBuffer abuf) |
| unsigned long | crc32 (DOMString str) |
| ArrayBuffer | sha1 (DOMString fname) |
| ArrayBuffer | sha1 (ArrayBuffer abuf) |
| ArrayBuffer | load_file (DOMString fname, optional boolean as_utf8=false) |
| ArrayBuffer | compress (ArrayBuffer in_data, optional boolean use_gz=false) |
| ArrayBuffer | decompress (ArrayBuffer in_data, optional boolean use_gz=false) |
| void | rmdir (DOMString dirname) |
| void | mkdir (DOMString dirname) |
| boolean | dir_exists (DOMString dirname) |
| void | dir_clean (DOMString dirname) |
| DOMString | basename (DOMString filename) |
| DOMString | file_ext (DOMString filename) |
| boolean | file_exists (DOMString filename) |
| void | del (DOMString filename) |
| unsigned long long | mod_time (DOMString filename) |
| void | move (DOMString filename, DOMString newname) |
| DOMString | get_opt (DOMString secname, DOMString keyname) |
| void | set_opt (DOMString secname, DOMString keyname, optional DOMString value=null) |
| void | discard_opts () |
| DOMString | base64enc (ArrayBuffer in_data) |
| ArrayBuffer | base64enc (DOMString in_data) |
| DOMString | base16enc (ArrayBuffer in_data) |
| ArrayBuffer | base16enc (DOMString in_data) |
| unsigned long | htonl (unsigned long value) |
| unsigned long | htons (unsigned long value) |
| unsigned long | ntohl (unsigned long value) |
| unsigned long | ntohs (unsigned long value) |
| unsigned long | pixfmt_size (DOMString pix_fmt, unsigned long width, unsigned long height) |
| boolean | pixfmt_transparent (DOMString pix_fmt) |
| boolean | pixfmt_yuv (DOMString pix_fmt) |
| boolean | pixfmt_depth (DOMString pix_fmt) |
| unsigned long | pcmfmt_depth (DOMString pcm_fmt) |
| DOMString | color_lerp (double interp, DOMString color1, DOMString color2) |
| double | color_component (DOMString color, unsigned long comp_idx) |
| DOMString | url_cat (DOMString parent, DOMString URL) |
| Rect | rect_union (Rect r1, Rect r2) |
| Rect | rect_intersect (Rect r1, Rect r2) |
| void | enable_rmtws (bool enable) |
| DOMString | get_logs (bool original_logs=GF_FALSE) |
| void | set_logs (DOMString logs, bool reset=false) |
Data Fields | |
| attribute Array | args |
| optional attribute function | rmt_on_new_client |
| attribute readonly unsigned long | nb_cores |
| attribute readonly unsigned long | sampling_period_duration |
| attribute readonly unsigned long | total_cpu_time |
| attribute readonly unsigned long | process_cpu_time |
| attribute readonly unsigned long | total_cpu_time_diff |
| attribute readonly unsigned long | process_cpu_time_diff |
| attribute readonly unsigned long | cpu_idle_time |
| attribute readonly unsigned long | total_cpu_usage |
| attribute readonly unsigned long | process_cpu_usage |
| attribute readonly unsigned long | pid |
| attribute readonly unsigned long | thread_count |
| attribute readonly unsigned long long | process_memory |
| attribute readonly unsigned long long | physical_memory |
| attribute readonly unsigned long long | physical_memory_avail |
| attribute readonly unsigned long long | gpac_memory |
| attribute DOMString | last_wdir |
| readonly attribute boolean | batteryOn |
| readonly attribute boolean | batteryCharging |
| readonly attribute unsigned long | batteryPercent |
| readonly attribute unsigned long | batteryLifeTime |
| readonly attribute unsigned long | batteryFullLifeTime |
| readonly DOMString | hostname |
| readonly boolean | test_mode |
| readonly boolean | old_arch |
| readonly boolean | log_color |
| readonly boolean | quiet |
| readonly signed int | timezone |
| readonly unsigned int | nb_files_open |
| readonly DOMString | cache_dir |
| readonly DOMString | shared_dir |
| readonly DOMString | version |
| readonly DOMString | version_full |
| readonly DOMString | copyright |
| readonly unsigned long | version_major |
| readonly unsigned long | version_minor |
| readonly unsigned long | version_micro |
| optional attribute function | on_log |
JSGPACCoreSystem API.
The JSGPACCoreSystem interface has a single instance exposed to the script under the name "Sys". It implements binding to the underlying instance of libgpac.
| void JSGPACCoreSystem::gc | ( | ) |
run garbage collection
| void JSGPACCoreSystem::set_arg_used | ( | unsigned int | arg_idx, |
| boolean | arg_used | ||
| ) |
marks an argument as used (for argument tracking at prompt)
| arg_idx | index of argument to mark as used |
| arg_used | if true, argument is marked as used |
gets string for error
| e | the error code |
| DOMString JSGPACCoreSystem::prompt_input | ( | ) |
returns character input from prompt, or null if no input (this will be moved soon to core API)
| DOMString JSGPACCoreSystem::prompt_string | ( | ) |
wait character input from prompt and returns it
| void JSGPACCoreSystem::prompt_echo_off | ( | boolean | echo_off | ) |
sets prompt echo off (input characters not visible) or on - see gf_prompt_set_echo_off
| echo_off | if true, echo is disabled |
| void JSGPACCoreSystem::prompt_code | ( | unsigned long | code | ) |
sets stderr color and other code for upcoming strings - see gf_sys_set_console_code
| code | code to set |
| WinRect JSGPACCoreSystem::prompt_size | ( | ) |
gets stdin TTY size - see gf_prompt_get_size
| Array JSGPACCoreSystem::enum_directory | ( | DOMString | dir, |
| optional DOMString | filter = null, |
||
| optional bool | go_up = false |
||
| ) |
enumerate directories
| dir | the directory to enumerate |
| filter | the filter for file extensions. If "dir", only enumerate directories |
| go_up | if true, enumerate parent directory or root (/). |
| unsigned long JSGPACCoreSystem::clock_ms | ( | ) |
get system clock in milliseconds - see gf_sys_clock
| unsigned long long JSGPACCoreSystem::clock_us | ( | ) |
get system clock in microseconds - see gf_sys_clock_high_res
| void JSGPACCoreSystem::sleep | ( | optional unsigned long | sleep = 0 | ) |
sleep for a given time - see gf_sleep
| sleep | sleep value in milliseconds |
| void JSGPACCoreSystem::exit | ( | optional unsigned long | ret_code = 0 | ) |
exit gpac process
| ret_code | exit return code |
| DOMString JSGPACCoreSystem::fcc_to_str | ( | unsigned long | value | ) |
convert a 4CC code to its string representation - see gf_4cc_to_str
| value | the 4CC code to convert |
| void JSGPACCoreSystem::rand_init | ( | optional boolean | reset = false | ) |
inits random number - see gf_rand_init
| reset | if true, resets the random seed |
| unsigned long JSGPACCoreSystem::rand | ( | ) |
gets a random number - see gf_rand
| unsigned long long JSGPACCoreSystem::rand64 | ( | ) |
gets a random number
gets an environment variable
| var_name | environment variable name |
| unsigned long long JSGPACCoreSystem::get_utc | ( | ) |
gets UTC clock - see gf_net_get_utc
| unsigned long long JSGPACCoreSystem::get_utc | ( | unsigned long | year, |
| unsigned long | month, | ||
| unsigned long | day, | ||
| unsigned long | hour, | ||
| unsigned long | min, | ||
| unsigned long | sec | ||
| ) |
gets UTC timestamp for a given date - see gf_net_get_utc_ts
| year | date's year |
| month | date's month of the year, 0 to 11 |
| day | date's day of the week, 1 to 31 |
| hour | date's hours |
| min | date's minutes |
| sec | date's seconds |
| unsigned long long JSGPACCoreSystem::get_utc | ( | DOMString | date | ) |
gets UTC clock from a date - see gf_net_parse_date
| date | date string |
| Fraction JSGPACCoreSystem::get_ntp | ( | ) |
gets NTP 64-bit timestamp - see gf_net_get_ntp_ts
shifts an NTP 64-bit timestamp by the given number of microseconds
| ntp | source NTP |
| microseconds | number of microseconds to add (positive) or remove (negative) |
| unsigned long JSGPACCoreSystem::crc32 | ( | ArrayBuffer | abuf | ) |
| unsigned long JSGPACCoreSystem::crc32 | ( | DOMString | str | ) |
| ArrayBuffer JSGPACCoreSystem::sha1 | ( | DOMString | fname | ) |
gets SHA1 digest of an arraybuffer - see gf_sha1_file
| fname | name of file to hash |
| ArrayBuffer JSGPACCoreSystem::sha1 | ( | ArrayBuffer | abuf | ) |
gets SHA1 digest of a file - see gf_sha1_csum
| abuf | array buffer |
loads file content into an array buffer - see gf_file_load_data
| fname | name of file to load |
| as_utf8 | load as UTF8 string |
| ArrayBuffer JSGPACCoreSystem::compress | ( | ArrayBuffer | in_data, |
| optional boolean | use_gz = false |
||
| ) |
compress using deflate() an array buffer
| in_data | input data to compress |
| use_gz | compress using gz (adds headers) |
| ArrayBuffer JSGPACCoreSystem::decompress | ( | ArrayBuffer | in_data, |
| optional boolean | use_gz = false |
||
| ) |
decompress using inflate() an array buffer
| in_data | input data to decompress |
| use_gz | compressed payload uses gz (has headers) |
| void JSGPACCoreSystem::rmdir | ( | DOMString | dirname | ) |
removes directory - cf gf_rmdir
| dirname | name of directory |
| void JSGPACCoreSystem::mkdir | ( | DOMString | dirname | ) |
creates directory - cf gf_mkdir
| dirname | name of directory |
| boolean JSGPACCoreSystem::dir_exists | ( | DOMString | dirname | ) |
checks if directory exists - cf gf_dir_exists
| dirname | name of directory |
| void JSGPACCoreSystem::dir_clean | ( | DOMString | dirname | ) |
remove files in directory - cf gf_dir_cleanup
| dirname | name of directory |
get basename of file or dir - cf gf_file_basename
| filename | name of file |
get file extension - cf gf_file_ext_start
| filename | name of file |
| boolean JSGPACCoreSystem::file_exists | ( | DOMString | filename | ) |
check if file exists - cf gf_file_exists
| filename | name of file |
| void JSGPACCoreSystem::del | ( | DOMString | filename | ) |
deletes a file - cf gf_file_delete
| filename | name of file |
| unsigned long long JSGPACCoreSystem::mod_time | ( | DOMString | filename | ) |
get file modification time - cf gf_file_modification_time
| filename | name of file |
rename/move file - cf gf_file_move
| filename | name of file |
| newname | new name of the file |
get option from GPAC config - cf gf_opts_get_key
| secname | name of section |
| keyname | name of key |
| void JSGPACCoreSystem::set_opt | ( | DOMString | secname, |
| DOMString | keyname, | ||
| optional DOMString | value = null |
||
| ) |
get option from GPAC config - cf gf_opts_get_key
| secname | name of section |
| keyname | name of key |
| value | new value of key or null to remove key |
| void JSGPACCoreSystem::discard_opts | ( | ) |
discard all changes in GPAC config - see gf_opts_discard_changes
| DOMString JSGPACCoreSystem::base64enc | ( | ArrayBuffer | in_data | ) |
encodes an arraybuffer to a base64 string
| in_data | input buffer |
| ArrayBuffer JSGPACCoreSystem::base64enc | ( | DOMString | in_data | ) |
decodes a base64 string to an arraybuffer
| in_data | input encoded string |
| DOMString JSGPACCoreSystem::base16enc | ( | ArrayBuffer | in_data | ) |
encodes an arraybuffer to a base16 string
| in_data | input buffer |
| ArrayBuffer JSGPACCoreSystem::base16enc | ( | DOMString | in_data | ) |
decodes a base16 string to an arraybuffer
| in_data | input encoded string |
| unsigned long JSGPACCoreSystem::htonl | ( | unsigned long | value | ) |
converts 32 bit value from host to network byte order
| value | value to convert |
| unsigned long JSGPACCoreSystem::htons | ( | unsigned long | value | ) |
converts 16 bit value from host to network byte order
| value | value to convert |
| unsigned long JSGPACCoreSystem::ntohl | ( | unsigned long | value | ) |
converts 32 bit value from network to host byte order
| value | value to convert |
| unsigned long JSGPACCoreSystem::ntohs | ( | unsigned long | value | ) |
converts 16 bit value from network to host byte order
| value | value to convert |
| unsigned long JSGPACCoreSystem::pixfmt_size | ( | DOMString | pix_fmt, |
| unsigned long | width, | ||
| unsigned long | height | ||
| ) |
gets size in bytes of an image of given size and pixel format
| pix_fmt | pixel format name |
| width | image width in pixels |
| height | image height in pixels |
| boolean JSGPACCoreSystem::pixfmt_transparent | ( | DOMString | pix_fmt | ) |
checks if pixel format is potentially transparent (uses alpha)
| pix_fmt | pixel format name |
| boolean JSGPACCoreSystem::pixfmt_yuv | ( | DOMString | pix_fmt | ) |
checks if pixel format is YUV
| pix_fmt | pixel format name |
| boolean JSGPACCoreSystem::pixfmt_depth | ( | DOMString | pix_fmt | ) |
checks bit depth of component in pixel format
| pix_fmt | pixel format name |
| unsigned long JSGPACCoreSystem::pcmfmt_depth | ( | DOMString | pcm_fmt | ) |
gets size in bytes of an audio sample in the given format
| pcm_fmt | PCM format name |
interpolates colors
| interp | interpolation fraction between 0 and 1 |
| color1 | first color to use |
| color2 | second color to use |
| double JSGPACCoreSystem::color_component | ( | DOMString | color, |
| unsigned long | comp_idx | ||
| ) |
gets color component
| color | color to use |
| comp_idx | component idx, 0 for alpha, 1 for red, 2 for green 3 for blue |
concatenates URLs
| parent | parent URL |
| URL | URL to concatenate |
gets union of two rectangles
| r1 | first rectangle |
| r2 | second rectangle |
gets intersection of two rectangles
| r1 | first rectangle |
| r2 | second rectangle |
| void JSGPACCoreSystem::enable_rmtws | ( | bool | enable | ) |
enables websocket monitoring server - see gf_sys_enable_rmtws
define the rmt_on_new_client attribute to set callbacks
| enable | (default: true) will enable the server if true, stop it if false |
get the log tools and levels - see gf_log_get_tools_levels
| original_logs | if set to true, return the logs set by the application, otherwise current logs as possibly modified by JS |
set the log tools and levels - see gf_log_set_tools_levels
| logs | string describing logs and levels. Using null will reset logs to original value before modified by JS |
| reset | reset all tools if true, otherwise only modify specified tools |
| attribute Array JSGPACCoreSystem::args |
launch arguments
| optional attribute function JSGPACCoreSystem::rmt_on_new_client |
set the callback function when new clients connect to the websocket server the function shall take one parameter of type JS_RMTClient
| attribute readonly unsigned long JSGPACCoreSystem::nb_cores |
number of cores
| attribute readonly unsigned long JSGPACCoreSystem::sampling_period_duration |
see GF_SystemRTInfo
| attribute readonly unsigned long JSGPACCoreSystem::total_cpu_time |
see GF_SystemRTInfo
| attribute readonly unsigned long JSGPACCoreSystem::process_cpu_time |
see GF_SystemRTInfo
| attribute readonly unsigned long JSGPACCoreSystem::total_cpu_time_diff |
see GF_SystemRTInfo
| attribute readonly unsigned long JSGPACCoreSystem::process_cpu_time_diff |
see GF_SystemRTInfo
| attribute readonly unsigned long JSGPACCoreSystem::cpu_idle_time |
see GF_SystemRTInfo
| attribute readonly unsigned long JSGPACCoreSystem::total_cpu_usage |
see GF_SystemRTInfo
| attribute readonly unsigned long JSGPACCoreSystem::process_cpu_usage |
see GF_SystemRTInfo
| attribute readonly unsigned long JSGPACCoreSystem::pid |
see GF_SystemRTInfo
| attribute readonly unsigned long JSGPACCoreSystem::thread_count |
see GF_SystemRTInfo
| attribute readonly unsigned long long JSGPACCoreSystem::process_memory |
see GF_SystemRTInfo
| attribute readonly unsigned long long JSGPACCoreSystem::physical_memory |
see GF_SystemRTInfo
| attribute readonly unsigned long long JSGPACCoreSystem::physical_memory_avail |
see GF_SystemRTInfo
| attribute readonly unsigned long long JSGPACCoreSystem::gpac_memory |
see GF_SystemRTInfo
| attribute DOMString JSGPACCoreSystem::last_wdir |
last working directory
| readonly attribute boolean JSGPACCoreSystem::batteryOn |
indicates if running on battery or with power charge
| readonly attribute boolean JSGPACCoreSystem::batteryCharging |
indicates if battery is charging
| readonly attribute unsigned long JSGPACCoreSystem::batteryPercent |
battery percent (0 to 100)
| readonly attribute unsigned long JSGPACCoreSystem::batteryLifeTime |
estimated battery lifetime - see gf_sys_get_battery_state
| readonly attribute unsigned long JSGPACCoreSystem::batteryFullLifeTime |
estimated battery lifetime in full charge - see gf_sys_get_battery_state
| readonly DOMString JSGPACCoreSystem::hostname |
host name
| readonly boolean JSGPACCoreSystem::test_mode |
test mode - see gf_sys_is_test_mode
| readonly boolean JSGPACCoreSystem::old_arch |
old arch compatibility mode - see gf_sys_old_arch_compat
| readonly boolean JSGPACCoreSystem::log_color |
check if logs use color - see gf_log_use_color
| readonly boolean JSGPACCoreSystem::quiet |
quiet mode - see gf_sys_is_quiet
| readonly signed int JSGPACCoreSystem::timezone |
timezone - see gf_net_get_timezone
| readonly unsigned int JSGPACCoreSystem::nb_files_open |
number of opened file handles - see gf_file_handles_count
| readonly DOMString JSGPACCoreSystem::cache_dir |
default cache directory - see gf_get_default_cache_directory
| readonly DOMString JSGPACCoreSystem::shared_dir |
default shared directory (containing gui, shaders, etc) - see gf_opts_default_shared_directory
| readonly DOMString JSGPACCoreSystem::version |
GPAC version string
| readonly DOMString JSGPACCoreSystem::version_full |
GPAC full version string, including GIT rev
| readonly DOMString JSGPACCoreSystem::copyright |
GPAC copyright string
| readonly unsigned long JSGPACCoreSystem::version_major |
GPAC version major
| readonly unsigned long JSGPACCoreSystem::version_minor |
GPAC version minor
| readonly unsigned long JSGPACCoreSystem::version_micro |
GPAC version micro
| optional attribute function JSGPACCoreSystem::on_log |
set the callback function for logs, or disable log callback and reset tools to original value if null. the callback function is of form log(DOMString tool, unsigned int level, DOMString message).