QAbstractVideoSurface 类

QAbstractVideoSurface class is a base class for video presentation surfaces. 更多...

头: #include <QAbstractVideoSurface>
qmake: QT += multimedia
继承: QObject

公共类型

enum Error { NoError, UnsupportedFormatError, IncorrectFormatError, StoppedError, ResourceError }

特性

公共函数

QAbstractVideoSurface (QObject * parent = Q_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::PixelFormat> supportedPixelFormats (QAbstractVideoBuffer::HandleType type = QAbstractVideoBuffer::NoHandle) const = 0
QVideoSurfaceFormat surfaceFormat () const

信号

void activeChanged (bool active )
void nativeResolutionChanged (const QSize & resolution )
void supportedFormatsChanged ()
void surfaceFormatChanged (const QVideoSurfaceFormat & format )

保护函数

void setError (Error error )
void setNativeResolution (const QSize & resolution )

额外继承成员

详细描述

QAbstractVideoSurface class is a base class for video presentation surfaces.

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 解码媒体 or cameras 以履行自己的处理。

视频表面呈现连续流同等格式 QVideoFrame 实例,每帧格式兼容流供给格式当开始呈现时。每帧可以拥有时间戳信息,可以用于表面以决定何时显示该帧。

表面可以呈现的像素列表格式的给出通过 supportedPixelFormats () 函数,和 isFormatSupported () 函数将测试是否支持视频表面格式。若格式不支持 nearestFormat () 函数也许能建议类似格式。例如:若表面支持一组固定分辨率,它可能建议包含提议分辨率的最小支持分辨率。

start () 函数接受支持格式并启用视频表面。一旦启动,表面将开始显示它收到的帧在 present () 函数。表面可以保持呈现视频帧缓冲的引用,直到呈现新的帧或流停止为止。此外,视频表面可以保持视频帧引用,直到 结束时间戳 被传递。 stop () 函数将禁用表面并释放它保持引用的任何视频缓冲。

实现 QAbstractVideoSurface 子类

当实现此接口的子类时,只有少数函数要实现,分成 2 类:

  • 格式相关
  • 呈现相关

对于格式相关功能,仅仅必须描述支持的像素格式 (和 nearestFormat () 函数)。对于呈现相关功能,必须实现 present () 函数,和 start () 和 stop () 函数。

注意: 必须调用基类实现的 start () 和 stop () 在您的实现中。

成员类型文档编制

enum QAbstractVideoSurface:: Error

此枚举描述可能的错误,错误返回通过 error () 函数。

常量 描述
QAbstractVideoSurface::NoError 0 没有出现错误。
QAbstractVideoSurface::UnsupportedFormatError 1 视频格式不被支持。
QAbstractVideoSurface::IncorrectFormatError 2 视频帧不兼容表面格式。
QAbstractVideoSurface::StoppedError 3 表面尚未开始。
QAbstractVideoSurface::ResourceError 4 表面无法分配一些资源。

特性文档编制

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.

访问函数:

QSize nativeResolution () const

通知程序信号:

void nativeResolutionChanged (const QSize & resolution )

成员函数文档编制

QAbstractVideoSurface:: QAbstractVideoSurface ( QObject * parent = Q_NULLPTR)

构造视频表面采用给定 parent .

QAbstractVideoSurface:: ~QAbstractVideoSurface ()

销毁视频表面。

[signal] void QAbstractVideoSurface:: activeChanged ( bool active )

信号 active 视频表面状态已改变。

另请参阅 isActive (), start (),和 stop ().

Error QAbstractVideoSurface:: error () const

返回上次发生的错误。

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

另请参阅 setError ().

bool QAbstractVideoSurface:: isActive () const

指示视频表面是否已启动。

返回 true 若表面已启动,否则返回 false。

[virtual] bool QAbstractVideoSurface:: isFormatSupported (const QVideoSurfaceFormat & format ) const

测试视频表面 format 以确定表面是否能接受它。

返回 true,若格式被表面支持,否则,返回 false。

[signal] void QAbstractVideoSurface:: nativeResolutionChanged (const QSize & resolution )

信号本机 resolution 在视频表面已改变。

注意: 通知程序信号对于特性 nativeResolution .

[virtual] QVideoSurfaceFormat QAbstractVideoSurface:: nearestFormat (const QVideoSurfaceFormat & format ) const

返回所支持的视频表面格式,类似于 format .

A similar surface format is one that has the same pixel format and handle type but may differ 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.

[pure virtual] bool QAbstractVideoSurface:: present (const QVideoFrame & frame )

呈现视频 frame .

返回 true,若帧被呈现;返回 false,若发生错误。

并非所有表面都会阻塞,直到框架呈现完成为止。在非阻塞表面调用 present() 可能失败,若调用在上一帧呈现完成之前。在这种情况下,表面可能不返回到就绪状态直到有机会处理事件为止。

若 present() 失败对于任何其它原因,表面应立即进入停止状态且 error () 值将被设置。

视频表面必须处于启动状态为 present() 成功,且视频帧格式必须兼容当前视频表面格式。

另请参阅 error ().

[protected] void QAbstractVideoSurface:: setError ( Error error )

设置值为 error () 到 error .

此接口的实现者可以调用这,以传达最近错误是什么。

另请参阅 error ().

[protected] void QAbstractVideoSurface:: setNativeResolution (const QSize & resolution )

设置视频表面的原始 resolution .

This function can be called by implementors of this interface to specify to frame producers what the native resolution of this surface is.

另请参阅 nativeResolution ().

[virtual] bool QAbstractVideoSurface:: start (const QVideoSurfaceFormat & format )

使视频表面开始呈现 format 帧。

返回 true,若表面已开始;返回 false,若发生错误。

注意: 必须在实现末尾,调用基类实现的 start()。

另请参阅 isActive () 和 stop ().

[virtual] void QAbstractVideoSurface:: stop ()

停止在视频表面呈现帧,并释放任何获得资源在 start ().

注意: 必须在实现的起始,调用基类实现的 stop()。

另请参阅 isActive () 和 start ().

[signal] void QAbstractVideoSurface:: supportedFormatsChanged ()

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

另请参阅 supportedPixelFormats () 和 isFormatSupported ().

[pure virtual] QList < QVideoFrame::PixelFormat > QAbstractVideoSurface:: supportedPixelFormats ( QAbstractVideoBuffer::HandleType type = QAbstractVideoBuffer::NoHandle) const

返回视频表面能呈现的像素格式列表,针对给定句柄 type .

返回像素格式为 QAbstractVideoBuffer::NoHandle 类型是有效的,对于能以只读方式映射的任何缓冲。

可假定列表中的首个类型,渲染会更快。

QVideoSurfaceFormat QAbstractVideoSurface:: surfaceFormat () const

返回视频表面的格式。

[signal] void QAbstractVideoSurface:: surfaceFormatChanged (const QVideoSurfaceFormat & format )

信号配置 format of a video surface has changed.

另请参阅 surfaceFormat () 和 start ().