forked from wang-bin/QtAV
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: should be done in VideoRenderer
- Loading branch information
Showing
5 changed files
with
68 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2013-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2013-2016 Wang Bin <[email protected]> | ||
theoribeiro <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -59,6 +59,8 @@ class QQuickItemRendererPrivate : public VideoRendererPrivate | |
virtual void setupQuality() { | ||
if (!node) | ||
return; | ||
if (opengl) | ||
return; | ||
if (quality == VideoRenderer::QualityFastest) { | ||
((QSGSimpleTextureNode*)node)->setFiltering(QSGTexture::Nearest); | ||
} else { | ||
|
@@ -172,7 +174,12 @@ void QQuickItemRenderer::setFillMode(FillMode mode) | |
} | ||
//m_geometryDirty = true; | ||
//update(); | ||
emit fillModeChanged(mode); | ||
Q_EMIT fillModeChanged(mode); | ||
} | ||
|
||
QRectF QQuickItemRenderer::contentRect() const | ||
{ | ||
return videoRect(); | ||
} | ||
|
||
bool QQuickItemRenderer::isOpenGL() const | ||
|
@@ -285,7 +292,7 @@ void QQuickItemRenderer::afterRendering() | |
bool QQuickItemRenderer::onSetRegionOfInterest(const QRectF &roi) | ||
{ | ||
Q_UNUSED(roi); | ||
emit regionOfInterestChanged(); | ||
Q_EMIT regionOfInterestChanged(); | ||
return true; | ||
} | ||
|
||
|
@@ -296,10 +303,21 @@ bool QQuickItemRenderer::onSetOrientation(int value) | |
if (value == 90 || value == 270) | ||
return false; | ||
} | ||
emit orientationChanged(); | ||
Q_EMIT orientationChanged(); | ||
return true; | ||
} | ||
|
||
void QQuickItemRenderer::onSetOutAspectRatio(qreal ratio) | ||
{ | ||
Q_UNUSED(ratio); | ||
Q_EMIT contentRectChanged(); | ||
} | ||
|
||
void QQuickItemRenderer::onResizeRenderer(int, int) | ||
{ | ||
Q_EMIT contentRectChanged(); | ||
} | ||
|
||
void QQuickItemRenderer::onFrameSizeChanged(const QSize &size) | ||
{ | ||
Q_UNUSED(size); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2013-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2013-2016 Wang Bin <[email protected]> | ||
theoribeiro <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -37,6 +37,7 @@ class QQuickItemRenderer : public QQuickItem, public VideoRenderer | |
Q_PROPERTY(QObject* source READ source WRITE setSource NOTIFY sourceChanged) | ||
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged) | ||
Q_PROPERTY(int orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) | ||
Q_PROPERTY(QRectF contentRect READ contentRect NOTIFY contentRectChanged) | ||
// regionOfInterest > sourceRect | ||
Q_PROPERTY(QRectF regionOfInterest READ regionOfInterest WRITE setRegionOfInterest NOTIFY regionOfInterestChanged) | ||
Q_PROPERTY(qreal sourceAspectRatio READ sourceAspectRatio NOTIFY sourceAspectRatioChanged) | ||
|
@@ -59,13 +60,16 @@ class QQuickItemRenderer : public QQuickItem, public VideoRenderer | |
FillMode fillMode() const; | ||
void setFillMode(FillMode mode); | ||
|
||
QRectF contentRect() const; | ||
|
||
bool isOpenGL() const; | ||
void setOpenGL(bool o); | ||
|
||
Q_SIGNALS: | ||
void sourceChanged(); | ||
void fillModeChanged(QQuickItemRenderer::FillMode); | ||
void orientationChanged(); | ||
void contentRectChanged(); | ||
void regionOfInterestChanged(); | ||
void openGLChanged(); | ||
void sourceAspectRatioChanged(qreal value) Q_DECL_OVERRIDE; | ||
|
@@ -88,6 +92,8 @@ private slots: | |
private: | ||
bool onSetRegionOfInterest(const QRectF& roi) Q_DECL_OVERRIDE; | ||
bool onSetOrientation(int value) Q_DECL_OVERRIDE; | ||
void onSetOutAspectRatio(qreal ratio) Q_DECL_OVERRIDE; | ||
void onResizeRenderer(int, int) Q_DECL_OVERRIDE; | ||
void onFrameSizeChanged(const QSize& size) Q_DECL_OVERRIDE; | ||
}; | ||
typedef QQuickItemRenderer VideoRendererQQuickItem; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2015 Wang Bin <[email protected]> | ||
Copyright (C) 2015-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -36,6 +36,7 @@ class QuickFBORenderer : public QQuickFramebufferObject, public VideoRenderer | |
Q_PROPERTY(QObject* source READ source WRITE setSource NOTIFY sourceChanged) | ||
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged) | ||
Q_PROPERTY(int orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) | ||
Q_PROPERTY(QRectF contentRect READ contentRect NOTIFY contentRectChanged) | ||
// regionOfInterest > sourceRect | ||
Q_PROPERTY(QRectF regionOfInterest READ regionOfInterest WRITE setRegionOfInterest NOTIFY regionOfInterestChanged) | ||
Q_PROPERTY(qreal sourceAspectRatio READ sourceAspectRatio NOTIFY sourceAspectRatioChanged) | ||
|
@@ -51,15 +52,17 @@ class QuickFBORenderer : public QQuickFramebufferObject, public VideoRenderer | |
Renderer *createRenderer() const Q_DECL_OVERRIDE; | ||
|
||
explicit QuickFBORenderer(QQuickItem *parent = 0); | ||
virtual VideoRendererId id() const Q_DECL_OVERRIDE; | ||
virtual bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE; | ||
VideoRendererId id() const Q_DECL_OVERRIDE; | ||
bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE; | ||
|
||
QObject *source() const; | ||
void setSource(QObject *source); | ||
|
||
FillMode fillMode() const; | ||
void setFillMode(FillMode mode); | ||
|
||
QRectF contentRect() const; | ||
|
||
bool isOpenGL() const; | ||
void setOpenGL(bool o); | ||
void fboSizeChanged(const QSize& size); | ||
|
@@ -68,22 +71,24 @@ class QuickFBORenderer : public QQuickFramebufferObject, public VideoRenderer | |
void sourceChanged(); | ||
void fillModeChanged(QuickFBORenderer::FillMode); | ||
void orientationChanged(); | ||
void contentRectChanged(); | ||
void regionOfInterestChanged(); | ||
void openGLChanged(); | ||
void sourceAspectRatioChanged(qreal value) Q_DECL_OVERRIDE; | ||
void frameSizeChanged(); | ||
protected: | ||
virtual bool event(QEvent *e) Q_DECL_OVERRIDE; | ||
virtual bool receiveFrame(const VideoFrame &frame) Q_DECL_OVERRIDE; | ||
virtual bool needUpdateBackground() const Q_DECL_OVERRIDE; | ||
virtual void drawBackground() Q_DECL_OVERRIDE; | ||
virtual bool needDrawFrame() const Q_DECL_OVERRIDE; | ||
virtual void drawFrame() Q_DECL_OVERRIDE; | ||
bool event(QEvent *e) Q_DECL_OVERRIDE; | ||
bool receiveFrame(const VideoFrame &frame) Q_DECL_OVERRIDE; | ||
bool needUpdateBackground() const Q_DECL_OVERRIDE; | ||
void drawBackground() Q_DECL_OVERRIDE; | ||
bool needDrawFrame() const Q_DECL_OVERRIDE; | ||
void drawFrame() Q_DECL_OVERRIDE; | ||
private: | ||
virtual bool onSetRegionOfInterest(const QRectF& roi) Q_DECL_OVERRIDE; | ||
virtual bool onSetOrientation(int value) Q_DECL_OVERRIDE; | ||
virtual void onSetOutAspectRatio(qreal ratio) Q_DECL_OVERRIDE; | ||
virtual void onSetOutAspectRatioMode(OutAspectRatioMode mode) Q_DECL_OVERRIDE; | ||
bool onSetRegionOfInterest(const QRectF& roi) Q_DECL_OVERRIDE; | ||
bool onSetOrientation(int value) Q_DECL_OVERRIDE; | ||
void onSetOutAspectRatio(qreal ratio) Q_DECL_OVERRIDE; | ||
void onSetOutAspectRatioMode(OutAspectRatioMode mode) Q_DECL_OVERRIDE; | ||
void onResizeRenderer(int, int) Q_DECL_OVERRIDE; | ||
void onFrameSizeChanged(const QSize& size) Q_DECL_OVERRIDE; | ||
void updateRenderRect(); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2015 Wang Bin <[email protected]> | ||
Copyright (C) 2015-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -166,7 +166,12 @@ void QuickFBORenderer::setFillMode(FillMode mode) | |
return; | ||
d_func().fill_mode = mode; | ||
updateRenderRect(); | ||
emit fillModeChanged(mode); | ||
Q_EMIT fillModeChanged(mode); | ||
} | ||
|
||
QRectF QuickFBORenderer::contentRect() const | ||
{ | ||
return videoRect(); | ||
} | ||
|
||
bool QuickFBORenderer::isOpenGL() const | ||
|
@@ -180,7 +185,7 @@ void QuickFBORenderer::setOpenGL(bool o) | |
if (d.opengl == o) | ||
return; | ||
d.opengl = o; | ||
emit openGLChanged(); | ||
Q_EMIT openGLChanged(); | ||
if (o) | ||
setPreferredPixelFormat(VideoFormat::Format_YUV420P); | ||
else | ||
|
@@ -243,14 +248,15 @@ bool QuickFBORenderer::event(QEvent *e) | |
bool QuickFBORenderer::onSetRegionOfInterest(const QRectF &roi) | ||
{ | ||
Q_UNUSED(roi); | ||
emit regionOfInterestChanged(); | ||
Q_EMIT regionOfInterestChanged(); | ||
return true; | ||
} | ||
|
||
bool QuickFBORenderer::onSetOrientation(int value) | ||
{ | ||
Q_UNUSED(value); | ||
emit orientationChanged(); | ||
Q_EMIT orientationChanged(); | ||
// will call onSetOutAspectRatio after out_rect updated. so emit contentChanged there | ||
return true; | ||
} | ||
|
||
|
@@ -259,19 +265,27 @@ void QuickFBORenderer::onSetOutAspectRatio(qreal ratio) | |
Q_UNUSED(ratio); | ||
DPTR_D(QuickFBORenderer); | ||
d.setupAspectRatio(); | ||
Q_EMIT contentRectChanged(); | ||
} | ||
|
||
void QuickFBORenderer::onSetOutAspectRatioMode(OutAspectRatioMode mode) | ||
{ | ||
Q_UNUSED(mode); | ||
DPTR_D(QuickFBORenderer); | ||
d.setupAspectRatio(); | ||
// already called onSetOutAspectRatio, so no contentChanged here | ||
} | ||
|
||
void QuickFBORenderer::onResizeRenderer(int, int) | ||
{ | ||
Q_EMIT contentRectChanged(); | ||
} | ||
|
||
void QuickFBORenderer::onFrameSizeChanged(const QSize &size) | ||
{ | ||
Q_UNUSED(size); | ||
Q_EMIT frameSizeChanged(); | ||
// will call onSetOutAspectRatio after out_rect updated. so emit contentChanged there | ||
} | ||
|
||
void QuickFBORenderer::updateRenderRect() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters