diff options
author | Gareth Stockwell <gareth.stockwell@sosco.com> | 2009-08-21 11:58:45 (GMT) |
---|---|---|
committer | Gareth Stockwell <gareth.stockwell@sosco.com> | 2009-08-21 11:58:45 (GMT) |
commit | 0761ebabf9f3cf6c968f4ce86e31c323dc8fe9c8 (patch) | |
tree | 2ad21f1f9e0578fe3db689f0190074402278ca41 /src/3rdparty/phonon | |
parent | 3f39d630d3dcc161c4a85127129274ca7ea857a2 (diff) | |
download | Qt-0761ebabf9f3cf6c968f4ce86e31c323dc8fe9c8.zip Qt-0761ebabf9f3cf6c968f4ce86e31c323dc8fe9c8.tar.gz Qt-0761ebabf9f3cf6c968f4ce86e31c323dc8fe9c8.tar.bz2 |
Implemented connection between MediaOutput and VideoWidget
Video is still not visible; need to debug the initialization of the
VideoOutput object to determine whether DSA is being aborted.
Diffstat (limited to 'src/3rdparty/phonon')
-rw-r--r-- | src/3rdparty/phonon/mmf/abstractplayer.cpp | 21 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/abstractplayer.h | 18 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/audiooutput.cpp | 10 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/audiooutput.h | 2 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/audioplayer.cpp | 3 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/backend.cpp | 11 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/mediaobject.cpp | 10 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/mediaobject.h | 8 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/videooutput.cpp | 10 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/videoplayer.cpp | 112 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/videoplayer.h | 16 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/videowidget.cpp | 10 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/videowidget.h | 7 |
13 files changed, 198 insertions, 40 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractplayer.cpp b/src/3rdparty/phonon/mmf/abstractplayer.cpp index 870b50f..9027f08 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractplayer.cpp @@ -28,7 +28,8 @@ using namespace Phonon::MMF; //----------------------------------------------------------------------------- MMF::AbstractPlayer::AbstractPlayer() - : m_tickInterval(DefaultTickInterval) + : m_videoOutput(NULL) + , m_tickInterval(DefaultTickInterval) , m_transitionTime(0) , m_prefinishMark(0) { @@ -36,7 +37,8 @@ MMF::AbstractPlayer::AbstractPlayer() } MMF::AbstractPlayer::AbstractPlayer(const AbstractPlayer& player) - : m_tickInterval(player.tickInterval()) + : m_videoOutput(player.m_videoOutput) + , m_tickInterval(player.tickInterval()) , m_transitionTime(player.transitionTime()) , m_prefinishMark(player.prefinishMark()) { @@ -79,3 +81,18 @@ void MMF::AbstractPlayer::setTransitionTime(qint32 time) } +//----------------------------------------------------------------------------- +// Video output +//----------------------------------------------------------------------------- + +void MMF::AbstractPlayer::setVideoOutput(VideoOutput* videoOutput) +{ + m_videoOutput = videoOutput; + videoOutputChanged(); +} + +void MMF::AbstractPlayer::videoOutputChanged() +{ + // Default behaviour is empty - overridden by VideoPlayer +} + diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 4b899d2..1c9ef9b 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -19,19 +19,22 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #ifndef PHONON_MMF_ABSTRACTPLAYER_H #define PHONON_MMF_ABSTRACTPLAYER_H -#include <QObject> #include <Phonon/phononnamespace.h> #include <Phonon/MediaSource.h> +#include <QObject> + #include "volumeobserver.h" +#include "videooutput.h" + class RFile; namespace Phonon { namespace MMF { - class AudioOutput; + class VideoOutput; /** * @short Interface which abstracts from MediaObject the current @@ -81,10 +84,19 @@ namespace Phonon virtual void setFileSource(const Phonon::MediaSource&, RFile&) = 0; virtual void setNextSource(const Phonon::MediaSource &) = 0; + void setVideoOutput(VideoOutput* videoOutput); + + protected: + virtual void videoOutputChanged(); + private: virtual void doSetTickInterval(qint32 interval) = 0; - private: + protected: + // Not owned + VideoOutput* m_videoOutput; + + private: qint32 m_tickInterval; qint32 m_transitionTime; qint32 m_prefinishMark; diff --git a/src/3rdparty/phonon/mmf/audiooutput.cpp b/src/3rdparty/phonon/mmf/audiooutput.cpp index 13b953d..82b2b82 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.cpp +++ b/src/3rdparty/phonon/mmf/audiooutput.cpp @@ -83,10 +83,12 @@ bool MMF::AudioOutput::setOutputDevice(const Phonon::AudioOutputDevice &) return true; } -void MMF::AudioOutput::setVolumeObserver(VolumeObserver& observer) +void MMF::AudioOutput::setVolumeObserver(VolumeObserver* observer) { - Q_ASSERT(!m_observer); - m_observer = &observer; - m_observer->volumeChanged(m_volume); + m_observer = observer; + if(m_observer) + { + m_observer->volumeChanged(m_volume); + } } diff --git a/src/3rdparty/phonon/mmf/audiooutput.h b/src/3rdparty/phonon/mmf/audiooutput.h index 38623a8..5ecfc0d 100644 --- a/src/3rdparty/phonon/mmf/audiooutput.h +++ b/src/3rdparty/phonon/mmf/audiooutput.h @@ -70,7 +70,7 @@ namespace Phonon /** * Called by backend when nodes are connected. */ - void setVolumeObserver(VolumeObserver& observer); + void setVolumeObserver(VolumeObserver* observer); Q_SIGNALS: void volumeChanged(qreal volume); diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 67ed7a5..d4ae1a8 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -45,7 +45,8 @@ void MMF::AudioPlayer::construct() TRACE_CONTEXT(AudioPlayer::AudioPlayer, EAudioApi); TRACE_ENTRY_0(); - // TODO: is this the correct way to handle errors in constructing Symbian objects? + // TODO: is this the correct way to handle errors which occur when + // creating a Symbian object in the constructor of a Qt object? TRAPD(err, m_player = CPlayerType::NewL(*this, 0, EMdaPriorityPreferenceNone)); if(KErrNone != err) { diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index ad60046..5b360f2 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -105,14 +105,14 @@ bool Backend::connectNodes(QObject *source, QObject *target) if(mediaObject and audioOutput) { TRACE("mediaObject 0x%08x -> audioOutput 0x%08x", mediaObject, audioOutput); - audioOutput->setVolumeObserver(*mediaObject); + audioOutput->setVolumeObserver(mediaObject); result = true; } if(mediaObject and videoWidget) { TRACE("mediaObject 0x%08x -> videoWidget 0x%08x", mediaObject, videoWidget); - // TODO: the actual connection :) + mediaObject->setVideoOutput(&videoWidget->videoOutput()); result = true; } @@ -124,11 +124,14 @@ bool Backend::disconnectNodes(QObject *source, QObject *target) TRACE_CONTEXT(Backend::disconnectNodes, EBackend); TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); - Q_UNUSED(source); // silence warnings in release builds - Q_UNUSED(target); // silence warnings in release builds + MediaObject *const mediaObject = qobject_cast<MediaObject *>(source); + AudioOutput *const audioOutput = qobject_cast<AudioOutput *>(target); + VideoWidget *const videoWidget = qobject_cast<VideoWidget *>(target); bool result = true; + // TODO: disconnection + TRACE_RETURN("%d", result); } diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index bf0356e..82c671c 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -377,3 +377,13 @@ void MMF::MediaObject::volumeChanged(qreal volume) } +//----------------------------------------------------------------------------- +// Video output +//----------------------------------------------------------------------------- + +void MMF::MediaObject::setVideoOutput(VideoOutput* videoOutput) +{ + m_player->setVideoOutput(videoOutput); +} + + diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 2e12b72..130b7e1 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -33,8 +33,8 @@ namespace Phonon { namespace MMF { - class AbstractPlayer; - class AudioOutput; + class AbstractPlayer; + class VideoOutput; /** * @short Facade class which wraps MMF client utility instance @@ -73,7 +73,9 @@ namespace Phonon virtual void setTransitionTime(qint32); // VolumeObserver - void volumeChanged(qreal volume); + void volumeChanged(qreal volume); + + void setVideoOutput(VideoOutput* videoOutput); Q_SIGNALS: void totalTimeChanged(); diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 5e32b28..3079668 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -30,12 +30,18 @@ using namespace Phonon::MMF; MMF::VideoOutput::VideoOutput(QWidget* parent) : QWidget(parent) { - + TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal); + TRACE_ENTRY("parent 0x%08x", parent); + + TRACE_EXIT_0(); } MMF::VideoOutput::~VideoOutput() { - + TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal); + TRACE_ENTRY_0(); + + TRACE_EXIT_0(); } diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index 3868672..4bffce3 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -33,14 +33,19 @@ using namespace Phonon::MMF; // Constructor / destructor //----------------------------------------------------------------------------- -MMF::VideoPlayer::VideoPlayer() : m_widget(new VideoOutput(NULL)) +MMF::VideoPlayer::VideoPlayer() + : m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) { construct(); } MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) - : AbstractMediaPlayer(player) - , m_widget(new VideoOutput(NULL)) // TODO: copy?? + : AbstractMediaPlayer(player) + , m_wsSession(NULL) + , m_screenDevice(NULL) + , m_window(NULL) { construct(); } @@ -50,26 +55,26 @@ void MMF::VideoPlayer::construct() TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); TRACE_ENTRY_0(); - CCoeControl* control = m_widget->winId(); - CCoeEnv* coeEnv = control->ControlEnv(); + if(!m_videoOutput) + { + m_dummyVideoOutput.reset(new VideoOutput(NULL)); + } const TInt priority = 0; const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; - RWsSession& wsSession = coeEnv->WsSession(); - CWsScreenDevice& screenDevice = *(coeEnv->ScreenDevice()); - RDrawableWindow& window = *(control->DrawableWindow()); - const TRect screenRect = control->Rect(); - const TRect clipRect = control->Rect(); - // TODO: is this the correct way to handle errors in constructing Symbian objects? + getNativeWindowSystemHandles(); + + // TODO: is this the correct way to handle errors which occur when + // creating a Symbian object in the constructor of a Qt object? TRAPD(err, m_player = CVideoPlayerUtility::NewL ( *this, priority, preference, - wsSession, screenDevice, - window, - screenRect, clipRect + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect ) ); @@ -282,4 +287,83 @@ void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) } +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- +VideoOutput& MMF::VideoPlayer::videoOutput() +{ + TRACE_CONTEXT(VideoPlayer::videoOutput, EVideoInternal); + TRACE("videoOutput 0x%08x dummy 0x%08x", m_videoOutput, m_dummyVideoOutput.data()); + + return m_videoOutput ? *m_videoOutput : *m_dummyVideoOutput; +} + +void MMF::VideoPlayer::videoOutputChanged() +{ + TRACE_CONTEXT(VideoPlayer::videoOutputChanged, EVideoInternal); + TRACE_ENTRY_0(); + + // Lazily construct a dummy output if needed here + if(!m_videoOutput and m_dummyVideoOutput.isNull()) + { + m_dummyVideoOutput.reset(new VideoOutput(NULL)); + } + + getNativeWindowSystemHandles(); + + TRAPD(err, + m_player->SetDisplayWindowL + ( + *m_wsSession, *m_screenDevice, + *m_window, + m_windowRect, m_clipRect + ) + ); + + if(KErrNone != err) + { + TRACE("SetDisplayWindowL error %d", err); + setError(NormalError); + } + + TRACE_EXIT_0(); +} + +void MMF::VideoPlayer::getNativeWindowSystemHandles() +{ + TRACE_CONTEXT(VideoPlayer::getNativeWindowSystemHandles, EVideoInternal); + + CCoeControl* const control = videoOutput().winId(); + + TRACE("control 0x%08x", control); + TRACE("control isVisible %d", control->IsVisible()); + TRACE("control isDimmed %d", control->IsDimmed()); + TRACE("control hasBorder %d", control->HasBorder()); + TRACE("control position %d %d", + control->Position().iX, control->Position().iY); + TRACE("control rect %d %d - %d %d", + control->Rect().iTl.iX, control->Rect().iTl.iY, + control->Rect().iBr.iX, control->Rect().iBr.iY); + + CCoeEnv* const coeEnv = control->ControlEnv(); + + m_wsSession = &(coeEnv->WsSession()); + + TRACE("session handle %d", m_wsSession->Handle()); + + m_screenDevice = coeEnv->ScreenDevice(); + + TRACE("device srv handle %d", m_screenDevice->WsHandle()); + + m_window = control->DrawableWindow(); + + TRACE("window cli handle %d", m_window->ClientHandle()); + TRACE("window srv handle %d", m_window->WsHandle()); + TRACE("window group %d", m_window->WindowGroupId()); + TRACE("window position %d %d", + m_window->Position().iX, m_window->Position().iY); + + m_windowRect = control->Rect(); + m_clipRect = control->Rect(); +} diff --git a/src/3rdparty/phonon/mmf/videoplayer.h b/src/3rdparty/phonon/mmf/videoplayer.h index ce3b3ac..e784812 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.h +++ b/src/3rdparty/phonon/mmf/videoplayer.h @@ -24,7 +24,6 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include "abstractmediaplayer.h" #include "videooutput.h" -class CVideoPlayerUtility; namespace Phonon { @@ -76,11 +75,24 @@ namespace Phonon private: void construct(); + VideoOutput& videoOutput(); + + // AbstractPlayer + virtual void videoOutputChanged(); + + void getNativeWindowSystemHandles(); private: CVideoPlayerUtility* m_player; - QScopedPointer<VideoOutput> m_widget; + QScopedPointer<VideoOutput> m_dummyVideoOutput; + // Not owned + RWsSession* m_wsSession; + CWsScreenDevice* m_screenDevice; + RWindowBase* m_window; + TRect m_windowRect; + TRect m_clipRect; + }; } } diff --git a/src/3rdparty/phonon/mmf/videowidget.cpp b/src/3rdparty/phonon/mmf/videowidget.cpp index e08fcea..7849109 100644 --- a/src/3rdparty/phonon/mmf/videowidget.cpp +++ b/src/3rdparty/phonon/mmf/videowidget.cpp @@ -17,6 +17,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. */ #include "utils.h" +#include "videooutput.h" #include "videowidget.h" using namespace Phonon; @@ -41,7 +42,7 @@ static const qreal DefaultSaturation = 1.0; //----------------------------------------------------------------------------- MMF::VideoWidget::VideoWidget(QWidget* parent) - : m_widget(new VideoOutput(parent)) + : m_videoOutput(new VideoOutput(parent)) , m_aspectRatio(DefaultAspectRatio) , m_brightness(DefaultBrightness) , m_scaleMode(DefaultScaleMode) @@ -149,6 +150,11 @@ void MMF::VideoWidget::setSaturation(qreal saturation) QWidget* MMF::VideoWidget::widget() { - return m_widget.data(); + return m_videoOutput.data(); +} + +VideoOutput& MMF::VideoWidget::videoOutput() +{ + return *m_videoOutput; } diff --git a/src/3rdparty/phonon/mmf/videowidget.h b/src/3rdparty/phonon/mmf/videowidget.h index 6967f7e..5c27c7f 100644 --- a/src/3rdparty/phonon/mmf/videowidget.h +++ b/src/3rdparty/phonon/mmf/videowidget.h @@ -22,12 +22,13 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include <QtGui/QWidget> #include <phonon/videowidget.h> #include <phonon/videowidgetinterface.h> -#include "videooutput.h" namespace Phonon { namespace MMF { + class VideoOutput; + class VideoWidget : public QObject , public Phonon::VideoWidgetInterface { @@ -53,8 +54,10 @@ namespace Phonon virtual void setSaturation(qreal saturation); virtual QWidget *widget(); + VideoOutput& videoOutput(); + private: - QScopedPointer<VideoOutput> m_widget; + QScopedPointer<VideoOutput> m_videoOutput; Phonon::VideoWidget::AspectRatio m_aspectRatio; qreal m_brightness; |