User-defined filters.
More...
A custom filter allows your application to interact closely with the media pipeline, but cannot be used in graph resolution. Custom filters can be sources, sinks, or intermediate filters. The following limitations however exist:
- custom filters will not be cloned
- custom filters cannot be used as sources of filters loading a source filter graph dynamically, such as the dashin filter.
- custom filters cannot be used as destination of filters loading a destination filter graph dynamically, such as the dasher filters.
A custom filter must implement the CustomFilter class, and optionally provide the following methods
- configure_pid: callback for PID configuration, mandatory if your filter is not a source
- process: callback for processing
- process_event: callback for processing and event
- reconfigure_output: callback for output reconfiguration (PID capability negotiation)
A custom filter must also declare its capabilities, input and output, using push_cap method
let fs = new gpac.FilterSession();
let cust = fs.new_filter("NodeJS_Test");
cust.set_max_pids(-1);
cust.pids = [];
cust.push_cap('StreamType', 'Visual', gpac.GF_CAPS_INPUT);
cust.push_cap('StreamType', 'Audio', gpac.GF_CAPS_INPUT);
cust.configure_pid = function(pid, is_remove)
{
if (this.pids.indexOf(pid) < 0) {
this.pids.push(pid);
console.log('New PID !');
} else if (is_remove) {
console.log('PID remove !');
} else {
console.log('PID reconfigure !');
}
return gpac.GF_OK;
}
cust.process = function() {
let nb_eos=0;
this.pids.forEach(pid =>{
if (pid.eos) {
nb_eos++;
return;
}
let pck = pid.get_packet();
if (!pck) return;
pid.drop_packet();
return;
}
if (nb_eos == this.pids.length)
return gpac.GF_EOS;
return gpac.GF_OK;
}
cust.process_event = function(evt)
{
return false;
}
See GF_Filter
◆ _BufferOccupancy
interface _BufferOccupancy |
buffer occupancy descriptor
Data Fields |
unsigned long |
max_units |
maximum number of packets (partial or full AU) allowed in buffer
|
unsigned long |
nb_pck |
number of block allowed in buffer
|
unsigned long |
max_dur |
maximum buffer duration in microseconds
|
unsigned long |
dur |
buffer duration in microseconds
|
boolean |
is_final_flush |
if true, the session has been aborted and this is the final flush for this buffer
|
◆ _FilterEvent
event object for filters and GPAC event proc.
The variables defined have the same names as the fields in the various unions of __gf_filter_event.
The variables are defined depending on the event type.
Additional variables are defined:
- name: string decribing the event type
- ui_type: integer giving the UI event type (see GF_Event)
- ui_name: string decribing the UI event type
Events properties are read-only for input events and read/write for events created by the JS code.