Skip to content

Commit

Permalink
vo: add x11 renderer. no scale support now
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Sep 22, 2015
1 parent 354d7be commit 0856ed2
Show file tree
Hide file tree
Showing 11 changed files with 503 additions and 41 deletions.
6 changes: 1 addition & 5 deletions QtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ OTHER_FILES += \
templates/derived.h templates/derived.cpp templates/derived_p.h \
templates/final.h templates/final.cpp
#OTHER_FILES += config.test/mktest.sh


EssentialDepends = avutil avcodec avformat swscale
OptionalDepends = \
swresample \
Expand Down Expand Up @@ -66,6 +64,7 @@ win32 {
}
unix {
!no-pulseaudio: OptionalDepends *= pulseaudio
!no-x11:!no-widgets: OptionalDepends *= x11
!no-xv:!no-widgets: OptionalDepends *= xv
!no-vaapi: OptionalDepends *= vaapi
!no-cedarv: OptionalDepends *= libcedarv
Expand All @@ -77,10 +76,7 @@ runConfigTests()
!config_avresample:!config_swresample {
error("libavresample or libswresample is required. Setup your environment correctly then delete $$BUILD_DIR/.qmake.conf and run qmake again")
}


PACKAGE_VERSION = $$QTAV_VERSION
PACKAGE_NAME= QtAV

include(pack.pri)
#packageSet($$QTAV_VERSION, QtAV)
9 changes: 5 additions & 4 deletions config.tests/gentest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ NAME=$1
help_post $NAME
mkdir -p $NAME
cat >$NAME/${NAME}.pro <<EOF
CONFIG -= qt app_bundle
CONFIG += console
include(../paths.pri)
TARGET = ${NAME}_test
SOURCES += main.cpp
LIBS += -l$NAME
include(../paths.pri)
EOF

YEAR=`date +%Y`
COPY=../templates/COPYRIGHT.h
cat $COPY | sed "s/%YEAR%/$YEAR/g" > $NAME/main.cpp
cat >> $NAME/main.cpp <<EOF
#include <${NAME}.h>
void test() {
}
EOF

echo "test for $NAME created"
25 changes: 25 additions & 0 deletions config.tests/x11/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2015 Wang Bin <[email protected]>
* This file is part of QtAV
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/
#include <X11/Xlib.h>

void test() {
XPutImage(NULL, 0, NULL, NULL, 0, 0, 0, 0, 0, 0);
}
5 changes: 5 additions & 0 deletions config.tests/x11/x11.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include(../paths.pri)

TARGET = x11_test
SOURCES += main.cpp
LIBS += -lX11
16 changes: 6 additions & 10 deletions examples/player/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ MainWindow::MainWindow(QWidget *parent) :
, mRepeateMax(0)
, mpPlayer(0)
, mpRenderer(0)
, mpTempRenderer(0)
, mpVideoFilter(0)
, mpAudioFilter(0)
, mpStatisticsView(0)
Expand Down Expand Up @@ -145,6 +144,11 @@ void MainWindow::initPlayer()
{
mpPlayer = new AVPlayer(this);
mIsReady = true;
VideoRenderer *vo = VideoRenderer::create((VideoRendererId)property("rendererId").toInt());
if (!vo || !vo->isAvailable() || !vo->widget()) {
QMessageBox::critical(0, QString::fromLatin1("QtAV"), tr("Video renderer is ") + tr("not availabe on your platform!"));
}
setRenderer(vo);
//mpSubtitle->installTo(mpPlayer); //filter on frame
mpSubtitle->setPlayer(mpPlayer);
//mpPlayer->setAudioOutput(AudioOutputFactory::create(AudioOutputId_OpenAL));
Expand Down Expand Up @@ -492,6 +496,7 @@ void MainWindow::setupUi()
subMenu->addAction(QString::fromLatin1("GDI+"))->setData(VideoRendererId_GDI);
subMenu->addAction(QString::fromLatin1("Direct2D"))->setData(VideoRendererId_Direct2D);
subMenu->addAction(QString::fromLatin1("XV"))->setData(VideoRendererId_XV);
subMenu->addAction(QString::fromLatin1("X11"))->setData(VideoRendererId_X11);
mVOActions = subMenu->actions();
foreach(QAction* action, subMenu->actions()) {
action->setCheckable(true);
Expand Down Expand Up @@ -603,7 +608,6 @@ void MainWindow::changeVO(QAction *action)
VideoRendererId vid = (VideoRendererId)action->data().toInt();
VideoRenderer *vo = VideoRenderer::create(vid);
if (vo && vo->isAvailable()) {

setRenderer(vo);
} else {
action->toggle(); //check state changes if clicked
Expand All @@ -614,10 +618,6 @@ void MainWindow::changeVO(QAction *action)

void MainWindow::processPendingActions()
{
if (!mpTempRenderer)
return;
setRenderer(mpTempRenderer);
mpTempRenderer = 0;
if (mHasPendingPlay) {
mHasPendingPlay = false;
play(mFile);
Expand All @@ -631,10 +631,6 @@ void MainWindow::setAudioBackends(const QStringList& backends)

void MainWindow::setRenderer(QtAV::VideoRenderer *renderer)
{
if (!mIsReady) {
mpTempRenderer = renderer;
return;
}
if (!renderer)
return;
mpOSD->uninstall();
Expand Down
2 changes: 1 addition & 1 deletion examples/player/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private slots:

QtAV::AVClock *mpClock;
QtAV::AVPlayer *mpPlayer;
QtAV::VideoRenderer *mpRenderer, *mpTempRenderer;
QtAV::VideoRenderer *mpRenderer;
QtAV::LibAVFilterVideo *mpVideoFilter;
QtAV::LibAVFilterAudio *mpAudioFilter;
QString mFile;
Expand Down
24 changes: 8 additions & 16 deletions examples/player/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ int main(int argc, char *argv[])
}
qDebug("vo: %s", vo.toUtf8().constData());
vo = vo.toLower();
if (vo != QLatin1String("opengl") && vo != QLatin1String("gl") && vo != QLatin1String("d2d") && vo != QLatin1String("gdi") && vo != QLatin1String("xv") && vo != QLatin1String("qt")) {
if (vo != QLatin1String("opengl") && vo != QLatin1String("gl") && vo != QLatin1String("d2d") && vo != QLatin1String("gdi")
&& vo != QLatin1String("xv") && vo != QLatin1String("x11") && vo != QLatin1String("qt")) {
#ifndef QT_NO_OPENGL
#ifdef Q_OS_ANDROID
vo = "opengl"; // qglwidget is not suitable for android
Expand All @@ -153,6 +154,7 @@ int main(int argc, char *argv[])
{ "d2d", VideoRendererId_Direct2D },
{ "gdi", VideoRendererId_GDI },
{ "xv", VideoRendererId_XV },
{ "x11", VideoRendererId_X11 },
{ "qt", VideoRendererId_Widget },
{ 0, 0 }
};
Expand All @@ -162,29 +164,19 @@ int main(int argc, char *argv[])
break;
}
}
VideoOutput *renderer = new VideoOutput(vid); //or VideoRenderer
if (!renderer) {
QMessageBox::critical(0, QString::fromLatin1("QtAV"), QString::fromLatin1("vo '%1' not supported").arg(vo));
return 1;
}
//renderer->scaleInRenderer(false);
renderer->setOutAspectRatioMode(VideoRenderer::VideoAspectRatio);

MainWindow window;
window.setProperty("rendererId", vid);
window.show();
window.setWindowTitle(title);
AppEventFilter ae(&window);
qApp->installEventFilter(&ae);

window.show();
window.setWindowTitle(title);
window.setRenderer(renderer);
int w = renderer->widget()->width();
int h = renderer->widget()->width()*9/16;
int x = window.x();
int y = window.y();
op = options.option(QString::fromLatin1("width"));
w = op.value().toInt();
int w = op.value().toInt();
op = options.option(QString::fromLatin1("height"));
h = op.value().toInt();
int h = op.value().toInt();
op = options.option(QString::fromLatin1("x"));
if (op.isSet())
x = op.value().toInt();
Expand Down
1 change: 1 addition & 0 deletions widgets/QtAVWidgets/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern Q_AVWIDGETS_EXPORT VideoRendererId VideoRendererId_GLWidget;
extern Q_AVWIDGETS_EXPORT VideoRendererId VideoRendererId_GDI;
extern Q_AVWIDGETS_EXPORT VideoRendererId VideoRendererId_Direct2D;
extern Q_AVWIDGETS_EXPORT VideoRendererId VideoRendererId_XV;
extern Q_AVWIDGETS_EXPORT VideoRendererId VideoRendererId_X11;
extern Q_AVWIDGETS_EXPORT VideoRendererId VideoRendererId_GLWidget2;
extern Q_AVWIDGETS_EXPORT VideoRendererId VideoRendererId_OpenGLWidget;
//popup a dialog
Expand Down
Loading

0 comments on commit 0856ed2

Please sign in to comment.