summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/mmf/videooutput.cpp
diff options
context:
space:
mode:
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 1b338a2..ddf30de 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