1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | /*!
|
---|
43 | \page phonon-overview.html
|
---|
44 | \title Phonon Overview
|
---|
45 | \ingroup frameworks-technologies
|
---|
46 |
|
---|
47 | \tableofcontents
|
---|
48 |
|
---|
49 | \section1 Introduction
|
---|
50 |
|
---|
51 | Qt uses the Phonon multimedia framework to provide functionality
|
---|
52 | for playback of the most common multimedia formats. The media can
|
---|
53 | be read from files or streamed over a network, using a QURL to a
|
---|
54 | file.
|
---|
55 |
|
---|
56 | In this overview, we take a look at the main concepts of Phonon.
|
---|
57 | We also explain the architecture, examine the
|
---|
58 | core API classes, and show examples on how to use the classes
|
---|
59 | provided.
|
---|
60 |
|
---|
61 | \section1 Architecture
|
---|
62 |
|
---|
63 | Phonon has three basic concepts: media objects, sinks, and paths.
|
---|
64 | A media object manages a media source, for instance, a music file;
|
---|
65 | it provides simple playback control, such as starting, stopping,
|
---|
66 | and pausing the playback. A sink outputs the media from Phonon,
|
---|
67 | e.g., by rendering video on a widget, or by sending audio to a
|
---|
68 | sound card. Paths are used to connect Phonon objects, i.e., a
|
---|
69 | media object and a sink, in a graph - called a media graph in
|
---|
70 | Phonon.
|
---|
71 |
|
---|
72 | As an example, we show a media graph for an audio stream:
|
---|
73 |
|
---|
74 | \image conceptaudio.png
|
---|
75 |
|
---|
76 | The playback is started and managed by the media object, which
|
---|
77 | send the media stream to any sinks connected to it by a path. The
|
---|
78 | sink then plays the stream back, usually though a sound card.
|
---|
79 |
|
---|
80 | \omit Not sure if this goes here, or anywhere...
|
---|
81 | All nodes in the graph are synchronized by the framework,
|
---|
82 | meaning that if more than one sink is connected to the same
|
---|
83 | media object, the framework will handle the synchronization
|
---|
84 | between the sinks; this happens for instance when a media
|
---|
85 | source containing video with sound is played back. More on
|
---|
86 | this later.
|
---|
87 | \endomit
|
---|
88 |
|
---|
89 | \section2 Media Objects
|
---|
90 |
|
---|
91 | The media object, an instance of the \l{Phonon::}{MediaObject}
|
---|
92 | class, lets you start, pause, and stop the playback of a media
|
---|
93 | stream, i.e., it provided basic control over the playback. You may
|
---|
94 | think of the object as a simple media player.
|
---|
95 |
|
---|
96 | The media data is provided by a media source, which is
|
---|
97 | kept by the media object. The media source is a separate
|
---|
98 | object - an instance of \l{Phonon::}{MediaSource} - in Phonon, and
|
---|
99 | not part of the graph itself. The source will supply the media
|
---|
100 | object with raw data. The data can be read from files and streamed
|
---|
101 | over a network. The contents of the source will be interpreted by
|
---|
102 | the media object.
|
---|
103 |
|
---|
104 | A media object is always instantiated with the default constructor
|
---|
105 | and then supplied with a media source. Concrete code examples are
|
---|
106 | given later in this overview.
|
---|
107 |
|
---|
108 | As a complement to the media object, Phonon also provides
|
---|
109 | \l{Phonon::}{MediaController}, which provides control over
|
---|
110 | features that are optional for a given media. For instance, for
|
---|
111 | chapters, menus, and titles of a VOB (DVD) file will be features
|
---|
112 | managed by a \l{Phonon::}{MediaController}.
|
---|
113 |
|
---|
114 | \section2 Sinks
|
---|
115 |
|
---|
116 | A sink is a node that can output media from the graph, i.e., it
|
---|
117 | does not send its output to other nodes. A sink is usually a
|
---|
118 | rendering device.
|
---|
119 |
|
---|
120 | The input of sinks in a Phonon media graph comes from a
|
---|
121 | \l{Phonon::}{MediaObject}, though it might have been processed
|
---|
122 | through other nodes on the way.
|
---|
123 |
|
---|
124 | While the \l{Phonon::}{MediaObject} controls the playback, the
|
---|
125 | sink has basic controls for manipulation of the media. With an
|
---|
126 | audio sink, for instance, you can control the volume and mute the
|
---|
127 | sound, i.e., it represents a virtual audio device. Another example
|
---|
128 | is the \l{Phonon::}{VideoWidget}, which can render video on a
|
---|
129 | QWidget and alter the brightness, hue, and scaling of the video.
|
---|
130 |
|
---|
131 | As an example we give an image of a graph used for playing back a
|
---|
132 | video file with sound.
|
---|
133 |
|
---|
134 | \image conceptvideo.png
|
---|
135 |
|
---|
136 | \section2 Processors
|
---|
137 |
|
---|
138 | Phonon does not allow manipulation of media streams directly,
|
---|
139 | i.e., one cannot alter a media stream's bytes programmatically
|
---|
140 | after they have been given to a media object. We have other nodes
|
---|
141 | to help with this: processors, which are placed in the graph on
|
---|
142 | the path somewhere between the media object and its sinks. In
|
---|
143 | Phonon, processors are of the \l{Phonon::}{Effect} class.
|
---|
144 |
|
---|
145 | When inserted into the rendering process, the processor will
|
---|
146 | alter the media stream, and will be active as long as it is part
|
---|
147 | of the graph. To stop, it needs to be removed.
|
---|
148 |
|
---|
149 | \omit \image conceptprocessor.png \endomit
|
---|
150 |
|
---|
151 | The \c {Effect}s may also have controls that affect how the media
|
---|
152 | stream is manipulated. A processor applying a depth effect to
|
---|
153 | audio, for instance, can have a value controlling the amount of
|
---|
154 | depth. An \c Effect can be configured at any point in time.
|
---|
155 |
|
---|
156 | \section1 Playback
|
---|
157 |
|
---|
158 | In some common cases, it is not necessary to build a graph
|
---|
159 | yourself.
|
---|
160 |
|
---|
161 | Phonon has convenience functions for building common graphs. For
|
---|
162 | playing an audio file, you can use the
|
---|
163 | \l{Phonon::}{createPlayer()} function. This will set up the
|
---|
|
---|