https://techbase.kde.org/index.php?title=Development/Tutorials/Phonon/Backends&feed=atom&action=historyDevelopment/Tutorials/Phonon/Backends - Revision history2015-03-03T19:15:48ZRevision history for this page on the wikiMediaWiki 1.20.2https://techbase.kde.org/index.php?title=Development/Tutorials/Phonon/Backends&diff=56325&oldid=prevApachelogger: port from http://phonon.kde.org/cms/10242010-12-23T14:49:48Z<p>port from http://phonon.kde.org/cms/1024</p>
<p><b>New page</b></p><div>Phonon itself does not implement any multimedia functionality and depends completely on a backend to do what the applications want. This is comparable to engines in Amarok or Player subclasses in JuK but with one big difference: once your backend works correctly it will make all KDE applications using Phonon use the mediaframework you used for implementing the backend.<br />
<br />
Subscribe to the [https://mail.kde.org/mailman/listinfo/phonon-backends phonon-backends] mailinglist if you want to discuss development of your backend or read about the development of other backends.<br />
<br />
== How to Write a Backend for Phonon ==<br />
<br />
To simplify the text the following terms are used below:<br />
<br />
The backend has to implement some abstract classes (always named Interface) and some QObject interfaces. The classes/objects that implement those interfaces I will denote with impl classes/objects.<br />
For most media frameworks the objects have to be connected in some way forming a graph. I will simply talk about a graph or flow graph.<br />
In order to get started and see some progress early, I recommend to copy the fake backend that ships with Phonon. First you'll want to edit the CMakeLists.txt and phonon_fake.desktop files. In the CMakeLists.txt you can comment out all classes except MediaObject, AudioPath, AudioOutput and Backend. Those four are the minimum requirement for audio playback. In the Backend class you return 0 for all classes that you have not implemented. In the source you then change the namespace from Fake to whatever your backend is called. Then you can get going on implementing the three classes.<br />
<br />
To test whether your classes are working you can use the test programs from the tests directory. Compiling kdelibs with KDE4_BUILD_TESTS will create the test programs in builddir/phonon/tests/.<br />
<br />
There are two approaches on how to implement the functionality:<br />
<br />
* Create graph objects in impl objects<br />
<br />
This is an approach that was already successfully used for a proof-of-concept aRts backend. The MediaObject impl creates the PlayObject. The AudioPath impl creates a StereoEffectStack and Synth_MULTI_ADD if needed. The AudioOutput impl creates the Synth_AMAN_PLAY object. You get the idea. All the common objects are held in the Backend object and are accessible for the other impl objects. Examples for this are the KArtsServer and KArtsDispatcher classes used in the aRts backend.<br />
<br />
You might want to consider this approach if it is easy to find a 1:1 mapping between impl classes and entities of the mediaframework.<br />
<br />
* Use the impl objects as a description to let some other entity create the graph<br />
<br />
Create simple impl classes that do nothing else than describe the state that is requested from the application. Another class then can use that description to create the according flow graph. Whenever the state of the impl objects changes this class is notified and can take action accordingly.<br />
<br />
This approach is what you need if you cannot find a 1:1 mapping like above, and might often be the more flexible approach even if you have a good mapping of Phonon impl classes to media framework entities.</div>Apachelogger