Recently in project I faced challenge of resizing VirtualDisplay
"on flight". So the use case is :
- Start stream
- In undetermined period of stream there may come specific data which indicates that my streaming capabilities have changed
- Update
VirtualDisplay's
parameters without recreation, so that state loss is avoided
I've found in documentation for VirtualDisplay
resize method, though it seems to have no effect on new parameters incoming. For implementation I am using
virtualDisplay = mDisplayManager.createVirtualDisplay("DispName",
getResolution().getResolutionWidth(), getResolution().getResolutionHeight(),
getDisplayDensity(), inputSurface, DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION);
where inputSurface
is created by mediaEncoder.createInputSurface()
and cofigured properly by this moment. So, the question is, how can I resize VirtualDisplay
? I also didn't find any examples how to do it in official sources, would appreciate any help!
UPDATE
Just forgot to mention, I've put Listener
for VirtualDisplays
and onChange
method is triggered, though check if actual metrics were changed shows negative results