|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
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 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include <QtCore/qurl.h> |
|
43 #include <QtCore/qvariant.h> |
|
44 |
|
45 #include <qmediacontent.h> |
|
46 |
|
47 QTM_BEGIN_NAMESPACE |
|
48 |
|
49 |
|
50 class QMediaContentPrivate : public QSharedData |
|
51 { |
|
52 public: |
|
53 QMediaContentPrivate() {} |
|
54 QMediaContentPrivate(const QMediaResourceList &r): |
|
55 resources(r) {} |
|
56 |
|
57 QMediaContentPrivate(const QMediaContentPrivate &other): |
|
58 QSharedData(other), |
|
59 resources(other.resources) |
|
60 {} |
|
61 |
|
62 bool operator ==(const QMediaContentPrivate &other) const |
|
63 { |
|
64 return resources == other.resources; |
|
65 } |
|
66 |
|
67 QMediaResourceList resources; |
|
68 private: |
|
69 QMediaContentPrivate& operator=(const QMediaContentPrivate &other); |
|
70 }; |
|
71 |
|
72 |
|
73 /*! |
|
74 \class QMediaContent |
|
75 \preliminary |
|
76 \brief The QMediaContent class provides access to the resources relating to a media content. |
|
77 |
|
78 \ingroup multimedia |
|
79 |
|
80 QMediaContent is used within the multimedia framework as the logical handle |
|
81 to media content. A QMediaContent object is composed of one or more |
|
82 \l {QMediaResource}s where each resource provides the URL and format |
|
83 information of a different encoding of the content. |
|
84 |
|
85 A non-null QMediaContent will always have a primary or canonical reference to |
|
86 the content available through the canonicalUrl() or canonicalResource() |
|
87 methods, any additional resources are optional. |
|
88 */ |
|
89 |
|
90 |
|
91 /*! |
|
92 Constructs a null QMediaContent. |
|
93 */ |
|
94 |
|
95 QMediaContent::QMediaContent() |
|
96 { |
|
97 } |
|
98 |
|
99 /*! |
|
100 Constructs a media content with \a url providing a reference to the content. |
|
101 */ |
|
102 |
|
103 QMediaContent::QMediaContent(const QUrl &url): |
|
104 d(new QMediaContentPrivate) |
|
105 { |
|
106 d->resources << QMediaResource(url); |
|
107 } |
|
108 |
|
109 /*! |
|
110 Constructs a media content with \a resource providing a reference to the content. |
|
111 */ |
|
112 |
|
113 QMediaContent::QMediaContent(const QMediaResource &resource): |
|
114 d(new QMediaContentPrivate) |
|
115 { |
|
116 d->resources << resource; |
|
117 } |
|
118 |
|
119 /*! |
|
120 Constructs a media content with \a resources providing a reference to the content. |
|
121 */ |
|
122 |
|
123 QMediaContent::QMediaContent(const QMediaResourceList &resources): |
|
124 d(new QMediaContentPrivate(resources)) |
|
125 { |
|
126 } |
|
127 |
|
128 /*! |
|
129 Constructs a copy of the media content \a other. |
|
130 */ |
|
131 |
|
132 QMediaContent::QMediaContent(const QMediaContent &other): |
|
133 d(other.d) |
|
134 { |
|
135 } |
|
136 |
|
137 /*! |
|
138 Destroys the media content object. |
|
139 */ |
|
140 |
|
141 QMediaContent::~QMediaContent() |
|
142 { |
|
143 } |
|
144 |
|
145 /*! |
|
146 Assigns the value of \a other to this media content. |
|
147 */ |
|
148 |
|
149 QMediaContent& QMediaContent::operator=(const QMediaContent &other) |
|
150 { |
|
151 d = other.d; |
|
152 return *this; |
|
153 } |
|
154 |
|
155 /*! |
|
156 Returns true if \a other is equivalent to this media content; false otherwise. |
|
157 */ |
|
158 |
|
159 bool QMediaContent::operator==(const QMediaContent &other) const |
|
160 { |
|
161 return (d.constData() == 0 && other.d.constData() == 0) || |
|
162 (d.constData() != 0 && other.d.constData() != 0 && |
|
163 *d.constData() == *other.d.constData()); |
|
164 } |
|
165 |
|
166 /*! |
|
167 Returns true if \a other is not equivalent to this media content; false otherwise. |
|
168 */ |
|
169 |
|
170 bool QMediaContent::operator!=(const QMediaContent &other) const |
|
171 { |
|
172 return !(*this == other); |
|
173 } |
|
174 |
|
175 /*! |
|
176 Returns true if this media content is null (uninitialized); false otherwise. |
|
177 */ |
|
178 |
|
179 bool QMediaContent::isNull() const |
|
180 { |
|
181 return d.constData() == 0; |
|
182 } |
|
183 |
|
184 /*! |
|
185 Returns a QUrl that represents that canonical resource for this media content. |
|
186 */ |
|
187 |
|
188 QUrl QMediaContent::canonicalUrl() const |
|
189 { |
|
190 return canonicalResource().url(); |
|
191 } |
|
192 |
|
193 /*! |
|
194 Returns a QMediaResource that represents that canonical resource for this media content. |
|
195 */ |
|
196 |
|
197 QMediaResource QMediaContent::canonicalResource() const |
|
198 { |
|
199 return d.constData() != 0 |
|
200 ? d->resources.value(0) |
|
201 : QMediaResource(); |
|
202 } |
|
203 |
|
204 /*! |
|
205 Returns a list of alternative resources for this media content. The first item in this list |
|
206 is always the canonical resource. |
|
207 */ |
|
208 |
|
209 QMediaResourceList QMediaContent::resources() const |
|
210 { |
|
211 return d.constData() != 0 |
|
212 ? d->resources |
|
213 : QMediaResourceList(); |
|
214 } |
|
215 |
|
216 QTM_END_NAMESPACE |
|
217 |