FileDocCategorySizeDatePackage
FilterFunction.javaAPI DocAndroid 5.1 API3909Thu Mar 12 22:22:30 GMT 2015android.filterfw.core

FilterFunction

public class FilterFunction extends Object
hide

Fields Summary
private Filter
mFilter
private FilterContext
mFilterContext
private boolean
mFilterIsSetup
private FrameHolderPort[]
mResultHolders
Constructors Summary
public FilterFunction(FilterContext context, Filter filter)

        mFilterContext = context;
        mFilter = filter;
    
Methods Summary
public voidclose()

        mFilter.performClose(mFilterContext);
    
private voidconnectFilterOutputs()

        int  i = 0;
        mResultHolders = new FrameHolderPort[mFilter.getNumberOfOutputs()];
        for (OutputPort outputPort : mFilter.getOutputPorts()) {
            mResultHolders[i] = new FrameHolderPort();
            outputPort.connectTo(mResultHolders[i]);
            ++i;
        }
    
public Frameexecute(KeyValueMap inputMap)

        int filterOutCount = mFilter.getNumberOfOutputs();

        // Sanity checks
        if (filterOutCount > 1) {
            throw new RuntimeException("Calling execute on filter " + mFilter + " with multiple "
                + "outputs! Use executeMulti() instead!");
        }

        // Setup filter
        if (!mFilterIsSetup) {
            connectFilterOutputs();
            mFilterIsSetup = true;
        }

        // Make sure GL environment is active
        boolean didActivateGLEnv = false;
        GLEnvironment glEnv = mFilterContext.getGLEnvironment();
        if (glEnv != null && !glEnv.isActive()) {
            glEnv.activate();
            didActivateGLEnv = true;
        }

        // Setup the inputs
        for (Entry<String, Object> entry : inputMap.entrySet()) {
            if (entry.getValue() instanceof Frame) {
                mFilter.pushInputFrame(entry.getKey(), (Frame)entry.getValue());
            } else {
                mFilter.pushInputValue(entry.getKey(), entry.getValue());
            }
        }

        // Process the filter
        if (mFilter.getStatus() != Filter.STATUS_PROCESSING) {
            mFilter.openOutputs();
        }

        mFilter.performProcess(mFilterContext);

        // Create result handle
        Frame result = null;
        if (filterOutCount == 1 && mResultHolders[0].hasFrame()) {
            result = mResultHolders[0].pullFrame();
        }

        // Deactivate GL environment if activated
        if (didActivateGLEnv) {
            glEnv.deactivate();
        }

        return result;
    
public FrameexecuteWithArgList(java.lang.Object inputs)

        return execute(KeyValueMap.fromKeyValues(inputs));
    
public FilterContextgetContext()

        return mFilterContext;
    
public FiltergetFilter()

        return mFilter;
    
public voidsetInputFrame(java.lang.String input, Frame frame)

        mFilter.setInputFrame(input, frame);
    
public voidsetInputValue(java.lang.String input, java.lang.Object value)

        mFilter.setInputValue(input, value);
    
public voidtearDown()

        mFilter.performTearDown(mFilterContext);
        mFilter = null;
    
public java.lang.StringtoString()

        return mFilter.getName();