FileDocCategorySizeDatePackage
CallbackFilter.javaAPI DocAndroid 5.1 API3079Thu Mar 12 22:22:30 GMT 2015android.filterpacks.base

CallbackFilter

public class CallbackFilter extends android.filterfw.core.Filter
hide

Fields Summary
private FilterContext.OnFrameReceivedListener
mListener
private Object
mUserData
private boolean
mCallbacksOnUiThread
private android.os.Handler
mUiThreadHandler
Constructors Summary
public CallbackFilter(String name)

        super(name);
    
Methods Summary
public voidprepare(android.filterfw.core.FilterContext context)

        if (mCallbacksOnUiThread) {
            mUiThreadHandler = new Handler(Looper.getMainLooper());
        }
    
public voidprocess(android.filterfw.core.FilterContext context)

        // Get frame and forward to listener
        final Frame input = pullInput("frame");
        if (mListener != null) {
            if (mCallbacksOnUiThread) {
                input.retain();
                CallbackRunnable uiRunnable = new CallbackRunnable(mListener, this, input, mUserData);
                if (!mUiThreadHandler.post(uiRunnable)) {
                    throw new RuntimeException("Unable to send callback to UI thread!");
                }
            } else {
                mListener.onFrameReceived(this, input, mUserData);
            }
        } else {
            throw new RuntimeException("CallbackFilter received frame, but no listener set!");
        }
    
public voidsetupPorts()

        addInputPort("frame");