From 6857fd7b99ba0c72c2f09cfc7ad38e9df4f0531c Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 28 Apr 2010 07:42:15 +1000 Subject: update multimedia qml element doc samples Reviewed-by:Derick Hawcroft --- src/imports/multimedia/qdeclarativeaudio.cpp | 16 +++++++++++++++- src/imports/multimedia/qdeclarativevideo.cpp | 19 ++++++++++++++++++- src/multimedia/mediaservices/effects/qsoundeffect.cpp | 12 +++++++----- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index 896f9b7..a163b10 100644 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp @@ -57,7 +57,21 @@ QT_BEGIN_NAMESPACE import Qt 4.7 import Qt.multimedia 4.7 - Audio { source: "audio/song.mp3" } + Text { + text: "Click Me!"; + font.pointSize: 24; + width: 150; height: 50; + + Audio { + id: playMusic + source: "music.wav" + } + MouseArea { + id: playArea + anchors.fill: parent + onPressed: { playMusic.play() } + } + } \endqml \sa Video diff --git a/src/imports/multimedia/qdeclarativevideo.cpp b/src/imports/multimedia/qdeclarativevideo.cpp index 9b02795..1b51e2c 100644 --- a/src/imports/multimedia/qdeclarativevideo.cpp +++ b/src/imports/multimedia/qdeclarativevideo.cpp @@ -79,7 +79,24 @@ void QDeclarativeVideo::_q_error(int errorCode, const QString &errorString) import Qt 4.7 import Qt.multimedia 4.7 - Video { source: "video/movie.mpg" } + Video { + id: video + width : 800 + height : 600 + source: "video.avi" + + MouseArea { + anchors.fill: parent + onClicked: { + video.play() + } + } + + focus: true + Keys.onSpacePressed: video.paused = !video.paused + Keys.onLeftPressed: video.position -= 5000 + Keys.onRightPressed: video.position += 5000 + } \endqml The Video item supports untransformed, stretched, and uniformly scaled video presentation. diff --git a/src/multimedia/mediaservices/effects/qsoundeffect.cpp b/src/multimedia/mediaservices/effects/qsoundeffect.cpp index 1992ee5..3537566 100644 --- a/src/multimedia/mediaservices/effects/qsoundeffect.cpp +++ b/src/multimedia/mediaservices/effects/qsoundeffect.cpp @@ -64,17 +64,19 @@ QT_BEGIN_NAMESPACE import Qt 4.7 import Qt.multimedia 4.7 - Item { + Text { + text: "Click Me!"; + font.pointSize: 24; + width: 150; height: 50; + SoundEffect { id: playSound - source: "test.wav" + source: "soundeffect.wav" } MouseArea { id: playArea anchors.fill: parent - onPressed: { - playSound.play() - } + onPressed: { playSound.play() } } } \endqml -- cgit v0.12 From 5db00ed35bc87b6502478d727624f67b82e80cb6 Mon Sep 17 00:00:00 2001 From: Derick Hawcroft Date: Wed, 28 Apr 2010 07:42:28 +1000 Subject: When deployed on symbian, give player application the standard QT icon Reviewed-by: Kurt Korbatits --- demos/multimedia/player/player.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/multimedia/player/player.pro b/demos/multimedia/player/player.pro index 0b868bd..12bdf64 100644 --- a/demos/multimedia/player/player.pro +++ b/demos/multimedia/player/player.pro @@ -24,5 +24,6 @@ INSTALLS += target sources symbian { TARGET.UID3 = 0xA000E3FA + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } -- cgit v0.12 From a2effe201fd2480f632c356cd9307e1e631c0fe7 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 28 Apr 2010 07:50:00 +1000 Subject: Fix qdoc error in low-level audio Reviewed-by:Derick Hawcroft --- src/multimedia/multimedia/audio/qaudioinput.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/multimedia/multimedia/audio/qaudioinput.cpp b/src/multimedia/multimedia/audio/qaudioinput.cpp index c99e870..3676f64 100644 --- a/src/multimedia/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/multimedia/audio/qaudioinput.cpp @@ -211,7 +211,7 @@ QAudioInput::~QAudioInput() If a problem occurs during this process the error() is set to QAudio::OpenError, state() is set to QAudio::StoppedState and stateChanged() signal is emitted. - \sa {Symbian Platform Security Requirements} + \l{QAudioInput#Symbian Platform Security Requirements} \sa QIODevice */ @@ -233,7 +233,7 @@ void QAudioInput::start(QIODevice* device) If a problem occurs during this process the error() is set to QAudio::OpenError, state() is set to QAudio::StoppedState and stateChanged() signal is emitted. - \sa {Symbian Platform Security Requirements} + \l{QAudioInput#Symbian Platform Security Requirements} \sa QIODevice */ -- cgit v0.12 From 872ffd81772ff39d173da90184a5124242909707 Mon Sep 17 00:00:00 2001 From: hawcroft Date: Thu, 29 Apr 2010 11:08:49 +1000 Subject: S60 mediaservices backend Reviewed-by: Justin McPherson --- src/plugins/mediaservices/mediaservices.pro | 2 + .../symbian/mediaplayer/mediaplayer.pri | 63 +++ .../symbian/mediaplayer/ms60mediaplayerresolver.h | 58 +++ .../symbian/mediaplayer/s60audioplayersession.cpp | 268 +++++++++++ .../symbian/mediaplayer/s60audioplayersession.h | 116 +++++ .../mediaplayer/s60mediametadataprovider.cpp | 185 ++++++++ .../symbian/mediaplayer/s60mediametadataprovider.h | 81 ++++ .../s60mediaplayeraudioendpointselector.cpp | 127 ++++++ .../s60mediaplayeraudioendpointselector.h | 81 ++++ .../symbian/mediaplayer/s60mediaplayercontrol.cpp | 274 ++++++++++++ .../symbian/mediaplayer/s60mediaplayercontrol.h | 143 ++++++ .../symbian/mediaplayer/s60mediaplayerservice.cpp | 259 +++++++++++ .../symbian/mediaplayer/s60mediaplayerservice.h | 105 +++++ .../symbian/mediaplayer/s60mediaplayersession.cpp | 496 +++++++++++++++++++++ .../symbian/mediaplayer/s60mediaplayersession.h | 167 +++++++ .../symbian/mediaplayer/s60mediarecognizer.cpp | 127 ++++++ .../symbian/mediaplayer/s60mediarecognizer.h | 83 ++++ .../symbian/mediaplayer/s60videooverlay.cpp | 209 +++++++++ .../symbian/mediaplayer/s60videooverlay.h | 109 +++++ .../symbian/mediaplayer/s60videoplayersession.cpp | 486 ++++++++++++++++++++ .../symbian/mediaplayer/s60videoplayersession.h | 148 ++++++ .../symbian/mediaplayer/s60videorenderer.cpp | 69 +++ .../symbian/mediaplayer/s60videorenderer.h | 68 +++ .../symbian/mediaplayer/s60videosurface.cpp | 478 ++++++++++++++++++++ .../symbian/mediaplayer/s60videosurface.h | 112 +++++ .../symbian/mediaplayer/s60videowidget.cpp | 208 +++++++++ .../symbian/mediaplayer/s60videowidget.h | 115 +++++ .../symbian/s60mediaserviceplugin.cpp | 100 +++++ .../mediaservices/symbian/s60mediaserviceplugin.h | 64 +++ .../symbian/s60videooutputcontrol.cpp | 76 ++++ .../mediaservices/symbian/s60videooutputcontrol.h | 72 +++ src/plugins/mediaservices/symbian/symbian.pro | 27 ++ src/s60installs/s60installs.pro | 8 +- 33 files changed, 4983 insertions(+), 1 deletion(-) create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/mediaplayer.pri create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/ms60mediaplayerresolver.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60audioplayersession.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediametadataprovider.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayeraudioendpointselector.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayercontrol.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayerservice.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediaplayersession.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60mediarecognizer.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videooverlay.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videoplayersession.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videorenderer.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videosurface.h create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.cpp create mode 100644 src/plugins/mediaservices/symbian/mediaplayer/s60videowidget.h create mode 100644 src/plugins/mediaservices/symbian/s60mediaserviceplugin.cpp create mode 100644 src/plugins/mediaservices/symbian/s60mediaserviceplugin.h create mode 100644 src/plugins/mediaservices/symbian/s60videooutputcontrol.cpp create mode 100644 src/plugins/mediaservices/symbian/s60videooutputcontrol.h create mode 100644 src/plugins/mediaservices/symbian/symbian.pro diff --git a/src/plugins/mediaservices/mediaservices.pro b/src/plugins/mediaservices/mediaservices.pro index 6a00a14..fdc1cd9 100644 --- a/src/plugins/mediaservices/mediaservices.pro +++ b/src/plugins/mediaservices/mediaservices.pro @@ -8,4 +8,6 @@ contains(QT_CONFIG, media-backend) { unix:!mac:!symbian:contains(QT_CONFIG, xvideo):contains(QT_CONFIG, gstreamer) { SUBDIRS += gstreamer } + + symbian:SUBDIRS += symbian } 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 +#include + +#include +#include + +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 +typedef CMdaAudioPlayerUtility CAudioPlayer; +typedef MMdaAudioPlayerCallback MAudioPlayerObserver; + +#include +#include + +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 + +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 S60MediaMetaDataProvider::availableMetaData() const +{ + m_session = m_mediaPlayerResolver.PlayerSession(); + QList 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 +#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 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 +#include + +QT_BEGIN_NAMESPACE + +S60MediaPlayerAudioEndpointSelector::S60MediaPlayerAudioEndpointSelector(QObject *control, QObject *parent) + :QMediaControl(parent) + , m_control(0) + , m_audioEndpointNames(0) +{ + m_control = qobject_cast(control); +} + +S60MediaPlayerAudioEndpointSelector::~S60MediaPlayerAudioEndpointSelector() +{ + delete m_audioEndpointNames; +} + +QList 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 + +#include + +QT_BEGIN_NAMESPACE + +class S60MediaPlayerControl; +class S60MediaPlayerSession; + +class S60MediaPlayerAudioEndpointSelector : public QMediaControl +{ + +Q_OBJECT + +public: + S60MediaPlayerAudioEndpointSelector(QObject *control, QObject *parent = 0); + ~S60MediaPlayerAudioEndpointSelector(); + + QList 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 *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 +#include +#include + +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 + +#include + +#include "ms60mediaplayerresolver.h" +#include + +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 +#include +#include + +#include "s60mediaplayerservice.h" +#include "s60mediaplayercontrol.h" +#include "s60videoplayersession.h" +#include "s60audioplayersession.h" +#include "s60mediametadataprovider.h" +#include "s60videowidget.h" +#include "s60mediarecognizer.h" +//#include +#include "s60videooverlay.h" +#include "s60videorenderer.h" +#include "s60mediaplayeraudioendpointselector.h" + +#include +#include + +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::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 + +#include +#include + +#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 +#include +#include +#include +#include +#include + +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 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& 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(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 +#include +#include +#include +#include // for TDesC +#include +#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 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& 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 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 +#include +#include +#include +#include + +#include + +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(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 + +#include +#include + +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 +#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 +#include + +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 +#include +#include +#include + +#include +#include // For CCoeEnv +#include +#include + +#include +#include + +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(m_service.control(QVideoOutputControl_iid)); + + //Render changes + if (m_output != videoControl->output()) { + + if (m_output == QVideoOutputControl::WidgetOutput) { + S60VideoWidgetControl *widgetControl = qobject_cast(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(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(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(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(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 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(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 +#include +#include + +#include +#include + +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 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 +#include + +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 +#include + +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 + +#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 S60VideoSurface::supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const +{ + /*return handleType == QAbstractVideoBuffer::NoHandle + ? m_supportedPixelFormats + : QList();*/ +} + +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(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 +#include + +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 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 m_supportedPixelFormats; + QVector m_formatIds; + QRect m_viewport; + QRect m_displayRect; + QPair m_brightnessRange; + QPair m_contrastRange; + QPair m_hueRange; + QPair 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 +#include +#include // 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 +#include + +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 +#include + +#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 +#include +#include + +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 S60VideoOutputControl::availableOutputs() const +{ + return m_outputs; +} + +void S60VideoOutputControl::setAvailableOutputs(const QList &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 +#include + +QT_BEGIN_NAMESPACE + +class S60VideoOutputControl : public QVideoOutputControl +{ + Q_OBJECT +public: + S60VideoOutputControl(QObject *parent = 0); + + QList availableOutputs() const; + void setAvailableOutputs(const QList &outputs); + + Output output() const; + void setOutput(Output output); + +Q_SIGNALS: + void outputChanged(QVideoOutputControl::Output output); + +private: + QList 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 diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index ad196a8..9826967 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -151,9 +151,15 @@ symbian: { graphicssystems_plugins.sources += $$QT_BUILD_TREE/plugins/graphicssystems/qvggraphicssystem$${QT_LIBINFIX}.dll } - contains(QT_CONFIG, multimedia) { + contains(QT_CONFIG, multimedia):contains(QT_CONFIG, mediaservices):contains(QT_CONFIG, media-backend) { qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtMultimedia$${QT_LIBINFIX}.dll qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtMediaServices$${QT_LIBINFIX}.dll + + mediaservices_plugins.path = c:$$QT_PLUGINS_BASE_DIR/mediaservices + mediaservices_plugins.sources += $$QT_BUILD_TREE/plugins/mediaservices/qmmfengine$${QT_LIBINFIX}.dll + + DEPLOYMENT += mediaservices_plugins + } BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)" -- cgit v0.12 From fcabd4c7901cc33e2a4bf437f661dba36cb400b4 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Thu, 29 Apr 2010 16:46:55 +1000 Subject: Gstreamer media backend: fixed embedded qt build XVideo is not available on framebuffer, so widget and window video outputs are disabled, only the renderer video output is supported. Reviewed-by: Justin McPherson --- src/plugins/mediaservices/gstreamer/gstreamer.pro | 35 ++++++++++++++-------- .../mediaplayer/qgstreamerplayerservice.cpp | 22 ++++++++++---- .../gstreamer/qvideosurfacegstsink.cpp | 18 +++++++++-- .../mediaservices/gstreamer/qvideosurfacegstsink.h | 6 ++++ src/plugins/mediaservices/mediaservices.pro | 2 +- 5 files changed, 62 insertions(+), 21 deletions(-) diff --git a/src/plugins/mediaservices/gstreamer/gstreamer.pro b/src/plugins/mediaservices/gstreamer/gstreamer.pro index 0273139..6af9c3f 100644 --- a/src/plugins/mediaservices/gstreamer/gstreamer.pro +++ b/src/plugins/mediaservices/gstreamer/gstreamer.pro @@ -9,39 +9,48 @@ unix:contains(QT_CONFIG, alsa) { } QMAKE_CXXFLAGS += $$QT_CFLAGS_GSTREAMER -LIBS += -lXv $$QT_LIBS_GSTREAMER -lgstinterfaces-0.10 -lgstvideo-0.10 -lgstbase-0.10 -lgstaudio-0.10 +LIBS += $$QT_LIBS_GSTREAMER -lgstinterfaces-0.10 -lgstvideo-0.10 -lgstbase-0.10 -lgstaudio-0.10 # Input HEADERS += \ qgstreamermessage.h \ qgstreamerbushelper.h \ qgstreamervideooutputcontrol.h \ - qgstreamervideorendererinterface.h \ - qgstreamervideowidget.h \ + qgstreamervideorendererinterface.h \ qgstreamerserviceplugin.h \ qgstreamervideoinputdevicecontrol.h \ - qgstreamervideooverlay.h \ qgstreamervideorenderer.h \ qgstvideobuffer.h \ - qvideosurfacegstsink.h \ - qx11videosurface.h \ - qgstxvimagebuffer.h + qvideosurfacegstsink.h SOURCES += \ qgstreamermessage.cpp \ qgstreamerbushelper.cpp \ qgstreamervideooutputcontrol.cpp \ - qgstreamervideorendererinterface.cpp \ - qgstreamervideowidget.cpp \ + qgstreamervideorendererinterface.cpp \ qgstreamerserviceplugin.cpp \ qgstreamervideoinputdevicecontrol.cpp \ - qgstreamervideooverlay.cpp \ qgstreamervideorenderer.cpp \ qgstvideobuffer.cpp \ - qvideosurfacegstsink.cpp \ - qx11videosurface.cpp \ - qgstxvimagebuffer.cpp + qvideosurfacegstsink.cpp + + +x11 { + LIBS += -lXv + + HEADERS += \ + qgstreamervideooverlay.h \ + qgstreamervideowidget.h \ + qx11videosurface.h \ + qgstxvimagebuffer.h + + SOURCES += \ + qgstreamervideooverlay.cpp \ + qgstreamervideowidget.cpp \ + qx11videosurface.cpp \ + qgstxvimagebuffer.cpp +} include(mediaplayer/mediaplayer.pri) diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp index d5d7bd0..3228722 100644 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp +++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayerservice.cpp @@ -63,7 +63,10 @@ QT_BEGIN_NAMESPACE QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent): - QMediaService(parent) + QMediaService(parent), + m_videoRenderer(0), + m_videoWindow(0), + m_videoWidget(0) { m_session = new QGstreamerPlayerSession(this); m_control = new QGstreamerPlayerControl(m_session, this); @@ -74,13 +77,22 @@ QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent): connect(m_videoOutput, SIGNAL(outputChanged(QVideoOutputControl::Output)), this, SLOT(videoOutputChanged(QVideoOutputControl::Output))); m_videoRenderer = new QGstreamerVideoRenderer(this); + +#ifdef Q_WS_X11 m_videoWindow = new QGstreamerVideoOverlay(this); m_videoWidget = new QGstreamerVideoWidgetControl(this); +#endif + + QList outputs; + + if (m_videoRenderer) + outputs << QVideoOutputControl::RendererOutput; + if (m_videoWidget) + outputs << QVideoOutputControl::WidgetOutput; + if (m_videoWindow) + outputs << QVideoOutputControl::WindowOutput; - m_videoOutput->setAvailableOutputs(QList() - << QVideoOutputControl::RendererOutput - << QVideoOutputControl::WindowOutput - << QVideoOutputControl::WidgetOutput); + m_videoOutput->setAvailableOutputs(outputs); } QGstreamerPlayerService::~QGstreamerPlayerService() diff --git a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp index 76d87ce..596e39d 100644 --- a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp +++ b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp @@ -44,12 +44,16 @@ #include #include #include + +#include "qgstvideobuffer.h" + +#ifdef Q_WS_X11 #include +#include "qgstxvimagebuffer.h" +#endif #include "qvideosurfacegstsink.h" -#include "qgstvideobuffer.h" -#include "qgstxvimagebuffer.h" @@ -131,11 +135,13 @@ GstFlowReturn QVideoSurfaceGstDelegate::render(GstBuffer *buffer) QGstVideoBuffer *videoBuffer = 0; +#ifdef Q_WS_X11 if (G_TYPE_CHECK_INSTANCE_TYPE(buffer, QGstXvImageBuffer::get_type())) { QGstXvImageBuffer *xvBuffer = reinterpret_cast(buffer); QVariant handle = QVariant::fromValue(xvBuffer->xvImage); videoBuffer = new QGstVideoBuffer(buffer, m_bytesPerLine, XvHandleType, handle); } else +#endif videoBuffer = new QGstVideoBuffer(buffer, m_bytesPerLine); m_frame = QVideoFrame( @@ -387,7 +393,9 @@ void QVideoSurfaceGstSink::instance_init(GTypeInstance *instance, gpointer g_cla Q_UNUSED(g_class); sink->delegate = 0; +#ifdef Q_WS_X11 sink->pool = new QGstXvImageBufferPool(); +#endif sink->lastRequestedCaps = 0; sink->lastBufferCaps = 0; sink->lastSurfaceFormat = new QVideoSurfaceFormat; @@ -396,8 +404,11 @@ void QVideoSurfaceGstSink::instance_init(GTypeInstance *instance, gpointer g_cla void QVideoSurfaceGstSink::finalize(GObject *object) { VO_SINK(object); +#ifdef Q_WS_X11 delete sink->pool; sink->pool = 0; +#endif + delete sink->lastSurfaceFormat; sink->lastSurfaceFormat = 0; @@ -588,6 +599,8 @@ GstFlowReturn QVideoSurfaceGstSink::buffer_alloc( *buffer = 0; +#ifdef Q_WS_X11 + if (sink->lastRequestedCaps && gst_caps_is_equal(sink->lastRequestedCaps, caps)) { //qDebug() << "reusing last caps"; *buffer = GST_BUFFER(sink->pool->takeBuffer(*sink->lastSurfaceFormat, sink->lastBufferCaps)); @@ -649,6 +662,7 @@ GstFlowReturn QVideoSurfaceGstSink::buffer_alloc( *buffer = GST_BUFFER(sink->pool->takeBuffer(surfaceFormat, intersection)); +#endif return GST_FLOW_OK; } diff --git a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h index f59a43c..75fa854 100644 --- a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h +++ b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.h @@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE class QAbstractVideoSurface; +#ifdef Q_WS_X11 class QGstXvImageBuffer; class QGstXvImageBufferPool; +#endif class QVideoSurfaceGstDelegate : public QObject @@ -137,7 +139,11 @@ private: private: QVideoSurfaceGstDelegate *delegate; + +#ifdef Q_WS_X11 QGstXvImageBufferPool *pool; +#endif + GstCaps *lastRequestedCaps; GstCaps *lastBufferCaps; QVideoSurfaceFormat *lastSurfaceFormat; diff --git a/src/plugins/mediaservices/mediaservices.pro b/src/plugins/mediaservices/mediaservices.pro index fdc1cd9..27f05bc 100644 --- a/src/plugins/mediaservices/mediaservices.pro +++ b/src/plugins/mediaservices/mediaservices.pro @@ -5,7 +5,7 @@ contains(QT_CONFIG, media-backend) { mac: SUBDIRS += qt7 - unix:!mac:!symbian:contains(QT_CONFIG, xvideo):contains(QT_CONFIG, gstreamer) { + unix:!mac:!symbian:contains(QT_CONFIG, gstreamer) { SUBDIRS += gstreamer } -- cgit v0.12 From 9406280363fcc228009e745f8c9a15aec6d8190f Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 29 Apr 2010 17:50:43 +1000 Subject: Don't disable the symbian media backend. The absence of the DirectX or Windows SDK is of no relevance to the symbian media backend. Reviewed-by: Derick Hawcroft --- tools/configure/configureapp.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index f4bd92e..bfa7445 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2074,22 +2074,26 @@ bool Configure::checkAvailability(const QString &part) && dictionary.value("QMAKESPEC") != "win32-msvc2002" && dictionary.value("EXCEPTIONS") == "yes"; } else if (part == "PHONON" || part == "MEDIA_BACKEND") { - available = findFile("vmr9.h") && findFile("dshow.h") && findFile("dmo.h") && findFile("dmodshow.h") - && (findFile("strmiids.lib") || findFile("libstrmiids.a")) - && (findFile("dmoguids.lib") || findFile("libdmoguids.a")) - && (findFile("msdmo.lib") || findFile("libmsdmo.a")) - && findFile("d3d9.h"); - - if (!available) { - cout << "All the required DirectShow/Direct3D files couldn't be found." << endl - << "Make sure you have either the platform SDK AND the DirectShow SDK or the Windows SDK installed." << endl - << "If you have the DirectShow SDK installed, please make sure that you have run the \\SetEnv.Cmd script." << endl; - if (!findFile("vmr9.h")) cout << "vmr9.h not found" << endl; - if (!findFile("dshow.h")) cout << "dshow.h not found" << endl; - if (!findFile("strmiids.lib")) cout << "strmiids.lib not found" << endl; - if (!findFile("dmoguids.lib")) cout << "dmoguids.lib not found" << endl; - if (!findFile("msdmo.lib")) cout << "msdmo.lib not found" << endl; - if (!findFile("d3d9.h")) cout << "d3d9.h not found" << endl; + if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) { + available = true; + } else { + available = findFile("vmr9.h") && findFile("dshow.h") && findFile("dmo.h") && findFile("dmodshow.h") + && (findFile("strmiids.lib") || findFile("libstrmiids.a")) + && (findFile("dmoguids.lib") || findFile("libdmoguids.a")) + && (findFile("msdmo.lib") || findFile("libmsdmo.a")) + && findFile("d3d9.h"); + + if (!available) { + cout << "All the required DirectShow/Direct3D files couldn't be found." << endl + << "Make sure you have either the platform SDK AND the DirectShow SDK or the Windows SDK installed." << endl + << "If you have the DirectShow SDK installed, please make sure that you have run the \\SetEnv.Cmd script." << endl; + if (!findFile("vmr9.h")) cout << "vmr9.h not found" << endl; + if (!findFile("dshow.h")) cout << "dshow.h not found" << endl; + if (!findFile("strmiids.lib")) cout << "strmiids.lib not found" << endl; + if (!findFile("dmoguids.lib")) cout << "dmoguids.lib not found" << endl; + if (!findFile("msdmo.lib")) cout << "msdmo.lib not found" << endl; + if (!findFile("d3d9.h")) cout << "d3d9.h not found" << endl; + } } } else if (part == "WMSDK") { available = findFile("wmsdk.h"); -- cgit v0.12 From 3f3b145039e9bc0620e8ff3111fa3c338e44502c Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 29 Apr 2010 17:56:29 +1000 Subject: Rebuild configure.exe with updated symbian media backend check. --- configure.exe | Bin 1318400 -> 1319424 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index f1e0215..35116ff 100755 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From 7adae4f0078fd9364081c66aa84431bf4a2108f5 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 30 Apr 2010 11:13:23 +1000 Subject: Fix crash in direct show media service with mingw and a video surface. Mingw appears unable to resolve a valid pointer to the IMemInputPin interface from the DirectShowSampleScheduler class when it inherits from QWinEventNotifier. Inheriting from QObject does not have the same problem, so do that instead and connect to the activated signal of a separate instance of QWinEventNotifier. Task-number: 10221 Reviewed-by: Justin McPherson --- .../mediaplayer/directshowsamplescheduler.cpp | 23 ++++++---------------- .../mediaplayer/directshowsamplescheduler.h | 5 ++--- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp index 150860f..23675fb 100644 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp +++ b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp @@ -118,7 +118,7 @@ bool DirectShowTimedSample::isReady(IReferenceClock *clock) const } DirectShowSampleScheduler::DirectShowSampleScheduler(IUnknown *pin, QObject *parent) - : QWinEventNotifier(parent) + : QObject(parent) , m_pin(pin) , m_clock(0) , m_allocator(0) @@ -131,13 +131,15 @@ DirectShowSampleScheduler::DirectShowSampleScheduler(IUnknown *pin, QObject *par { m_semaphore.release(m_maximumSamples); - setHandle(m_timeoutEvent); - setEnabled(true); + m_eventNotifier.setHandle(m_timeoutEvent); + m_eventNotifier.setEnabled(true); + + connect(&m_eventNotifier, SIGNAL(activated(HANDLE)), this, SIGNAL(sampleReady())); } DirectShowSampleScheduler::~DirectShowSampleScheduler() { - setEnabled(false); + m_eventNotifier.setEnabled(false); ::CloseHandle(m_timeoutEvent); @@ -398,17 +400,4 @@ bool DirectShowSampleScheduler::scheduleEndOfStream() } } -bool DirectShowSampleScheduler::event(QEvent *event) -{ - if (event->type() == QEvent::WinEventAct) { - QObject::event(event); - - emit sampleReady(); - - return true; - } else { - return QWinEventNotifier::event(event); - } -} - QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h index 007fa99..21823c3 100644 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h +++ b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE class DirectShowTimedSample; -class DirectShowSampleScheduler : public QWinEventNotifier, public IMemInputPin +class DirectShowSampleScheduler : public QObject, public IMemInputPin { Q_OBJECT public: @@ -101,8 +101,6 @@ public: IMediaSample *takeSample(bool *eos); - bool event(QEvent *event); - Q_SIGNALS: void sampleReady(); @@ -118,6 +116,7 @@ private: HANDLE m_timeoutEvent; QSemaphore m_semaphore; QMutex m_mutex; + QWinEventNotifier m_eventNotifier; }; QT_END_NAMESPACE -- cgit v0.12