public interface VideoOutput

A class that will produce video data from a Surface.

Implementations will provide a Surface to a video frame producer via the SurfaceRequest sent to onSurfaceRequested(SurfaceRequest).

The type of video data produced by a video output and API for saving or communicating that data is left to the implementation. An implementation commonly used for local video saving is Recorder. This interface is usually only needs to be implemented by applications for advanced use cases.


Public methods

abstract void onSurfaceRequested(SurfaceRequest request)

Called when a new Surface has been requested by a video frame producer.

Public methods


public abstract void onSurfaceRequested (SurfaceRequest request)

Called when a new Surface has been requested by a video frame producer.

Users of this class should not call this method directly. It will be called by the video frame producer. Implementors of this class should be aware that this method is called when a video frame producer is ready to receive a surface that it can use to send video frames to the video output. The video frame producer may repeatedly request a surface more than once, but only the latest SurfaceRequest should be considered active. All previous surface requests will complete by sending a SurfaceRequest.Result to the consumer passed to SurfaceRequest.provideSurface(Surface, Executor, Consumer).

A request is considered active until it is fulfilled, marked as 'will not complete', or cancelled by the video frame producer. After one of these conditions occurs, a request is considered completed.

Once a request is successfully completed, it is guaranteed that if a new request is made, the Surface used to fulfill the previous request will be detached from the video frame producer and the resultListener provided in SurfaceRequest.provideSurface(Surface, Executor, Consumer) will be invoked with a SurfaceRequest.Result containing SurfaceRequest.Result.RESULT_SURFACE_USED_SUCCESSFULLY.

request SurfaceRequest: the request for a surface which contains the requirements of the surface and methods for completing the request.