FileDocCategorySizeDatePackage
RemoteDisplay.javaAPI DocAndroid 5.1 API4839Thu Mar 12 22:22:30 GMT 2015android.media

RemoteDisplay

public final class RemoteDisplay extends Object
Listens for Wifi remote display connections managed by the media server.
hide

Fields Summary
public static final int
DISPLAY_FLAG_SECURE
public static final int
DISPLAY_ERROR_UNKOWN
public static final int
DISPLAY_ERROR_CONNECTION_DROPPED
private final dalvik.system.CloseGuard
mGuard
private final Listener
mListener
private final android.os.Handler
mHandler
private long
mPtr
Constructors Summary
private RemoteDisplay(Listener listener, android.os.Handler handler)


        
        
        
        

         
        mListener = listener;
        mHandler = handler;
    
Methods Summary
private voiddispose(boolean finalized)

        if (mPtr != 0) {
            if (mGuard != null) {
                if (finalized) {
                    mGuard.warnIfOpen();
                } else {
                    mGuard.close();
                }
            }

            nativeDispose(mPtr);
            mPtr = 0;
        }
    
public voiddispose()
Disconnects the remote display and stops listening for new connections.

        dispose(false);
    
protected voidfinalize()

        try {
            dispose(true);
        } finally {
            super.finalize();
        }
    
public static android.media.RemoteDisplaylisten(java.lang.String iface, android.media.RemoteDisplay$Listener listener, android.os.Handler handler)
Starts listening for displays to be connected on the specified interface.

param
iface The interface address and port in the form "x.x.x.x:y".
param
listener The listener to invoke when displays are connected or disconnected.
param
handler The handler on which to invoke the listener.

        if (iface == null) {
            throw new IllegalArgumentException("iface must not be null");
        }
        if (listener == null) {
            throw new IllegalArgumentException("listener must not be null");
        }
        if (handler == null) {
            throw new IllegalArgumentException("handler must not be null");
        }

        RemoteDisplay display = new RemoteDisplay(listener, handler);
        display.startListening(iface);
        return display;
    
private native voidnativeDispose(long ptr)

private native longnativeListen(java.lang.String iface)

private native voidnativePause(long ptr)

private native voidnativeResume(long ptr)

private voidnotifyDisplayConnected(android.view.Surface surface, int width, int height, int flags, int session)

        mHandler.post(new Runnable() {
            @Override
            public void run() {
                mListener.onDisplayConnected(surface, width, height, flags, session);
            }
        });
    
private voidnotifyDisplayDisconnected()

        mHandler.post(new Runnable() {
            @Override
            public void run() {
                mListener.onDisplayDisconnected();
            }
        });
    
private voidnotifyDisplayError(int error)

        mHandler.post(new Runnable() {
            @Override
            public void run() {
                mListener.onDisplayError(error);
            }
        });
    
public voidpause()

        nativePause(mPtr);
    
public voidresume()

        nativeResume(mPtr);
    
private voidstartListening(java.lang.String iface)

        mPtr = nativeListen(iface);
        if (mPtr == 0) {
            throw new IllegalStateException("Could not start listening for "
                    + "remote display connection on \"" + iface + "\"");
        }
        mGuard.open("dispose");