The 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 = nullptr) | |
| virtual | ~QAbstractVideoSurface () |
| 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 ) |
| const QMetaObject | staticMetaObject |
| void | setError (QAbstractVideoSurface::Error error ) |
| void | setNativeResolution (const QSize & resolution ) |
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. You can subclass this interface to receive video frames from sources like 解码媒体 or cameras 以履行自己的处理。
视频表面呈现的连续流等同格式化 QVideoFrame 实例,其中每帧的格式兼容流供给格式,当开始呈现时。每帧可能拥有时间戳信息,可以用于表面以决定何时显示该帧。
表面可以呈现的像素列表格式的给出是通过 supportedPixelFormats () 函数,和 isFormatSupported () 函数将测试是否支持视频表面格式。若格式不支持 nearestFormat () 函数也许能建议类似格式。例如:若表面支持一组固定分辨率,它可能建议包含提议分辨率的最小支持分辨率。
The start () 函数接受支持格式,并启用视频表面。一旦启动,表面将开始显示收到的帧在 present () 函数。表面可以保持呈现视频帧缓冲的引用,直到呈现新的帧 (或流停止)。此外,视频表面可以保持视频帧的引用,直到 结束时间戳 被传递。 stop () 函数将禁用表面,并释放它保持引用的任何视频缓冲。
当实现此接口的子类时,只要实现的少量函数分成 2 类:
对于格式相关功能,仅仅必须描述支持的像素格式 (和 nearestFormat () 函数)。对于呈现相关功能,必须实现 present () 函数,和 start () 和 stop () 函数。
注意: 必须调用基类实现的 start () 和 stop () 在您的实现中。
此枚举描述的错误,返回可能是通过 error () 函数。
| 常量 | 值 | 描述 |
|---|---|---|
QAbstractVideoSurface::NoError
|
0
|
没有出现错误。 |
QAbstractVideoSurface::UnsupportedFormatError
|
1
|
视频格式不被支持。 |
QAbstractVideoSurface::IncorrectFormatError
|
2
|
视频帧不兼容表面格式。 |
QAbstractVideoSurface::StoppedError
|
3
|
表面尚未开始。 |
QAbstractVideoSurface::ResourceError
|
4
|
表面无法分配一些资源。 |
视频表面的本机分辨率。这是表面可以按最优品质和/或性能渲染视频帧的分辨率。
本机分辨率并不总是已知,且在回放期间可以改变。
访问函数:
| QSize | nativeResolution () const |
通知程序信号:
| void | nativeResolutionChanged (const QSize & resolution ) |
构造视频表面采用给定 parent .
[虚拟]
QAbstractVideoSurface::
~QAbstractVideoSurface
()
销毁视频表面。
[signal]
void
QAbstractVideoSurface::
activeChanged
(
bool
active
)
发射信号,当 active 视频表面状态已改变。
另请参阅 isActive (), start (),和 stop ().
返回最后出现的错误。
若表面失败当 start (),或意外停止,可以调用此函数以探索出现了什么错误。
另请参阅 setError ().
指示视频表面是否已启动。
返回 true 若表面已启动,否则返回 false。
[虚拟]
bool
QAbstractVideoSurface::
isFormatSupported
(const
QVideoSurfaceFormat
&
format
) const
测试视频表面 format 以确定表面是否可以接受它。
返回 true,若格式被表面支持,否则,返回 false。
[signal]
void
QAbstractVideoSurface::
nativeResolutionChanged
(const
QSize
&
resolution
)
发射信号,若本机 resolution 对于视频表面已改变。
注意: 通知程序信号对于特性 nativeResolution .
[虚拟]
QVideoSurfaceFormat
QAbstractVideoSurface::
nearestFormat
(const
QVideoSurfaceFormat
&
format
) const
返回所支持的视频表面格式,类似于 format .
类似的表面格式是拥有相同 像素格式 and 句柄类型 但在某些其它特性方面可能不同。例如,若存在限定对于 帧大小 视频表面可以接受的可能建议格式具有更大的帧大小和 viewport 大小对于原始帧大小。
若格式已支持,将保持不变返回该格式,或者,若没有类似支持格式,将返回无效格式。
[pure virtual]
bool
QAbstractVideoSurface::
present
(const
QVideoFrame
&
frame
)
呈现视频 frame .
返回 true,若帧被呈现;返回 false,若发生错误。
并非所有表面都会阻塞,直到框架呈现完成。在非阻塞表面调用 present() 可能失败,若在上一帧呈现完成前调用。在这种情况下,表面可能不会返回到就绪状态,直到有机会处理事件。
若因任何其它原因 present() 失败,表面应立即进入停止状态且 error () 值将被设置。
视频表面必须处于启动状态当 present() 成功,且视频帧的格式必须兼容当前视频表面格式。
另请参阅 error ().
[protected]
void
QAbstractVideoSurface::
setError
(
QAbstractVideoSurface::Error
error
)
设置值为 error () 到 error .
此接口的实现者可以调用这,以传达最近错误是什么。
另请参阅 error ().
[protected]
void
QAbstractVideoSurface::
setNativeResolution
(const
QSize
&
resolution
)
设置视频表面的原始 resolution .
该接口的实现者可以调用此函数,以向框架生产者指定该表面的本机分辨率。
另请参阅 nativeResolution ().
[虚拟]
bool
QAbstractVideoSurface::
start
(const
QVideoSurfaceFormat
&
format
)
使视频表面开始呈现 format 帧。
返回 true,若表面已开始;返回 false,若发生错误。
注意: 必须在实现末尾,调用基类实现的 start()。
[虚拟]
void
QAbstractVideoSurface::
stop
()
使视频表面停止呈现帧,并释放任何获得资源在 start ().
注意: 必须在实现的起始,调用基类实现的 stop()。
[signal]
void
QAbstractVideoSurface::
supportedFormatsChanged
()
发射信号,当视频表面支持的格式集已改变。
另请参阅 supportedPixelFormats () 和 isFormatSupported ().
[pure virtual]
QList
<
QVideoFrame::PixelFormat
> QAbstractVideoSurface::
supportedPixelFormats
(
QAbstractVideoBuffer::HandleType
type
= QAbstractVideoBuffer::NoHandle) const
返回视频表面能呈现的像素格式列表,针对给定句柄 type .
返回像素格式为 QAbstractVideoBuffer::NoHandle 类型是有效的,对于能以只读方式映射的任何缓冲。
可假定列表中的首个类型,渲染会更快。
返回视频表面的格式。
[signal]
void
QAbstractVideoSurface::
surfaceFormatChanged
(const
QVideoSurfaceFormat
&
format
)
发射信号,当配置 format 对于视频表面已改变。
另请参阅 surfaceFormat () 和 start ().