diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2010-03-30 13:49:21 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2010-03-30 13:49:21 (GMT) |
commit | 00f7426f3906361fb5addb36e428648eee5e2983 (patch) | |
tree | c299b0f6f323ea2f37161cfdf5b2fb33bbe35673 /src/plugins | |
parent | 429b747d492ef038c2ed58a9a72060d951721252 (diff) | |
parent | ae305abfdb795b472b2b9d200bf3b11af00d7d1f (diff) | |
download | Qt-00f7426f3906361fb5addb36e428648eee5e2983.zip Qt-00f7426f3906361fb5addb36e428648eee5e2983.tar.gz Qt-00f7426f3906361fb5addb36e428648eee5e2983.tar.bz2 |
Merge remote branch 'origin/4.7' into 4.7
Conflicts:
src/3rdparty/phonon/ds9/iodevicereader.cpp
Diffstat (limited to 'src/plugins')
18 files changed, 299 insertions, 100 deletions
diff --git a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp index e25dd99..1c6df2c 100644 --- a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp +++ b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp @@ -61,6 +61,7 @@ Vmr9VideoWindowControl::Vmr9VideoWindowControl(QObject *parent) if (IVMRFilterConfig9 *config = com_cast<IVMRFilterConfig9>(m_filter, IID_IVMRFilterConfig9)) { config->SetRenderingMode(VMR9Mode_Windowless); config->SetNumberOfStreams(1); + config->SetRenderingPrefs(RenderPrefs9_DoNotRenderBorder); config->Release(); } } diff --git a/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp b/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp index 589d2b5..98068ac 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamerserviceplugin.cpp @@ -52,9 +52,9 @@ #ifdef QMEDIA_GSTREAMER_CAPTURE #include "qgstreamercaptureservice.h" #endif - #include <QtMultimedia/qmediaserviceprovider.h> +#ifdef QMEDIA_GSTREAMER_CAPTURE #include <linux/types.h> #include <sys/time.h> #include <sys/ioctl.h> @@ -66,6 +66,7 @@ #include <stdlib.h> #include <sys/mman.h> #include <linux/videodev2.h> +#endif QT_BEGIN_NAMESPACE @@ -109,18 +110,21 @@ void QGstreamerServicePlugin::release(QMediaService *service) QList<QByteArray> QGstreamerServicePlugin::devices(const QByteArray &service) const { +#ifdef QMEDIA_GSTREAMER_CAPTURE if (service == Q_MEDIASERVICE_CAMERA) { if (m_cameraDevices.isEmpty()) updateDevices(); return m_cameraDevices; } +#endif return QList<QByteArray>(); } QString QGstreamerServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device) { +#ifdef QMEDIA_GSTREAMER_CAPTURE if (service == Q_MEDIASERVICE_CAMERA) { if (m_cameraDevices.isEmpty()) updateDevices(); @@ -129,12 +133,14 @@ QString QGstreamerServicePlugin::deviceDescription(const QByteArray &service, co if (m_cameraDevices[i] == device) return m_cameraDescriptions[i]; } +#endif return QString(); } void QGstreamerServicePlugin::updateDevices() const { +#ifdef QMEDIA_GSTREAMER_CAPTURE m_cameraDevices.clear(); m_cameraDescriptions.clear(); @@ -178,6 +184,7 @@ void QGstreamerServicePlugin::updateDevices() const } ::close(fd); } +#endif } Q_EXPORT_PLUGIN2(gstengine, QGstreamerServicePlugin); diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp index 406cefe11..4ecf10b 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp @@ -117,6 +117,7 @@ void QGstreamerVideoInputDeviceControl::update() m_names.clear(); m_descriptions.clear(); +#ifdef QMEDIA_GSTREAMER_CAPTURE QDir devDir("/dev"); devDir.setFilter(QDir::System); @@ -157,6 +158,7 @@ void QGstreamerVideoInputDeviceControl::update() } ::close(fd); } +#endif } QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm index d83c0e3..65c9f7d 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm @@ -128,25 +128,25 @@ - (void) processEOS:(NSNotification *)notification { Q_UNUSED(notification); - m_session->processEOS(); + QMetaObject::invokeMethod(m_session, "processEOS", Qt::AutoConnection); } - (void) processLoadStateChange:(NSNotification *)notification { Q_UNUSED(notification); - m_session->processLoadStateChange(); + QMetaObject::invokeMethod(m_session, "processLoadStateChange", Qt::AutoConnection); } - (void) processVolumeChange:(NSNotification *)notification { Q_UNUSED(notification); - m_session->processVolumeChange(); + QMetaObject::invokeMethod(m_session, "processVolumeChange", Qt::AutoConnection); } - (void) processNaturalSizeChange :(NSNotification *)notification { Q_UNUSED(notification); - m_session->processNaturalSizeChange(); + QMetaObject::invokeMethod(m_session, "processNaturalSizeChange", Qt::AutoConnection); } @end @@ -193,17 +193,13 @@ void QT7PlayerSession::setVideoOutput(QT7VideoOutput *output) if (m_videoOutput == output) return; - if (m_videoOutput) { - m_videoOutput->setEnabled(false); + if (m_videoOutput) m_videoOutput->setMovie(0); - } m_videoOutput = output; - if (m_videoOutput) { - m_videoOutput->setEnabled(m_QTMovie != 0); + if (m_videoOutput && m_state != QMediaPlayer::StoppedState) m_videoOutput->setMovie(m_QTMovie); - } } @@ -297,6 +293,9 @@ void QT7PlayerSession::setPosition(qint64 pos) void QT7PlayerSession::play() { + if (m_videoOutput) + m_videoOutput->setMovie(m_QTMovie); + float preferredRate = [[(QTMovie*)m_QTMovie attributeForKey:@"QTMoviePreferredRateAttribute"] floatValue]; [(QTMovie*)m_QTMovie setRate:preferredRate*m_rate]; @@ -306,6 +305,9 @@ void QT7PlayerSession::play() void QT7PlayerSession::pause() { + if (m_videoOutput) + m_videoOutput->setMovie(m_QTMovie); + m_state = QMediaPlayer::PausedState; [(QTMovie*)m_QTMovie setRate:0]; @@ -320,6 +322,9 @@ void QT7PlayerSession::stop() [(QTMovie*)m_QTMovie setRate:0]; setPosition(0); + if (m_videoOutput) + m_videoOutput->setMovie(0); + if (m_state == QMediaPlayer::StoppedState) emit stateChanged(m_state); } @@ -361,10 +366,8 @@ void QT7PlayerSession::setMedia(const QMediaContent &content, QIODevice *stream) if (m_QTMovie) { [(QTMovieObserver*)m_movieObserver setMovie:nil]; - if (m_videoOutput) { - m_videoOutput->setEnabled(false); + if (m_videoOutput) m_videoOutput->setMovie(0); - } [(QTMovie*)m_QTMovie release]; m_QTMovie = 0; @@ -425,10 +428,9 @@ void QT7PlayerSession::setMedia(const QMediaContent &content, QIODevice *stream) } else { [(QTMovieObserver*)m_movieObserver setMovie:(QTMovie*)m_QTMovie]; - if (m_videoOutput) { + if (m_videoOutput && m_state != QMediaPlayer::StoppedState) m_videoOutput->setMovie(m_QTMovie); - m_videoOutput->setEnabled(true); - } + processLoadStateChange(); [(QTMovie*)m_QTMovie setMuted:m_muted]; @@ -457,6 +459,8 @@ bool QT7PlayerSession::isVideoAvailable() const void QT7PlayerSession::processEOS() { m_mediaStatus = QMediaPlayer::EndOfMedia; + if (m_videoOutput) + m_videoOutput->setMovie(0); emit stateChanged(m_state = QMediaPlayer::StoppedState); emit mediaStatusChanged(m_mediaStatus); } @@ -493,6 +497,9 @@ void QT7PlayerSession::processLoadStateChange() if (state == kMovieLoadStateError) { newStatus = QMediaPlayer::InvalidMedia; + if (m_videoOutput) + m_videoOutput->setMovie(0); + emit error(QMediaPlayer::FormatError, tr("Failed to load media")); emit stateChanged(m_state = QMediaPlayer::StoppedState); } diff --git a/src/plugins/mediaservices/qt7/qt7.pro b/src/plugins/mediaservices/qt7/qt7.pro index 6624d13..8791d73 100644 --- a/src/plugins/mediaservices/qt7/qt7.pro +++ b/src/plugins/mediaservices/qt7/qt7.pro @@ -25,6 +25,7 @@ HEADERS += \ qt7movieviewrenderer.h \ qt7serviceplugin.h \ qt7movierenderer.h \ + qt7ciimagevideobuffer.h \ qcvdisplaylink.h OBJECTIVE_SOURCES += \ @@ -35,6 +36,7 @@ OBJECTIVE_SOURCES += \ qt7movieviewrenderer.mm \ qt7movierenderer.mm \ qt7videooutputcontrol.mm \ + qt7ciimagevideobuffer.mm \ qcvdisplaylink.mm include(mediaplayer/mediaplayer.pri) diff --git a/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.h b/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.h new file mode 100644 index 0000000..669724f --- /dev/null +++ b/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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 QT7CIIMAGEVIDEOBUFFER_H +#define QT7CIIMAGEVIDEOBUFFER_H + +#include "qt7backend.h" +#import <QTKit/QTKit.h> + +#include <QtCore/qvariant.h> +#include <QtMultimedia/qabstractvideobuffer.h> + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QT7CIImageVideoBuffer : public QAbstractVideoBuffer +{ +public: + QT7CIImageVideoBuffer(CIImage *image); + + virtual ~QT7CIImageVideoBuffer(); + + MapMode mapMode() const; + uchar *map(MapMode mode, int *numBytes, int *bytesPerLine); + void unmap(); + QVariant handle() const; + +private: + CIImage *m_image; + NSBitmapImageRep *m_buffer; + MapMode m_mode; +}; + + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.mm b/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.mm new file mode 100644 index 0000000..3778b58 --- /dev/null +++ b/src/plugins/mediaservices/qt7/qt7ciimagevideobuffer.mm @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** 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 "qt7ciimagevideobuffer.h" + +QT7CIImageVideoBuffer::QT7CIImageVideoBuffer(CIImage *image) + : QAbstractVideoBuffer(CoreImageHandle) + , m_image(image) + , m_buffer(0) + , m_mode(NotMapped) +{ + [m_image retain]; +} + +QT7CIImageVideoBuffer::~QT7CIImageVideoBuffer() +{ + [m_image release]; + [m_buffer release]; +} + +QAbstractVideoBuffer::MapMode QT7CIImageVideoBuffer::mapMode() const +{ + return m_mode; +} + +uchar *QT7CIImageVideoBuffer::map(QAbstractVideoBuffer::MapMode mode, int *numBytes, int *bytesPerLine) +{ + if (mode == NotMapped || m_mode != NotMapped || !m_image) + return 0; + + if (!m_buffer) { + //swap R and B channels + CIFilter *colorSwapFilter = [CIFilter filterWithName: @"CIColorMatrix" keysAndValues: + @"inputImage", m_image, + @"inputRVector", [CIVector vectorWithX: 0 Y: 0 Z: 1 W: 0], + @"inputGVector", [CIVector vectorWithX: 0 Y: 1 Z: 0 W: 0], + @"inputBVector", [CIVector vectorWithX: 1 Y: 0 Z: 0 W: 0], + @"inputAVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 1], + @"inputBiasVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 0], + nil]; + CIImage *img = [colorSwapFilter valueForKey: @"outputImage"]; + + m_buffer = [[NSBitmapImageRep alloc] initWithCIImage:img]; + } + + if (numBytes) + *numBytes = [m_buffer bytesPerPlane]; + + if (bytesPerLine) + *bytesPerLine = [m_buffer bytesPerRow]; + + m_mode = mode; + + return [m_buffer bitmapData]; +} + +void QT7CIImageVideoBuffer::unmap() +{ + m_mode = NotMapped; +} + +QVariant QT7CIImageVideoBuffer::handle() const +{ + return QVariant::fromValue<void*>(m_image); +} + diff --git a/src/plugins/mediaservices/qt7/qt7movierenderer.h b/src/plugins/mediaservices/qt7/qt7movierenderer.h index a547329..c2dd177 100644 --- a/src/plugins/mediaservices/qt7/qt7movierenderer.h +++ b/src/plugins/mediaservices/qt7/qt7movierenderer.h @@ -74,7 +74,6 @@ public: QT7MovieRenderer(QObject *parent = 0); virtual ~QT7MovieRenderer(); - void setEnabled(bool); void setMovie(void *movie); void updateNaturalSize(const QSize &newSize); diff --git a/src/plugins/mediaservices/qt7/qt7movierenderer.mm b/src/plugins/mediaservices/qt7/qt7movierenderer.mm index 1c1f5e4..95f5d4c 100644 --- a/src/plugins/mediaservices/qt7/qt7movierenderer.mm +++ b/src/plugins/mediaservices/qt7/qt7movierenderer.mm @@ -46,6 +46,7 @@ #include "qt7playercontrol.h" #include "qt7movierenderer.h" #include "qt7playersession.h" +#include "qt7ciimagevideobuffer.h" #include "qcvdisplaylink.h" #include <QtCore/qdebug.h> #include <QtCore/qcoreapplication.h> @@ -64,7 +65,7 @@ class CVGLTextureVideoBuffer : public QAbstractVideoBuffer { public: CVGLTextureVideoBuffer(CVOpenGLTextureRef buffer) - : QAbstractVideoBuffer(NoHandle) + : QAbstractVideoBuffer(GLTextureHandle) , m_buffer(buffer) , m_mode(NotMapped) { @@ -82,11 +83,6 @@ public: return QVariant(int(id)); } - HandleType handleType() const - { - return GLTextureHandle; - } - MapMode mapMode() const { return m_mode; } uchar *map(MapMode mode, int *numBytes, int *bytesPerLine) @@ -372,10 +368,6 @@ void QT7MovieRenderer::setupVideoOutput() } -void QT7MovieRenderer::setEnabled(bool) -{ -} - void QT7MovieRenderer::setMovie(void *movie) { // qDebug() << "QT7MovieRenderer::setMovie" << movie; @@ -447,15 +439,14 @@ void QT7MovieRenderer::updateVideoFrame(const CVTimeStamp &ts) OSStatus status = QTVisualContextCopyImageForTime(m_visualContext, NULL, &ts, &imageBuffer); if (status == noErr && imageBuffer) { - //qDebug() << "render video frame"; QAbstractVideoBuffer *buffer = 0; if (m_usingGLContext) { - buffer = new CVGLTextureVideoBuffer((CVOpenGLTextureRef)imageBuffer); + buffer = new QT7CIImageVideoBuffer([CIImage imageWithCVImageBuffer:imageBuffer]); CVOpenGLTextureRelease((CVOpenGLTextureRef)imageBuffer); - //qDebug() << "render GL video frame" << buffer->handle(); } else { buffer = new CVPixelBufferVideoBuffer((CVPixelBufferRef)imageBuffer); + //buffer = new QT7CIImageVideoBuffer( [CIImage imageWithCVImageBuffer:imageBuffer] ); CVPixelBufferRelease((CVPixelBufferRef)imageBuffer); } diff --git a/src/plugins/mediaservices/qt7/qt7movievideowidget.h b/src/plugins/mediaservices/qt7/qt7movievideowidget.h index 7908efd..831a18d 100644 --- a/src/plugins/mediaservices/qt7/qt7movievideowidget.h +++ b/src/plugins/mediaservices/qt7/qt7movievideowidget.h @@ -72,7 +72,6 @@ public: QT7MovieVideoWidget(QObject *parent = 0); virtual ~QT7MovieVideoWidget(); - void setEnabled(bool); void setMovie(void *movie); void updateNaturalSize(const QSize &newSize); diff --git a/src/plugins/mediaservices/qt7/qt7movievideowidget.mm b/src/plugins/mediaservices/qt7/qt7movievideowidget.mm index 197c26e..648d6b4 100644 --- a/src/plugins/mediaservices/qt7/qt7movievideowidget.mm +++ b/src/plugins/mediaservices/qt7/qt7movievideowidget.mm @@ -73,7 +73,8 @@ public: void initializeGL() { - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + QColor bgColor = palette().color(QPalette::Background); + glClearColor(bgColor.redF(), bgColor.greenF(), bgColor.blueF(), bgColor.alphaF()); } void resizeGL(int w, int h) @@ -279,10 +280,6 @@ void QT7MovieVideoWidget::setupVideoOutput() m_displayLink->start(); } -void QT7MovieVideoWidget::setEnabled(bool) -{ -} - void QT7MovieVideoWidget::setMovie(void *movie) { if (m_movie == movie) diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h b/src/plugins/mediaservices/qt7/qt7movieviewoutput.h index 49049ad..0fee41c 100644 --- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h +++ b/src/plugins/mediaservices/qt7/qt7movieviewoutput.h @@ -63,7 +63,6 @@ public: QT7MovieViewOutput(QObject *parent = 0); ~QT7MovieViewOutput(); - void setEnabled(bool); void setMovie(void *movie); void updateNaturalSize(const QSize &newSize); diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm index 8e4dd9b..20f1a02 100644 --- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm +++ b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm @@ -194,10 +194,6 @@ void QT7MovieViewOutput::setupVideoOutput() setDisplayRect(m_displayRect); } -void QT7MovieViewOutput::setEnabled(bool) -{ -} - void QT7MovieViewOutput::setMovie(void *movie) { if (m_movie != movie) { diff --git a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h index 336006c..0b515ae 100644 --- a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h +++ b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h @@ -67,7 +67,6 @@ public: QT7MovieViewRenderer(QObject *parent = 0); ~QT7MovieViewRenderer(); - void setEnabled(bool); void setMovie(void *movie); void updateNaturalSize(const QSize &newSize); @@ -87,6 +86,7 @@ private: QSize m_nativeSize; QAbstractVideoSurface *m_surface; QVideoFrame m_currentFrame; + bool m_pendingRenderEvent; QMutex m_mutex; }; diff --git a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm index 5047853..33a6970 100644 --- a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm +++ b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm @@ -46,6 +46,7 @@ #include "qt7playercontrol.h" #include "qt7movieviewrenderer.h" #include "qt7playersession.h" +#include "qt7ciimagevideobuffer.h" #include <QtCore/qdebug.h> #include <QtCore/qcoreevent.h> #include <QtCore/qcoreapplication.h> @@ -113,6 +114,7 @@ QT_END_NAMESPACE - (HiddenQTMovieView *) initWithRenderer:(QT7MovieViewRenderer *)renderer; - (void) setRenderer:(QT7MovieViewRenderer *)renderer; - (void) setDrawRect:(const QRect &)rect; +- (CIImage *) view:(QTMovieView *)view willDisplayImage:(CIImage *)img; @end @implementation HiddenQTMovieView @@ -163,33 +165,37 @@ QT_END_NAMESPACE // before the image will be drawn. Q_UNUSED(view); if (m_renderer) { - NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithCIImage:img]; CGRect bounds = [img extent]; int w = bounds.size.width; int h = bounds.size.height; - // Swap red and blue (same as QImage::rgbSwapped, but without copy) - uchar *data = [bitmap bitmapData]; - //qDebug() << data << w << h; - int bytesPerLine = [bitmap bytesPerRow]; - for (int i=0; i<h; ++i) { - quint32 *p = (quint32*)data; - data += bytesPerLine; - quint32 *end = p + w; - while (p < end) { - *p = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | (*p & 0xff00ff00); - p++; - } - } + QVideoFrame frame; - QVideoFrame frame( new NSBitmapVideoBuffer(bitmap), QSize(w,h), QVideoFrame::Format_RGB32 ); + QAbstractVideoSurface *surface = m_renderer->surface(); + if (!surface || !surface->isActive()) + return img; - //static int i=0; - //i++; - //QImage img([bitmap bitmapData], w, h, QImage::Format_RGB32); - //img.save(QString("img%1.jpg").arg(i)); - - [bitmap release]; + if (surface->surfaceFormat().handleType() == QAbstractVideoBuffer::CoreImageHandle) { + //surface supports rendering of opengl based CIImage + frame = QVideoFrame(new QT7CIImageVideoBuffer(img), QSize(w,h), QVideoFrame::Format_RGB32 ); + } else { + //Swap R and B colors + CIFilter *colorSwapFilter = [CIFilter filterWithName: @"CIColorMatrix" keysAndValues: + @"inputImage", img, + @"inputRVector", [CIVector vectorWithX: 0 Y: 0 Z: 1 W: 0], + @"inputGVector", [CIVector vectorWithX: 0 Y: 1 Z: 0 W: 0], + @"inputBVector", [CIVector vectorWithX: 1 Y: 0 Z: 0 W: 0], + @"inputAVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 1], + @"inputBiasVector", [CIVector vectorWithX: 0 Y: 0 Z: 0 W: 0], + nil]; + CIImage *img = [colorSwapFilter valueForKey: @"outputImage"]; + NSBitmapImageRep *bitmap =[[NSBitmapImageRep alloc] initWithCIImage:img]; + //requesting the bitmap data is slow, + //but it's better to do it here to avoid blocking the main thread for a long. + [bitmap bitmapData]; + frame = QVideoFrame(new NSBitmapVideoBuffer(bitmap), QSize(w,h), QVideoFrame::Format_RGB32 ); + [bitmap release]; + } if (m_renderer) m_renderer->renderFrame(frame); @@ -230,7 +236,8 @@ QT7MovieViewRenderer::QT7MovieViewRenderer(QObject *parent) :QT7VideoRendererControl(parent), m_movie(0), m_movieView(0), - m_surface(0) + m_surface(0), + m_pendingRenderEvent(false) { } @@ -267,11 +274,15 @@ void QT7MovieViewRenderer::setupVideoOutput() } [movieView setMovie:(QTMovie*)m_movie]; - //[movieView setDrawRect:QRect(QPoint(0,0), m_nativeSize)]; + [movieView setDrawRect:QRect(QPoint(0,0), m_nativeSize)]; } if (m_surface && !m_nativeSize.isEmpty()) { - QVideoSurfaceFormat format(m_nativeSize, QVideoFrame::Format_RGB32); + bool coreImageFrameSupported = !m_surface->supportedPixelFormats(QAbstractVideoBuffer::CoreImageHandle).isEmpty() && + !m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).isEmpty(); + + QVideoSurfaceFormat format(m_nativeSize, QVideoFrame::Format_RGB32, + coreImageFrameSupported ? QAbstractVideoBuffer::CoreImageHandle : QAbstractVideoBuffer::NoHandle); if (m_surface->isActive() && m_surface->surfaceFormat() != format) { // qDebug() << "Surface format was changed, stop the surface."; @@ -279,18 +290,15 @@ void QT7MovieViewRenderer::setupVideoOutput() } if (!m_surface->isActive()) { -// qDebug() << "Starting the surface with format" << format; - m_surface->start(format); -// if (!m_surface->start(format)) -// qDebug() << "failed to start video surface" << m_surface->error(); + //qDebug() << "Starting the surface with format" << format; + if (!m_surface->start(format)) { + qWarning() << "Failed to start video surface" << m_surface->error(); + qWarning() << "Surface format:" << format; + } } } } -void QT7MovieViewRenderer::setEnabled(bool) -{ -} - void QT7MovieViewRenderer::setMovie(void *movie) { if (movie == m_movie) @@ -330,18 +338,21 @@ void QT7MovieViewRenderer::setSurface(QAbstractVideoSurface *surface) void QT7MovieViewRenderer::renderFrame(const QVideoFrame &frame) { - { - QMutexLocker locker(&m_mutex); - m_currentFrame = frame; - } - qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority); + QMutexLocker locker(&m_mutex); + m_currentFrame = frame; + + if (!m_pendingRenderEvent) + qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority); + + m_pendingRenderEvent = true; } bool QT7MovieViewRenderer::event(QEvent *event) { if (event->type() == QEvent::User) { QMutexLocker locker(&m_mutex); + m_pendingRenderEvent = false; if (m_surface->isActive()) m_surface->present(m_currentFrame); } diff --git a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h b/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h index 2c60919..3c74cb8 100644 --- a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h +++ b/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h @@ -67,7 +67,6 @@ class QT7PlayerService; class QT7VideoOutput { public: virtual ~QT7VideoOutput() {} - virtual void setEnabled(bool enabled) = 0; virtual void setMovie(void *movie) = 0; virtual void updateNaturalSize(const QSize &newSize) = 0; }; diff --git a/src/plugins/phonon/ds9/ds9.pro b/src/plugins/phonon/ds9/ds9.pro index 301808e..f40c561 100644 --- a/src/plugins/phonon/ds9/ds9.pro +++ b/src/plugins/phonon/ds9/ds9.pro @@ -22,6 +22,7 @@ HEADERS += \ $$PHONON_DS9_DIR/mediaobject.h \ $$PHONON_DS9_DIR/videowidget.h \ $$PHONON_DS9_DIR/videorenderer_soft.h \ + $$PHONON_DS9_DIR/videorenderer_vmr9.h \ $$PHONON_DS9_DIR/volumeeffect.h \ $$PHONON_DS9_DIR/qbasefilter.h \ $$PHONON_DS9_DIR/qpin.h \ @@ -44,6 +45,7 @@ SOURCES += \ $$PHONON_DS9_DIR/mediaobject.cpp \ $$PHONON_DS9_DIR/videowidget.cpp \ $$PHONON_DS9_DIR/videorenderer_soft.cpp \ + $$PHONON_DS9_DIR/videorenderer_vmr9.cpp \ $$PHONON_DS9_DIR/volumeeffect.cpp \ $$PHONON_DS9_DIR/qbasefilter.cpp \ $$PHONON_DS9_DIR/qpin.cpp \ @@ -51,15 +53,6 @@ SOURCES += \ $$PHONON_DS9_DIR/qaudiocdreader.cpp \ $$PHONON_DS9_DIR/qmeminputpin.cpp -#the EVR renderer (only available on desktop) -!wince*:SOURCES += $$PHONON_DS9_DIR/videorenderer_evr.cpp \ - $$PHONON_DS9_DIR/videorenderer_vmr9.cpp -!wince*:HEADERS += $$PHONON_DS9_DIR/qevr9.h \ - $$PHONON_DS9_DIR/videorenderer_evr.h \ - $$PHONON_DS9_DIR/videorenderer_vmr9.h -wince*:SOURCES += $$PHONON_DS9_DIR/videorenderer_default.cpp -wince*:HEADERS += $$PHONON_DS9_DIR/videorenderer_default.h - target.path = $$[QT_INSTALL_PLUGINS]/phonon_backend INSTALLS += target diff --git a/src/plugins/phonon/gstreamer/gstreamer.pro b/src/plugins/phonon/gstreamer/gstreamer.pro index ae597fa..1013205 100644 --- a/src/plugins/phonon/gstreamer/gstreamer.pro +++ b/src/plugins/phonon/gstreamer/gstreamer.pro @@ -15,6 +15,7 @@ PHONON_GSTREAMER_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/gstreamer HEADERS += $$PHONON_GSTREAMER_DIR/common.h \ $$PHONON_GSTREAMER_DIR/audiooutput.h \ + $$PHONON_GSTREAMER_DIR/audiodataoutput.h \ $$PHONON_GSTREAMER_DIR/artssink.h \ $$PHONON_GSTREAMER_DIR/abstractrenderer.h \ $$PHONON_GSTREAMER_DIR/backend.h \ @@ -35,26 +36,27 @@ HEADERS += $$PHONON_GSTREAMER_DIR/common.h \ $$PHONON_GSTREAMER_DIR/audioeffect.h \ $$PHONON_GSTREAMER_DIR/volumefadereffect.h -SOURCES += $$PHONON_GSTREAMER_DIR/audiooutput.cpp \ - $$PHONON_GSTREAMER_DIR/abstractrenderer.cpp \ +SOURCES += $$PHONON_GSTREAMER_DIR/abstractrenderer.cpp \ $$PHONON_GSTREAMER_DIR/artssink.cpp \ + $$PHONON_GSTREAMER_DIR/audioeffect.cpp \ + $$PHONON_GSTREAMER_DIR/audiooutput.cpp \ + $$PHONON_GSTREAMER_DIR/audiodataoutput.cpp \ $$PHONON_GSTREAMER_DIR/backend.cpp \ $$PHONON_GSTREAMER_DIR/devicemanager.cpp \ $$PHONON_GSTREAMER_DIR/effect.cpp \ $$PHONON_GSTREAMER_DIR/effectmanager.cpp \ + $$PHONON_GSTREAMER_DIR/glrenderer.cpp \ $$PHONON_GSTREAMER_DIR/gsthelper.cpp \ - $$PHONON_GSTREAMER_DIR/mediaobject.cpp \ $$PHONON_GSTREAMER_DIR/medianode.cpp \ $$PHONON_GSTREAMER_DIR/medianodeevent.cpp \ - $$PHONON_GSTREAMER_DIR/widgetrenderer.cpp \ - $$PHONON_GSTREAMER_DIR/videowidget.cpp \ - $$PHONON_GSTREAMER_DIR/glrenderer.cpp \ - $$PHONON_GSTREAMER_DIR/qwidgetvideosink.cpp \ + $$PHONON_GSTREAMER_DIR/mediaobject.cpp \ + $$PHONON_GSTREAMER_DIR/message.cpp \ $$PHONON_GSTREAMER_DIR/phononsrc.cpp \ + $$PHONON_GSTREAMER_DIR/qwidgetvideosink.cpp \ $$PHONON_GSTREAMER_DIR/streamreader.cpp \ - $$PHONON_GSTREAMER_DIR/message.cpp \ - $$PHONON_GSTREAMER_DIR/audioeffect.cpp \ - $$PHONON_GSTREAMER_DIR/volumefadereffect.cpp + $$PHONON_GSTREAMER_DIR/videowidget.cpp \ + $$PHONON_GSTREAMER_DIR/volumefadereffect.cpp \ + $$PHONON_GSTREAMER_DIR/widgetrenderer.cpp !embedded { HEADERS += $$PHONON_GSTREAMER_DIR/x11renderer.h |