|
1 /* This file is part of the KDE project. |
|
2 |
|
3 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 |
|
5 This library is free software: you can redistribute it and/or modify |
|
6 it under the terms of the GNU Lesser General Public License as published by |
|
7 the Free Software Foundation, either version 2.1 or 3 of the License. |
|
8 |
|
9 This library is distributed in the hope that it will be useful, |
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 GNU Lesser General Public License for more details. |
|
13 |
|
14 You should have received a copy of the GNU Lesser General Public License |
|
15 along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
16 */ |
|
17 |
|
18 #ifndef PHONON_MEDIAGRAPH_H |
|
19 #define PHONON_MEDIAGRAPH_H |
|
20 |
|
21 #include "backendnode.h" |
|
22 #include <QtCore/QMultiMap> |
|
23 |
|
24 #include <phonon/mediasource.h> |
|
25 |
|
26 //#define GRAPH_DEBUG |
|
27 |
|
28 QT_BEGIN_NAMESPACE |
|
29 |
|
30 namespace Phonon |
|
31 { |
|
32 namespace DS9 |
|
33 { |
|
34 class MediaObject; |
|
35 |
|
36 //in the end we should probably have no more inheritance here: everything should be in the interface of the class |
|
37 //could be nice to then remove all the "*this" in the code of this class |
|
38 class MediaGraph : public QObject |
|
39 { |
|
40 public: |
|
41 MediaGraph(MediaObject *mo, short index); |
|
42 ~MediaGraph(); |
|
43 bool isSeekable() const; |
|
44 qint64 absoluteTotalTime() const; |
|
45 qint64 absoluteCurrentTime() const; |
|
46 void play(); |
|
47 void stop(); |
|
48 void pause(); |
|
49 void absoluteSeek(qint64); |
|
50 |
|
51 QMultiMap<QString, QString> metadata() const; |
|
52 |
|
53 static QList<Filter> getAllFilters(Graph graph); |
|
54 QList<Filter> getAllFilters() const; |
|
55 |
|
56 HRESULT loadSource(const Phonon::MediaSource &); |
|
57 |
|
58 bool hasVideo() const { return m_hasVideo; } |
|
59 void grabNode(BackendNode *node); |
|
60 void grabFilter(Filter filter); |
|
61 |
|
62 //connections of the nodes |
|
63 bool connectNodes(BackendNode *source, BackendNode *sink); |
|
64 bool disconnectNodes(BackendNode *source, BackendNode *sink); |
|
65 |
|
66 Phonon::MediaSource mediaSource() const; |
|
67 |
|
68 //before loading a source, and after its playback this will be called |
|
69 HRESULT cleanup(); |
|
70 void ensureStopped(); |
|
71 |
|
72 short index() const; |
|
73 |
|
74 Filter realSource() const; |
|
75 |
|
76 |
|
77 #ifndef QT_NO_PHONON_MEDIACONTROLLER |
|
78 QList<qint64> titles() const; |
|
79 void setStopPosition(qint64 time); |
|
80 qint64 stopPosition() const; |
|
81 #endif //QT_NO_PHONON_MEDIACONTROLLER |
|
82 |
|
83 void switchFilters(Filter oldFilter, Filter newFilter); |
|
84 OAFilterState syncGetRealState() const; |
|
85 |
|
86 bool isLoading() const; |
|
87 bool isStopping() const; |
|
88 HRESULT renderResult() const; |
|
89 |
|
90 Graph graph() const; |
|
91 |
|
92 void finishLoading(quint16 workId, HRESULT hr, Graph); |
|
93 void finishSeeking(quint16 workId, qint64 time); |
|
94 |
|
95 private: |
|
96 bool isSourceFilter(const Filter &filter) const; |
|
97 bool isDemuxerFilter(const Filter &filter) const; |
|
98 bool isDecoderFilter(const Filter &filter); |
|
99 static QList<Filter> getFilterChain(const Filter &source, const Filter &sink); |
|
100 |
|
101 HRESULT reallyFinishLoading(HRESULT, const Graph &graph); |
|
102 |
|
103 |
|
104 //utility functions |
|
105 void ensureSourceConnectedTo(bool force = false); |
|
106 void ensureSourceDisconnected(); |
|
107 bool tryConnect(const OutputPin &, const InputPin &); |
|
108 bool tryDisconnect(const OutputPin &, const InputPin &); |
|
109 HRESULT removeFilter(const Filter& filter); |
|
110 |
|
111 //after loading, removes the decoders that are not linked to a sink |
|
112 HRESULT removeUselessDecoders(); |
|
113 |
|
114 //COM objects |
|
115 Graph m_graph; |
|
116 ComPointer<IMediaControl> m_mediaControl; |
|
117 ComPointer<IMediaSeeking> m_mediaSeeking; |
|
118 Filter m_fakeSource, m_realSource; |
|
119 Filter m_demux; |
|
120 QList<OutputPin> m_decoderPins; |
|
121 QList<Filter> m_decoders; |
|
122 |
|
123 bool m_hasVideo; |
|
124 bool m_hasAudio; |
|
125 bool m_connectionsDirty; |
|
126 bool m_isStopping; |
|
127 mutable bool m_isSeekable; |
|
128 HRESULT m_result; |
|
129 quint16 m_index; |
|
130 quint16 m_renderId; |
|
131 quint16 m_seekId; |
|
132 |
|
133 //while seeking we need to store the current time |
|
134 qint64 m_currentTime; |
|
135 qint64 m_totalTime; |
|
136 |
|
137 MediaObject *m_mediaObject; |
|
138 Phonon::MediaSource m_mediaSource; |
|
139 QList<BackendNode*> m_sinkConnections; //connections to the source |
|
140 |
|
141 Q_DISABLE_COPY(MediaGraph); |
|
142 }; |
|
143 } |
|
144 } |
|
145 |
|
146 QT_END_NAMESPACE |
|
147 |
|
148 #endif // PHONON_MEDIAGRAPH_H |