libgpac
Documentation of the core library of GPAC
JSFilterSession Interface Reference

JSFilterSession API. More...

import"filtersession.idl";

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 rmt_set_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)
 

Data Fields

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

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

Parameters
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

Parameters
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

Parameters
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.

Parameters
indexindex of filter to query. This index is only valid when session is locked
Returns
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.

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

◆ rmt_send()

void JSFilterSession::rmt_send ( DOMString  command)

sends the given string to the remotery client(s)

Parameters
commandthe command to send
Returns
error code if any

◆ rmt_set_fun()

void JSFilterSession::rmt_set_fun ( function  callback)

sets callback function to use when processing remotery client request

Parameters
callbackthe callback function to call. This function takes one parameter which is the text being received
Returns
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

Parameters
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
Returns
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.

Parameters
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.

Parameters
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).

Parameters
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

Parameters
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)
Returns
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.

Parameters
enableenables reporting if true

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 - used for DASH simulations mostly

◆ http_bitrate

readonly attribute unsigned long JSFilterSession::http_bitrate

current http download rate averaged on all active resources