summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-26 05:50:54 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-26 05:50:54 (GMT)
commitfd330a5a6009c17e28fb9eb36b5bffbc19c5df68 (patch)
tree16025a01c1aa172fb497b31c3bf8f8fc4edf691c
parentc55ac19acfcad0e204d9e9dc47fb4bf891924e0a (diff)
parent31461202c1ee2979f88f9642192ab53a2bc7e8cf (diff)
downloadQt-fd330a5a6009c17e28fb9eb36b5bffbc19c5df68.zip
Qt-fd330a5a6009c17e28fb9eb36b5bffbc19c5df68.tar.gz
Qt-fd330a5a6009c17e28fb9eb36b5bffbc19c5df68.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging: Don't specify a BottomToTop scan line direction for YUV frames. Support expanding aspect ratio in direct show video window control. Support the Expanding aspect ratio mode in the gstreamer window control.
-rw-r--r--src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp28
-rw-r--r--src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp7
-rw-r--r--src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h3
-rw-r--r--src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp59
-rw-r--r--src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h4
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp19
-rw-r--r--src/plugins/mediaservices/gstreamer/qx11videosurface.cpp10
-rw-r--r--src/plugins/mediaservices/gstreamer/qx11videosurface.h3
8 files changed, 95 insertions, 38 deletions
diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp
index cf6d45b..f8f519d 100644
--- a/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp
+++ b/src/plugins/mediaservices/directshow/mediaplayer/directshowmediatype.cpp
@@ -130,9 +130,17 @@ QVideoSurfaceFormat DirectShowMediaType::formatFromType(const AM_MEDIA_TYPE &typ
if (header->AvgTimePerFrame > 0)
format.setFrameRate(10000 /header->AvgTimePerFrame);
- format.setScanLineDirection(header->bmiHeader.biHeight < 0
- ? QVideoSurfaceFormat::TopToBottom
- : QVideoSurfaceFormat::BottomToTop);
+ switch (qt_typeLookup[i].pixelFormat) {
+ case QVideoFrame::Format_RGB32:
+ case QVideoFrame::Format_BGR24:
+ case QVideoFrame::Format_RGB565:
+ case QVideoFrame::Format_RGB555:
+ if (header->bmiHeader.biHeight >= 0)
+ format.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
+ break;
+ default:
+ break;
+ }
return format;
} else if (IsEqualGUID(type.formattype, FORMAT_VideoInfo2)) {
@@ -145,9 +153,17 @@ QVideoSurfaceFormat DirectShowMediaType::formatFromType(const AM_MEDIA_TYPE &typ
if (header->AvgTimePerFrame > 0)
format.setFrameRate(10000 / header->AvgTimePerFrame);
- format.setScanLineDirection(header->bmiHeader.biHeight < 0
- ? QVideoSurfaceFormat::TopToBottom
- : QVideoSurfaceFormat::BottomToTop);
+ switch (qt_typeLookup[i].pixelFormat) {
+ case QVideoFrame::Format_RGB32:
+ case QVideoFrame::Format_BGR24:
+ case QVideoFrame::Format_RGB565:
+ case QVideoFrame::Format_RGB555:
+ if (header->bmiHeader.biHeight >= 0)
+ format.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
+ break;
+ default:
+ break;
+ }
return format;
}
diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp
index d54d188..a5f143f 100644
--- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp
+++ b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.cpp
@@ -191,6 +191,8 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream
m_atEnd = false;
m_metaDataControl->updateGraph(0, 0);
+ QCoreApplication::postEvent(this, new QEvent(QEvent::Type(VideoOutputChange)));
+
if (m_resources.isEmpty() && !stream) {
m_pendingTasks = 0;
m_graphStatus = NoMedia;
@@ -464,6 +466,8 @@ void DirectShowPlayerService::doRender(QMutexLocker *locker)
QCoreApplication::postEvent(this, new QEvent(QEvent::Type(Error)));
}
+ QCoreApplication::postEvent(this, new QEvent(QEvent::Type(VideoOutputChange)));
+
m_executedTasks |= Render;
}
}
@@ -1144,6 +1148,9 @@ void DirectShowPlayerService::customEvent(QEvent *event)
QMutexLocker locker(&m_mutex);
m_playerControl->updatePosition(m_position);
+ } else if (event->type() == QEvent::Type(VideoOutputChange)) {
+ if (m_videoWindowControl)
+ m_videoWindowControl->updateNativeSize();
} else {
QMediaService::customEvent(event);
}
diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h
index 23515d0..d3ef809 100644
--- a/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h
+++ b/src/plugins/mediaservices/directshow/mediaplayer/directshowplayerservice.h
@@ -164,7 +164,8 @@ private:
DurationChange,
StatusChange,
EndOfMedia,
- PositionChange
+ PositionChange,
+ VideoOutputChange
};
enum GraphStatus
diff --git a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp
index 4b9aeb8..e25dd99 100644
--- a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp
+++ b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp
@@ -51,6 +51,7 @@ Vmr9VideoWindowControl::Vmr9VideoWindowControl(QObject *parent)
, m_filter(com_new<IBaseFilter>(CLSID_VideoMixingRenderer9, IID_IBaseFilter))
, m_windowId(0)
, m_dirtyValues(0)
+ , m_aspectRatioMode(Qt::KeepAspectRatio)
, m_brightness(0)
, m_contrast(0)
, m_hue(0)
@@ -90,33 +91,30 @@ void Vmr9VideoWindowControl::setWinId(WId id)
QRect Vmr9VideoWindowControl::displayRect() const
{
- QRect rect;
-
- if (IVMRWindowlessControl9 *control = com_cast<IVMRWindowlessControl9>(
- m_filter, IID_IVMRWindowlessControl9)) {
- RECT sourceRect;
- RECT displayRect;
-
- if (control->GetVideoPosition(&sourceRect, &displayRect) == S_OK) {
- rect = QRect(
- displayRect.left,
- displayRect.bottom,
- displayRect.right - displayRect.left,
- displayRect.bottom - displayRect.top);
- }
- control->Release();
- }
- return rect;
+ return m_displayRect;
}
void Vmr9VideoWindowControl::setDisplayRect(const QRect &rect)
{
+ m_displayRect = rect;
+
if (IVMRWindowlessControl9 *control = com_cast<IVMRWindowlessControl9>(
m_filter, IID_IVMRWindowlessControl9)) {
RECT sourceRect = { 0, 0, 0, 0 };
RECT displayRect = { rect.left(), rect.top(), rect.right(), rect.bottom() };
control->GetNativeVideoSize(&sourceRect.right, &sourceRect.bottom, 0, 0);
+
+ if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) {
+ QSize clippedSize = rect.size();
+ clippedSize.scale(sourceRect.right, sourceRect.bottom, Qt::KeepAspectRatio);
+
+ sourceRect.left = (sourceRect.right - clippedSize.width()) / 2;
+ sourceRect.top = (sourceRect.bottom - clippedSize.height()) / 2;
+ sourceRect.right = sourceRect.left + clippedSize.width();
+ sourceRect.bottom = sourceRect.top + clippedSize.height();
+ }
+
control->SetVideoPosition(&sourceRect, &displayRect);
control->Release();
}
@@ -134,7 +132,6 @@ void Vmr9VideoWindowControl::setFullScreen(bool fullScreen)
void Vmr9VideoWindowControl::repaint()
{
-
if (QWidget *widget = QWidget::find(m_windowId)) {
HDC dc = widget->getDC();
if (IVMRWindowlessControl9 *control = com_cast<IVMRWindowlessControl9>(
@@ -164,21 +161,13 @@ QSize Vmr9VideoWindowControl::nativeSize() const
Qt::AspectRatioMode Vmr9VideoWindowControl::aspectRatioMode() const
{
- Qt::AspectRatioMode mode = Qt::KeepAspectRatio;
-
- if (IVMRWindowlessControl9 *control = com_cast<IVMRWindowlessControl9>(
- m_filter, IID_IVMRWindowlessControl9)) {
- DWORD arMode;
-
- if (control->GetAspectRatioMode(&arMode) == S_OK && arMode == VMR9ARMode_None)
- mode = Qt::IgnoreAspectRatio;
- control->Release();
- }
- return mode;
+ return m_aspectRatioMode;
}
void Vmr9VideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
{
+ m_aspectRatioMode = mode;
+
if (IVMRWindowlessControl9 *control = com_cast<IVMRWindowlessControl9>(
m_filter, IID_IVMRWindowlessControl9)) {
switch (mode) {
@@ -188,10 +177,15 @@ void Vmr9VideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
case Qt::KeepAspectRatio:
control->SetAspectRatioMode(VMR9ARMode_LetterBox);
break;
+ case Qt::KeepAspectRatioByExpanding:
+ control->SetAspectRatioMode(VMR9ARMode_LetterBox);
+ break;
default:
break;
}
control->Release();
+
+ setDisplayRect(m_displayRect);
}
}
@@ -259,6 +253,13 @@ void Vmr9VideoWindowControl::setSaturation(int saturation)
emit saturationChanged(saturation);
}
+void Vmr9VideoWindowControl::updateNativeSize()
+{
+ setDisplayRect(m_displayRect);
+
+ emit nativeSizeChanged();
+}
+
void Vmr9VideoWindowControl::setProcAmpValues()
{
if (IVMRMixerControl9 *control = com_cast<IVMRMixerControl9>(m_filter, IID_IVMRMixerControl9)) {
diff --git a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h
index bf4fb42..beac433 100644
--- a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h
+++ b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.h
@@ -90,6 +90,8 @@ public:
int saturation() const;
void setSaturation(int saturation);
+ void updateNativeSize();
+
private:
void setProcAmpValues();
float scaleProcAmpValue(
@@ -98,6 +100,8 @@ private:
IBaseFilter *m_filter;
WId m_windowId;
DWORD m_dirtyValues;
+ Qt::AspectRatioMode m_aspectRatioMode;
+ QRect m_displayRect;
int m_brightness;
int m_contrast;
int m_hue;
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp
index 427d514..f381f7f 100644
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp
+++ b/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp
@@ -192,21 +192,36 @@ void QGstreamerVideoOverlay::surfaceFormatChanged()
void QGstreamerVideoOverlay::setScaledDisplayRect()
{
+ QRect formatViewport = m_surface->surfaceFormat().viewport();
+
switch (m_aspectRatioMode) {
case Qt::KeepAspectRatio:
{
- QSize size = m_surface->surfaceFormat().viewport().size();
-
+ QSize size = m_surface->surfaceFormat().sizeHint();
size.scale(m_displayRect.size(), Qt::KeepAspectRatio);
QRect rect(QPoint(0, 0), size);
rect.moveCenter(m_displayRect.center());
m_surface->setDisplayRect(rect);
+ m_surface->setViewport(formatViewport);
}
break;
case Qt::IgnoreAspectRatio:
m_surface->setDisplayRect(m_displayRect);
+ m_surface->setViewport(formatViewport);
+ break;
+ case Qt::KeepAspectRatioByExpanding:
+ {
+ QSize size = m_displayRect.size();
+ size.scale(m_surface->surfaceFormat().sizeHint(), Qt::KeepAspectRatio);
+
+ QRect viewport(QPoint(0, 0), size);
+ viewport.moveCenter(formatViewport.center());
+
+ m_surface->setDisplayRect(m_displayRect);
+ m_surface->setViewport(viewport);
+ }
break;
};
}
diff --git a/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp b/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp
index cbd5a76..70b8527 100644
--- a/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp
+++ b/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp
@@ -213,6 +213,16 @@ void QX11VideoSurface::setDisplayRect(const QRect &rect)
m_displayRect = rect;
}
+QRect QX11VideoSurface::viewport() const
+{
+ return m_viewport;
+}
+
+void QX11VideoSurface::setViewport(const QRect &rect)
+{
+ m_viewport = rect;
+}
+
int QX11VideoSurface::brightness() const
{
return getAttribute("XV_BRIGHTNESS", m_brightnessRange.first, m_brightnessRange.second);
diff --git a/src/plugins/mediaservices/gstreamer/qx11videosurface.h b/src/plugins/mediaservices/gstreamer/qx11videosurface.h
index 1be963e..10f79a6 100644
--- a/src/plugins/mediaservices/gstreamer/qx11videosurface.h
+++ b/src/plugins/mediaservices/gstreamer/qx11videosurface.h
@@ -67,6 +67,9 @@ public:
QRect displayRect() const;
void setDisplayRect(const QRect &rect);
+ QRect viewport() const;
+ void setViewport(const QRect &rect);
+
int brightness() const;
void setBrightness(int brightness);