QAbstractVideoSurface Class
The QAbstractVideoSurface class is a base class for video presentation surfaces. More...
| Header: | #include <QAbstractVideoSurface> |
| qmake: | QT += multimedia |
| Inherits: | QObject |
Public Types
| enum | Error { NoError, UnsupportedFormatError, IncorrectFormatError, StoppedError, ResourceError } |
Properties
- nativeResolution : const QSize
Public Functions
| QSize | nativeResolution() const |
Signals
| void | nativeResolutionChanged(const QSize &resolution) |
Detailed Description
The QAbstractVideoSurface class defines the standard interface that video producers use to inter-operate with video presentation surfaces. You can subclass this interface to receive video frames from sources like decoded media or cameras to perform your own processing.
A video surface presents a continuous stream of identically formatted QVideoFrame instances, where the format of each frame is compatible with a stream format supplied when starting a presentation. Each frame may have timestamp information that can be used by the surface to decide when to display that frame.
A list of pixel formats a surface can present is given by the supportedPixelFormats() function, and the isFormatSupported() function will test if a video surface format is supported. If a format is not supported the nearestFormat() function may be able to suggest a similar format. For example, if a surface supports fixed set of resolutions it may suggest the smallest supported resolution that contains the proposed resolution.
The start() function takes a supported format and enables a video surface. Once started a surface will begin displaying the frames it receives in the present() function. Surfaces may hold a reference to the buffer of a presented video frame until a new frame is presented or streaming is stopped. In addition, a video surface may hold a reference to a video frame until the end timestamp has passed. The stop() function will disable a surface and release any video buffers it holds references to.
Implementing a subclass of QAbstractVideoSurface
When implementing a subclass of this interface, there are only a handful of functions to implement, broken down into two classes:
- Format related
- Presentation related
For format related functionality, you just have to describe the pixel formats that you support (and the nearestFormat() function). For presentation related functionality, you have to implement the present() function, and the start() and stop() functions.
Note: You must call the base class implementation of start() and stop() in your implementation.
Member Type Documentation
enum QAbstractVideoSurface::Error
This enum describes the errors that may be returned by the error() function.
| Constant | Value | Description |
|---|---|---|
QAbstractVideoSurface::NoError | 0 | No error occurred. |
QAbstractVideoSurface::UnsupportedFormatError | 1 | A video format was not supported. |
QAbstractVideoSurface::IncorrectFormatError | 2 | A video frame was not compatible with the format of the surface. |
QAbstractVideoSurface::StoppedError | 3 | The surface has not been started. |
QAbstractVideoSurface::ResourceError | 4 | The surface could not allocate some resource. |
Property Documentation
nativeResolution : const QSize
The native resolution of video surface. This is the resolution of video frames the surface can render with optimal quality and/or performance.
The native resolution is not always known and can be changed during playback.
Access functions:
| QSize | nativeResolution() const |
Notifier signal:
| void | nativeResolutionChanged(const QSize &resolution) |