DisplaySourceServicepublic class DisplaySourceService extends com.android.accessorydisplay.common.Service
Fields Summary |
---|
private static final int | MSG_DISPATCH_DISPLAY_ADDED | private static final int | MSG_DISPATCH_DISPLAY_REMOVED | private static final String | DISPLAY_NAME | private static final int | BIT_RATE | private static final int | FRAME_RATE | private static final int | I_FRAME_INTERVAL | private final Callbacks | mCallbacks | private final ServiceHandler | mHandler | private final android.hardware.display.DisplayManager | mDisplayManager | private boolean | mSinkAvailable | private int | mSinkWidth | private int | mSinkHeight | private int | mSinkDensityDpi | private VirtualDisplayThread | mVirtualDisplayThread |
Methods Summary |
---|
private void | createVirtualDisplay()
releaseVirtualDisplay();
mVirtualDisplayThread = new VirtualDisplayThread(
mSinkWidth, mSinkHeight, mSinkDensityDpi);
mVirtualDisplayThread.start();
| private void | handleSinkAvailable(int width, int height, int densityDpi)
if (mSinkAvailable && mSinkWidth == width && mSinkHeight == height
&& mSinkDensityDpi == densityDpi) {
return;
}
getLogger().log("Accessory display sink available: "
+ "width=" + width + ", height=" + height
+ ", densityDpi=" + densityDpi);
mSinkAvailable = true;
mSinkWidth = width;
mSinkHeight = height;
mSinkDensityDpi = densityDpi;
createVirtualDisplay();
| private void | handleSinkNotAvailable()
getLogger().log("Accessory display sink not available.");
mSinkAvailable = false;
mSinkWidth = 0;
mSinkHeight = 0;
mSinkDensityDpi = 0;
releaseVirtualDisplay();
| public void | onMessageReceived(int service, int what, java.nio.ByteBuffer content)
switch (what) {
case Protocol.DisplaySourceService.MSG_SINK_AVAILABLE: {
getLogger().log("Received MSG_SINK_AVAILABLE");
if (content.remaining() >= 12) {
final int width = content.getInt();
final int height = content.getInt();
final int densityDpi = content.getInt();
if (width >= 0 && width <= 4096
&& height >= 0 && height <= 4096
&& densityDpi >= 60 && densityDpi <= 640) {
handleSinkAvailable(width, height, densityDpi);
return;
}
}
getLogger().log("Receive invalid MSG_SINK_AVAILABLE message.");
break;
}
case Protocol.DisplaySourceService.MSG_SINK_NOT_AVAILABLE: {
getLogger().log("Received MSG_SINK_NOT_AVAILABLE");
handleSinkNotAvailable();
break;
}
}
| private void | releaseVirtualDisplay()
if (mVirtualDisplayThread != null) {
mVirtualDisplayThread.quit();
mVirtualDisplayThread = null;
}
| public void | start()
super.start();
getLogger().log("Sending MSG_QUERY.");
getTransport().sendMessage(Protocol.DisplaySinkService.ID,
Protocol.DisplaySinkService.MSG_QUERY, null);
| public void | stop()
super.stop();
handleSinkNotAvailable();
|
|