VirtualDisplay createVirtualDisplay (String name,
int width,
int height,
int dpi,
int flags,
Surface surface,
VirtualDisplay.Callback callback,
Handler handler)
Creates a VirtualDisplay to capture thecontentsofthe screen.
Parameters
name String: The nameofthe virtual display, must be non-empty.
要建立的投射器的名稱,非空
width int: The width ofthe virtual display in pixels. Must be greater than0.
投射後視頻的寬度,這裏的寬度就是實際上後面MediaCodec初始化的寬度.
height int: The height ofthe virtual display in pixels. Must be greater than0.
投射後視頻的高度,這裏的寬度就是實際上後面MediaCodec初始化的高度.
dpi int: The density ofthe virtual display in dpi. Must be greater than0.
投射器的像素密度,未理解啥意思,咱們直接用DisplayMetrics的densityDpi便可.
flags int: A combination of virtual display flags. See DisplayManager forthe full listof flags.
咱們傳
DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR|DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC|DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION 便可。
surface Surface: The surface to which the content ofthe virtual display should be rendered, or null if there is none initially.
投射器要投射到的Surface
callback VirtualDisplay.Callback: Callback to call when the virtual display's state changes, or null if none.
投射器更改後的狀態回調,咱們這裏不須要,傳null便可。
handler Handler: The Handler on which the callback should be invoked, or null ifthe callback should be invoked onthe calling thread's main Looper.
回調函數將在該Handler所在的線程調用,咱們也不須要,傳null便可。
1
2
3
4
5
6
1
2
3
4
5
6
createInputSurface
Surface createInputSurface ()
Requests a Surface to use asthe input toan encoder, in place of input buffers.
該接口建立一個做爲編碼器輸入的Surface。