diff options
author | Nicholas Young <nicholas.young@nokia.com> | 2010-02-04 00:45:43 (GMT) |
---|---|---|
committer | Nicholas Young <nicholas.young@nokia.com> | 2010-02-04 00:45:43 (GMT) |
commit | 1d48062f758ae82129583b0e95b18d06faf57547 (patch) | |
tree | b9037132db7e725b0f9997a0258a8cb0c4fdc414 /src/multimedia | |
parent | 5588657ba3b2a060e60bf8d83fd5ba60bbdc9c64 (diff) | |
download | Qt-1d48062f758ae82129583b0e95b18d06faf57547.zip Qt-1d48062f758ae82129583b0e95b18d06faf57547.tar.gz Qt-1d48062f758ae82129583b0e95b18d06faf57547.tar.bz2 |
Added QNetworkRequest constructor to QMediaResource.
Diffstat (limited to 'src/multimedia')
-rw-r--r-- | src/multimedia/base/base.pri | 1 | ||||
-rw-r--r-- | src/multimedia/base/qmediaresource.cpp | 24 | ||||
-rw-r--r-- | src/multimedia/base/qmediaresource.h | 6 |
3 files changed, 28 insertions, 3 deletions
diff --git a/src/multimedia/base/base.pri b/src/multimedia/base/base.pri index fb2784d..5aebbf0 100644 --- a/src/multimedia/base/base.pri +++ b/src/multimedia/base/base.pri @@ -1,4 +1,5 @@ +QT += network contains(QT_CONFIG, opengl):QT += opengl HEADERS += \ diff --git a/src/multimedia/base/qmediaresource.cpp b/src/multimedia/base/qmediaresource.cpp index ab18ce7..515e432 100644 --- a/src/multimedia/base/qmediaresource.cpp +++ b/src/multimedia/base/qmediaresource.cpp @@ -93,7 +93,17 @@ QMediaResource::QMediaResource() */ QMediaResource::QMediaResource(const QUrl &url, const QString &mimeType) { - values.insert(Url, qVariantFromValue(url)); + values.insert(Url, url); + values.insert(MimeType, mimeType); +} + +/*! + Constructs a media resource with the given \a mimeType from a network \a request. +*/ +QMediaResource::QMediaResource(const QNetworkRequest &request, const QString &mimeType) +{ + values.insert(Request, QVariant::fromValue(request)); + values.insert(Url, request.url()); values.insert(MimeType, mimeType); } @@ -162,6 +172,17 @@ QUrl QMediaResource::url() const } /*! + Returns the network request associated with this media resource. +*/ +QNetworkRequest QMediaResource::request() const +{ + if(values.contains(Request)) + return qvariant_cast<QNetworkRequest>(values.value(Request)); + + return QNetworkRequest(url()); +} + +/*! Returns the MIME type of a media resource. This may be null if the MIME type is unknown. @@ -373,6 +394,5 @@ void QMediaResource::setResolution(int width, int height) else values.remove(Resolution); } - QT_END_NAMESPACE diff --git a/src/multimedia/base/qmediaresource.h b/src/multimedia/base/qmediaresource.h index 33b5a79..516120a 100644 --- a/src/multimedia/base/qmediaresource.h +++ b/src/multimedia/base/qmediaresource.h @@ -44,6 +44,7 @@ #include <QtCore/qmap.h> #include <QtCore/qmetatype.h> +#include <QtNetwork/qnetworkrequest.h> QT_BEGIN_HEADER @@ -58,6 +59,7 @@ class Q_MULTIMEDIA_EXPORT QMediaResource public: QMediaResource(); QMediaResource(const QUrl &url, const QString &mimeType = QString()); + QMediaResource(const QNetworkRequest &request, const QString &mimeType = QString()); QMediaResource(const QMediaResource &other); QMediaResource &operator =(const QMediaResource &other); ~QMediaResource(); @@ -68,6 +70,7 @@ public: bool operator !=(const QMediaResource &other) const; QUrl url() const; + QNetworkRequest request() const; QString mimeType() const; QString language() const; @@ -103,6 +106,7 @@ private: enum Property { Url, + Request, MimeType, Language, AudioCodec, @@ -112,7 +116,7 @@ private: VideoBitRate, SampleRate, ChannelCount, - Resolution, + Resolution }; QMap<int, QVariant> values; }; |