QAbstractVideoSurface 類

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 = 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 )

額外繼承成員

詳細描述

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 () 函數將禁用錶麵,並釋放它保持引用的任何視頻緩衝。

實現 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

視頻錶麵的本機分辨率。這是錶麵可以按最優品質和/或性能渲染視頻幀的分辨率。

本機分辨率並不總是已知,且在迴放期間可以改變。

訪問函數:

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

返迴上次發生的錯誤。

若錶麵失敗當 start (),或意外停止,可以調用此函數以探索齣現瞭什麼錯誤。

另請參閱 setError ().

bool QAbstractVideoSurface:: isActive () const

指示視頻錶麵是否已啓動。

返迴 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 ( Error error )

設置值為 error () 到 error .

此接口的實現者可以調用這,以傳達最近錯誤是什麼。

另請參閱 error ().

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

設置視頻錶麵的原始 resolution .

該接口的實現者可以調用此函數,以嚮框架生産者指定該錶麵的本機分辨率。

另請參閱 nativeResolution ().

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

使視頻錶麵開始呈現 format 幀。

返迴 true,若錶麵已開始;返迴 false,若發生錯誤。

注意: 必須在實現末尾,調用基類實現的 start()。

另請參閱 isActive () 和 stop ().

[虛擬] void QAbstractVideoSurface:: stop ()

使視頻錶麵停止呈現幀,並釋放任何獲得資源在 start ().

注意: 必須在實現的起始,調用基類實現的 stop()。

另請參閱 isActive () 和 start ().

[signal] void QAbstractVideoSurface:: supportedFormatsChanged ()

發射信號,當視頻錶麵支持的格式集已改變。

另請參閱 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 對於視頻錶麵已改變。

另請參閱 surfaceFormat () 和 start ().