diff options
author | hawcroft <derick.hawcroft@nokia.com> | 2010-04-29 01:08:49 (GMT) |
---|---|---|
committer | hawcroft <derick.hawcroft@nokia.com> | 2010-04-29 01:09:29 (GMT) |
commit | 872ffd81772ff39d173da90184a5124242909707 (patch) | |
tree | 593f9700279daffbb28dd98ed4ce2d71a67cd357 /src/plugins/mediaservices/symbian | |
parent | 1bfd49e9f6a19c5d8ecdd0a412d340bc9d399740 (diff) | |
download | Qt-872ffd81772ff39d173da90184a5124242909707.zip Qt-872ffd81772ff39d173da90184a5124242909707.tar.gz Qt-872ffd81772ff39d173da90184a5124242909707.tar.bz2 |
S60 mediaservices backend
Reviewed-by: Justin McPherson
Diffstat (limited to 'src/plugins/mediaservices/symbian')
31 files changed, 4974 insertions, 0 deletions
diff --git a/src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri b/src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri new file mode 100644 index 0000000..205e014 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri @@ -0,0 +1,63 @@ +INCLUDEPATH += $$PWD +LIBS += -lmediaclientvideo \ + -lmediaclientaudio \ + -lws32 \ + -lfbscli \ + -lcone \ + -lmmfcontrollerframework \ + -lefsrv \ + -lbitgdi \ + -lapgrfx \ + -lapmime + + +# We are building Symbian backend with media player support +DEFINES += QMEDIA_MMF_PLAYER + + +HEADERS += \ + $$PWD/s60mediaplayercontrol.h \ + $$PWD/s60mediaplayerservice.h \ + $$PWD/s60mediaplayersession.h \ + $$PWD/s60videoplayersession.h \ + $$PWD/s60mediametadataprovider.h \ + $$PWD/s60videosurface.h \ + $$PWD/s60videooverlay.h \ + $$PWD/s60videorenderer.h \ + $$PWD/s60mediarecognizer.h \ + $$PWD/s60audioplayersession.h \ + $$PWD/ms60mediaplayerresolver.h \ + $$PWD/s60videowidget.h \ + $$PWD/s60mediaplayeraudioendpointselector.h + +SOURCES += \ + $$PWD/s60mediaplayercontrol.cpp \ + $$PWD/s60mediaplayerservice.cpp \ + $$PWD/s60mediaplayersession.cpp \ + $$PWD/s60videoplayersession.cpp \ + $$PWD/s60mediametadataprovider.cpp \ + $$PWD/s60videosurface.cpp \ + $$PWD/s60videooverlay.cpp \ + $$PWD/s60videorenderer.cpp \ + $$PWD/s60mediarecognizer.cpp \ + $$PWD/s60audioplayersession.cpp \ + $$PWD/s60videowidget.cpp \ + $$PWD/s60mediaplayeraudioendpointselector.cpp + +contains(S60_VERSION, 3.1) { + + #3.1 doesn't provide audio routing in videoplayer + DEFINES += HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER + + !exists($${EPOCROOT}epoc32\release\winscw\udeb\audiooutputrouting.lib) { + MMP_RULES += "$${LITERAL_HASH}ifdef WINSCW" \ + "MACRO HAS_NO_AUDIOROUTING" \ + "$${LITERAL_HASH}else" \ + "LIBRARY audiooutputrouting.lib" \ + "$${LITERAL_HASH}endif" + } + +} else { + LIBS += -laudiooutputrouting +} + diff --git a/src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h b/src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h new file mode 100644 index 0000000..b655a83 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef MS60MEDIAPLAYERRESOLVER_H +#define MS60MEDIAPLAYERRESOLVER_H + +QT_BEGIN_NAMESPACE + +class S60MediaPlayerSession; + +class MS60MediaPlayerResolver +{ + public: + virtual S60MediaPlayerSession* PlayerSession() = 0; + virtual S60MediaPlayerSession* VideoPlayerSession() = 0; + virtual S60MediaPlayerSession* AudioPlayerSession() = 0; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp new file mode 100644 index 0000000..f4065e4 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp @@ -0,0 +1,268 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60audioplayersession.h" +#include <QtCore/qdebug.h> +#include <QtCore/qvariant.h> + +#include <AudioOutput.h> +#include <MAudioOutputObserver.h> + +QT_BEGIN_NAMESPACE + +S60AudioPlayerSession::S60AudioPlayerSession(QObject *parent) + : S60MediaPlayerSession(parent) + , m_player(0) + , m_audioOutput(0) + , m_audioEndpoint("Default") +{ + QT_TRAP_THROWING(m_player = CAudioPlayer::NewL(*this, 0, EMdaPriorityPreferenceNone)); + m_player->RegisterForAudioLoadingNotification(*this); +} + +S60AudioPlayerSession::~S60AudioPlayerSession() +{ +#if !defined(HAS_NO_AUDIOROUTING) + if (m_audioOutput) + m_audioOutput->UnregisterObserver(*this); + delete m_audioOutput; +#endif + m_player->Close(); + delete m_player; +} + +void S60AudioPlayerSession::doLoadL(const TDesC &path) +{ + // m_audioOutput needs to be reinitialized after MapcInitComplete + if (m_audioOutput) + m_audioOutput->UnregisterObserver(*this); + delete m_audioOutput; + m_audioOutput = NULL; + + m_player->OpenFileL(path); +} + +qint64 S60AudioPlayerSession::doGetDurationL() const +{ + return m_player->Duration().Int64() / qint64(1000); +} + +qint64 S60AudioPlayerSession::doGetPositionL() const +{ + TTimeIntervalMicroSeconds ms = 0; + m_player->GetPosition(ms); + return ms.Int64() / qint64(1000); +} + +bool S60AudioPlayerSession::isVideoAvailable() const +{ + return false; +} +bool S60AudioPlayerSession::isAudioAvailable() const +{ + return true; // this is a bit happy scenario, but we do emit error that we can't play +} + +void S60AudioPlayerSession::MaloLoadingStarted() +{ + buffering(); +} + +void S60AudioPlayerSession::MaloLoadingComplete() +{ + buffered(); +} + +void S60AudioPlayerSession::doPlay() +{ +// For some reason loading progress callbalck are not called on emulator +#ifdef __WINSCW__ + buffering(); +#endif + m_player->Play(); +#ifdef __WINSCW__ + buffered(); +#endif + +} + +void S60AudioPlayerSession::doPauseL() +{ + m_player->Pause(); +} + +void S60AudioPlayerSession::doStop() +{ + m_player->Stop(); +} + +void S60AudioPlayerSession::doSetVolumeL(int volume) +{ + m_player->SetVolume((volume / 100.0) * m_player->MaxVolume()); +} + +void S60AudioPlayerSession::doSetPositionL(qint64 microSeconds) +{ + m_player->SetPosition(TTimeIntervalMicroSeconds(microSeconds)); +} + +void S60AudioPlayerSession::updateMetaDataEntriesL() +{ + metaDataEntries().clear(); + int numberOfMetaDataEntries = 0; + + m_player->GetNumberOfMetaDataEntries(numberOfMetaDataEntries); + + for (int i = 0; i < numberOfMetaDataEntries; i++) { + CMMFMetaDataEntry *entry = NULL; + entry = m_player->GetMetaDataEntryL(i); + metaDataEntries().insert(QString::fromUtf16(entry->Name().Ptr(), entry->Name().Length()), QString::fromUtf16(entry->Value().Ptr(), entry->Value().Length())); + delete entry; + } + emit metaDataChanged(); +} + +int S60AudioPlayerSession::doGetBufferStatusL() const +{ + int progress = 0; + m_player->GetAudioLoadingProgressL(progress); + return progress; +} + +void S60AudioPlayerSession::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration) +{ + Q_UNUSED(aDuration); + setError(aError); + TRAPD(err, + m_audioOutput = CAudioOutput::NewL(*m_player); + m_audioOutput->RegisterObserverL(*this); + ); + setActiveEndpoint(m_audioEndpoint); + setError(err); + loaded(); +} + +void S60AudioPlayerSession::MapcPlayComplete(TInt aError) +{ + setError(aError); + endOfMedia(); +} + +void S60AudioPlayerSession::doSetAudioEndpoint(const QString& audioEndpoint) +{ + m_audioEndpoint = audioEndpoint; +} + +QString S60AudioPlayerSession::activeEndpoint() const +{ + QString outputName = QString("Default"); +#if !defined(HAS_NO_AUDIOROUTING) + if (m_audioOutput) { + CAudioOutput::TAudioOutputPreference output = m_audioOutput->AudioOutput(); + outputName = qStringFromTAudioOutputPreference(output); + } +#endif + return outputName; +} + +QString S60AudioPlayerSession::defaultEndpoint() const +{ + QString outputName = QString("Default"); +#if !defined(HAS_NO_AUDIOROUTING) + if (m_audioOutput) { + CAudioOutput::TAudioOutputPreference output = m_audioOutput->DefaultAudioOutput(); + outputName = qStringFromTAudioOutputPreference(output); + } +#endif + return outputName; +} + +void S60AudioPlayerSession::setActiveEndpoint(const QString& name) +{ + CAudioOutput::TAudioOutputPreference output = CAudioOutput::ENoPreference; + + if (name == QString("Default")) + output = CAudioOutput::ENoPreference; + else if (name == QString("All")) + output = CAudioOutput::EAll; + else if (name == QString("None")) + output = CAudioOutput::ENoOutput; + else if (name == QString("Earphone")) + output = CAudioOutput::EPrivate; + else if (name == QString("Speaker")) + output = CAudioOutput::EPublic; +#if !defined(HAS_NO_AUDIOROUTING) + if (m_audioOutput) { + TRAPD(err, m_audioOutput->SetAudioOutputL(output)); + setError(err); + + if (m_audioEndpoint != name) { + m_audioEndpoint = name; + emit activeEndpointChanged(name); + } + } +#endif +} + +void S60AudioPlayerSession::DefaultAudioOutputChanged(CAudioOutput& aAudioOutput, + CAudioOutput::TAudioOutputPreference aNewDefault) +{ + // Emit already implemented in setActiveEndpoint function + Q_UNUSED(aAudioOutput) + Q_UNUSED(aNewDefault) +} + +QString S60AudioPlayerSession::qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const +{ + if (output == CAudioOutput::ENoPreference) + return QString("Default"); + else if (output == CAudioOutput::EAll) + return QString("All"); + else if (output == CAudioOutput::ENoOutput) + return QString("None"); + else if (output == CAudioOutput::EPrivate) + return QString("Earphone"); + else if (output == CAudioOutput::EPublic) + return QString("Speaker"); + return QString("Default"); +} + +QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h b/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h new file mode 100644 index 0000000..fca66b3 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60AUDIOPLAYERSESSION_H +#define S60AUDIOPLAYERSESSION_H + +#include "s60mediaplayersession.h" + +#include <mdaaudiosampleplayer.h> +typedef CMdaAudioPlayerUtility CAudioPlayer; +typedef MMdaAudioPlayerCallback MAudioPlayerObserver; + +#include <AudioOutput.h> +#include <MAudioOutputObserver.h> + +QT_BEGIN_NAMESPACE + +class S60AudioPlayerSession : public S60MediaPlayerSession + , public MAudioPlayerObserver + , public MAudioLoadingObserver + , public MAudioOutputObserver +{ + Q_OBJECT + +public: + S60AudioPlayerSession(QObject *parent); + ~S60AudioPlayerSession(); + + //From S60MediaPlayerSession + bool isVideoAvailable() const; + bool isAudioAvailable() const; + + // From MAudioLoadingObserver + void MaloLoadingStarted(); + void MaloLoadingComplete(); + + // From MAudioOutputObserver + void DefaultAudioOutputChanged( CAudioOutput& aAudioOutput, + CAudioOutput::TAudioOutputPreference aNewDefault ); + +public: + // From S60MediaPlayerAudioEndpointSelector + QString activeEndpoint() const; + QString defaultEndpoint() const; +public Q_SLOTS: + void setActiveEndpoint(const QString& name); +Q_SIGNALS: + void activeEndpointChanged(const QString & name); + +protected: + //From S60MediaPlayerSession + void doLoadL(const TDesC &path); + void doLoadUrlL(const TDesC &path){Q_UNUSED(path)/*empty implementation*/} + void doPlay(); + void doStop(); + void doPauseL(); + void doSetVolumeL(int volume); + qint64 doGetPositionL() const; + void doSetPositionL(qint64 microSeconds); + void updateMetaDataEntriesL(); + int doGetBufferStatusL() const; + qint64 doGetDurationL() const; + void doSetAudioEndpoint(const QString& audioEndpoint); + +private: + void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration); + void MapcPlayComplete(TInt aError); + QString qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const; + +private: + CAudioPlayer *m_player; + CAudioOutput *m_audioOutput; + QString m_audioEndpoint; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp new file mode 100644 index 0000000..e80c487 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60mediametadataprovider.h" +#include "s60mediaplayersession.h" +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +S60MediaMetaDataProvider::S60MediaMetaDataProvider(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent) + : QMetaDataControl(parent) + , m_mediaPlayerResolver(mediaPlayerResolver) + , m_session(NULL) +{ +} + +S60MediaMetaDataProvider::~S60MediaMetaDataProvider() +{ +} + +bool S60MediaMetaDataProvider::isMetaDataAvailable() const +{ + m_session = m_mediaPlayerResolver.PlayerSession(); + if (m_session) + return m_session->isMetadataAvailable(); + return false; +} + +bool S60MediaMetaDataProvider::isWritable() const +{ + return false; +} + +QVariant S60MediaMetaDataProvider::metaData(QtMediaServices::MetaData key) const +{ + m_session = m_mediaPlayerResolver.PlayerSession(); + if (m_session && m_session->isMetadataAvailable()) + return m_session->metaData(metaDataKeyAsString(key)); + return QVariant(); +} + +void S60MediaMetaDataProvider::setMetaData(QtMediaServices::MetaData key, QVariant const &value) +{ + Q_UNUSED(key); + Q_UNUSED(value); +} +QList<QtMediaServices::MetaData> S60MediaMetaDataProvider::availableMetaData() const +{ + m_session = m_mediaPlayerResolver.PlayerSession(); + QList<QtMediaServices::MetaData> metaDataTags; + if (m_session && m_session->isMetadataAvailable()) { + for (int i = QtMediaServices::Title; i <= QtMediaServices::DeviceSettingDescription; i++) { + QString metaData = metaDataKeyAsString((QtMediaServices::MetaData)i); + if (!metaData.isEmpty()) { + if (!m_session->metaData(metaData).toString().isEmpty()) { + metaDataTags.append((QtMediaServices::MetaData)i); + } + } + } + } + return metaDataTags; +} + +QVariant S60MediaMetaDataProvider::extendedMetaData(const QString &key) const +{ + m_session = m_mediaPlayerResolver.PlayerSession(); + if (m_session && m_session->isMetadataAvailable()) + return m_session->metaData(key); + return QVariant(); +} + +void S60MediaMetaDataProvider::setExtendedMetaData(const QString &key, QVariant const &value) +{ + Q_UNUSED(key); + Q_UNUSED(value); +} + +QStringList S60MediaMetaDataProvider::availableExtendedMetaData() const +{ + m_session = m_mediaPlayerResolver.PlayerSession(); + if (m_session && m_session->isMetadataAvailable()) + return m_session->availableMetaData().keys(); + return QStringList(); +} + +QString S60MediaMetaDataProvider::metaDataKeyAsString(QtMediaServices::MetaData key) const +{ + switch(key) { + case QtMediaServices::Title: return "title"; + case QtMediaServices::AlbumArtist: return "artist"; + case QtMediaServices::Comment: return "comment"; + case QtMediaServices::Genre: return "genre"; + case QtMediaServices::Year: return "year"; + case QtMediaServices::Copyright: return "copyright"; + case QtMediaServices::AlbumTitle: return "album"; + case QtMediaServices::Composer: return "composer"; + case QtMediaServices::TrackNumber: return "albumtrack"; + case QtMediaServices::AudioBitRate: return "audiobitrate"; + case QtMediaServices::VideoBitRate: return "videobitrate"; + case QtMediaServices::Duration: return "duration"; + case QtMediaServices::MediaType: return "contenttype"; + case QtMediaServices::SubTitle: // TODO: Find the matching metadata keys + case QtMediaServices::Description: + case QtMediaServices::Category: + case QtMediaServices::Date: + case QtMediaServices::UserRating: + case QtMediaServices::Keywords: + case QtMediaServices::Language: + case QtMediaServices::Publisher: + case QtMediaServices::ParentalRating: + case QtMediaServices::RatingOrganisation: + case QtMediaServices::Size: + case QtMediaServices::AudioCodec: + case QtMediaServices::AverageLevel: + case QtMediaServices::ChannelCount: + case QtMediaServices::PeakValue: + case QtMediaServices::SampleRate: + case QtMediaServices::Author: + case QtMediaServices::ContributingArtist: + case QtMediaServices::Conductor: + case QtMediaServices::Lyrics: + case QtMediaServices::Mood: + case QtMediaServices::TrackCount: + case QtMediaServices::CoverArtUrlSmall: + case QtMediaServices::CoverArtUrlLarge: + case QtMediaServices::Resolution: + case QtMediaServices::PixelAspectRatio: + case QtMediaServices::VideoFrameRate: + case QtMediaServices::VideoCodec: + case QtMediaServices::PosterUrl: + case QtMediaServices::ChapterNumber: + case QtMediaServices::Director: + case QtMediaServices::LeadPerformer: + case QtMediaServices::Writer: + case QtMediaServices::CameraManufacturer: + case QtMediaServices::CameraModel: + case QtMediaServices::Event: + case QtMediaServices::Subject: + default: + break; + } + + return QString(); +} + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h new file mode 100644 index 0000000..07ae494 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60MEDIAMETADATAPROVIDER_H +#define S60MEDIAMETADATAPROVIDER_H + +#include <qmetadatacontrol.h> +#include "ms60mediaplayerresolver.h" + +QT_BEGIN_NAMESPACE + +class S60MediaPlayerSession; + +class S60MediaMetaDataProvider : public QMetaDataControl +{ + Q_OBJECT + +public: + S60MediaMetaDataProvider(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent = 0); + ~S60MediaMetaDataProvider(); + + bool isMetaDataAvailable() const; + bool isWritable() const; + + QVariant metaData(QtMediaServices::MetaData key) const; + void setMetaData(QtMediaServices::MetaData key, const QVariant &value); + QList<QtMediaServices::MetaData> availableMetaData() const; + + QVariant extendedMetaData(const QString &key) const ; + void setExtendedMetaData(const QString &key, const QVariant &value); + QStringList availableExtendedMetaData() const; + +private: + QString metaDataKeyAsString(QtMediaServices::MetaData key) const; + +private: + MS60MediaPlayerResolver& m_mediaPlayerResolver; + mutable S60MediaPlayerSession *m_session; +}; + +QT_END_NAMESPACE + +#endif // S60VIDEOMETADATAPROVIDER_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp new file mode 100644 index 0000000..dbeed90 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60mediaplayercontrol.h" +#include "s60mediaplayersession.h" +#include "s60mediaplayeraudioendpointselector.h" + +#include <QtGui/QIcon> +#include <QtCore/QDebug> + +QT_BEGIN_NAMESPACE + +S60MediaPlayerAudioEndpointSelector::S60MediaPlayerAudioEndpointSelector(QObject *control, QObject *parent) + :QMediaControl(parent) + , m_control(0) + , m_audioEndpointNames(0) +{ + m_control = qobject_cast<S60MediaPlayerControl*>(control); +} + +S60MediaPlayerAudioEndpointSelector::~S60MediaPlayerAudioEndpointSelector() +{ + delete m_audioEndpointNames; +} + +QList<QString> S60MediaPlayerAudioEndpointSelector::availableEndpoints() const +{ + if(m_audioEndpointNames->count() == 0) { + m_audioEndpointNames->append("Default"); + m_audioEndpointNames->append("All"); + m_audioEndpointNames->append("None"); + m_audioEndpointNames->append("Earphone"); + m_audioEndpointNames->append("Speaker"); + } + return *m_audioEndpointNames; +} + +QString S60MediaPlayerAudioEndpointSelector::endpointDescription(const QString& name) const +{ + if (name == QString("Default")) //ENoPreference + return QString("Used to indicate that the playing audio can be routed to" + "any speaker. This is the default value for audio."); + else if (name == QString("All")) //EAll + return QString("Used to indicate that the playing audio should be routed to all speakers."); + else if (name == QString("None")) //ENoOutput + return QString("Used to indicate that the playing audio should not be routed to any output."); + else if (name == QString("Earphone")) //EPrivate + return QString("Used to indicate that the playing audio should be routed to" + "the default private speaker. A private speaker is one that can only" + "be heard by one person."); + else if (name == QString("Speaker")) //EPublic + return QString("Used to indicate that the playing audio should be routed to" + "the default public speaker. A public speaker is one that can " + "be heard by multiple people."); + + return QString(); +} + +QString S60MediaPlayerAudioEndpointSelector::activeEndpoint() const +{ + if (m_control->session()) + return m_control->session()->activeEndpoint(); + else + return m_control->mediaControlSettings().audioEndpoint(); +} + +QString S60MediaPlayerAudioEndpointSelector::defaultEndpoint() const +{ + if (m_control->session()) + return m_control->session()->defaultEndpoint(); + else + return m_control->mediaControlSettings().audioEndpoint(); +} + +void S60MediaPlayerAudioEndpointSelector::setActiveEndpoint(const QString& name) +{ + QString oldEndpoint = m_control->mediaControlSettings().audioEndpoint(); + + if (name != oldEndpoint && (name == QString("Default") || name == QString("All") || + name == QString("None") || name == QString("Earphone") || name == QString("Speaker"))) { + + if (m_control->session()) { + m_control->session()->setActiveEndpoint(name); + } + m_control->setAudioEndpoint(name); + } +} + +QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h new file mode 100644 index 0000000..a110ae8 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H +#define S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H + +#include <QStringList> + +#include <QtMediaServices/qmediacontrol.h> + +QT_BEGIN_NAMESPACE + +class S60MediaPlayerControl; +class S60MediaPlayerSession; + +class S60MediaPlayerAudioEndpointSelector : public QMediaControl +{ + +Q_OBJECT + +public: + S60MediaPlayerAudioEndpointSelector(QObject *control, QObject *parent = 0); + ~S60MediaPlayerAudioEndpointSelector(); + + QList<QString> availableEndpoints() const ; + QString endpointDescription(const QString& name) const; + QString defaultEndpoint() const; + QString activeEndpoint() const; + +public Q_SLOTS: + void setActiveEndpoint(const QString& name); + +private: + S60MediaPlayerControl* m_control; + QString m_audioInput; + QList<QString> *m_audioEndpointNames; +}; + +#define QAudioEndpointSelector_iid "com.nokia.Qt.QAudioEndpointSelector/1.0" + +QT_END_NAMESPACE + +#endif // S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp new file mode 100644 index 0000000..8e03afd --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp @@ -0,0 +1,274 @@ + +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60mediaplayercontrol.h" +#include "s60mediaplayersession.h" + +#include <QtCore/qdir.h> +#include <QtCore/qurl.h> +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +S60MediaPlayerControl::S60MediaPlayerControl(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent) + : QMediaPlayerControl(parent), + m_mediaPlayerResolver(mediaPlayerResolver), + m_session(NULL), + m_stream(NULL) +{ +} + +S60MediaPlayerControl::~S60MediaPlayerControl() +{ +} + +qint64 S60MediaPlayerControl::position() const +{ + if (m_session) + return m_session->position(); + return 0; +} + +qint64 S60MediaPlayerControl::duration() const +{ + if (m_session) + return m_session->duration(); + return -1; +} + +QMediaPlayer::State S60MediaPlayerControl::state() const +{ + if (m_session) + return m_session->state(); + return QMediaPlayer::StoppedState; +} + +QMediaPlayer::MediaStatus S60MediaPlayerControl::mediaStatus() const +{ + if (m_session) + return m_session->mediaStatus(); + return m_mediaSettings.mediaStatus(); +} + +int S60MediaPlayerControl::bufferStatus() const +{ + if (m_session) + return m_session->bufferStatus(); + return 0; +} + +int S60MediaPlayerControl::volume() const +{ + if (m_session) + return m_session->volume(); + return m_mediaSettings.volume(); +} + +bool S60MediaPlayerControl::isMuted() const +{ + if (m_session) + return m_session->isMuted(); + return m_mediaSettings.isMuted(); +} + +bool S60MediaPlayerControl::isSeekable() const +{ + if (m_session) + return m_session->isSeekable(); + return false; +} + +QMediaTimeRange S60MediaPlayerControl::availablePlaybackRanges() const +{ + QMediaTimeRange ranges; + + if(m_session && m_session->isSeekable()) + ranges.addInterval(0, m_session->duration()); + + return ranges; +} + +qreal S60MediaPlayerControl::playbackRate() const +{ + //None of symbian players supports this. + return m_mediaSettings.playbackRate(); +} + +void S60MediaPlayerControl::setPlaybackRate(qreal rate) +{ + //None of symbian players supports this. + m_mediaSettings.setPlaybackRate(rate); + emit playbackRateChanged(playbackRate()); + +} + +void S60MediaPlayerControl::setPosition(qint64 pos) +{ + if (m_session) + m_session->setPosition(pos); +} + +void S60MediaPlayerControl::play() +{ + if (m_session) + m_session->play(); +} + +void S60MediaPlayerControl::pause() +{ + if (m_session) + m_session->pause(); +} + +void S60MediaPlayerControl::stop() +{ + if (m_session) + m_session->stop(); +} + +void S60MediaPlayerControl::setVolume(int volume) +{ + int boundVolume = qBound(0, volume, 100); + if (boundVolume == m_mediaSettings.volume()) + return; + + m_mediaSettings.setVolume(boundVolume); + if (m_session) + m_session->setVolume(boundVolume); + + emit volumeChanged(boundVolume); +} + +void S60MediaPlayerControl::setMuted(bool muted) +{ + if (m_mediaSettings.isMuted() == muted) + return; + + m_mediaSettings.setMuted(muted); + if (m_session) + m_session->setMuted(muted); + + emit mutedChanged(muted); +} + +QMediaContent S60MediaPlayerControl::media() const +{ + return m_currentResource; +} + +const QIODevice *S60MediaPlayerControl::mediaStream() const +{ + return m_stream; +} + +void S60MediaPlayerControl::setMedia(const QMediaContent &source, QIODevice *stream) +{ + Q_UNUSED(stream) + // we don't want to set & load media again when it is already loaded + if (m_session && m_currentResource == source) + return; + + // store to variable as session is created based on the content type. + m_currentResource = source; + S60MediaPlayerSession *newSession = m_mediaPlayerResolver.PlayerSession(); + m_mediaSettings.setMediaStatus(QMediaPlayer::UnknownMediaStatus); + + if (m_session) + m_session->reset(); + else { + emit mediaStatusChanged(QMediaPlayer::UnknownMediaStatus); + emit error(QMediaPlayer::NoError, QString()); + } + + m_session = newSession; + + if (m_session) + m_session->load(source.canonicalUrl()); + else { + QMediaPlayer::MediaStatus status = (source.isNull()) ? QMediaPlayer::NoMedia : QMediaPlayer::InvalidMedia; + m_mediaSettings.setMediaStatus(status); + emit stateChanged(QMediaPlayer::StoppedState); + emit error((source.isNull()) ? QMediaPlayer::NoError : QMediaPlayer::ResourceError, + (source.isNull()) ? "" : tr("Media couldn't be resolved")); + emit mediaStatusChanged(status); + } + emit mediaChanged(m_currentResource); + } + +S60MediaPlayerSession* S60MediaPlayerControl::session() +{ + return m_session; +} + +void S60MediaPlayerControl::setVideoOutput(QObject *output) +{ + S60MediaPlayerSession *session = NULL; + session = m_mediaPlayerResolver.VideoPlayerSession(); + session->setVideoRenderer(output); +} + +bool S60MediaPlayerControl::isAudioAvailable() const +{ + if (m_session) + return m_session->isAudioAvailable(); + return false; +} + +bool S60MediaPlayerControl::isVideoAvailable() const +{ + if (m_session) + return m_session->isVideoAvailable(); + return false; +} + +const S60MediaSettings& S60MediaPlayerControl::mediaControlSettings() const +{ + return m_mediaSettings; +} + +void S60MediaPlayerControl::setAudioEndpoint(const QString& name) +{ + m_mediaSettings.setAudioEndpoint(name); +} + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h new file mode 100644 index 0000000..3d26a5e --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60MEDIAPLAYERCONTROL_H +#define S60MEDIAPLAYERCONTROL_H + +#include <QtCore/qobject.h> + +#include <qmediaplayercontrol.h> + +#include "ms60mediaplayerresolver.h" +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +class QMediaPlayer; +class QMediaTimeRange; +class QMediaContent; + + +class S60MediaPlayerSession; +class S60MediaPlayerService; + +class S60MediaSettings +{ + +public: + S60MediaSettings() + : m_volume(0) + , m_muted(false) + , m_playbackRate(0) + , m_mediaStatus(QMediaPlayer::UnknownMediaStatus) + , m_audioEndpoint(QString("Default")) + { + } + + void setVolume(int volume) { m_volume = volume; } + void setMuted(bool muted) { m_muted = muted; } + void setPlaybackRate(int rate) { m_playbackRate = rate; } + void setMediaStatus(QMediaPlayer::MediaStatus status) {m_mediaStatus=status;} + void setAudioEndpoint(const QString& audioEndpoint) { m_audioEndpoint = audioEndpoint; } + + int volume() const { return m_volume; } + bool isMuted() const { return m_muted; } + qreal playbackRate() const { return m_playbackRate; } + QMediaPlayer::MediaStatus mediaStatus() const {return m_mediaStatus;} + QString audioEndpoint() const { return m_audioEndpoint; } + +private: + int m_volume; + bool m_muted; + qreal m_playbackRate; + QMediaPlayer::MediaStatus m_mediaStatus; + QString m_audioEndpoint; +}; + +class S60MediaPlayerControl : public QMediaPlayerControl +{ + Q_OBJECT + +public: + S60MediaPlayerControl(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent = 0); + ~S60MediaPlayerControl(); + + // from QMediaPlayerControl + virtual QMediaPlayer::State state() const; + virtual QMediaPlayer::MediaStatus mediaStatus() const; + virtual qint64 duration() const; + virtual qint64 position() const; + virtual void setPosition(qint64 pos); + virtual int volume() const; + virtual void setVolume(int volume); + virtual bool isMuted() const; + virtual void setMuted(bool muted); + virtual int bufferStatus() const; + virtual bool isAudioAvailable() const; + virtual bool isVideoAvailable() const; + virtual bool isSeekable() const; + virtual QMediaTimeRange availablePlaybackRanges() const; + virtual qreal playbackRate() const; + virtual void setPlaybackRate(qreal rate); + virtual QMediaContent media() const; + virtual const QIODevice *mediaStream() const; + virtual void setMedia(const QMediaContent&, QIODevice *); + virtual void play(); + virtual void pause(); + virtual void stop(); + S60MediaPlayerSession* session(); + void setAudioEndpoint(const QString& name); + + // Own methods + void setVideoOutput(QObject *output); + const S60MediaSettings& mediaControlSettings() const; + +private: + MS60MediaPlayerResolver &m_mediaPlayerResolver; + S60MediaPlayerSession *m_session; + QMediaContent m_currentResource; + QIODevice *m_stream; + S60MediaSettings m_mediaSettings; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp new file mode 100644 index 0000000..0b1c7d5 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp @@ -0,0 +1,259 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/qvariant.h> +#include <QtCore/qdebug.h> +#include <QtGui/qwidget.h> + +#include "s60mediaplayerservice.h" +#include "s60mediaplayercontrol.h" +#include "s60videoplayersession.h" +#include "s60audioplayersession.h" +#include "s60mediametadataprovider.h" +#include "s60videowidget.h" +#include "s60mediarecognizer.h" +//#include <qmediatimerange.h> +#include "s60videooverlay.h" +#include "s60videorenderer.h" +#include "s60mediaplayeraudioendpointselector.h" + +#include <qmediaplaylistnavigator.h> +#include <qmediaplaylist.h> + +QT_BEGIN_NAMESPACE + +S60MediaPlayerService::S60MediaPlayerService(QObject *parent) + : QMediaService(parent) + , m_control(NULL) + , m_videoOutput(NULL) + , m_videoPlayerSession(NULL) + , m_audioPlayerSession(NULL) + , m_metaData(NULL) + , m_videoWidget(NULL) + , m_videoWindow(NULL) + , m_videoRenderer(NULL) + , m_audioEndpointSelector(NULL) +{ + m_control = new S60MediaPlayerControl(*this, this); + m_metaData = new S60MediaMetaDataProvider(*this); + m_audioEndpointSelector = new S60MediaPlayerAudioEndpointSelector(m_control, this); +} + +S60MediaPlayerService::~S60MediaPlayerService() +{ + delete m_videoWidget; + delete m_videoRenderer; + delete m_videoWindow; + delete m_videoOutput; +} + +QMediaControl *S60MediaPlayerService::control(const char *name) const +{ + if (qstrcmp(name, QMediaPlayerControl_iid) == 0) + return m_control; + + if (qstrcmp(name, QMetaDataControl_iid) == 0) { + return m_metaData; + } + + if (qstrcmp(name, QVideoOutputControl_iid) == 0) { + if (!m_videoOutput) { + m_videoOutput = new S60VideoOutputControl; + connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)), + this, SLOT(videoOutputChanged(QVideoOutputControl::Output))); + m_videoOutput->setAvailableOutputs(QList<QVideoOutputControl::Output>() +// << QVideoOutputControl::RendererOutput +// << QVideoOutputControl::WindowOutput + << QVideoOutputControl::WidgetOutput); + + } + return m_videoOutput; + } + + if (qstrcmp(name, QVideoWidgetControl_iid) == 0) { + if (!m_videoWidget) + m_videoWidget = new S60VideoWidgetControl; + return m_videoWidget; + } + + if (qstrcmp(name, QVideoRendererControl_iid) == 0) { + if (m_videoRenderer) + m_videoRenderer = new S60VideoRenderer; + return m_videoRenderer; + } + + if (qstrcmp(name, QVideoWindowControl_iid) == 0) { + if (!m_videoWindow) + m_videoWindow = new S60VideoOverlay; + return m_videoWindow; + } + + if (qstrcmp(name, QAudioEndpointSelector_iid) == 0) { + return m_audioEndpointSelector; + } + + return 0; + +} + +void S60MediaPlayerService::videoOutputChanged(QVideoOutputControl::Output output) +{ + switch (output) { + case QVideoOutputControl::NoOutput: + m_control->setVideoOutput(0); + break; + + case QVideoOutputControl::RendererOutput: + m_control->setVideoOutput(m_videoRenderer); + break; + case QVideoOutputControl::WindowOutput: + m_control->setVideoOutput(m_videoWindow); + break; + + case QVideoOutputControl::WidgetOutput: + m_control->setVideoOutput(m_videoWidget); + break; + default: + qWarning("Invalid video output selection"); + break; + } +} + +S60MediaPlayerSession* S60MediaPlayerService::PlayerSession() +{ + QUrl url = m_control->media().canonicalUrl(); + + if (url.isEmpty() == true) { + return NULL; + } + + S60MediaRecognizer *m_mediaRecognizer = new S60MediaRecognizer(this); + S60MediaRecognizer::MediaType mediaType = m_mediaRecognizer->mediaType(url); + + switch (mediaType) { + case S60MediaRecognizer::Video: + case S60MediaRecognizer::Url: + return VideoPlayerSession(); + case S60MediaRecognizer::Audio: + return AudioPlayerSession(); + default: + break; + } + + return NULL; +} + +S60MediaPlayerSession* S60MediaPlayerService::VideoPlayerSession() +{ + if (!m_videoPlayerSession) { + m_videoPlayerSession = new S60VideoPlayerSession(this); + + connect(m_videoPlayerSession, SIGNAL(positionChanged(qint64)), + m_control, SIGNAL(positionChanged(qint64))); + connect(m_videoPlayerSession, SIGNAL(durationChanged(qint64)), + m_control, SIGNAL(durationChanged(qint64))); + connect(m_videoPlayerSession, SIGNAL(stateChanged(QMediaPlayer::State)), + m_control, SIGNAL(stateChanged(QMediaPlayer::State))); + connect(m_videoPlayerSession, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), + m_control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); + connect(m_videoPlayerSession,SIGNAL(bufferStatusChanged(int)), + m_control, SIGNAL(bufferStatusChanged(int))); + connect(m_videoPlayerSession, SIGNAL(videoAvailableChanged(bool)), + m_control, SIGNAL(videoAvailableChanged(bool))); + connect(m_videoPlayerSession, SIGNAL(audioAvailableChanged(bool)), + m_control, SIGNAL(audioAvailableChanged(bool))); + connect(m_videoPlayerSession, SIGNAL(seekableChanged(bool)), + m_control, SIGNAL(seekableChanged(bool))); + connect(m_videoPlayerSession, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)), + m_control, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&))); + connect(m_videoPlayerSession, SIGNAL(error(int, const QString &)), + m_control, SIGNAL(error(int, const QString &))); + connect(m_videoPlayerSession, SIGNAL(metaDataChanged()), + m_metaData, SIGNAL(metaDataChanged())); + connect(m_videoPlayerSession, SIGNAL(activeEndpointChanged(const QString&)), + m_audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&))); + } + + m_videoPlayerSession->setVolume(m_control->mediaControlSettings().volume()); + m_videoPlayerSession->setMuted(m_control->mediaControlSettings().isMuted()); + m_videoPlayerSession->setAudioEndpoint(m_control->mediaControlSettings().audioEndpoint()); + return m_videoPlayerSession; +} + +S60MediaPlayerSession* S60MediaPlayerService::AudioPlayerSession() +{ + if (!m_audioPlayerSession) { + m_audioPlayerSession = new S60AudioPlayerSession(this); + + connect(m_audioPlayerSession, SIGNAL(positionChanged(qint64)), + m_control, SIGNAL(positionChanged(qint64))); + connect(m_audioPlayerSession, SIGNAL(durationChanged(qint64)), + m_control, SIGNAL(durationChanged(qint64))); + connect(m_audioPlayerSession, SIGNAL(stateChanged(QMediaPlayer::State)), + m_control, SIGNAL(stateChanged(QMediaPlayer::State))); + connect(m_audioPlayerSession, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), + m_control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus))); + connect(m_audioPlayerSession,SIGNAL(bufferStatusChanged(int)), + m_control, SIGNAL(bufferStatusChanged(int))); + connect(m_audioPlayerSession, SIGNAL(videoAvailableChanged(bool)), + m_control, SIGNAL(videoAvailableChanged(bool))); + connect(m_audioPlayerSession, SIGNAL(audioAvailableChanged(bool)), + m_control, SIGNAL(audioAvailableChanged(bool))); + connect(m_audioPlayerSession, SIGNAL(seekableChanged(bool)), + m_control, SIGNAL(seekableChanged(bool))); + connect(m_audioPlayerSession, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)), + m_control, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&))); + connect(m_audioPlayerSession, SIGNAL(error(int, const QString &)), + m_control, SIGNAL(error(int, const QString &))); + connect(m_audioPlayerSession, SIGNAL(metaDataChanged()), + m_metaData, SIGNAL(metaDataChanged())); + connect(m_audioPlayerSession, SIGNAL(activeEndpointChanged(const QString&)), + m_audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&))); + } + + m_audioPlayerSession->setVolume(m_control->mediaControlSettings().volume()); + m_audioPlayerSession->setMuted(m_control->mediaControlSettings().isMuted()); + m_audioPlayerSession->setAudioEndpoint(m_control->mediaControlSettings().audioEndpoint()); + return m_audioPlayerSession; +} + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h new file mode 100644 index 0000000..6c8155d --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOPLAYERSERVICE_H +#define S60VIDEOPLAYERSERVICE_H + +#include <QtCore/qobject.h> + +#include <qmediaservice.h> +#include <qvideooutputcontrol.h> + +#include "s60videooutputcontrol.h" +#include "ms60mediaplayerresolver.h" + +#include "s60mediaplayeraudioendpointselector.h" + +QT_BEGIN_NAMESPACE + +class QMediaMetaData; +class QMediaPlayerControl; +class QMediaPlaylist; + + +class S60VideoPlayerSession; +class S60AudioPlayerSession; +class S60MediaPlayerControl; +class S60MediaMetaDataProvider; +class S60VideoWidgetControl; +class S60MediaRecognizer; +class S60VideoRenderer; +class S60VideoOverlay; + +class QMediaPlaylistNavigator; + +class S60MediaPlayerService : public QMediaService, public MS60MediaPlayerResolver +{ + Q_OBJECT + +public: + S60MediaPlayerService(QObject *parent = 0); + ~S60MediaPlayerService(); + + QMediaControl *control(const char *name) const; + +private slots: + void videoOutputChanged(QVideoOutputControl::Output output); + +protected: // From MS60MediaPlayerResolver + S60MediaPlayerSession* PlayerSession(); + S60MediaPlayerSession* VideoPlayerSession(); + S60MediaPlayerSession* AudioPlayerSession(); + +private: + S60MediaPlayerControl *m_control; + mutable S60VideoOutputControl *m_videoOutput; + S60VideoPlayerSession *m_videoPlayerSession; + S60AudioPlayerSession *m_audioPlayerSession; + mutable S60MediaMetaDataProvider *m_metaData; + mutable S60VideoWidgetControl *m_videoWidget; + mutable S60VideoOverlay *m_videoWindow; + mutable S60VideoRenderer *m_videoRenderer; + S60MediaPlayerAudioEndpointSelector *m_audioEndpointSelector; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp new file mode 100644 index 0000000..693c103 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp @@ -0,0 +1,496 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60mediaplayersession.h" + +#include <QtCore/qdebug.h> +#include <QtCore/qdir.h> +#include <QtCore/qvariant.h> +#include <QtCore/qtimer.h> +#include <mmf/common/mmferrors.h> +#include <qmediatimerange.h> + +QT_BEGIN_NAMESPACE + +S60MediaPlayerSession::S60MediaPlayerSession(QObject *parent) + : QObject(parent) + , m_playbackRate(0) + , m_muted(false) + , m_volume(0) + , m_state(QMediaPlayer::StoppedState) + , m_mediaStatus(QMediaPlayer::UnknownMediaStatus) + , m_progressTimer(new QTimer(this)) + , m_stalledTimer(new QTimer(this)) + , m_error(KErrNone) + , m_play_requested(false) + , m_stream(false) +{ + connect(m_progressTimer, SIGNAL(timeout()), this, SLOT(tick())); + connect(m_stalledTimer, SIGNAL(timeout()), this, SLOT(stalled())); +} + +S60MediaPlayerSession::~S60MediaPlayerSession() +{ +} + +int S60MediaPlayerSession::volume() const +{ + return m_volume; +} + +void S60MediaPlayerSession::setVolume(int volume) +{ + if (m_volume == volume) + return; + + m_volume = volume; + // Dont set symbian players volume until media loaded. + // Leaves with KerrNotReady although documentation says otherwise. + if (!m_muted && + ( mediaStatus() == QMediaPlayer::LoadedMedia + || mediaStatus() == QMediaPlayer::StalledMedia + || mediaStatus() == QMediaPlayer::BufferingMedia + || mediaStatus() == QMediaPlayer::BufferedMedia + || mediaStatus() == QMediaPlayer::EndOfMedia)) { + TRAPD(err, doSetVolumeL(m_volume)); + setError(err); + } +} + +bool S60MediaPlayerSession::isMuted() const +{ + return m_muted; +} + +bool S60MediaPlayerSession::isSeekable() const +{ + return (m_stream)?false:true; +} + +void S60MediaPlayerSession::setMediaStatus(QMediaPlayer::MediaStatus status) +{ + if (m_mediaStatus == status) + return; + + m_mediaStatus = status; + + emit mediaStatusChanged(m_mediaStatus); + + if (m_play_requested) + play(); +} + +void S60MediaPlayerSession::setState(QMediaPlayer::State state) +{ + if (m_state == state) + return; + + m_state = state; + emit stateChanged(m_state); +} + +QMediaPlayer::State S60MediaPlayerSession::state() const +{ + return m_state; +} + +QMediaPlayer::MediaStatus S60MediaPlayerSession::mediaStatus() const +{ + return m_mediaStatus; +} + +void S60MediaPlayerSession::load(QUrl url) +{ + setMediaStatus(QMediaPlayer::LoadingMedia); + startStalledTimer(); + m_stream = (url.scheme() == "file")?false:true; + TRAPD(err, + if(m_stream) + doLoadUrlL(QString2TPtrC(url.toString())); + else + doLoadL(QString2TPtrC(QDir::toNativeSeparators(url.toLocalFile())))); + setError(err); +} + +void S60MediaPlayerSession::play() +{ + if (state() == QMediaPlayer::PlayingState + || mediaStatus() == QMediaPlayer::UnknownMediaStatus + || mediaStatus() == QMediaPlayer::NoMedia + || mediaStatus() == QMediaPlayer::InvalidMedia) + return; + + if (mediaStatus() == QMediaPlayer::LoadingMedia) { + m_play_requested = true; + return; + } + + m_play_requested = false; + setState(QMediaPlayer::PlayingState); + startProgressTimer(); + doPlay(); +} + +void S60MediaPlayerSession::pause() +{ + if (mediaStatus() == QMediaPlayer::NoMedia || + mediaStatus() == QMediaPlayer::InvalidMedia) + return; + + setState(QMediaPlayer::PausedState); + stopProgressTimer(); + TRAP_IGNORE(doPauseL()); +} + +void S60MediaPlayerSession::stop() +{ + m_play_requested = false; + setState(QMediaPlayer::StoppedState); + if (mediaStatus() == QMediaPlayer::BufferingMedia || + mediaStatus() == QMediaPlayer::BufferedMedia) + setMediaStatus(QMediaPlayer::LoadedMedia); + if (mediaStatus() == QMediaPlayer::LoadingMedia) + setMediaStatus(QMediaPlayer::UnknownMediaStatus); + stopProgressTimer(); + stopStalledTimer(); + doStop(); + emit positionChanged(0); +} +void S60MediaPlayerSession::reset() +{ + m_play_requested = false; + setError(KErrNone, QString(), true); + stopProgressTimer(); + stopStalledTimer(); + doStop(); + setState(QMediaPlayer::StoppedState); + setMediaStatus(QMediaPlayer::UnknownMediaStatus); +} + +void S60MediaPlayerSession::setVideoRenderer(QObject *renderer) +{ + Q_UNUSED(renderer); +} + +int S60MediaPlayerSession::bufferStatus() +{ + if( mediaStatus() == QMediaPlayer::LoadingMedia + || mediaStatus() == QMediaPlayer::UnknownMediaStatus + || mediaStatus() == QMediaPlayer::NoMedia + || mediaStatus() == QMediaPlayer::InvalidMedia) + return 0; + + int progress = 0; + TRAPD(err, progress = doGetBufferStatusL()); + + // If buffer status query not supported by codec return 100 + // do not set error + if(err == KErrNotSupported) + return 100; + + setError(err); + return progress; +} + +bool S60MediaPlayerSession::isMetadataAvailable() const +{ + return !m_metaDataMap.isEmpty(); +} + +QVariant S60MediaPlayerSession::metaData(const QString &key) const +{ + return m_metaDataMap.value(key); +} + +QMap<QString, QVariant> S60MediaPlayerSession::availableMetaData() const +{ + return m_metaDataMap; +} + +void S60MediaPlayerSession::setMuted(bool muted) +{ + m_muted = muted; + + if( m_mediaStatus == QMediaPlayer::LoadedMedia + || m_mediaStatus == QMediaPlayer::StalledMedia + || m_mediaStatus == QMediaPlayer::BufferingMedia + || m_mediaStatus == QMediaPlayer::BufferedMedia + || m_mediaStatus == QMediaPlayer::EndOfMedia) { + TRAPD(err, doSetVolumeL((m_muted)?0:m_volume)); + setError(err); + } +} + +qint64 S60MediaPlayerSession::duration() const +{ + if( mediaStatus() == QMediaPlayer::LoadingMedia + || mediaStatus() == QMediaPlayer::UnknownMediaStatus + || mediaStatus() == QMediaPlayer::NoMedia + || mediaStatus() == QMediaPlayer::InvalidMedia) + return -1; + + qint64 pos = 0; + TRAP_IGNORE(pos = doGetDurationL()); + return pos; +} + +qint64 S60MediaPlayerSession::position() const +{ + if( mediaStatus() == QMediaPlayer::LoadingMedia + || mediaStatus() == QMediaPlayer::UnknownMediaStatus + || mediaStatus() == QMediaPlayer::NoMedia + || mediaStatus() == QMediaPlayer::InvalidMedia) + return 0; + + qint64 pos = 0; + TRAP_IGNORE(pos = doGetPositionL()); + return pos; +} + +void S60MediaPlayerSession::setPosition(qint64 pos) +{ + if (position() == pos) + return; + + if (state() == QMediaPlayer::PlayingState) + pause(); + + TRAPD(err, doSetPositionL(pos * 1000)); + setError(err); + + if (state() == QMediaPlayer::PausedState) + play(); + + emit positionChanged(position()); +} + +void S60MediaPlayerSession::setAudioEndpoint(const QString& audioEndpoint) +{ + doSetAudioEndpoint(audioEndpoint); +} + +void S60MediaPlayerSession::loaded() +{ + stopStalledTimer(); + if (m_error == KErrNone || m_error == KErrMMPartialPlayback) { + setMediaStatus(QMediaPlayer::LoadedMedia); + TRAPD(err, updateMetaDataEntriesL()); + setError(err); + setVolume(m_volume); + setMuted(m_muted); + emit durationChanged(duration()); + emit videoAvailableChanged(isVideoAvailable()); + emit audioAvailableChanged(isAudioAvailable()); + } +} + +void S60MediaPlayerSession::endOfMedia() +{ + setMediaStatus(QMediaPlayer::EndOfMedia); + setState(QMediaPlayer::StoppedState); + emit positionChanged(0); +} + +void S60MediaPlayerSession::buffering() +{ + startStalledTimer(); + setMediaStatus(QMediaPlayer::BufferingMedia); +} + +void S60MediaPlayerSession::buffered() +{ + stopStalledTimer(); + setMediaStatus(QMediaPlayer::BufferedMedia); +} +void S60MediaPlayerSession::stalled() +{ + setMediaStatus(QMediaPlayer::StalledMedia); +} + +QMap<QString, QVariant>& S60MediaPlayerSession::metaDataEntries() +{ + return m_metaDataMap; +} + +QMediaPlayer::Error S60MediaPlayerSession::fromSymbianErrorToMultimediaError(int error) +{ + switch(error) { + case KErrNoMemory: + case KErrNotFound: + case KErrBadHandle: + case KErrAbort: + case KErrNotSupported: + case KErrCorrupt: + case KErrGeneral: + case KErrArgument: + case KErrPathNotFound: + case KErrDied: + case KErrServerTerminated: + case KErrServerBusy: + case KErrCompletion: + case KErrBadPower: + return QMediaPlayer::ResourceError; + + case KErrMMPartialPlayback: + return QMediaPlayer::FormatError; + + case KErrMMAudioDevice: + case KErrMMVideoDevice: + case KErrMMDecoder: + case KErrUnknown: + return QMediaPlayer::ServiceMissingError; + + case KErrMMNotEnoughBandwidth: + case KErrMMSocketServiceNotFound: + case KErrMMNetworkRead: + case KErrMMNetworkWrite: + case KErrMMServerSocket: + case KErrMMServerNotSupported: + case KErrMMUDPReceive: + case KErrMMInvalidProtocol: + case KErrMMInvalidURL: + case KErrMMMulticast: + case KErrMMProxyServer: + case KErrMMProxyServerNotSupported: + case KErrMMProxyServerConnect: + return QMediaPlayer::NetworkError; + + case KErrNotReady: + case KErrInUse: + case KErrAccessDenied: + case KErrLocked: + case KErrMMDRMNotAuthorized: + case KErrPermissionDenied: + case KErrCancel: + case KErrAlreadyExists: + return QMediaPlayer::AccessDeniedError; + + case KErrNone: + default: + return QMediaPlayer::NoError; + } +} + +void S60MediaPlayerSession::setError(int error, const QString &errorString, bool forceReset) +{ + if( forceReset ) { + m_error = KErrNone; + emit this->error(QMediaPlayer::NoError, QString()); + return; + } + + // If error does not change and m_error is reseted without forceReset flag + if (error == m_error || + (m_error != KErrNone && error == KErrNone)) + return; + + m_error = error; + QMediaPlayer::Error mediaError = fromSymbianErrorToMultimediaError(m_error); + QString symbianError = QString(errorString); + + if (mediaError != QMediaPlayer::NoError) { + // TODO: fix to user friendly string at some point + // These error string are only dev usable + symbianError.append("Symbian:"); + symbianError.append(QString::number(m_error)); + } + + emit this->error(mediaError, symbianError); + + switch(mediaError){ + case QMediaPlayer::ResourceError: + case QMediaPlayer::NetworkError: + case QMediaPlayer::AccessDeniedError: + case QMediaPlayer::ServiceMissingError: + m_play_requested = false; + setMediaStatus(QMediaPlayer::InvalidMedia); + stop(); + break; + } +} + +void S60MediaPlayerSession::tick() +{ + emit positionChanged(position()); + + if (bufferStatus() < 100) + emit bufferStatusChanged(bufferStatus()); +} + +void S60MediaPlayerSession::startProgressTimer() +{ + m_progressTimer->start(500); +} + +void S60MediaPlayerSession::stopProgressTimer() +{ + m_progressTimer->stop(); +} + +void S60MediaPlayerSession::startStalledTimer() +{ + m_stalledTimer->start(30000); +} + +void S60MediaPlayerSession::stopStalledTimer() +{ + m_stalledTimer->stop(); +} +QString S60MediaPlayerSession::TDesC2QString(const TDesC& aDescriptor) +{ + return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length()); +} +TPtrC S60MediaPlayerSession::QString2TPtrC( const QString& string ) +{ + // Returned TPtrC is valid as long as the given parameter is valid and unmodified + return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length()); +} +QRect S60MediaPlayerSession::TRect2QRect(const TRect& tr) +{ + return QRect(tr.iTl.iX, tr.iTl.iY, tr.Width(), tr.Height()); +} +TRect S60MediaPlayerSession::QRect2TRect(const QRect& qr) +{ + return TRect(TPoint(qr.left(), qr.top()), TSize(qr.width(), qr.height())); +} + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h new file mode 100644 index 0000000..bb9eddd --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60MEDIAPLAYERSESSION_H +#define S60MEDIAPLAYERSESSION_H + +#include <QtCore/qobject.h> +#include <QtCore/qurl.h> +#include <QtCore/qpair.h> +#include <qmediaplayer.h> +#include <e32cmn.h> // for TDesC +#include <QRect> +#include "s60mediaplayerservice.h" + +QT_BEGIN_NAMESPACE + +class QMediaTimeRange; + +class QTimer; + +class S60MediaPlayerSession : public QObject +{ + Q_OBJECT + +public: + S60MediaPlayerSession(QObject *parent); + virtual ~S60MediaPlayerSession(); + + // for player control interface to use + QMediaPlayer::State state() const; + QMediaPlayer::MediaStatus mediaStatus() const; + qint64 duration() const; + qint64 position() const; + void setPosition(qint64 pos); + int volume() const; + void setVolume(int volume); + bool isMuted() const; + void setMuted(bool muted); + virtual bool isVideoAvailable() const = 0; + virtual bool isAudioAvailable() const = 0; + bool isSeekable() const; + void play(); + void pause(); + void stop(); + void reset(); + bool isMetadataAvailable() const; + QVariant metaData(const QString &key) const; + QMap<QString, QVariant> availableMetaData() const; + void load(QUrl url); + int bufferStatus(); + virtual void setVideoRenderer(QObject *renderer); + void setMediaStatus(QMediaPlayer::MediaStatus); + void setState(QMediaPlayer::State state); + void setAudioEndpoint(const QString& audioEndpoint); + +protected: + virtual void doLoadL(const TDesC &path) = 0; + virtual void doLoadUrlL(const TDesC &path) = 0; + virtual void doPlay() = 0; + virtual void doStop() = 0; + virtual void doPauseL() = 0; + virtual void doSetVolumeL(int volume) = 0; + virtual void doSetPositionL(qint64 microSeconds) = 0; + virtual qint64 doGetPositionL() const = 0; + virtual void updateMetaDataEntriesL() = 0; + virtual int doGetBufferStatusL() const = 0; + virtual qint64 doGetDurationL() const = 0; + virtual void doSetAudioEndpoint(const QString& audioEndpoint) = 0; + +public: + // From S60MediaPlayerAudioEndpointSelector + virtual QString activeEndpoint() const = 0; + virtual QString defaultEndpoint() const = 0; +public Q_SLOTS: + virtual void setActiveEndpoint(const QString& name) = 0; + +protected: + void setError(int error, const QString &errorString = QString(), bool forceReset = false); + void loaded(); + void buffering(); + void buffered(); + void endOfMedia(); + QMap<QString, QVariant>& metaDataEntries(); + QMediaPlayer::Error fromSymbianErrorToMultimediaError(int error); + void startProgressTimer(); + void stopProgressTimer(); + void startStalledTimer(); + void stopStalledTimer(); + QString TDesC2QString(const TDesC& aDescriptor); + TPtrC QString2TPtrC( const QString& string ); + QRect TRect2QRect(const TRect& tr); + TRect QRect2TRect(const QRect& qr); + + +protected slots: + void tick(); + void stalled(); + +signals: + void durationChanged(qint64 duration); + void positionChanged(qint64 position); + void stateChanged(QMediaPlayer::State state); + void mediaStatusChanged(QMediaPlayer::MediaStatus mediaStatus); + void videoAvailableChanged(bool videoAvailable); + void audioAvailableChanged(bool audioAvailable); + void bufferStatusChanged(int percentFilled); + void seekableChanged(bool); + void availablePlaybackRangesChanged(const QMediaTimeRange&); + void metaDataChanged(); + void error(int error, const QString &errorString); + void activeEndpointChanged(const QString &name); + +private: + qreal m_playbackRate; + QMap<QString, QVariant> m_metaDataMap; + bool m_muted; + int m_volume; + QMediaPlayer::State m_state; + QMediaPlayer::MediaStatus m_mediaStatus; + QTimer *m_progressTimer; + QTimer *m_stalledTimer; + int m_error; + bool m_play_requested; + bool m_stream; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp new file mode 100644 index 0000000..b563dd9 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "S60mediarecognizer.h" +#include <e32def.h> +#include <e32cmn.h> +#include <QtCore/qurl.h> +#include <QtCore/qdir.h> +#include <QtCore/qdebug.h> + +#include <apgcli.h> + +QT_BEGIN_NAMESPACE + +static const TInt KMimeTypePrefixLength = 6; // "audio/" or "video/" +_LIT(KMimeTypePrefixAudio, "audio/"); +_LIT(KMimeTypePrefixVideo, "video/"); + +S60MediaRecognizer::S60MediaRecognizer(QObject *parent) : QObject(parent) +{ +} + +S60MediaRecognizer::~S60MediaRecognizer() +{ + m_file.Close(); + m_fileServer.Close(); + m_recognizer.Close(); +} + +S60MediaRecognizer::MediaType S60MediaRecognizer::mediaType(const QUrl &url) +{ + bool isStream = (url.scheme() == "file")?false:true; + + if (isStream) + return Url; + else + return identifyMediaType(url.toLocalFile()); +} + +S60MediaRecognizer::MediaType S60MediaRecognizer::identifyMediaType(const QString& fileName) +{ + S60MediaRecognizer::MediaType result = NotSupported; + bool recognizerOpened = false; + + TInt err = m_recognizer.Connect(); + if (err == KErrNone) { + recognizerOpened = true; + } + + err = m_fileServer.Connect(); + if (err == KErrNone) { + recognizerOpened = true; + } + + // This is needed for sharing file handles for the recognizer + err = m_fileServer.ShareProtected(); + if (err == KErrNone) { + recognizerOpened = true; + } + + if (recognizerOpened) { + m_file.Close(); + err = m_file.Open(m_fileServer, QString2TPtrC(QDir::toNativeSeparators(fileName)), EFileRead | + EFileShareReadersOnly); + + if (err == KErrNone) { + TDataRecognitionResult recognizerResult; + err = m_recognizer.RecognizeData(m_file, recognizerResult); + if (err == KErrNone) { + const TPtrC mimeType = recognizerResult.iDataType.Des(); + + if (mimeType.Left(KMimeTypePrefixLength).Compare(KMimeTypePrefixAudio) == 0) { + result = Audio; + } else if (mimeType.Left(KMimeTypePrefixLength).Compare(KMimeTypePrefixVideo) == 0) { + result = Video; + } + } + } + } + return result; +} + +TPtrC S60MediaRecognizer::QString2TPtrC( const QString& string ) +{ + // Returned TPtrC is valid as long as the given parameter is valid and unmodified + return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length()); +} + +QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.h b/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.h new file mode 100644 index 0000000..320c34c --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60MEDIARECOGNIZER_H_ +#define S60MEDIARECOGNIZER_H_ + +#include <QtCore/qobject.h> + +#include <apgcli.h> +#include <f32file.h> + +QT_BEGIN_NAMESPACE + +class QUrl; + +class S60MediaRecognizer : public QObject +{ + Q_OBJECT + +public: + enum MediaType { + Audio, + Video, + Url, + NotSupported = -1 + }; + + S60MediaRecognizer(QObject *parent = 0); + ~S60MediaRecognizer(); + + S60MediaRecognizer::MediaType mediaType(const QUrl &url); + S60MediaRecognizer::MediaType identifyMediaType(const QString& fileName); + +protected: + TPtrC QString2TPtrC( const QString& string ); + +private: + RApaLsSession m_recognizer; + RFile m_file; + RFs m_fileServer; +}; + +QT_END_NAMESPACE + +#endif /* S60MEDIARECOGNIZER_H_ */ diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.cpp new file mode 100644 index 0000000..489b2e3 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.cpp @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtMultimedia/qvideosurfaceformat.h> +#include "s60videooverlay.h" +#include "s60videosurface.h" + +QT_BEGIN_NAMESPACE + +S60VideoOverlay::S60VideoOverlay(QObject *parent) + : QVideoWindowControl(parent) + , m_surface(new S60VideoSurface) + , m_aspectRatioMode(Qt::KeepAspectRatio) + , m_fullScreen(false) +{ + connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), + this, SLOT(surfaceFormatChanged())); +} + +S60VideoOverlay::~S60VideoOverlay() +{ + delete m_surface; +} + +WId S60VideoOverlay::winId() const +{ + return m_surface->winId(); +} + +void S60VideoOverlay::setWinId(WId id) +{ + m_surface->setWinId(id); +} + +QRect S60VideoOverlay::displayRect() const +{ + return m_displayRect; +} + +void S60VideoOverlay::setDisplayRect(const QRect &rect) +{ + m_displayRect = rect; + + setScaledDisplayRect(); +} + +Qt::AspectRatioMode S60VideoOverlay::aspectRatioMode() const +{ + return m_aspectRatioMode; +} + +void S60VideoOverlay::setAspectRatioMode(Qt::AspectRatioMode ratio) +{ + m_aspectRatioMode = ratio; + + setScaledDisplayRect(); +} + +QSize S60VideoOverlay::customAspectRatio() const +{ + return m_aspectRatio; +} + +void S60VideoOverlay::setCustomAspectRatio(const QSize &customRatio) +{ + m_aspectRatio = customRatio; + + setScaledDisplayRect(); +} + +void S60VideoOverlay::repaint() +{ +} + +int S60VideoOverlay::brightness() const +{ + return m_surface->brightness(); +} + +void S60VideoOverlay::setBrightness(int brightness) +{ + m_surface->setBrightness(brightness); + + emit brightnessChanged(m_surface->brightness()); +} + +int S60VideoOverlay::contrast() const +{ + return m_surface->contrast(); +} + +void S60VideoOverlay::setContrast(int contrast) +{ + m_surface->setContrast(contrast); + + emit contrastChanged(m_surface->contrast()); +} + +int S60VideoOverlay::hue() const +{ + return m_surface->hue(); +} + +void S60VideoOverlay::setHue(int hue) +{ + m_surface->setHue(hue); + + emit hueChanged(m_surface->hue()); +} + +int S60VideoOverlay::saturation() const +{ + return m_surface->saturation(); +} + +void S60VideoOverlay::setSaturation(int saturation) +{ + m_surface->setSaturation(saturation); + + emit saturationChanged(m_surface->saturation()); +} + +bool S60VideoOverlay::isFullScreen() const +{ + return m_fullScreen; +} + +void S60VideoOverlay::setFullScreen(bool fullScreen) +{ + emit fullScreenChanged(m_fullScreen = fullScreen); +} + +QSize S60VideoOverlay::nativeSize() const +{ + return m_surface->surfaceFormat().sizeHint(); +} + +QAbstractVideoSurface *S60VideoOverlay::surface() const +{ + return m_surface; +} + +void S60VideoOverlay::surfaceFormatChanged() +{ + setScaledDisplayRect(); + + emit nativeSizeChanged(); +} + +void S60VideoOverlay::setScaledDisplayRect() +{ + switch (m_aspectRatioMode) { + case Qt::KeepAspectRatio: + { + QSize size = m_surface->surfaceFormat().viewport().size(); + + size.scale(m_displayRect.size(), Qt::KeepAspectRatio); + + QRect rect(QPoint(0, 0), size); + rect.moveCenter(m_displayRect.center()); + + m_surface->setDisplayRect(rect); + } + break; + case Qt::IgnoreAspectRatio: + m_surface->setDisplayRect(m_displayRect); + break; + }; +} + +QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h new file mode 100644 index 0000000..d846f32 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOOVERLAY_H +#define S60VIDEOOVERLAY_H + +#include <QtCore/qobject.h> +#include <qvideowindowcontrol.h> + +QT_BEGIN_NAMESPACE + +class QAbstractVideoSurface; +class S60VideoSurface; + +class S60VideoOverlay : public QVideoWindowControl +{ + Q_OBJECT + +public: + S60VideoOverlay(QObject *parent = 0); + ~S60VideoOverlay(); + + WId winId() const; + void setWinId(WId id); + + QRect displayRect() const; + void setDisplayRect(const QRect &rect); + + bool isFullScreen() const; + void setFullScreen(bool fullScreen); + + QSize nativeSize() const; + + Qt::AspectRatioMode aspectRatioMode() const; + void setAspectRatioMode(Qt::AspectRatioMode mode); + + QSize customAspectRatio() const; + void setCustomAspectRatio(const QSize &customRatio); + + void repaint(); + + int brightness() const; + void setBrightness(int brightness); + + int contrast() const; + void setContrast(int contrast); + + int hue() const; + void setHue(int hue); + + int saturation() const; + void setSaturation(int saturation); + + QAbstractVideoSurface *surface() const; + +private slots: + void surfaceFormatChanged(); + +private: + void setScaledDisplayRect(); + + S60VideoSurface *m_surface; + Qt::AspectRatioMode m_aspectRatioMode; + QRect m_displayRect; + QSize m_aspectRatio; + bool m_fullScreen; +}; + +QT_END_NAMESPACE + +#endif // S60VIDEOOVERLAY_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp new file mode 100644 index 0000000..134d5a0 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp @@ -0,0 +1,486 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videoplayersession.h" +#include "s60videowidget.h" +#include "s60mediaplayerservice.h" +#include "s60videooverlay.h" + +#include <QtCore/qdebug.h> +#include <QtGui/qwidget.h> +#include <QtCore/qtimer.h> +#include <QApplication> + +#include <coecntrl.h> +#include <coemain.h> // For CCoeEnv +#include <w32std.h> +#include <mmf/common/mmfcontrollerframeworkbase.h> + +#include <AudioOutput.h> +#include <MAudioOutputObserver.h> + +QT_BEGIN_NAMESPACE + +S60VideoPlayerSession::S60VideoPlayerSession(QMediaService *service) + : S60MediaPlayerSession(service) + , m_player(0) + , m_rect(0, 0, 0, 0) + , m_output(QVideoOutputControl::NoOutput) + , m_windowId(0) + , m_dsaActive(false) + , m_dsaStopped(false) + , m_wsSession(CCoeEnv::Static()->WsSession()) + , m_screenDevice(*CCoeEnv::Static()->ScreenDevice()) + , m_window(0) + , m_service(*service) + , m_aspectRatioMode(Qt::KeepAspectRatio) + , m_originalSize(1, 1) + , m_audioOutput(0) + , m_audioEndpoint("Default") +{ + resetNativeHandles(); + QT_TRAP_THROWING(m_player = CVideoPlayerUtility::NewL( + *this, + 0, + EMdaPriorityPreferenceNone, + m_wsSession, + m_screenDevice, + *m_window, + m_rect, + m_rect)); + m_dsaActive = true; + m_player->RegisterForVideoLoadingNotification(*this); +} + +S60VideoPlayerSession::~S60VideoPlayerSession() +{ +#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) + if (m_audioOutput) + m_audioOutput->UnregisterObserver(*this); + delete m_audioOutput; +#endif + m_player->Close(); + delete m_player; +} + +void S60VideoPlayerSession::doLoadL(const TDesC &path) +{ + // m_audioOutput needs to be reinitialized after MapcInitComplete + if (m_audioOutput) + m_audioOutput->UnregisterObserver(*this); + delete m_audioOutput; + m_audioOutput = NULL; + + m_player->OpenFileL(path); +} + +void S60VideoPlayerSession::doLoadUrlL(const TDesC &path) +{ + // m_audioOutput needs to be reinitialized after MapcInitComplete + if (m_audioOutput) + m_audioOutput->UnregisterObserver(*this); + delete m_audioOutput; + m_audioOutput = NULL; + + m_player->OpenUrlL(path); +} + +int S60VideoPlayerSession::doGetBufferStatusL() const +{ + int progress = 0; + m_player->GetVideoLoadingProgressL(progress); + return progress; +} + +qint64 S60VideoPlayerSession::doGetDurationL() const +{ + return m_player->DurationL().Int64() / qint64(1000); +} + +void S60VideoPlayerSession::setVideoRenderer(QObject *videoOutput) +{ + Q_UNUSED(videoOutput) + QVideoOutputControl *videoControl = qobject_cast<QVideoOutputControl *>(m_service.control(QVideoOutputControl_iid)); + + //Render changes + if (m_output != videoControl->output()) { + + if (m_output == QVideoOutputControl::WidgetOutput) { + S60VideoWidgetControl *widgetControl = qobject_cast<S60VideoWidgetControl *>(m_service.control(QVideoWidgetControl_iid)); + disconnect(widgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay())); + disconnect(widgetControl, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess())); + disconnect(widgetControl, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess())); + disconnect(this, SIGNAL(stateChanged(QMediaPlayer::State)), widgetControl, SLOT(videoStateChanged(QMediaPlayer::State))); + } + + if (videoControl->output() == QVideoOutputControl::WidgetOutput) { + S60VideoWidgetControl *widgetControl = qobject_cast<S60VideoWidgetControl *>(m_service.control(QVideoWidgetControl_iid)); + connect(widgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay())); + connect(widgetControl, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess())); + connect(widgetControl, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess())); + connect(this, SIGNAL(stateChanged(QMediaPlayer::State)), widgetControl, SLOT(videoStateChanged(QMediaPlayer::State))); + } + + m_output = videoControl->output(); + resetVideoDisplay(); + } +} + +bool S60VideoPlayerSession::resetNativeHandles() +{ + QVideoOutputControl* videoControl = qobject_cast<QVideoOutputControl *>(m_service.control(QVideoOutputControl_iid)); + WId newId = 0; + TRect newRect = TRect(0,0,0,0); + Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio; + + if (videoControl->output() == QVideoOutputControl::WidgetOutput) { + S60VideoWidgetControl* widgetControl = qobject_cast<S60VideoWidgetControl *>(m_service.control(QVideoWidgetControl_iid)); + QWidget *videoWidget = widgetControl->videoWidget(); + newId = widgetControl->videoWidgetWId(); + newRect = QRect2TRect(QRect(videoWidget->mapToGlobal(videoWidget->pos()), videoWidget->size())); + aspectRatioMode = widgetControl->aspectRatioMode(); + } else if (videoControl->output() == QVideoOutputControl::WindowOutput) { + S60VideoOverlay* windowControl = qobject_cast<S60VideoOverlay *>(m_service.control(QVideoWindowControl_iid)); + newId = windowControl->winId(); + newRect = TRect( newId->DrawableWindow()->AbsPosition(), newId->DrawableWindow()->Size()); + } else { + if (QApplication::activeWindow()) + newId = QApplication::activeWindow()->effectiveWinId(); + + if (!newId && QApplication::allWidgets().count()) + newId = QApplication::allWidgets().at(0)->effectiveWinId(); + + Q_ASSERT(newId != 0); + } + + if (newRect == m_rect && newId == m_windowId && aspectRatioMode == m_aspectRatioMode) + return false; + + if (newId) { + m_rect = newRect; + m_windowId = newId; + m_window = m_windowId->DrawableWindow(); + m_aspectRatioMode = aspectRatioMode; + return true; + } + return false; +} + +bool S60VideoPlayerSession::isVideoAvailable() const +{ +#ifdef PRE_S60_50_PLATFORM + return true; // this is not support in pre 5th platforms +#else + if (m_player) + return m_player->VideoEnabledL(); + else + return false; +#endif +} + +bool S60VideoPlayerSession::isAudioAvailable() const +{ + if (m_player) + return m_player->AudioEnabledL(); + else + return false; +} + +void S60VideoPlayerSession::doPlay() +{ + m_player->Play(); +} + +void S60VideoPlayerSession::doPauseL() +{ + m_player->PauseL(); +} + +void S60VideoPlayerSession::doStop() +{ + m_player->Stop(); +} + +qint64 S60VideoPlayerSession::doGetPositionL() const +{ + return m_player->PositionL().Int64() / qint64(1000); +} + +void S60VideoPlayerSession::doSetPositionL(qint64 microSeconds) +{ + m_player->SetPositionL(TTimeIntervalMicroSeconds(microSeconds)); +} + +void S60VideoPlayerSession::doSetVolumeL(int volume) +{ + m_player->SetVolumeL((volume / 100.0)* m_player->MaxVolume()); +} + +QPair<qreal, qreal> S60VideoPlayerSession::scaleFactor() +{ + QSize scaled = m_originalSize; + if (m_aspectRatioMode == Qt::IgnoreAspectRatio) + scaled.scale(TRect2QRect(m_rect).size(), Qt::IgnoreAspectRatio); + else if(m_aspectRatioMode == Qt::KeepAspectRatio) + scaled.scale(TRect2QRect(m_rect).size(), Qt::KeepAspectRatio); + + qreal width = qreal(scaled.width()) / qreal(m_originalSize.width()) * qreal(100); + qreal height = qreal(scaled.height()) / qreal(m_originalSize.height()) * qreal(100); + + return QPair<qreal, qreal>(width, height); +} + +void S60VideoPlayerSession::startDirectScreenAccess() +{ + if(m_dsaActive) + return; + + TRAPD(err, m_player->StartDirectScreenAccessL()); + if(err == KErrNone) + m_dsaActive = true; + setError(err); +} + +bool S60VideoPlayerSession::stopDirectScreenAccess() +{ + if(!m_dsaActive) + return false; + + TRAPD(err, m_player->StopDirectScreenAccessL()); + if(err == KErrNone) + m_dsaActive = false; + + setError(err); + return true; +} + +void S60VideoPlayerSession::MvpuoOpenComplete(TInt aError) +{ + setError(aError); + m_player->Prepare(); +} + +void S60VideoPlayerSession::MvpuoPrepareComplete(TInt aError) +{ + setError(aError); + TRAPD(err, + m_player->SetDisplayWindowL(m_wsSession, + m_screenDevice, + *m_window, + m_rect, + m_rect); + TSize originalSize; + m_player->VideoFrameSizeL(originalSize); + m_originalSize = QSize(originalSize.iWidth, originalSize.iHeight); + m_player->SetScaleFactorL(scaleFactor().first, scaleFactor().second, true)); + + setError(err); + m_dsaActive = true; +#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) + TRAP(err, + m_audioOutput = CAudioOutput::NewL(*m_player); + m_audioOutput->RegisterObserverL(*this); + ); + setActiveEndpoint(m_audioEndpoint); + setError(err); +#endif + loaded(); +} + +void S60VideoPlayerSession::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) +{ + Q_UNUSED(aFrame); + Q_UNUSED(aError); +} + +void S60VideoPlayerSession::MvpuoPlayComplete(TInt aError) +{ + setError(aError); + endOfMedia(); +} + +void S60VideoPlayerSession::MvpuoEvent(const TMMFEvent &aEvent) +{ + Q_UNUSED(aEvent); +} + +void S60VideoPlayerSession::updateMetaDataEntriesL() +{ + metaDataEntries().clear(); + int numberOfMetaDataEntries = 0; + + numberOfMetaDataEntries = m_player->NumberOfMetaDataEntriesL(); + + for (int i = 0; i < numberOfMetaDataEntries; i++) { + CMMFMetaDataEntry *entry = NULL; + entry = m_player->MetaDataEntryL(i); + metaDataEntries().insert(TDesC2QString(entry->Name()), TDesC2QString(entry->Value())); + delete entry; + } + emit metaDataChanged(); +} + +void S60VideoPlayerSession::resetVideoDisplay() +{ + if (resetNativeHandles()) { + TRAPD(err, + m_player->SetDisplayWindowL(m_wsSession, + m_screenDevice, + *m_window, + m_rect, + m_rect)); + setError(err); + if( mediaStatus() == QMediaPlayer::LoadedMedia + || mediaStatus() == QMediaPlayer::StalledMedia + || mediaStatus() == QMediaPlayer::BufferingMedia + || mediaStatus() == QMediaPlayer::BufferedMedia + || mediaStatus() == QMediaPlayer::EndOfMedia) { + TRAPD(err, m_player->SetScaleFactorL(scaleFactor().first, scaleFactor().second, true)); + setError(err); + } + } +} + +void S60VideoPlayerSession::suspendDirectScreenAccess() +{ + m_dsaStopped = stopDirectScreenAccess(); +} + +void S60VideoPlayerSession::resumeDirectScreenAccess() +{ + if(!m_dsaStopped) + return; + + startDirectScreenAccess(); + m_dsaStopped = false; +} + +void S60VideoPlayerSession::MvloLoadingStarted() +{ + buffering(); +} + +void S60VideoPlayerSession::MvloLoadingComplete() +{ + buffered(); +} + +void S60VideoPlayerSession::doSetAudioEndpoint(const QString& audioEndpoint) +{ + m_audioEndpoint = audioEndpoint; +} + +QString S60VideoPlayerSession::activeEndpoint() const +{ + QString outputName = QString("Default"); +#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) + if (m_audioOutput) { + CAudioOutput::TAudioOutputPreference output = m_audioOutput->AudioOutput(); + outputName = qStringFromTAudioOutputPreference(output); + } +#endif + return outputName; +} + +QString S60VideoPlayerSession::defaultEndpoint() const +{ + QString outputName = QString("Default"); +#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) + if (m_audioOutput) { + CAudioOutput::TAudioOutputPreference output = m_audioOutput->DefaultAudioOutput(); + outputName = qStringFromTAudioOutputPreference(output); + } +#endif + return outputName; +} + +void S60VideoPlayerSession::setActiveEndpoint(const QString& name) +{ + CAudioOutput::TAudioOutputPreference output = CAudioOutput::ENoPreference; + + if (name == QString("Default")) + output = CAudioOutput::ENoPreference; + else if (name == QString("All")) + output = CAudioOutput::EAll; + else if (name == QString("None")) + output = CAudioOutput::ENoOutput; + else if (name == QString("Earphone")) + output = CAudioOutput::EPrivate; + else if (name == QString("Speaker")) + output = CAudioOutput::EPublic; +#if !defined(HAS_NO_AUDIOROUTING_IN_VIDEOPLAYER) + if (m_audioOutput) { + TRAPD(err, m_audioOutput->SetAudioOutputL(output)); + setError(err); + + if (m_audioEndpoint != name) { + m_audioEndpoint = name; + emit activeEndpointChanged(name); + } + } +#endif +} + +void S60VideoPlayerSession::DefaultAudioOutputChanged( CAudioOutput& aAudioOutput, + CAudioOutput::TAudioOutputPreference aNewDefault ) +{ + // Emit already implemented in setActiveEndpoint function + Q_UNUSED(aAudioOutput) + Q_UNUSED(aNewDefault) +} + +QString S60VideoPlayerSession::qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const +{ + if (output == CAudioOutput::ENoPreference) + return QString("Default"); + else if (output == CAudioOutput::EAll) + return QString("All"); + else if (output == CAudioOutput::ENoOutput) + return QString("None"); + else if (output == CAudioOutput::EPrivate) + return QString("Earphone"); + else if (output == CAudioOutput::EPublic) + return QString("Speaker"); + return QString("Default"); +} + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h new file mode 100644 index 0000000..52e311a --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOPLAYERSESSION_H +#define S60VIDEOPLAYERSESSION_H + +#include "s60mediaplayersession.h" +#include "s60mediaplayeraudioendpointselector.h" +#include <videoplayer.h> +#include <QtGui/qwidget.h> +#include <qvideowidget.h> + +#include <AudioOutput.h> +#include <MAudioOutputObserver.h> + +QT_BEGIN_NAMESPACE + +class QTimer; + +class S60VideoPlayerSession : public S60MediaPlayerSession, + public MVideoPlayerUtilityObserver, + public MVideoLoadingObserver, + public MAudioOutputObserver +{ + Q_OBJECT + +public: + S60VideoPlayerSession(QMediaService *service); + ~S60VideoPlayerSession(); + + //From S60MediaPlayerSession + bool isVideoAvailable() const; + bool isAudioAvailable() const; + void setVideoRenderer(QObject *renderer); + + //From MVideoLoadingObserver + void MvloLoadingStarted(); + void MvloLoadingComplete(); + + // From MAudioOutputObserver + void DefaultAudioOutputChanged(CAudioOutput& aAudioOutput, + CAudioOutput::TAudioOutputPreference aNewDefault); + +public: + // From S60MediaPlayerAudioEndpointSelector + QString activeEndpoint() const; + QString defaultEndpoint() const; +public Q_SLOTS: + void setActiveEndpoint(const QString& name); +Q_SIGNALS: + void activeEndpointChanged(const QString &name); + +protected: + //From S60MediaPlayerSession + void doLoadL(const TDesC &path); + void doLoadUrlL(const TDesC &path); + void doPlay(); + void doStop(); + void doPauseL(); + void doSetVolumeL(int volume); + qint64 doGetPositionL() const; + void doSetPositionL(qint64 microSeconds); + void updateMetaDataEntriesL(); + int doGetBufferStatusL() const; + qint64 doGetDurationL() const; + void doSetAudioEndpoint(const QString& audioEndpoint); + +private slots: + void resetVideoDisplay(); + void suspendDirectScreenAccess(); + void resumeDirectScreenAccess(); + +private: + bool resetNativeHandles(); + QPair<qreal, qreal> scaleFactor(); + void startDirectScreenAccess(); + bool stopDirectScreenAccess(); + QString qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const; + + + // From MVideoPlayerUtilityObserver + void MvpuoOpenComplete(TInt aError); + void MvpuoPrepareComplete(TInt aError); + void MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError); + void MvpuoPlayComplete(TInt aError); + void MvpuoEvent(const TMMFEvent &aEvent); + +private: + // Qwn + CVideoPlayerUtility *m_player; + TRect m_rect; + QVideoOutputControl::Output m_output; + WId m_windowId; + bool m_dsaActive; + bool m_dsaStopped; + + //Reference + RWsSession &m_wsSession; + CWsScreenDevice &m_screenDevice; + RWindowBase *m_window; + QMediaService &m_service; + Qt::AspectRatioMode m_aspectRatioMode; + QSize m_originalSize; + CAudioOutput *m_audioOutput; + QString m_audioEndpoint; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp new file mode 100644 index 0000000..269dd43 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videorenderer.h" + +#include <QtCore/qcoreevent.h> +#include <QtGui/qapplication.h> + +QT_BEGIN_NAMESPACE + +S60VideoRenderer::S60VideoRenderer(QObject *parent) + : QVideoRendererControl(parent) +{ +} + +S60VideoRenderer::~S60VideoRenderer() +{ +} + + +QAbstractVideoSurface *S60VideoRenderer::surface() const +{ + return m_surface; +} + +void S60VideoRenderer::setSurface(QAbstractVideoSurface *surface) +{ + m_surface = surface; +} + +QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h new file mode 100644 index 0000000..260dc8b --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEORENDERER_H +#define S60VIDEORENDERER_H + +#include <QtCore/qobject.h> +#include <qvideorenderercontrol.h> + +QT_BEGIN_NAMESPACE + +class S60VideoRenderer : public QVideoRendererControl +{ + Q_OBJECT + +public: + S60VideoRenderer(QObject *parent = 0); + virtual ~S60VideoRenderer(); + + QAbstractVideoSurface *surface() const; + void setSurface(QAbstractVideoSurface *surface); + +private: + + QAbstractVideoSurface *m_surface; +}; + +QT_END_NAMESPACE + +#endif // S60VIDEORENDERER_H diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp new file mode 100644 index 0000000..bfa7a13 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp @@ -0,0 +1,478 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//#include <QtGui/qx11info_x11.h> + +#include "s60videosurface.h" + +QT_BEGIN_NAMESPACE + +/*struct XvFormatRgb +{ + QVideoFrame::PixelFormat pixelFormat; + int bits_per_pixel; + int format; + int num_planes; + + int depth; + unsigned int red_mask; + unsigned int green_mask; + unsigned int blue_mask; + +};*/ +/* +bool operator ==(const XvImageFormatValues &format, const XvFormatRgb &rgb) +{ + return format.type == XvRGB + && format.bits_per_pixel == rgb.bits_per_pixel + && format.format == rgb.format + && format.num_planes == rgb.num_planes + && format.depth == rgb.depth + && format.red_mask == rgb.red_mask + && format.blue_mask == rgb.blue_mask; +} + +static const XvFormatRgb qt_xvRgbLookup[] = +{ + { QVideoFrame::Format_ARGB32, 32, XvPacked, 1, 32, 0x00FF0000, 0x0000FF00, 0x000000FF }, + { QVideoFrame::Format_RGB32 , 32, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, + { QVideoFrame::Format_RGB24 , 24, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, + { QVideoFrame::Format_RGB565, 16, XvPacked, 1, 16, 0x0000F800, 0x000007E0, 0x0000001F }, + { QVideoFrame::Format_BGRA32, 32, XvPacked, 1, 32, 0xFF000000, 0x00FF0000, 0x0000FF00 }, + { QVideoFrame::Format_BGR32 , 32, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, + { QVideoFrame::Format_BGR24 , 24, XvPacked, 1, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, + { QVideoFrame::Format_BGR565, 16, XvPacked, 1, 16, 0x0000F800, 0x000007E0, 0x0000001F } +}; + +struct XvFormatYuv +{ + QVideoFrame::PixelFormat pixelFormat; + int bits_per_pixel; + int format; + int num_planes; + + unsigned int y_sample_bits; + unsigned int u_sample_bits; + unsigned int v_sample_bits; + unsigned int horz_y_period; + unsigned int horz_u_period; + unsigned int horz_v_period; + unsigned int vert_y_period; + unsigned int vert_u_period; + unsigned int vert_v_period; + char component_order[32]; +}; + +bool operator ==(const XvImageFormatValues &format, const XvFormatYuv &yuv) +{ + return format.type == XvYUV + && format.bits_per_pixel == yuv.bits_per_pixel + && format.format == yuv.format + && format.num_planes == yuv.num_planes + && format.y_sample_bits == yuv.y_sample_bits + && format.u_sample_bits == yuv.u_sample_bits + && format.v_sample_bits == yuv.v_sample_bits + && format.horz_y_period == yuv.horz_y_period + && format.horz_u_period == yuv.horz_u_period + && format.horz_v_period == yuv.horz_v_period + && format.horz_y_period == yuv.vert_y_period + && format.vert_u_period == yuv.vert_u_period + && format.vert_v_period == yuv.vert_v_period + && qstrncmp(format.component_order, yuv.component_order, 32) == 0; +} + +static const XvFormatYuv qt_xvYuvLookup[] = +{ + { QVideoFrame::Format_YUV444 , 24, XvPacked, 1, 8, 8, 8, 1, 1, 1, 1, 1, 1, "YUV" }, + { QVideoFrame::Format_YUV420P, 12, XvPlanar, 3, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YUV" }, + { QVideoFrame::Format_YV12 , 12, XvPlanar, 3, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YVU" }, + { QVideoFrame::Format_UYVY , 16, XvPacked, 1, 8, 8, 8, 1, 2, 2, 1, 1, 1, "UYVY" }, + { QVideoFrame::Format_YUYV , 16, XvPacked, 1, 8, 8, 8, 1, 2, 2, 1, 1, 1, "YUYV" }, + { QVideoFrame::Format_NV12 , 12, XvPlanar, 2, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YUV" }, + { QVideoFrame::Format_NV12 , 12, XvPlanar, 2, 8, 8, 8, 1, 2, 2, 1, 2, 2, "YVU" }, + { QVideoFrame::Format_Y8 , 8 , XvPlanar, 1, 8, 0, 0, 1, 0, 0, 1, 0, 0, "Y" } +}; +*/ + +S60VideoSurface::S60VideoSurface(QObject *parent) + : QAbstractVideoSurface(parent) + , m_winId(0) + //, m_portId(0) + //, m_gc(0) + //, m_image(0) +{ +} + +S60VideoSurface::~S60VideoSurface() +{ + /*if (m_gc) + XFreeGC(QX11Info::display(), m_gc); + + if (m_portId != 0) + XvUngrabPort(QX11Info::display(), m_portId, 0); + */ +} + +WId S60VideoSurface::winId() const +{ + return m_winId; +} + +void S60VideoSurface::setWinId(WId id) +{ + /*if (id == m_winId) + return; + + if (m_image) + XFree(m_image); + + if (m_gc) { + XFreeGC(QX11Info::display(), m_gc); + m_gc = 0; + } + + if (m_portId != 0) + XvUngrabPort(QX11Info::display(), m_portId, 0); + + m_supportedPixelFormats.clear(); + m_formatIds.clear(); + + m_winId = id; + + if (m_winId && findPort()) { + querySupportedFormats(); + + m_gc = XCreateGC(QX11Info::display(), m_winId, 0, 0); + + if (m_image) { + m_image = 0; + + if (!start(surfaceFormat())) + QAbstractVideoSurface::stop(); + } + } else if (m_image) { + m_image = 0; + + QAbstractVideoSurface::stop(); + }*/ +} + +QRect S60VideoSurface::displayRect() const +{ + return m_displayRect; +} + +void S60VideoSurface::setDisplayRect(const QRect &rect) +{ + m_displayRect = rect; +} + +int S60VideoSurface::brightness() const +{ + //return getAttribute("XV_BRIGHTNESS", m_brightnessRange.first, m_brightnessRange.second); +} + +void S60VideoSurface::setBrightness(int brightness) +{ + //setAttribute("XV_BRIGHTNESS", brightness, m_brightnessRange.first, m_brightnessRange.second); +} + +int S60VideoSurface::contrast() const +{ + //return getAttribute("XV_CONTRAST", m_contrastRange.first, m_contrastRange.second); +} + +void S60VideoSurface::setContrast(int contrast) +{ + //setAttribute("XV_CONTRAST", contrast, m_contrastRange.first, m_contrastRange.second); +} + +int S60VideoSurface::hue() const +{ + //return getAttribute("XV_HUE", m_hueRange.first, m_hueRange.second); +} + +void S60VideoSurface::setHue(int hue) +{ + // setAttribute("XV_HUE", hue, m_hueRange.first, m_hueRange.second); +} + +int S60VideoSurface::saturation() const +{ + //return getAttribute("XV_SATURATION", m_saturationRange.first, m_saturationRange.second); +} + +void S60VideoSurface::setSaturation(int saturation) +{ + //setAttribute("XV_SATURATION", saturation, m_saturationRange.first, m_saturationRange.second); +} + +int S60VideoSurface::getAttribute(const char *attribute, int minimum, int maximum) const +{ + /*if (m_portId != 0) { + Display *display = QX11Info::display(); + + Atom atom = XInternAtom(display, attribute, True); + + int value = 0; + + XvGetPortAttribute(display, m_portId, atom, &value); + + return redistribute(value, minimum, maximum, -100, 100); + } else { + return 0; + }*/ +} + +void S60VideoSurface::setAttribute(const char *attribute, int value, int minimum, int maximum) +{ + /* if (m_portId != 0) { + Display *display = QX11Info::display(); + + Atom atom = XInternAtom(display, attribute, True); + + XvSetPortAttribute( + display, m_portId, atom, redistribute(value, -100, 100, minimum, maximum)); + }*/ +} + +int S60VideoSurface::redistribute( + int value, int fromLower, int fromUpper, int toLower, int toUpper) +{ + /*return fromUpper != fromLower + ? ((value - fromLower) * (toUpper - toLower) / (fromUpper - fromLower)) + toLower + : 0;*/ +} + +QList<QVideoFrame::PixelFormat> S60VideoSurface::supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const +{ + /*return handleType == QAbstractVideoBuffer::NoHandle + ? m_supportedPixelFormats + : QList<QVideoFrame::PixelFormat>();*/ +} + +bool S60VideoSurface::start(const QVideoSurfaceFormat &format) +{ + /*if (m_image) + XFree(m_image); + + int xvFormatId = 0; + for (int i = 0; i < m_supportedPixelFormats.count(); ++i) { + if (m_supportedPixelFormats.at(i) == format.pixelFormat()) { + xvFormatId = m_formatIds.at(i); + break; + } + } + + if (xvFormatId == 0) { + setError(UnsupportedFormatError); + } else { + XvImage *image = XvCreateImage( + QX11Info::display(), + m_portId, + xvFormatId, + 0, + format.frameWidth(), + format.frameHeight()); + + if (!image) { + setError(ResourceError); + } else { + m_viewport = format.viewport(); + m_image = image; + + return QAbstractVideoSurface::start(format); + } + } + + if (m_image) { + m_image = 0; + + QAbstractVideoSurface::stop(); + } +*/ + return false; +} + +void S60VideoSurface::stop() +{/* + if (m_image) { + XFree(m_image); + m_image = 0; + + QAbstractVideoSurface::stop(); + }*/ +} + +bool S60VideoSurface::present(const QVideoFrame &frame) +{/* + if (!m_image) { + setError(StoppedError); + return false; + } else if (m_image->width != frame.width() || m_image->height != frame.height()) { + setError(IncorrectFormatError); + return false; + } else { + QVideoFrame frameCopy(frame); + + if (!frameCopy.map(QAbstractVideoBuffer::ReadOnly)) { + setError(IncorrectFormatError); + return false; + } else { + bool presented = false; + + if (m_image->data_size > frame.numBytes()) { + qWarning("Insufficient frame buffer size"); + setError(IncorrectFormatError); + } else if (m_image->num_planes > 0 && m_image->pitches[0] != frame.bytesPerLine()) { + qWarning("Incompatible frame pitches"); + setError(IncorrectFormatError); + } else { + m_image->data = reinterpret_cast<char *>(frameCopy.bits()); + + XvPutImage( + QX11Info::display(), + m_portId, + m_winId, + m_gc, + m_image, + m_viewport.x(), + m_viewport.y(), + m_viewport.width(), + m_viewport.height(), + m_displayRect.x(), + m_displayRect.y(), + m_displayRect.width(), + m_displayRect.height()); + + m_image->data = 0; + + presented = true; + } + + frameCopy.unmap(); + + return presented; + } + }*/ +} + +bool S60VideoSurface::findPort() +{/* + unsigned int count = 0; + XvAdaptorInfo *adaptors = 0; + bool portFound = false; + + if (XvQueryAdaptors(QX11Info::display(), m_winId, &count, &adaptors) == Success) { + for (unsigned int i = 0; i < count && !portFound; ++i) { + if (adaptors[i].type & XvImageMask) { + m_portId = adaptors[i].base_id; + + for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId) + portFound = XvGrabPort(QX11Info::display(), m_portId, 0) == Success; + } + } + XvFreeAdaptorInfo(adaptors); + } + + return portFound;*/ +} + +void S60VideoSurface::querySupportedFormats() +{/* + int count = 0; + if (XvImageFormatValues *imageFormats = XvListImageFormats( + QX11Info::display(), m_portId, &count)) { + const int rgbCount = sizeof(qt_xvRgbLookup) / sizeof(XvFormatRgb); + const int yuvCount = sizeof(qt_xvYuvLookup) / sizeof(XvFormatYuv); + + for (int i = 0; i < count; ++i) { + switch (imageFormats[i].type) { + case XvRGB: + for (int j = 0; j < rgbCount; ++j) { + if (imageFormats[i] == qt_xvRgbLookup[j]) { + m_supportedPixelFormats.append(qt_xvRgbLookup[j].pixelFormat); + m_formatIds.append(imageFormats[i].id); + break; + } + } + break; + case XvYUV: + for (int j = 0; j < yuvCount; ++j) { + if (imageFormats[i] == qt_xvYuvLookup[j]) { + m_supportedPixelFormats.append(qt_xvYuvLookup[j].pixelFormat); + m_formatIds.append(imageFormats[i].id); + break; + } + } + break; + } + } + XFree(imageFormats); + } + + m_brightnessRange = qMakePair(0, 0); + m_contrastRange = qMakePair(0, 0); + m_hueRange = qMakePair(0, 0); + m_saturationRange = qMakePair(0, 0); + + if (XvAttribute *attributes = XvQueryPortAttributes(QX11Info::display(), m_portId, &count)) { + for (int i = 0; i < count; ++i) { + if (qstrcmp(attributes[i].name, "XV_BRIGHTNESS") == 0) + m_brightnessRange = qMakePair(attributes[i].min_value, attributes[i].max_value); + else if (qstrcmp(attributes[i].name, "XV_CONTRAST") == 0) + m_contrastRange = qMakePair(attributes[i].min_value, attributes[i].max_value); + else if (qstrcmp(attributes[i].name, "XV_HUE") == 0) + m_hueRange = qMakePair(attributes[i].min_value, attributes[i].max_value); + else if (qstrcmp(attributes[i].name, "XV_SATURATION") == 0) + m_saturationRange = qMakePair(attributes[i].min_value, attributes[i].max_value); + } + + XFree(attributes); + }*/ +} + +bool S60VideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const +{ +} + +QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h new file mode 100644 index 0000000..836e52f --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOSURFACE_H +#define S60VIDEOSURFACE_H + +#include <QtGui/qwidget.h> +#include <QtMultimedia/qabstractvideosurface.h> + +QT_BEGIN_NAMESPACE + +class QVideoSurfaceFormat; + +class S60VideoSurface : public QAbstractVideoSurface +{ + Q_OBJECT +public: + S60VideoSurface(QObject *parent = 0); + ~S60VideoSurface(); + + WId winId() const; + void setWinId(WId id); + + QRect displayRect() const; + void setDisplayRect(const QRect &rect); + + int brightness() const; + void setBrightness(int brightness); + + int contrast() const; + void setContrast(int contrast); + + int hue() const; + void setHue(int hue); + + int saturation() const; + void setSaturation(int saturation); + + QList<QVideoFrame::PixelFormat> supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; + + bool isFormatSupported(const QVideoSurfaceFormat &format) const; + + bool start(const QVideoSurfaceFormat &format); + void stop(); + + bool present(const QVideoFrame &frame); + +private: + WId m_winId; + //XvPortID m_portId; + //GC m_gc; + //XvImage *m_image; + QList<QVideoFrame::PixelFormat> m_supportedPixelFormats; + QVector<int> m_formatIds; + QRect m_viewport; + QRect m_displayRect; + QPair<int, int> m_brightnessRange; + QPair<int, int> m_contrastRange; + QPair<int, int> m_hueRange; + QPair<int, int> m_saturationRange; + + bool findPort(); + void querySupportedFormats(); + + int getAttribute(const char *attribute, int minimum, int maximum) const; + void setAttribute(const char *attribute, int value, int minimum, int maximum); + + static int redistribute(int value, int fromLower, int fromUpper, int toLower, int toUpper); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp b/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp new file mode 100644 index 0000000..84000d5 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp @@ -0,0 +1,208 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videowidget.h" +#include <QtGui/private/qwidget_p.h> +#include <QEvent> +#include <coemain.h> // For CCoeEnv + +QT_BEGIN_NAMESPACE + +QBlackWidget::QBlackWidget(QWidget *parent) + : QWidget(parent) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + setAutoFillBackground(false); + setPalette(QPalette(Qt::black)); +#if QT_VERSION >= 0x040601 && !defined(__WINSCW__) + qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill; + qt_widget_private(this)->extraData()->receiveNativePaintEvents = true; +#endif +} + +QBlackWidget::~QBlackWidget() +{ +} + +void QBlackWidget::beginNativePaintEvent(const QRect& /*controlRect*/) +{ + emit beginVideoWindowNativePaint(); +} + +void QBlackWidget::endNativePaintEvent(const QRect& /*controlRect*/) +{ + CCoeEnv::Static()->WsSession().Flush(); + emit endVideoWindowNativePaint(); +} + +void QBlackWidget::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + // Do nothing +} + +S60VideoWidgetControl::S60VideoWidgetControl(QObject *parent) + : QVideoWidgetControl(parent) + , m_widget(0) + , m_aspectRatioMode(Qt::KeepAspectRatio) +{ + m_widget = new QBlackWidget(); + connect(m_widget, SIGNAL(beginVideoWindowNativePaint()), this, SIGNAL(beginVideoWindowNativePaint())); + connect(m_widget, SIGNAL(endVideoWindowNativePaint()), this, SIGNAL(endVideoWindowNativePaint())); + m_widget->installEventFilter(this); + m_widget->winId(); +} + +S60VideoWidgetControl::~S60VideoWidgetControl() +{ + delete m_widget; +} + +QWidget *S60VideoWidgetControl::videoWidget() +{ + return m_widget; +} + +Qt::AspectRatioMode S60VideoWidgetControl::aspectRatioMode() const +{ + return m_aspectRatioMode; +} + +void S60VideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode ratio) +{ + if (m_aspectRatioMode == ratio) + return; + + m_aspectRatioMode = ratio; + emit widgetUpdated(); +} + +bool S60VideoWidgetControl::isFullScreen() const +{ + return m_widget->isFullScreen(); +} + +void S60VideoWidgetControl::setFullScreen(bool fullScreen) +{ + emit fullScreenChanged(fullScreen); +} + +int S60VideoWidgetControl::brightness() const +{ + return 0; +} + +void S60VideoWidgetControl::setBrightness(int brightness) +{ + Q_UNUSED(brightness); +} + +int S60VideoWidgetControl::contrast() const +{ + return 0; +} + +void S60VideoWidgetControl::setContrast(int contrast) +{ + Q_UNUSED(contrast); +} + +int S60VideoWidgetControl::hue() const +{ + return 0; +} + +void S60VideoWidgetControl::setHue(int hue) +{ + Q_UNUSED(hue); +} + +int S60VideoWidgetControl::saturation() const +{ + return 0; +} + +void S60VideoWidgetControl::setSaturation(int saturation) +{ + Q_UNUSED(saturation); +} + +bool S60VideoWidgetControl::eventFilter(QObject *object, QEvent *e) +{ + if (object == m_widget) { + if ( e->type() == QEvent::Resize + || e->type() == QEvent::Move + || e->type() == QEvent::WinIdChange + || e->type() == QEvent::ParentChange + || e->type() == QEvent::Show) + emit widgetUpdated(); + } + return false; +} + +WId S60VideoWidgetControl::videoWidgetWId() +{ + if (m_widget->internalWinId()) + return m_widget->internalWinId(); + + if (m_widget->effectiveWinId()) + return m_widget->effectiveWinId(); + + return NULL; +} + +void S60VideoWidgetControl::videoStateChanged(QMediaPlayer::State state) +{ + if (state == QMediaPlayer::StoppedState) { +#if QT_VERSION <= 0x040600 && !defined(FF_QT) + qt_widget_private(m_widget)->extraData()->disableBlit = false; +#endif + m_widget->repaint(); + } else if (state == QMediaPlayer::PlayingState) { +#if QT_VERSION <= 0x040600 && !defined(FF_QT) + qt_widget_private(m_widget)->extraData()->disableBlit = true; +#endif + } +} + +QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h b/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h new file mode 100644 index 0000000..28a1455 --- /dev/null +++ b/src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOWIDGET_H +#define S60VIDEOWIDGET_H + +#include <qvideowidgetcontrol.h> +#include <qmediaplayer.h> + +QT_BEGIN_NAMESPACE + +class QBlackWidget : public QWidget +{ + Q_OBJECT + +public: + QBlackWidget(QWidget *parent = 0); + virtual ~QBlackWidget(); + +signals: + void beginVideoWindowNativePaint(); + void endVideoWindowNativePaint(); + +public slots: + void beginNativePaintEvent(const QRect&); + void endNativePaintEvent(const QRect&); + +protected: + void paintEvent(QPaintEvent *event); +}; + +class S60VideoWidgetControl : public QVideoWidgetControl +{ + Q_OBJECT + +public: + S60VideoWidgetControl(QObject *parent = 0); + virtual ~S60VideoWidgetControl(); + + // from QVideoWidgetControl + QWidget *videoWidget(); + Qt::AspectRatioMode aspectRatioMode() const; + void setAspectRatioMode(Qt::AspectRatioMode ratio); + bool isFullScreen() const; + void setFullScreen(bool fullScreen); + int brightness() const; + void setBrightness(int brightness); + int contrast() const; + void setContrast(int contrast); + int hue() const; + void setHue(int hue); + int saturation() const; + void setSaturation(int saturation); + + // from QObject + bool eventFilter(QObject *object, QEvent *event); + + //new methods + WId videoWidgetWId(); + +signals: + void widgetUpdated(); + void beginVideoWindowNativePaint(); + void endVideoWindowNativePaint(); + +private slots: + void videoStateChanged(QMediaPlayer::State state); + +private: + QBlackWidget *m_widget; + Qt::AspectRatioMode m_aspectRatioMode; +}; + +QT_END_NAMESPACE + + +#endif // S60VIDEOWIDGET_H diff --git a/src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp b/src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp new file mode 100644 index 0000000..1185583 --- /dev/null +++ b/src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/qstring.h> +#include <QtCore/qdebug.h> + +#include "s60mediaserviceplugin.h" +#ifdef QMEDIA_MMF_RADIO +#include "s60radiotunerservice.h" +#endif +#ifdef QMEDIA_MMF_PLAYER +#include "s60mediaplayerservice.h" +#endif +#ifdef QMEDIA_MMF_CAPTURE +#include "s60audiocaptureservice.h" +#endif + +QT_BEGIN_NAMESPACE + +QStringList S60MediaServicePlugin::keys() const +{ + QStringList list; +#ifdef QMEDIA_MMF_RADIO + list << QLatin1String(Q_MEDIASERVICE_RADIO); +#endif + +#ifdef QMEDIA_MMF_PLAYER + list << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER); +#endif +#ifdef QMEDIA_MMF_CAPTURE + list << QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE); +#endif + return list; +} + +QMediaService* S60MediaServicePlugin::create(QString const& key) +{ +#ifdef QMEDIA_MMF_PLAYER + if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)) + return new S60MediaPlayerService; +#endif +#ifdef QMEDIA_MMF_CAPTURE + if (key == QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE)) + return new S60AudioCaptureService; +#endif +#ifdef QMEDIA_MMF_RADIO + if (key == QLatin1String(Q_MEDIASERVICE_RADIO)) + return new S60RadioTunerService; +#endif + + return 0; +} + +void S60MediaServicePlugin::release(QMediaService *service) +{ + delete service; +} + +QT_END_NAMESPACE + +Q_EXPORT_PLUGIN2(qmmfengine, S60MediaServicePlugin); + diff --git a/src/plugins/mediaservices/symbian/s60mediaserviceplugin.h b/src/plugins/mediaservices/symbian/s60mediaserviceplugin.h new file mode 100644 index 0000000..be2e05d --- /dev/null +++ b/src/plugins/mediaservices/symbian/s60mediaserviceplugin.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef S60SERVICEPLUGIN_H +#define S60SERVICEPLUGIN_H + +#include <QtCore/qobject.h> +#include <qmediaservice.h> +#include <qmediaserviceproviderplugin.h> + +QT_BEGIN_NAMESPACE + +class S60MediaServicePlugin : public QMediaServiceProviderPlugin +{ + Q_OBJECT +public: + + QStringList keys() const; + QMediaService* create(QString const& key); + void release(QMediaService *service); +}; + +QT_END_NAMESPACE + +#endif // S60SERVICEPLUGIN_H diff --git a/src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp b/src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp new file mode 100644 index 0000000..da07a7d --- /dev/null +++ b/src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "s60videooutputcontrol.h" + +QT_BEGIN_NAMESPACE + +S60VideoOutputControl::S60VideoOutputControl(QObject *parent) + : QVideoOutputControl(parent) + , m_output(NoOutput) +{ +} + +QList<QVideoOutputControl::Output> S60VideoOutputControl::availableOutputs() const +{ + return m_outputs; +} + +void S60VideoOutputControl::setAvailableOutputs(const QList<Output> &outputs) +{ + emit availableOutputsChanged(m_outputs = outputs); +} + +QVideoOutputControl::Output S60VideoOutputControl::output() const +{ + return m_output; +} + +void S60VideoOutputControl::setOutput(Output output) +{ + if (!m_outputs.contains(output)) + output = NoOutput; + + if (m_output != output) + emit outputChanged(m_output = output); +} + +QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/symbian/s60videooutputcontrol.h b/src/plugins/mediaservices/symbian/s60videooutputcontrol.h new file mode 100644 index 0000000..dbad889 --- /dev/null +++ b/src/plugins/mediaservices/symbian/s60videooutputcontrol.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef S60VIDEOOUTPUTCONTROL_H +#define S60VIDEOOUTPUTCONTROL_H + +#include <QObject> +#include <qvideooutputcontrol.h> + +QT_BEGIN_NAMESPACE + +class S60VideoOutputControl : public QVideoOutputControl +{ + Q_OBJECT +public: + S60VideoOutputControl(QObject *parent = 0); + + QList<Output> availableOutputs() const; + void setAvailableOutputs(const QList<Output> &outputs); + + Output output() const; + void setOutput(Output output); + +Q_SIGNALS: + void outputChanged(QVideoOutputControl::Output output); + +private: + QList<Output> m_outputs; + Output m_output; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/mediaservices/symbian/symbian.pro b/src/plugins/mediaservices/symbian/symbian.pro new file mode 100644 index 0000000..f76858f --- /dev/null +++ b/src/plugins/mediaservices/symbian/symbian.pro @@ -0,0 +1,27 @@ +TARGET = qmmfengine +QT += multimedia mediaservices + +load(data_caging_paths) + +include (../../qpluginbase.pri) +include(mediaplayer/mediaplayer.pri) + +HEADERS += s60mediaserviceplugin.h \ + s60videooutputcontrol.h + +SOURCES += s60mediaserviceplugin.cpp \ + s60videooutputcontrol.cpp + +contains(S60_VERSION, 3.2)|contains(S60_VERSION, 3.1) { + DEFINES += PRE_S60_50_PLATFORM +} + +INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE +symbian-abld:INCLUDEPATH += $$QT_BUILD_TREE/include/QtWidget/private + +# This is needed for having the .qtplugin file properly created on Symbian. +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/mediaservices +target.path += $$[QT_INSTALL_PLUGINS]/mediaservices +INSTALLS += target + +TARGET.UID3=0x20021318 |