diff options
author | Ruth Sadler <ext-ruth.sadler@nokia.com> | 2011-01-11 10:32:46 (GMT) |
---|---|---|
committer | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2011-01-11 13:18:56 (GMT) |
commit | 1640acce5ca8f49c5655edffa2a1108048c5a414 (patch) | |
tree | f8697351bab1f13ded31c1f0ccef7e221b3c4b49 /src/3rdparty/phonon/mmf/mediaobject.cpp | |
parent | d33fd349c8a22b2e4a6d9bc1bf4defcb2a047744 (diff) | |
download | Qt-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/phonon/mmf/mediaobject.cpp')
-rw-r--r-- | src/3rdparty/phonon/mmf/mediaobject.cpp | 57 |
1 files changed, 56 insertions, 1 deletions
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 //----------------------------------------------------------------------------- |