Documentation of the core library of GPAC
JSFilterSession Interface Reference

JSFilterSession API. More...


Public Member Functions

void post_task (function task_callback, optional DOMString task_name=null)
void abort (optional boolean do_flush=false)
void lock_filters (boolean do_lock)
JSFSFilter get_filter (unsigned long index)
JSFSFilter get_filter (DOMString iname)
void rmt_send (DOMString command)
void set_rmt_fun (function callback)
JSFSFilter add_filter (DOMString filter_to_add, optional JSFSFilter link_from=null, optional DOMString link_args=null)
void set_new_filter_fun (function callback)
void set_del_filter_fun (function callback)
void set_event_fun (function callback)
boolean fire_event (FilterEvent evt, optional JSFSFilter *filter=null, optional boolean upstream=false)
void reporting (boolean enable)
JSFilter new_filter (DOMString name=null)

Data Fields

attribute long nb_filters
readonly attribute boolean last_task
attribute unsigned long http_max_bitrate
readonly attribute unsigned long http_bitrate
readonly attribute boolean connected

Detailed Description

The JSFilterSession interface has a single instance exposed to the script under the name "session". It implements binding to the underlying filter session object, see GF_FilterSession.

Member Function Documentation

◆ post_task()

void JSFilterSession::post_task ( function  task_callback,
optional DOMString  task_name = null 

posts a task to the main scheduler - see gf_fs_post_user_task

task_callbackthe callback function to use. This callback functions has no parameters, and returns false or an exception to abort the task, true to reschedule the task immediately or a reschedule time in milliseconds
task_nameoptional value giving a label for the task

◆ abort()

void JSFilterSession::abort ( optional boolean  do_flush = false)

aborts the filter session - see gf_fs_abort

do_flushif true, wait for all packets currently pending to be processed before closing the session

◆ lock_filters()

void JSFilterSession::lock_filters ( boolean  do_lock)

locks the filter session - see gf_fs_lock_filters. When the session is locked, tasks are suspended and filters cannot be destroyed. The session only needs to be locked when enumerating filters

do_lockif true, locks the session, otherwise unlocks it

◆ get_filter() [1/2]

JSFSFilter JSFilterSession::get_filter ( unsigned long  index)

returns the JSFSFilter object for the given index.

indexindex of filter to query. This index is only valid when session is locked
the filter object, null if none found

◆ get_filter() [2/2]

JSFSFilter JSFilterSession::get_filter ( DOMString  iname)

returns the JSFSFilter object for a given filter iname.

inamethe iname of filter to query
the filter object, null if none found

◆ rmt_send()

void JSFilterSession::rmt_send ( DOMString  command)

sends the given string to the remotery client(s)

commandthe command to send
error code if any

◆ set_rmt_fun()

void JSFilterSession::set_rmt_fun ( function  callback)

sets callback function to use when processing remotery client request

callbackthe callback function to call. This function takes one parameter which is the text being received
error code if any

◆ add_filter()

JSFSFilter JSFilterSession::add_filter ( DOMString  filter_to_add,
optional JSFSFilter  link_from = null,
optional DOMString  link_args = null 

inserts a filter in graph

filter_to_addstring describin the filter to add, can be in the form "src=" for sources, "dst=" for sinks or regular string for filters.
link_fromfilter used as source for the created filters - see gf_filter_set_source
link_argsarguments for the link (used to assign new filter SID - see gf_filter_set_source
new filter created

◆ set_new_filter_fun()

void JSFilterSession::set_new_filter_fun ( function  callback)

sets callback function to get notifications upon each new filter creation.

callbackcallback function - it is passed a single parameter, the filter object

◆ set_del_filter_fun()

void JSFilterSession::set_del_filter_fun ( function  callback)

sets callback function to get notifications upon each filter destruction.

callbackthe callback function - it is passed a single parameter, the filter object

◆ set_event_fun()

void JSFilterSession::set_event_fun ( function  callback)

sets callback function to get events being sent back to application (see gf_fs_set_ui_callback).

callbackcallback function - it is passed a single parameter set, an event instance of FilterEvent interface. The return value of the function should be as indicated for each event type

◆ fire_event()

boolean JSFilterSession::fire_event ( FilterEvent  evt,
optional JSFSFilter filter = null,
optional boolean  upstream = false 

fires a given event on all registered user event if no filter is specified, or on the filter

evtthe event to send
filterthe filter to send the event to
upstreamif filter is not null, indicates whether the event shall be sent upstream (towards the sink) or downstream (towards the destination)
true if event was fired, false if no event target was found or if the filter is not an event target

◆ reporting()

void JSFilterSession::reporting ( boolean  enable)

enables session reporting - see gf_fs_enable_reporting.

enableenables reporting if true

◆ new_filter()

JSFilter JSFilterSession::new_filter ( DOMString  name = null)

creates a new custom JS filter. This filter will share the same script context as the filter session script - see JSFilter

A custom filter cannot use default arguments, and will not have the initialize callback function called.
namename for the filter
new filter

Field Documentation

◆ nb_filters

attribute long JSFilterSession::nb_filters

number of filters in the session - see gf_fs_get_filters_count. This number is only valid when session is locked

◆ last_task

readonly attribute boolean JSFilterSession::last_task

check if the calling task is the last task in the session - see gf_fs_is_last_task

◆ http_max_bitrate

attribute unsigned long JSFilterSession::http_max_bitrate

max capped HTTP download rate in bps - used for DASH simulations mostly

◆ http_bitrate

readonly attribute unsigned long JSFilterSession::http_bitrate

current http download rate averaged on all active resources in bps

◆ connected

readonly attribute boolean JSFilterSession::connected

set to true if no PID initialization task (connections) is pending