summaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
authorRuth Sadler <ext-ruth.sadler@nokia.com>2011-01-11 10:32:46 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2011-01-11 13:18:56 (GMT)
commit1640acce5ca8f49c5655edffa2a1108048c5a414 (patch)
treef8697351bab1f13ded31c1f0ccef7e221b3c4b49 /src/3rdparty
parentd33fd349c8a22b2e4a6d9bc1bf4defcb2a047744 (diff)
downloadQt-1640acce5ca8f49c5655edffa2a1108048c5a414.zip
Qt-1640acce5ca8f49c5655edffa2a1108048c5a414.tar.gz
Qt-1640acce5ca8f49c5655edffa2a1108048c5a414.tar.bz2
Allow IAP to be selected in Phonon MMF backend
The Phonon API does not provide any way for the client to specify which network connection should be used for streaming playback. If the application already has a connection open, using a bearer other than the default (e.g. using WiFi when the device default is GPRS), it may be desirable to use it for streaming, rather than allowing the Phonon backend to open a second connection on the default bearer. This patch adds a custom property on the Phonon::MediaObject, called InternetAccessPointName. The client can specify the IAP which Phonon should use by setting this property. Note that support for this property is only provided in the Phonon MMF backend. Task-number: QTBUG-11436 Reviewed-by: Gareth Stockwell
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/phonon/mmf/abstractmediaplayer.cpp11
-rw-r--r--src/3rdparty/phonon/mmf/abstractmediaplayer.h2
-rw-r--r--src/3rdparty/phonon/mmf/abstractvideoplayer.cpp4
-rw-r--r--src/3rdparty/phonon/mmf/abstractvideoplayer.h2
-rw-r--r--src/3rdparty/phonon/mmf/audioplayer.cpp2
-rw-r--r--src/3rdparty/phonon/mmf/audioplayer.h2
-rw-r--r--src/3rdparty/phonon/mmf/download.cpp9
-rw-r--r--src/3rdparty/phonon/mmf/download.h4
-rw-r--r--src/3rdparty/phonon/mmf/mediaobject.cpp57
-rw-r--r--src/3rdparty/phonon/mmf/mediaobject.h7
10 files changed, 86 insertions, 14 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
index dfc5840..4f7caff 100644
--- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
+++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp
@@ -23,6 +23,9 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "defs.h"
#include "mediaobject.h"
#include "utils.h"
+#include <cdbcols.h>
+#include <cdblen.h>
+#include <commdb.h>
QT_BEGIN_NAMESPACE
@@ -267,11 +270,15 @@ void MMF::AbstractMediaPlayer::open()
this, SLOT(downloadLengthChanged(qint64)));
connect(m_download, SIGNAL(stateChanged(Download::State)),
this, SLOT(downloadStateChanged(Download::State)));
- m_download->start();
+ int iap = m_parent->currentIAP();
+ TRACE("HTTP Url: Using IAP %d", iap);
+ m_download->start(iap);
}
#endif
else {
- symbianErr = openUrl(url.toString());
+ int iap = m_parent->currentIAP();
+ TRACE("Using IAP %d", iap);
+ symbianErr = openUrl(url.toString(), iap);
if (KErrNone != symbianErr)
errorMessage = tr("Error opening URL");
}
diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h
index c3b4528..df0a42f 100644
--- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h
+++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h
@@ -75,7 +75,7 @@ protected:
virtual int setDeviceVolume(int mmfVolume) = 0;
virtual int openFile(const QString &fileName) = 0;
virtual int openFile(RFile& file) = 0;
- virtual int openUrl(const QString& url) = 0;
+ virtual int openUrl(const QString& url, int iap) = 0;
virtual int openDescriptor(const TDesC8 &des) = 0;
virtual int bufferStatus() const = 0;
virtual void doClose() = 0;
diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
index 1ab5bae..ad4ee83 100644
--- a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
+++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
@@ -146,9 +146,9 @@ int MMF::AbstractVideoPlayer::openFile(RFile &file)
return err;
}
-int MMF::AbstractVideoPlayer::openUrl(const QString &url)
+int MMF::AbstractVideoPlayer::openUrl(const QString &url, int iap)
{
- TRAPD(err, m_player->OpenUrlL(qt_QString2TPtrC(url)));
+ TRAPD(err, m_player->OpenUrlL(qt_QString2TPtrC(url), iap));
return err;
}
diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.h b/src/3rdparty/phonon/mmf/abstractvideoplayer.h
index 3bc5c7c..21446d2 100644
--- a/src/3rdparty/phonon/mmf/abstractvideoplayer.h
+++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.h
@@ -66,7 +66,7 @@ public:
virtual int setDeviceVolume(int mmfVolume);
virtual int openFile(const QString &fileName);
virtual int openFile(RFile &file);
- virtual int openUrl(const QString &url);
+ virtual int openUrl(const QString &url, int iap);
virtual int openDescriptor(const TDesC8 &des);
virtual int bufferStatus() const;
virtual void doClose();
diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp
index dc5c800..2ae6a3d 100644
--- a/src/3rdparty/phonon/mmf/audioplayer.cpp
+++ b/src/3rdparty/phonon/mmf/audioplayer.cpp
@@ -134,7 +134,7 @@ int MMF::AudioPlayer::openFile(RFile& file)
return err;
}
-int MMF::AudioPlayer::openUrl(const QString& /*url*/)
+int MMF::AudioPlayer::openUrl(const QString& /*url*/, int /*iap*/)
{
// Streaming playback is generally not supported by the implementation
// of the audio player API, so we use CVideoPlayerUtility for both
diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h
index cf4f6d5..e963c26 100644
--- a/src/3rdparty/phonon/mmf/audioplayer.h
+++ b/src/3rdparty/phonon/mmf/audioplayer.h
@@ -67,7 +67,7 @@ typedef CMdaAudioPlayerUtility NativePlayer;
virtual int setDeviceVolume(int mmfVolume);
virtual int openFile(const QString &fileName);
virtual int openFile(RFile& file);
- virtual int openUrl(const QString& url);
+ virtual int openUrl(const QString& url, int iap);
virtual int openDescriptor(const TDesC8 &des);
virtual int bufferStatus() const;
virtual void doClose();
diff --git a/src/3rdparty/phonon/mmf/download.cpp b/src/3rdparty/phonon/mmf/download.cpp
index 7b80e4a..de65811 100644
--- a/src/3rdparty/phonon/mmf/download.cpp
+++ b/src/3rdparty/phonon/mmf/download.cpp
@@ -20,6 +20,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "utils.h"
#include <QtCore/QDir>
#include <QtCore/private/qcore_symbian_p.h>
+#include <mmf/common/mmfcontrollerframeworkbase.h>
QT_BEGIN_NAMESPACE
@@ -43,7 +44,7 @@ DownloadPrivate::~DownloadPrivate()
m_downloadManager.Close();
}
-bool DownloadPrivate::start()
+bool DownloadPrivate::start(int iap)
{
TRACE_CONTEXT(DownloadPrivate::start, EVideoApi);
Q_ASSERT(!m_download);
@@ -54,6 +55,8 @@ bool DownloadPrivate::start()
TRACE("connect err %d", err);
if (KErrNone == err) {
// Start download
+ if (KUseDefaultIap != iap)
+ m_downloadManager.SetIntAttribute(EDlMgrIap, iap);
QHBufC url(m_parent->sourceUrl().toString());
TPtr8 url8 = url->Des().Collapse();
TRAP(err, m_download = &m_downloadManager.CreateDownloadL(url8));
@@ -140,12 +143,12 @@ const QString &Download::targetFileName() const
return m_targetFileName;
}
-void Download::start()
+void Download::start(int iap)
{
TRACE_CONTEXT(Download::start, EVideoApi);
TRACE_ENTRY_0();
Q_ASSERT(Idle == m_state);
- const bool ok = m_private->start();
+ const bool ok = m_private->start(iap);
setState(ok ? Initializing : Error);
TRACE_EXIT_0();
}
diff --git a/src/3rdparty/phonon/mmf/download.h b/src/3rdparty/phonon/mmf/download.h
index bda7963..2ce54a8 100644
--- a/src/3rdparty/phonon/mmf/download.h
+++ b/src/3rdparty/phonon/mmf/download.h
@@ -43,7 +43,7 @@ class DownloadPrivate : public QObject
public:
DownloadPrivate(Download *parent);
~DownloadPrivate();
- bool start();
+ bool start(int iap);
void resume();
signals:
void error();
@@ -69,7 +69,7 @@ public:
~Download();
const QUrl &sourceUrl() const;
const QString &targetFileName() const;
- void start();
+ void start(int iap);
void resume();
enum State {
diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp
index 2c7a7ef..9da94ee 100644
--- a/src/3rdparty/phonon/mmf/mediaobject.cpp
+++ b/src/3rdparty/phonon/mmf/mediaobject.cpp
@@ -36,6 +36,10 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <QDir>
#include <QResource>
#include <QUrl>
+#include <cdbcols.h>
+#include <cdblen.h>
+#include <commdb.h>
+#include <mmf/common/mmfcontrollerframeworkbase.h>
QT_BEGIN_NAMESPACE
@@ -64,7 +68,8 @@ MMF::MediaObject::MediaObject(QObject *parent) : MMF::MediaNode::MediaNode(paren
const int err = m_fileServer.Connect();
QT_TRAP_THROWING(User::LeaveIfError(err));
- Q_UNUSED(parent);
+ parent->installEventFilter(this);
+ m_iap = KUseDefaultIap;
TRACE_EXIT_0();
}
@@ -74,6 +79,7 @@ MMF::MediaObject::~MediaObject()
TRACE_CONTEXT(MediaObject::~MediaObject, EAudioApi);
TRACE_ENTRY_0();
+ parent()->removeEventFilter(this);
delete m_resource;
if (m_file)
@@ -493,6 +499,55 @@ void MMF::MediaObject::switchToNextSource()
}
//-----------------------------------------------------------------------------
+// IAP support
+//-----------------------------------------------------------------------------
+
+int MMF::MediaObject::currentIAP() const
+{
+ return m_iap;
+}
+
+bool MMF::MediaObject::eventFilter(QObject *watched, QEvent *event)
+{
+ if (event->type() == QEvent::DynamicPropertyChange ) {
+ QDynamicPropertyChangeEvent* dynamicEvent = static_cast<QDynamicPropertyChangeEvent*>(event);
+ if (dynamicEvent->propertyName() == "InternetAccessPointName") {
+ QVariant value = watched->property("InternetAccessPointName");
+ if (value.isValid()) {
+ QString iapName = value.toString();
+ TRAPD(err, setIAPIdFromNameL(iapName));
+ if (err)
+ m_player->setError(tr("Failed to set requested IAP"), err);
+ }
+ }
+ }
+ return false;
+}
+
+void MMF::MediaObject::setIAPIdFromNameL(const QString& iapString)
+{
+ TRACE_CONTEXT(MediaObject::getIapIdFromName, EVideoInternal);
+ TBuf<KCommsDbSvrMaxColumnNameLength> iapDes = qt_QString2TPtrC(iapString);
+ CCommsDatabase *commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
+ CleanupStack::PushL(commsDb);
+ commsDb->ShowHiddenRecords();
+ CCommsDbTableView *view = commsDb->OpenTableLC(TPtrC(IAP));
+ for (TInt l = view->GotoFirstRecord(); l != KErrNotFound; l = view->GotoNextRecord()) {
+ TBuf<KCommsDbSvrMaxColumnNameLength> iapName;
+ view->ReadTextL(TPtrC(COMMDB_NAME), iapName);
+ TRACE("found IAP %S", &iapName);
+ if (iapName.CompareF(iapDes) == 0) {
+ TUint32 uiap;
+ view->ReadUintL(TPtrC(COMMDB_ID), uiap);
+ TRACE("matched IAP %S, setting m_iap %d", &iapName, uiap);
+ m_iap = uiap;
+ break;
+ }
+ }
+ CleanupStack::PopAndDestroy(2); // commsDb, view
+}
+
+//-----------------------------------------------------------------------------
// Other private functions
//-----------------------------------------------------------------------------
diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h
index 5d785fb..0ed70ff 100644
--- a/src/3rdparty/phonon/mmf/mediaobject.h
+++ b/src/3rdparty/phonon/mmf/mediaobject.h
@@ -23,6 +23,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <phonon/mediaobjectinterface.h>
#include <QScopedPointer>
#include <QTimer>
+#include <QString>
// For recognizer
#include <apgcli.h>
@@ -92,6 +93,7 @@ public:
int openFileHandle(const QString &fileName);
RFile* file() const;
QResource* resource() const;
+ int currentIAP() const;
public Q_SLOTS:
void volumeChanged(qreal volume);
@@ -113,6 +115,9 @@ Q_SIGNALS:
void finished();
void tick(qint64 time);
+protected:
+ bool eventFilter(QObject *watched, QEvent *event);
+
private Q_SLOTS:
void handlePrefinishMarkReached(qint32);
@@ -120,6 +125,7 @@ private:
void switchToSource(const MediaSource &source);
void createPlayer(const MediaSource &source);
bool openRecognizer();
+ void setIAPIdFromNameL(const QString& iapString);
// Audio / video media type recognition
MediaType fileMediaType(const QString& fileName);
@@ -143,6 +149,7 @@ private:
QResource* m_resource;
QScopedPointer<AbstractPlayer> m_player;
+ int m_iap;
};
}