Skip to content

Commit

Permalink
build without widgets module support
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Sep 3, 2014
1 parent 15d9773 commit f1c9cd3
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 77 deletions.
8 changes: 4 additions & 4 deletions QtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ OptionalDepends = \
swresample \
avresample
# QtOpenGL module. In Qt5 we can disable it and still have opengl support
!no-gl: OptionalDepends *= gl
!no-gl:!no-widgets: OptionalDepends *= gl
!no-avfilter: OptionalDepends *= avfilter
## sse2 sse4_1 may be defined in Qt5 qmodule.pri but is not included. Qt4 defines sse and sse2
!no-sse4_1:!sse4_1: OptionalDepends *= sse4_1
# no-xxx can set in $$PWD/user.conf
!no-openal: OptionalDepends *= openal
!no-portaudio: OptionalDepends *= portaudio
!no-direct2d: OptionalDepends *= direct2d
!no-gdiplus: OptionalDepends *= gdiplus
!no-direct2d:!no-widgets: OptionalDepends *= direct2d
!no-gdiplus:!no-widgets: OptionalDepends *= gdiplus
# why win32 is false?
!no-dxva: OptionalDepends *= dxva
unix {
!no-xv: OptionalDepends *= xv
!no-xv:!no-widgets: OptionalDepends *= xv
!no-vaapi: OptionalDepends *= vaapi
!no-cedarv: OptionalDepends *= libcedarv
}
Expand Down
11 changes: 8 additions & 3 deletions root.pri
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ defineTest(testArch) {

#cache mkspecs. compare mkspec with cached one. if not equal, remove old cache to run new compile tests
#Qt5 does not have QMAKE_MKSPECS, use QMAKE_SPEC, QMAKE_XSPEC
isEmpty(mkspecs_cached)|!isEmpty(mkspecs_cached):!isEqual(mkspecs_cached, $$mkspecs_build) {
isEmpty(mkspecs_cached)|!isEqual(mkspecs_cached, $$mkspecs_build) {
CONFIG += recheck
testArch()
} else {
Expand All @@ -98,13 +98,18 @@ cache(SOURCE_ROOT, set, SOURCE_ROOT)
cache(mkspecs_cached, set, mkspecs_build)

# no-framework can be defined in user.conf. default is the same as QT_CONFIG
MAC_LIB = mac_dylib
MAC_LIB = mac_dylib
no-framework {
cache(CONFIG, add, MAC_LIB)
} else {
cache(CONFIG, sub, MAC_LIB)
}

NO_WIDGETS = no_widgets
no-widgets {
cache(CONFIG, add, NO_WIDGETS)
} else {
cache(CONFIG, sub, NO_WIDGETS)
}
defineTest(runConfigTests) {
no_config_tests:return(false)
#config.tests
Expand Down
9 changes: 6 additions & 3 deletions src/AVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

#include <limits>

#include <QApplication>
#include <QCoreApplication>
#include <QtCore/QEvent>
#include <QtCore/QDir>
#include <QtCore/QIODevice>

#if QTAV_HAVE(WIDGETS)
#include <QWidget>
#endif //QTAV_HAVE(WIDGETS)
#include "QtAV/AVDemuxer.h"
#include "QtAV/AudioFormat.h"
#include "QtAV/AudioResampler.h"
Expand All @@ -38,7 +40,6 @@
#include "QtAV/AVClock.h"
#include "QtAV/VideoCapture.h"
#include "QtAV/VideoDecoderTypes.h"
#include "QtAV/WidgetRenderer.h"
#include "QtAV/VideoThread.h"
#include "QtAV/AVDemuxThread.h"
#include "QtAV/VideoCapture.h"
Expand Down Expand Up @@ -184,13 +185,15 @@ void AVPlayer::addVideoRenderer(VideoRenderer *renderer)
return;
}
renderer->setStatistics(&mStatistics);
#if QTAV_HAVE(WIDGETS)
QObject *voo = renderer->widget();
if (voo) {
//TODO: how to delete filter if no parent?
//the filtering object must be in the same thread as this object.
if (renderer->widget())
voo->installEventFilter(new VideoOutputEventFilter(renderer));
}
#endif //QTAV_HAVE(WIDGETS)
mpVOSet->addOutput(renderer);
}

Expand Down
1 change: 0 additions & 1 deletion src/QtAV/QPainterRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class Q_AV_EXPORT QPainterRenderer : public VideoRenderer
DPTR_DECLARE_PRIVATE(QPainterRenderer)
public:
QPainterRenderer();
virtual VideoRendererId id () const;
virtual bool isSupported(VideoFormat::PixelFormat pixfmt) const;
//virtual QImage currentFrameImage() const;
protected:
Expand Down
6 changes: 6 additions & 0 deletions src/QtAV/QtAV_Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,11 @@ Q_AV_EXPORT void setFFmpegLogHandler(void(*)(void *, int, const char *, va_list)
#define GCC_VERSION_AT_LEAST(major, minor, patch) 0
#endif

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) || defined(QT_WIDGETS_LIB)
#ifndef QTAV_HAVE_WIDGETS
#define QTAV_HAVE_WIDGETS 1
#endif //QTAV_HAVE_WIDGETS
#endif

#endif // QTAV_GLOBAL_H

1 change: 1 addition & 0 deletions src/QtAV/VideoRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class Q_AV_EXPORT VideoRenderer : public AVOutput
virtual bool onSetContrast(qreal contrast);
virtual bool onSetHue(qreal hue);
virtual bool onSetSaturation(qreal saturation);
void updateUi();
private:
friend class VideoOutput;
//the size of decoded frame. get called in receiveFrame(). internal use only
Expand Down
1 change: 0 additions & 1 deletion src/QtAV/VideoRendererTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace QtAV {

//Q_AV_EXPORT(dllexport/import) is needed if used out of the library
//TODO graphics item?
extern Q_AV_EXPORT VideoRendererId VideoRendererId_QPainter;
extern Q_AV_EXPORT VideoRendererId VideoRendererId_Widget;
extern Q_AV_EXPORT VideoRendererId VideoRendererId_GraphicsItem;
extern Q_AV_EXPORT VideoRendererId VideoRendererId_GLWidget;
Expand Down
16 changes: 16 additions & 0 deletions src/QtAV_Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
#include "QtAV/QtAV_Global.h"
#include <QtCore/QObject>
#include <QtCore/QRegExp>
#include <QtDebug>
#if QTAV_HAVE(WIDGETS)
#include <QBoxLayout>
#include <QMessageBox>
#include <QPushButton>
#include <QTableWidget>
#include <QTextBrowser>
#endif //QTAV_HAVE(WIDGETS)
#include "QtAV/version.h"
#include "QtAV/private/AVCompat.h"

Expand All @@ -50,6 +53,7 @@ namespace QtAV {
//TODO: auto add new depend libraries information
void about()
{
#if QTAV_HAVE(WIDGETS)
//we should use new because a qobject will delete it's children
QTextBrowser *viewQtAV = new QTextBrowser;
QTextBrowser *viewFFmpeg = new QTextBrowser;
Expand All @@ -72,11 +76,19 @@ void about()
layout->addLayout(btnLayout);
QObject::connect(btn, SIGNAL(clicked()), &dialog, SLOT(accept()));
dialog.exec();
#else
aboutQtAV();
aboutFFmpeg();
#endif //QTAV_HAVE(WIDGETS)
}

void aboutFFmpeg()
{
#if QTAV_HAVE(WIDGETS)
QMessageBox::about(0, QObject::tr("About FFmpeg"), aboutFFmpeg_HTML());
#else
qDebug() << aboutFFmpeg_PlainText();
#endif
}

QString aboutFFmpeg_PlainText()
Expand Down Expand Up @@ -134,7 +146,11 @@ QString aboutFFmpeg_HTML()

void aboutQtAV()
{
#if QTAV_HAVE(WIDGETS)
QMessageBox::about(0, QObject::tr("About QtAV"), aboutQtAV_HTML());
#else
qDebug() << aboutQtAV_PlainText();
#endif //QTAV_HAVE(WIDGETS)
}

QString aboutQtAV_PlainText()
Expand Down
67 changes: 22 additions & 45 deletions src/VideoRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#include <QtAV/private/VideoRenderer_p.h>
#include <QtAV/Filter.h>
#include <QtCore/QCoreApplication>
#if QTAV_HAVE(WIDGETS)
#include <QWidget>
#include <QGraphicsItem>
#endif //QTAV_HAVE(WIDGETS)
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtGui/QWindow>
#endif
Expand Down Expand Up @@ -481,17 +483,7 @@ bool VideoRenderer::setBrightness(qreal brightness)
d.brightness = old;
return false;
}
// TODO: qwindow() and widget() can both use event?
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
if (qwindow()) {
qApp->postEvent(qwindow(), new QEvent(QEvent::UpdateRequest));
}
#endif
if (widget()) {
widget()->update();
} else if (graphicsItem()) {
graphicsItem()->update();
}
updateUi();
return true;
}

Expand All @@ -512,17 +504,7 @@ bool VideoRenderer::setContrast(qreal contrast)
d.contrast = old;
return false;
}
// TODO: qwindow() and widget() can both use event?
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
if (qwindow()) {
qApp->postEvent(qwindow(), new QEvent(QEvent::UpdateRequest));
}
#endif
if (widget()) {
widget()->update();
} else if (graphicsItem()) {
graphicsItem()->update();
}
updateUi();
return true;
}

Expand All @@ -540,21 +522,10 @@ bool VideoRenderer::setHue(qreal hue)
qreal old = d.hue;
d.hue = hue;
if (!onSetHue(hue)) {
qWarning("onSetHue failed");
d.hue = old;
return false;
}
// TODO: qwindow() and widget() can both use event?
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
if (qwindow()) {
qApp->postEvent(qwindow(), new QEvent(QEvent::UpdateRequest));
}
#endif
if (widget()) {
widget()->update();
} else if (graphicsItem()) {
graphicsItem()->update();
}
updateUi();
return true;
}

Expand All @@ -575,17 +546,7 @@ bool VideoRenderer::setSaturation(qreal saturation)
d.saturation = old;
return false;
}
// TODO: qwindow() and widget() can both use event?
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
if (qwindow()) {
qApp->postEvent(qwindow(), new QEvent(QEvent::UpdateRequest));
}
#endif
if (widget()) {
widget()->update();
} else if (graphicsItem()) {
graphicsItem()->update();
}
updateUi();
return true;
}

Expand Down Expand Up @@ -613,5 +574,21 @@ bool VideoRenderer::onSetSaturation(qreal s)
return false;
}

void VideoRenderer::updateUi()
{
// TODO: qwindow() and widget() can both use event?
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
if (qwindow()) {
qApp->postEvent(qwindow(), new QEvent(QEvent::UpdateRequest));
}
#endif
#if QTAV_HAVE(WIDGETS)
if (widget()) {
widget()->update();
} else if (graphicsItem()) {
graphicsItem()->update();
}
#endif //QTAV_HAVE(WIDGETS)
}

} //namespace QtAV
16 changes: 9 additions & 7 deletions src/VideoRendererTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#include <cstdio>
#include <cstdlib>
#include "QtAV/prepost.h"
#if QTAV_HAVE(WIDGETS)
#include "QtAV/WidgetRenderer.h"
#include "QtAV/GraphicsItemRenderer.h"
#endif
#if QTAV_HAVE(GL)
#include "QtAV/GLWidgetRenderer2.h"
#endif //QTAV_HAVE(GL)
Expand All @@ -43,7 +45,6 @@ namespace QtAV {

FACTORY_DEFINE(VideoRenderer)

VideoRendererId VideoRendererId_QPainter = 1;
VideoRendererId VideoRendererId_Widget = 2;
VideoRendererId VideoRendererId_GraphicsItem = 3;
VideoRendererId VideoRendererId_GLWidget = 4;
Expand All @@ -54,6 +55,7 @@ VideoRendererId VideoRendererId_GLWidget2 = 8;
VideoRendererId VideoRendererId_OpenGLWindow = 9;
VideoRendererId VideoRendererId_OpenGLWidget = 10;

#if QTAV_HAVE(WIDGETS)
//QPainterRenderer is abstract. So can not register(operator new will needed)
FACTORY_REGISTER_ID_AUTO(VideoRenderer, Widget, "QWidegt")

Expand All @@ -78,11 +80,7 @@ VideoRendererId GraphicsItemRenderer::id() const
{
return VideoRendererId_GraphicsItem;
}

VideoRendererId QPainterRenderer::id() const
{
return VideoRendererId_QPainter;
}
#endif //QTAV_HAVE(WIDGETS)

#if QTAV_HAVE(GL)
#if QTAV_HAVE(GL1)
Expand All @@ -97,7 +95,7 @@ VideoRendererId GLWidgetRenderer::id() const
return VideoRendererId_GLWidget;
}
#endif //QTAV_HAVE(GL1)

#if QTAV_HAVE(WIDGETS)
FACTORY_REGISTER_ID_AUTO(VideoRenderer, GLWidget2, "QGLWidegt2")

void RegisterVideoRendererGLWidget2_Man()
Expand All @@ -109,6 +107,7 @@ VideoRendererId GLWidgetRenderer2::id() const
{
return VideoRendererId_GLWidget2;
}
#endif
#endif //QTAV_HAVE(GL)
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
FACTORY_REGISTER_ID_AUTO(VideoRenderer, OpenGLWindow, "OpenGLWindow")
Expand Down Expand Up @@ -143,7 +142,10 @@ extern void RegisterVideoRendererXV_Man();

void VideoRenderer_RegisterAll()
{
#if QTAV_HAVE(WIDGETS)
RegisterVideoRendererWidget_Man();
RegisterVideoRendererGraphicsItem_Man();
#endif //QTAV_HAVE(WIDGETS)
#if QTAV_HAVE(GL)
RegisterVideoRendererGLWidget2_Man();
#endif //QTAV_HAVE(GL)
Expand Down
Loading

0 comments on commit f1c9cd3

Please sign in to comment.