Building the Phonon backend plugin on Windows using MinGW

From QtCentreWiki

Jump to:navigation, search


Introduction

Before read next, please read this blog: http://labs.trolltech.com/blogs/2009/07/15/phonon-and-mingw-a-story-about-true-windows-love

See the phonon4qtmingw package too: http://www.qtcentre.org/forum/f-installation-and-deployment-5/t-phonon4qtmingwzip-a-magical-package-22652.html It is very small to download (6MB), and fully automatic (but still beta). All needed files, tools and commands are gathered there. update: use the last version of the package (3MB): http://www.4shared.com/file/161942847/2f1b88fc/phonon4qtmingw--3.html

(Remainder is the old qtcentre's article)

The KDE people made it very easy to compile the DirectShow 9 Phonon backend on windows. Make sure your Qt is configured with -phonon -phonon-backend.

Remember that you need Microsoft DirectX SDK on your system for the Qt's phonon backend (which is DirectShow based) compilation to be activated realy; you need to run the dx_setenv.cmd from the MS DX SDK on the command line before running configure.

Prerequisites

1. Get the kdewin32 package from KDE svn (Indeed, you need only kdewin32/include/mingw and kdewin32/include/directx directories):

 http://websvn.kde.org/trunk/kdesupport/kdewin/
 svn://anonsvn.kde.org/home/kde/trunk/kdesupport/kdewin

2. Copy the file comdef.h from kdewin32/include/mingw into kdewin32/include/directx

 copy kdewin32/include/mingw/comdef.h kdewin32/include/directx

How to Build the Plug-in

1. Edit src/plugins/phonon/ds9/ds9.pro - make the beginning look like this:

 DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend
 QT += phonon
 win32:!win32-g++*:!wince*:contains(QT_CONFIG,opengl):LIBS += opengl32.lib
 win32:!win32-g++*:!wince*:LIBS += gdi32.lib
 !win32-g++*:win32-msvc2005:DEFINES += _CRT_SECURE_NO_WARNINGS
 !win32-g++*:LIBS += strmiids.lib Dmoguids.lib uuid.lib msdmo.lib
 win32-g++*:contains(QT_CONFIG,opengl):LIBS += -lopengl32
 win32-g++*:LIBS += -lgdi32 -lstrmiids -lDmoguids -luuid -lmsdmo -lole32 -loleaut32
 TARGET = phonon_ds9
 DEFINES += PHONON_MAKE_QT_ONLY_BACKEND
 PHONON_DS9_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/ds9
 INCLUDEPATH += path/to/kdewin32/include/directx

2. Build!

 mingw32-make

Problems with Video

The DS9 backend contains 2 renderers, VMR9 and softrenderer. In my Windows XP installation the VMR9 one doesn't work (can be seen by a warning "the video widget could not be initialized correctly" when the video widget is created) The softrenderer didn't work at all until I edited the file src/3rdparty/phonon/ds9/videowidget.cpp and commented out the following function from VideoWindow:

 QPaintEngine* paintEngine() const
 {
   return 0;
 }

Problems with compilation

You can't compiling /examples/phonon/capabilities and can't build Qt with -static key. © SABROG

Update: with Qt 4.5.2 /capabilities is now compilable.

Official reply from Trolltech/QtSoftware about MinGW and Phonon (Issue N247549)

"The problem with this is that it is not an official port and we need to stick with the official port when supporting Phonon with MinGW. If it starts to make itself available with MinGW officially then we can certainly look into it."

Reply from MinGW

">Comment By: Earnie Boyd (earnie) Date: 2009-05-04 08:55

Message: http://www.mingw.org/wiki/SubmitPatches

And pay careful attention to item 8 "Document your Work". We cannot accept work that was not derived from documentation."

8. Document your Work: "Note, in particular, that we adopt a much stricter standpoint on extracting information from Microsoft's SDK headers, than that taken by some other projects, such as Wine or ReactOS; consequently we will always reject, unconditionally, patches based on information extracted from files published by such projects."