Issue
Android apps, via the Presentation
class and related facilities, can display separate content on an external display (HDMI, MHL, Miracast, etc.) than on a phone or tablet's own touchscreen (what I'll call the "primary display" here).
For the primary display, we can use screencap
or DDMS to do a screenshot.
Is there a way to do a screenshot of the external display?
Ideally, it would be a solution that could be used akin to screencap
/DDMS, with no app modifications. However, solutions that involve somehow copying the contents of the Window
representing the external display would also be interesting.
Solution
There is no OS feature for capturing the external display.
The main display is composited from a number of sources, as is the external display. The "screen capture" feature is actually just another way to composite the various sources. Because it uses the same parameters as the main display, you get the same output. (Note that any "secure" layers, such as DRM-protected video, do not appear however.) So to "capture" the external display, you'd want a screen capture variant that uses the external display "layer stack" rather than the main, and there is no API for doing so.
(See SurfaceFlinger::captureScreenImplLocked()
in SurfaceFlinger.cpp.)
The screenrecord
command does something similar: it creates a virtual display with the main display's layer stack, and captures whatever gets rendered there.
As far as capturing the output of a Presentation
goes, there are a couple of CTS tests that may be of interest. The VirtualDisplayTest creates a Presentation
and captures it with an ImageReader, while EncodeVirtualDisplayTest feeds the Presentation through a full video encode/decode path. The tests just draw a series of colors and then check to make sure the colors can be read back. Both of these require recent very versions of Android (e.g. ImageReader
didn't exist until API 19), and the app's limited permissions will restrict the output to what the app itself is rendering.
Answered By - fadden
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.