Skip to content

Commit

Permalink
qml: VideoOutput/VideoOutput2.source can be an AVPlayer object wang-b…
Browse files Browse the repository at this point in the history
…in#935

use c   player and qml renderer
  • Loading branch information
wang-bin committed Aug 6, 2017
1 parent 206d89f commit 2110aa6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
11 changes: 10 additions & 1 deletion qml/QQuickItemRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 156,16 @@ void QQuickItemRenderer::setSource(QObject *source)
Q_EMIT sourceChanged();
if (!source)
return;
((QmlAVPlayer*)source)->player()->addVideoRenderer(this);
AVPlayer* p = qobject_cast<AVPlayer*>(source);
if (!p) {
QmlAVPlayer* qp = qobject_cast<QmlAVPlayer*>(source);
if (!qp) {
qWarning("source MUST be of type AVPlayer or QmlAVPlayer");
return;
}
p = qp->player();
}
p->addVideoRenderer(this);
}

QQuickItemRenderer::FillMode QQuickItemRenderer::fillMode() const
Expand Down
6 changes: 5 additions & 1 deletion qml/QmlAV/QQuickItemRenderer.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2017 Wang Bin <[email protected]>
theoribeiro <[email protected]>
* This file is part of QtAV (from 2013)
Expand Down Expand Up @@ -60,6 60,10 @@ class QQuickItemRenderer : public QQuickItem, public VideoRenderer
bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE;

QObject *source() const;
/*!
* \brief setSource
* \param source nullptr, an object of type AVPlayer or QmlAVPlayer
*/
void setSource(QObject *source);

FillMode fillMode() const;
Expand Down
6 changes: 5 additions & 1 deletion qml/QmlAV/QuickFBORenderer.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2017 Wang Bin <[email protected]>
* This file is part of QtAV (from 2015)
Expand Down Expand Up @@ -66,6 66,10 @@ class QuickFBORenderer : public QQuickFramebufferObject, public VideoRenderer
OpenGLVideo* opengl() const Q_DECL_OVERRIDE;

QObject *source() const;
/*!
* \brief setSource
* \param source nullptr, an object of type AVPlayer or QmlAVPlayer
*/
void setSource(QObject *source);

FillMode fillMode() const;
Expand Down
11 changes: 10 additions & 1 deletion qml/QuickFBORenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 155,16 @@ void QuickFBORenderer::setSource(QObject *source)
Q_EMIT sourceChanged();
if (!source)
return;
((QmlAVPlayer*)source)->player()->addVideoRenderer(this);
AVPlayer* p = qobject_cast<AVPlayer*>(source);
if (!p) {
QmlAVPlayer* qp = qobject_cast<QmlAVPlayer*>(source);
if (!qp) {
qWarning("source MUST be of type AVPlayer or QmlAVPlayer");
return;
}
p = qp->player();
}
p->addVideoRenderer(this);
}

QuickFBORenderer::FillMode QuickFBORenderer::fillMode() const
Expand Down

0 comments on commit 2110aa6

Please sign in to comment.