-
-
Notifications
You must be signed in to change notification settings - Fork 791
Real time filters
This library support OpenGL real time filters. By default you can choose between 36 different filters:
If you want use this feature you need use the following constructors:
- Camera1Base: OpenglView, Context.
- Camera2Base: OpenglView, Context (useOpengl = true).
- DisplayBase: Context (useOpengl = true).
- FromFileBase: Context.
If you want add a filter to stream you only need use setFilter method. Example set gray scale filter:
rtmpCamera1.getGlInterface().setFilter(new GreyScaleFilterRender());
In this version, the filters was refactored to remove or add filters dinamically without limitations. This produce a better performance in most of cases respect of previous versions.
Actually, it is working like if you are using a java ArrayList class with the following options:
/**
* Replaces the filter at the specified position with the specified filter.
* You can modify filter's parameters after set it to stream.
*
* @param filterPosition filter position
* @param baseFilterRender filter to set
*/
void setFilter(int filterPosition, BaseFilterRender baseFilterRender);
/**
* Appends the specified filter to the end.
* You can modify filter's parameters after set it to stream.
*
* @param baseFilterRender filter to add
*/
void addFilter(BaseFilterRender baseFilterRender);
/**
* Inserts the specified filter at the specified position.
* You can modify filter's parameters after set it to stream.
*
* @param filterPosition filter position
* @param baseFilterRender filter to set
*/
void addFilter(int filterPosition, BaseFilterRender baseFilterRender);
/**
* Remove all filters
*/
void clearFilters();
/**
* Remove the filter at the specified position.
*
* @param filterPosition position of filter to remove
*/
void removeFilter(int filterPosition);
/**
* @return number of filters
*/
int filtersCount();
/**
* Replace the filter in position 0 or add the filter if list is empty.
* You can modify filter's parameters after set it to stream.
*
* @param baseFilterRender filter to set.
*/
void setFilter(BaseFilterRender baseFilterRender);
You can set multiple filters by position:
//Greyscale + basic deformation
rtmpCamera1.getGlInterface().setFilter(0, new GreyScaleFilterRender());
rtmpCamera1.getGlInterface().setFilter(1, new BasicDeformationFilterRender());
You can select max number of filters in OpenGlView attrs:
app:numFilters="2"
Or modify it by code before create stream object:
ManagerRender.numFilters = 2;
rtmpFromFile = new RtmpFromFile(context, connectChecker, videoDecoderInterface, audioDecoderInterface);
You can do your own filter if you extend from BaseFilterRender class. I recommend you see GreyScaleFilterRender class that is the most easy filter in the library to know how to work it and create your own filter.