6#include <private/qvideooutputorientationhandler_p.h>
7#include <QtMultimedia/qmediaplayer.h>
8#include <QtMultimedia/qmediacapturesession.h>
9#include <private/qfactoryloader_p.h>
10#include <QtCore/qloggingcategory.h>
12#include <QtQuick/QQuickWindow>
13#include <private/qquickwindow_p.h>
22inline bool qIsDefaultAspect(
int o)
24 return (
o % 180) == 0;
30inline int qNormalizedOrientation(
int o)
107 qRegisterMetaType<QVideoFrameFormat>();
115 this, &QQuickVideoOutput::_q_newFrame);
164 m_geometryDirty =
true;
170void QQuickVideoOutput::_q_newFrame(
QSize size)
174 if (!qIsDefaultAspect(m_orientation + m_frameOrientation)) {
178 if (m_nativeSize !=
size) {
181 m_geometryDirty =
true;
191void QQuickVideoOutput::_q_updateGeometry()
196 if (!m_geometryDirty && m_lastRect == absoluteRect)
199 QRectF oldContentRect(m_contentRect);
201 m_geometryDirty =
false;
202 m_lastRect = absoluteRect;
204 const auto fill = m_aspectRatioMode;
208 m_contentRect =
rect;
210 m_contentRect =
rect;
221 if (m_contentRect != oldContentRect)
243 return m_orientation;
258 if ((m_orientation % 360) == (
orientation % 360)) {
264 m_geometryDirty =
true;
268 bool oldAspect = qIsDefaultAspect(m_orientation);
273 if (oldAspect != newAspect) {
302 return m_contentRect;
329 if (!qIsDefaultAspect(m_orientation + m_frameOrientation))
355void QQuickVideoOutput::_q_invalidateSceneGraph()
357 invalidateSceneGraph();
360void QQuickVideoOutput::_q_sceneGraphInitialized()
368 invalidateSceneGraph();
371void QQuickVideoOutput::invalidateSceneGraph()
378void QQuickVideoOutput::initRhiForSink()
390 if (changeData.
window == m_window)
394 m_window = changeData.
window;
406QSize QQuickVideoOutput::nativeSize()
const
411void QQuickVideoOutput::updateGeometry()
420 if (nativeSize().isEmpty()) {
421 m_renderedRect =
rect;
422 m_sourceTextureRect = normalizedViewport;
424 m_renderedRect =
rect;
425 m_sourceTextureRect = normalizedViewport;
427 m_sourceTextureRect = normalizedViewport;
430 m_renderedRect =
rect;
437 const qreal relativeWidth =
rect.width() / contentWidth;
438 const qreal relativeHeight =
rect.height() / contentHeight;
441 const qreal totalOffsetLeft = normalizedViewport.x() + relativeOffsetLeft * normalizedViewport.width();
442 const qreal totalOffsetTop = normalizedViewport.y() + relativeOffsetTop * normalizedViewport.height();
443 const qreal totalWidth = normalizedViewport.width() * relativeWidth;
444 const qreal totalHeight = normalizedViewport.height() * relativeHeight;
446 if (qIsDefaultAspect(
orientation() + m_frameOrientation)) {
447 m_sourceTextureRect =
QRectF(totalOffsetLeft, totalOffsetTop,
448 totalWidth, totalHeight);
450 m_sourceTextureRect =
QRectF(totalOffsetTop, totalOffsetLeft,
451 totalHeight, totalWidth);
457 m_sourceTextureRect.
setTop(m_sourceTextureRect.
bottom());
463 m_sourceTextureRect.
setLeft(m_sourceTextureRect.
right());
478 if (m_frameChanged) {
480 qCDebug(qLcVideo) <<
"updatePaintNode: deleting old video node because frame format changed";
486 qCDebug(qLcVideo) <<
"updatePaintNode: no frames yet";
487 m_frameChanged =
false;
496 qCDebug(qLcVideo) <<
"updatePaintNode: Video node created. Handle type:" << m_frame.
handleType();
501 m_frameChanged =
false;
506 if (m_frameChanged) {
510 m_frameChanged =
false;
521QRectF QQuickVideoOutput::adjustedViewport()
const
529 m_surfaceFormat =
frame.surfaceFormat();
531 m_frameOrientation =
frame.rotationAngle();
532 m_frameChanged =
true;
536void QQuickVideoOutput::stop()
544#include "moc_qquickvideooutput_p.cpp"
void unlock() noexcept
Unlocks the mutex.
void lock() noexcept
Locks the mutex.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
\inmodule QtCore\reentrant
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
qreal x
\qmlproperty real QtQuick::Item::x \qmlproperty real QtQuick::Item::y \qmlproperty real QtQuick::Item...
qreal y
Defines the item's y position relative to its parent.
qreal width
This property holds the width of this item.
void setImplicitHeight(qreal)
qreal height
This property holds the height of this item.
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
void setImplicitWidth(qreal)
void update()
Schedules a call to updatePaintNode() for this item.
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void fillModeChanged(QQuickVideoOutput::FillMode)
void contentRectChanged()
void orientationChanged()
void itemChange(ItemChange change, const ItemChangeData &changeData) override
Called when change occurs for this item.
QQuickVideoOutput(QQuickItem *parent=0)
void releaseResources() override
This function is called when an item should release graphics resources which are not already managed ...
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
void setFillMode(FillMode mode)
static QQuickWindowPrivate * get(QQuickWindow *c)
void sceneGraphInitialized()
\qmlsignal QtQuick::Window::frameSwapped()
void sceneGraphInvalidated()
\qmlsignal QtQuick::Window::sceneGraphInitialized()
\inmodule QtCore\reentrant
constexpr void moveCenter(const QPointF &p) noexcept
Moves the rectangle, leaving the center point at the given position.
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr void setBottom(qreal pos) noexcept
Sets the bottom edge of the rectangle to the given finite y coordinate.
constexpr void setRight(qreal pos) noexcept
Sets the right edge of the rectangle to the given finite x coordinate.
constexpr void setLeft(qreal pos) noexcept
Sets the left edge of the rectangle to the given finite x coordinate.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr void setTop(qreal pos) noexcept
Sets the top edge of the rectangle to the given finite y coordinate.
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
void setTexturedRectGeometry(const QRectF &boundingRect, const QRectF &textureRect, int orientation)
QVideoFrameFormat::PixelFormat pixelFormat() const
void setCurrentFrame(const QVideoFrame &frame)
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
void transpose() noexcept
Swaps the width and height values.
The QVideoFrame class represents a frame of video data.
QVideoFrame::HandleType handleType() const
Returns the type of a video frame's handle.
QVideoFrameFormat::PixelFormat pixelFormat() const
Returns the pixel format of this video frame.
bool isValid() const
Identifies whether a video frame is valid.
The QVideoSink class represents a generic sink for video data.
void videoFrameChanged(const QVideoFrame &frame) QT6_ONLY(const)
Signals when the video frame changes.
Combined button and popup list for selecting options.
@ KeepAspectRatioByExpanding
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
static constexpr QSize frameSize(const T &frame)
QImage scaled(const QImage &image)
[0]
myObject disconnect()
[26]
view viewport() -> scroll(dx, dy, deviceRect)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent