summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/mmf/videooutput.cpp
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2009-11-06 17:00:12 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2009-11-13 16:28:27 (GMT)
commit3328e0ee94b94c83fe9d64f741bede6725f5c952 (patch)
tree616c02a944a96c75181bae060c3c028e47b2b4bd /src/3rdparty/phonon/mmf/videooutput.cpp
parentb880e4d85caf17e43eb3bd4c9f358ca6f181a790 (diff)
downloadQt-3328e0ee94b94c83fe9d64f741bede6725f5c952.zip
Qt-3328e0ee94b94c83fe9d64f741bede6725f5c952.tar.gz
Qt-3328e0ee94b94c83fe9d64f741bede6725f5c952.tar.bz2
Implemented aspect ratio and scale mode handling in Phonon MMF backend
- Replaced VolumeObserver and VideoOutputObserver interfaces with signals. - Added signals for propagating changes in aspect ratio and scale mode from VideoOutput to VideoPlayer. - Removed VideoPlayer::getNativeWindowSystemHandles. Interaction with window system is moved into VideoOutput, so that VideoPlayer is better focussed on its main task: interacting with CVideoPlayerUtility. - WId changes, resize and move events received by the VideoOutput widget cause it to emit a videoWindowChanged signal. This is received by the VideoPlayer, which triggers a call to updateVideoRect. The main task of this function is to calculate the scale factors which are provided to the MMF via CVideoPlayerUtility::SetScaleFactorL. Note that: i) This function must be called both before and after the call to SetDisplayWindowL. For changes in aspect ratio or scale mode, setting the scale mode after updating the display window is sufficient. However, testing showed that, when switching in or out of full-screen mode, two calls were necessary in order to preserve the correct aspect ratio. ii) The screen rectangle passed to the MMF is still the full window extent; it is not the region in which video will actually be rendered. The post-processor will fill in the remainder of the window with a background colour (typically black). If, on the other hand, we passed in the actual video display rectangle, we would need to do this background painting in the widget. This in turn would require a change to QtGui: at present, we can only disable blitting on a per-widget basis (by setting QWExtra::disableBlit). If we needed to paint the borders of the video window, disableBlit would need to contain the actual DSA region, rather than just a single boolean flag. Task-number: QTBUG-5585 Reviewed-by: Frans Englich
Diffstat (limited to 'src/3rdparty/phonon/mmf/videooutput.cpp')
-rw-r--r--src/3rdparty/phonon/mmf/videooutput.cpp135
1 files changed, 107 insertions, 28 deletions
diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp
index 5288b4d..6b6f71a 100644
--- a/src/3rdparty/phonon/mmf/videooutput.cpp
+++ b/src/3rdparty/phonon/mmf/videooutput.cpp
@@ -19,7 +19,6 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "ancestormovemonitor.h"
#include "utils.h"
#include "videooutput.h"
-#include "videooutputobserver.h"
#ifndef QT_NO_DEBUG
#include "objectdump.h"
@@ -30,8 +29,11 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <QMoveEvent>
#include <QResizeEvent>
+#include <QtCore/private/qcore_symbian_p.h> // for qt_TRect2QRect
#include <QtGui/private/qwidget_p.h> // to access QWExtra
+#include <coecntrl.h>
+
QT_BEGIN_NAMESPACE
using namespace Phonon;
@@ -42,6 +44,16 @@ using namespace Phonon::MMF;
*/
//-----------------------------------------------------------------------------
+// Constants
+//-----------------------------------------------------------------------------
+
+static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio =
+ Phonon::VideoWidget::AspectRatioAuto;
+static const Phonon::VideoWidget::ScaleMode DefaultScaleMode =
+ Phonon::VideoWidget::FitInView;
+
+
+//-----------------------------------------------------------------------------
// Constructor / destructor
//-----------------------------------------------------------------------------
@@ -49,7 +61,8 @@ MMF::VideoOutput::VideoOutput
(AncestorMoveMonitor* ancestorMoveMonitor, QWidget* parent)
: QWidget(parent)
, m_ancestorMoveMonitor(ancestorMoveMonitor)
- , m_observer(0)
+ , m_aspectRatio(DefaultAspectRatio)
+ , m_scaleMode(DefaultScaleMode)
{
TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal);
TRACE_ENTRY("parent 0x%08x", parent);
@@ -66,6 +79,7 @@ MMF::VideoOutput::VideoOutput
// to be invisible when running on the target device.
qt_widget_private(this)->extraData()->disableBlit = true;
+ getVideoWindowRect();
registerForAncestorMoved();
dump();
@@ -83,33 +97,35 @@ MMF::VideoOutput::~VideoOutput()
TRACE_EXIT_0();
}
-void MMF::VideoOutput::setFrameSize(const QSize& frameSize)
+void MMF::VideoOutput::setVideoSize(const QSize& frameSize)
{
- TRACE_CONTEXT(VideoOutput::setFrameSize, EVideoInternal);
+ TRACE_CONTEXT(VideoOutput::setVideoSize, EVideoInternal);
TRACE("oldSize %d %d newSize %d %d",
- m_frameSize.width(), m_frameSize.height(),
+ m_videoFrameSize.width(), m_videoFrameSize.height(),
frameSize.width(), frameSize.height());
- if (frameSize != m_frameSize) {
- m_frameSize = frameSize;
+ if (frameSize != m_videoFrameSize) {
+ m_videoFrameSize = frameSize;
updateGeometry();
}
}
-void MMF::VideoOutput::setObserver(VideoOutputObserver* observer)
-{
- TRACE_CONTEXT(VideoOutput::setObserver, EVideoInternal);
- TRACE("observer 0x%08x", observer);
-
- m_observer = observer;
-}
-
void MMF::VideoOutput::ancestorMoved()
{
TRACE_CONTEXT(VideoOutput::ancestorMoved, EVideoInternal);
TRACE_ENTRY_0();
- videoOutputRegionChanged();
+ RWindowBase *const window = videoWindow();
+
+ if(window) {
+ const TPoint newWindowPosSymbian = window->AbsPosition();
+ const QPoint newWindowPos(newWindowPosSymbian.iX, newWindowPosSymbian.iY);
+
+ if(newWindowPos != m_videoWindowRect.topLeft()) {
+ m_videoWindowRect.moveTo(newWindowPos);
+ emit videoWindowChanged();
+ }
+ }
TRACE_EXIT_0();
}
@@ -123,9 +139,8 @@ QSize MMF::VideoOutput::sizeHint() const
// TODO: replace this with a more sensible default
QSize result(320, 240);
- if (!m_frameSize.isNull()) {
- result = m_frameSize;
- }
+ if (!m_videoFrameSize.isNull())
+ result = m_videoFrameSize;
return result;
}
@@ -149,7 +164,10 @@ void MMF::VideoOutput::resizeEvent(QResizeEvent* event)
event->oldSize().width(), event->oldSize().height(),
event->size().width(), event->size().height());
- videoOutputRegionChanged();
+ if(event->size() != event->oldSize()) {
+ m_videoWindowRect.setSize(event->size());
+ emit videoWindowChanged();
+ }
}
void MMF::VideoOutput::moveEvent(QMoveEvent* event)
@@ -159,7 +177,10 @@ void MMF::VideoOutput::moveEvent(QMoveEvent* event)
event->oldPos().x(), event->oldPos().y(),
event->pos().x(), event->pos().y());
- videoOutputRegionChanged();
+ if(event->pos() != event->oldPos()) {
+ m_videoWindowRect.moveTo(event->pos());
+ emit videoWindowChanged();
+ }
}
bool MMF::VideoOutput::event(QEvent* event)
@@ -168,7 +189,8 @@ bool MMF::VideoOutput::event(QEvent* event)
if (event->type() == QEvent::WinIdChange) {
TRACE_0("WinIdChange");
- videoOutputRegionChanged();
+ getVideoWindowRect();
+ emit videoWindowChanged();
return true;
} else if (event->type() == QEvent::ParentChange) {
// Tell ancestor move monitor to update ancestor list for this widget
@@ -180,14 +202,66 @@ bool MMF::VideoOutput::event(QEvent* event)
//-----------------------------------------------------------------------------
+// Public functions
+//-----------------------------------------------------------------------------
+
+RWindowBase* MMF::VideoOutput::videoWindow()
+{
+ CCoeControl *control = internalWinId();
+ if(!control)
+ control = effectiveWinId();
+
+ RWindowBase *window = 0;
+ if(control)
+ window = control->DrawableWindow();
+
+ return window;
+}
+
+const QRect& MMF::VideoOutput::videoWindowRect() const
+{
+ return m_videoWindowRect;
+}
+
+Phonon::VideoWidget::AspectRatio MMF::VideoOutput::aspectRatio() const
+{
+ return m_aspectRatio;
+}
+
+void MMF::VideoOutput::setAspectRatio
+ (Phonon::VideoWidget::AspectRatio aspectRatio)
+{
+ if(m_aspectRatio != aspectRatio) {
+ m_aspectRatio = aspectRatio;
+ emit aspectRatioChanged();
+ }
+}
+
+Phonon::VideoWidget::ScaleMode MMF::VideoOutput::scaleMode() const
+{
+ return m_scaleMode;
+}
+
+void MMF::VideoOutput::setScaleMode
+ (Phonon::VideoWidget::ScaleMode scaleMode)
+{
+ if(m_scaleMode != scaleMode) {
+ m_scaleMode = scaleMode;
+ emit scaleModeChanged();
+ }
+}
+
+
+//-----------------------------------------------------------------------------
// Private functions
//-----------------------------------------------------------------------------
-void MMF::VideoOutput::videoOutputRegionChanged()
+void MMF::VideoOutput::getVideoWindowRect()
{
- dump();
- if (m_observer)
- m_observer->videoOutputRegionChanged();
+ RWindowBase *const window = videoWindow();
+ if(window)
+ m_videoWindowRect =
+ qt_TRect2QRect(TRect(window->AbsPosition(), window->Size()));
}
void MMF::VideoOutput::registerForAncestorMoved()
@@ -199,15 +273,20 @@ void MMF::VideoOutput::dump() const
{
#ifndef QT_NO_DEBUG
TRACE_CONTEXT(VideoOutput::dump, EVideoInternal);
+
QScopedPointer<ObjectDump::QVisitor> visitor(new ObjectDump::QVisitor);
visitor->setPrefix("Phonon::MMF"); // to aid searchability of logs
ObjectDump::addDefaultAnnotators(*visitor);
TRACE("Dumping tree from leaf 0x%08x:", this);
- //ObjectDump::dumpAncestors(*this, *visitor);
ObjectDump::dumpTreeFromLeaf(*this, *visitor);
+
+ QScopedPointer<ObjectDump::QDumper> dumper(new ObjectDump::QDumper);
+ dumper->setPrefix("Phonon::MMF"); // to aid searchability of logs
+ ObjectDump::addDefaultAnnotators(*dumper);
+ TRACE_0("Dumping VideoOutput:");
+ dumper->dumpObject(*this);
#endif
}
-
QT_END_NAMESPACE