CopperSpice API  1.9.2
QAbstractVideoSurface Class Referenceabstract

The QAbstractVideoSurface class is a base class for video presentation surfaces. More...

Inheritance diagram for QAbstractVideoSurface:
QObject

Public Types

enum  Error
 

Public Signals

void activeChanged (bool active)
 
void nativeResolutionChanged (const QSize &resolution)
 
void supportedFormatsChanged ()
 
void surfaceFormatChanged (const QVideoSurfaceFormat &format)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Methods

 QAbstractVideoSurface (QObject *parent=nullptr)
 
 ~QAbstractVideoSurface ()
 
Error error () const
 
bool isActive () const
 
virtual bool isFormatSupported (const QVideoSurfaceFormat &format) const
 
QSize nativeResolution () const
 
virtual QVideoSurfaceFormat nearestFormat (const QVideoSurfaceFormat &format) const
 
virtual bool present (const QVideoFrame &frame) = 0
 
virtual bool start (const QVideoSurfaceFormat &format)
 
virtual void stop ()
 
virtual QList< QVideoFrame::PixelFormatsupportedPixelFormats (QAbstractVideoBuffer::HandleType handleType=QAbstractVideoBuffer::NoHandle) const = 0
 
QVideoSurfaceFormat surfaceFormat () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Protected Methods

void setError (Error error)
 
void setNativeResolution (const QSize &resolution)
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Properties

 nativeResolution
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 

Detailed Description

The QAbstractVideoSurface class is a base class for video presentation surfaces.

The QAbstractVideoSurface class defines the standard interface that video producers use to inter-operate with video presentation surfaces. It is not supposed to be instantiated directly. Instead, you should subclass it to create new video surfaces.

A video surface presents a continuous stream of identically formatted frames, where the format of each frame is compatible with a stream format supplied when starting a presentation.

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. The stop() function will disable a surface and a release any video buffers it holds references to.

See also
isActive(), start(), stop()

Member Enumeration Documentation

This enum describes the errors that may be returned by the error() function.

ConstantValueDescription
QAbstractVideoSurface::NoError0No error occurred.
QAbstractVideoSurface::UnsupportedFormatError1A video format was not supported.
QAbstractVideoSurface::IncorrectFormatError2A video frame was not compatible with the format of the surface.
QAbstractVideoSurface::StoppedError3The surface has not been started.
QAbstractVideoSurface::ResourceError4The surface could not allocate some resource.

Constructor & Destructor Documentation

QAbstractVideoSurface::QAbstractVideoSurface ( QObject parent = nullptr)
explicit

Constructs a video surface with the given parent.

QAbstractVideoSurface::~QAbstractVideoSurface ( )

Destroys this video surface.

Method Documentation

void QAbstractVideoSurface::activeChanged ( bool  active)
signal

Signals the active state of a video surface has changed.

See also
isActive(), start(), stop()
Error QAbstractVideoSurface::error ( ) const

Returns the last error that occurred. If a surface fails to start(), or stops unexpectedly this function can be called to discover what error occurred.

See also
setError()
bool QAbstractVideoSurface::isActive ( ) const

Indicates whether a video surface has been started. Returns true if the surface has been started, and false otherwise.

bool QAbstractVideoSurface::isFormatSupported ( const QVideoSurfaceFormat format) const
virtual

Tests a video surface format to determine if a surface can accept it.

Returns true if the format is supported by the surface, and false otherwise.

QSize QAbstractVideoSurface::nativeResolution ( ) const

Returns the property containing the native resolution of video surface.

void QAbstractVideoSurface::nativeResolutionChanged ( const QSize resolution)
signal

Signals the native resolution of video surface has changed.

QVideoSurfaceFormat QAbstractVideoSurface::nearestFormat ( const QVideoSurfaceFormat format) const
virtual

Returns a supported video surface format that is similar to format.

A similar surface format is one that has the same pixel format and handle type but differs in some of the other properties. For example if there are restrictions on the frame sizes a video surface can accept it may suggest a format with a larger frame size and a viewport the size of the original frame size.

If the format is already supported it will be returned unchanged, or if there is no similar supported format an invalid format will be returned.

bool QAbstractVideoSurface::present ( const QVideoFrame frame)
pure virtual

Presents a video frame. Returns true if the frame was presented, and false if an error occurred.

Not all surfaces will block until the presentation of a frame has completed. Calling present() on a non-blocking surface may fail if called before the presentation of a previous frame has completed. In such cases the surface may not return to a ready state until it is had an opportunity to process events.

If this method fails for any other reason the surface will immediately enter the stopped state and an error() value will be set. A video surface must be in the started state for this method to succeed, and the format of the video frame must be compatible with the current video surface format.

See also
error()
void QAbstractVideoSurface::setError ( Error  error)
protected

Sets the value of error() to error.

See also
error()
void QAbstractVideoSurface::setNativeResolution ( const QSize resolution)
protected

Sets the resolution property of the video surface to resolution.

bool QAbstractVideoSurface::start ( const QVideoSurfaceFormat format)
virtual

Starts a video surface presenting format frames. Returns true if the surface was started, and false if an error occurred.

See also
isActive(), stop()
void QAbstractVideoSurface::stop ( )
virtual

Stops a video surface presenting frames and releases any resources acquired in start().

See also
isActive(), start()
void QAbstractVideoSurface::supportedFormatsChanged ( )
signal

Signals the set of formats supported by a video surface has changed.

See also
supportedPixelFormats(), isFormatSupported()
QList< QVideoFrame::PixelFormat > QAbstractVideoSurface::supportedPixelFormats ( QAbstractVideoBuffer::HandleType  handleType = QAbstractVideoBuffer::NoHandle) const
pure virtual

Returns a list of pixel formats a video surface can present for a given handleType.

The pixel formats returned for the QAbstractVideoBuffer::NoHandle type are valid for any buffer that can be mapped in read-only mode. Types that are first in the list can be assumed to be faster to render.

QVideoSurfaceFormat QAbstractVideoSurface::surfaceFormat ( ) const

Returns the format of a video surface.

void QAbstractVideoSurface::surfaceFormatChanged ( const QVideoSurfaceFormat format)
signal

Signals the configured format of a video surface has changed.

See also
surfaceFormat(), start()

Property Documentation

QAbstractVideoSurface::nativeResolution

The native resolution of this 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.

PropertiesClass Methods
read nativeResolution
notify nativeResolutionChanged