diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2010-02-25 07:37:52 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2010-02-25 07:37:52 (GMT) |
commit | b4432f78cba8b395b5835633212ab7099e9e27b6 (patch) | |
tree | 01197447b5d104e606d8e91f72fe73f44ec889ce /src/plugins | |
parent | 8d98125460c223c5b9da017edd4a05dba8ba82af (diff) | |
parent | 40ee581661e07e522a2852b32a25337d13ca25f9 (diff) | |
download | Qt-b4432f78cba8b395b5835633212ab7099e9e27b6.zip Qt-b4432f78cba8b395b5835633212ab7099e9e27b6.tar.gz Qt-b4432f78cba8b395b5835633212ab7099e9e27b6.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging
Diffstat (limited to 'src/plugins')
23 files changed, 202 insertions, 71 deletions
diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp index 4d0ffe4..eff6ea4 100644 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp +++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp @@ -45,6 +45,8 @@ #include <gst/gstversion.h> +QT_BEGIN_NAMESPACE + struct QGstreamerMetaDataKeyLookup { QtMultimedia::MetaData key; @@ -202,3 +204,6 @@ void QGstreamerMetaDataProvider::updateTags() { emit metaDataChanged(); } + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp index d417266..2d7aaa8 100644 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp +++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp @@ -54,6 +54,8 @@ #include <fcntl.h> #include <unistd.h> +QT_BEGIN_NAMESPACE + QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *session, QObject *parent) : QMediaPlayerControl(parent) , m_session(session) @@ -341,3 +343,6 @@ void QGstreamerPlayerControl::closeFifo() m_bufferOffset = 0; } } + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp index 2e5d10f..600621e 100644 --- a/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp +++ b/src/plugins/mediaservices/gstreamer/mediaplayer/qgstreamerplayersession.cpp @@ -51,6 +51,9 @@ //#define USE_PLAYBIN2 + +QT_BEGIN_NAMESPACE + QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent) :QObject(parent), m_state(QMediaPlayer::StoppedState), @@ -710,3 +713,6 @@ void QGstreamerPlayerSession::getStreamsInfo() emit streamsChanged(); } + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp b/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp index 59ae5be..5049fa1 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamerbushelper.cpp @@ -45,6 +45,7 @@ #include "qgstreamerbushelper.h" +QT_BEGIN_NAMESPACE #ifndef QT_NO_GLIB class QGstreamerBusHelperPrivate : public QObject @@ -200,4 +201,6 @@ void QGstreamerBusHelper::installSyncEventFilter(QGstreamerSyncEventFilter *filt d->filter = filter; } +QT_END_NAMESPACE + #include "qgstreamerbushelper.moc" diff --git a/src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp b/src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp index 0a689d9..d52aa75 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamermessage.cpp @@ -44,6 +44,8 @@ #include "qgstreamermessage.h" +QT_BEGIN_NAMESPACE + static int wuchi = qRegisterMetaType<QGstreamerMessage>(); @@ -91,3 +93,5 @@ QGstreamerMessage& QGstreamerMessage::operator=(QGstreamerMessage const& rhs) return *this; } + +QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp index 94ae847..406cefe11 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamervideoinputdevicecontrol.cpp @@ -57,6 +57,9 @@ #include <sys/mman.h> #include <linux/videodev2.h> + +QT_BEGIN_NAMESPACE + QGstreamerVideoInputDeviceControl::QGstreamerVideoInputDeviceControl(QObject *parent) :QVideoDeviceControl(parent), m_selectedDevice(0) { @@ -155,3 +158,6 @@ void QGstreamerVideoInputDeviceControl::update() ::close(fd); } } + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp index decf524..f406bff 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamervideooutputcontrol.cpp @@ -41,6 +41,8 @@ #include "qgstreamervideooutputcontrol.h" +QT_BEGIN_NAMESPACE + QGstreamerVideoOutputControl::QGstreamerVideoOutputControl(QObject *parent) : QVideoOutputControl(parent) , m_output(NoOutput) @@ -70,3 +72,6 @@ void QGstreamerVideoOutputControl::setOutput(Output output) if (m_output != output) emit outputChanged(m_output = output); } + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp index 6c6c802..846a24a 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp @@ -46,6 +46,8 @@ #include "qx11videosurface.h" +QT_BEGIN_NAMESPACE + QGstreamerVideoOverlay::QGstreamerVideoOverlay(QObject *parent) : QVideoWindowControl(parent) , m_surface(new QX11VideoSurface) @@ -208,3 +210,6 @@ void QGstreamerVideoOverlay::setScaledDisplayRect() break; }; } + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp index 25a53cf..1f03990 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamervideorenderer.cpp @@ -47,6 +47,9 @@ #include <gst/gst.h> + +QT_BEGIN_NAMESPACE + QGstreamerVideoRenderer::QGstreamerVideoRenderer(QObject *parent) :QVideoRendererControl(parent),m_videoSink(0) { @@ -80,3 +83,6 @@ void QGstreamerVideoRenderer::setSurface(QAbstractVideoSurface *surface) m_surface = surface; } +QT_END_NAMESPACE + + diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp index 0a1c20d..886a064 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.cpp @@ -41,6 +41,12 @@ #include "qgstreamervideorendererinterface.h" + +QT_BEGIN_NAMESPACE + QGstreamerVideoRendererInterface::~QGstreamerVideoRendererInterface() { } + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h b/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h index 39deee8..c63a757 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h +++ b/src/plugins/mediaservices/gstreamer/qgstreamervideorendererinterface.h @@ -59,11 +59,11 @@ public: virtual void precessNewStream() {} }; -QT_END_NAMESPACE - #define QGstreamerVideoRendererInterface_iid "com.nokia.Qt.QGstreamerVideoRendererInterface/1.0" Q_DECLARE_INTERFACE(QGstreamerVideoRendererInterface, QGstreamerVideoRendererInterface_iid) +QT_END_NAMESPACE + QT_END_HEADER #endif diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp index 1d8d43d..47fb451 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp @@ -51,6 +51,9 @@ #include <gst/interfaces/xoverlay.h> #include <gst/interfaces/propertyprobe.h> + +QT_BEGIN_NAMESPACE + class QGstreamerVideoWidget : public QWidget { public: @@ -320,3 +323,6 @@ void QGstreamerVideoWidgetControl::setSaturation(int saturation) emit saturationChanged(saturation); } } + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp b/src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp index 9519db6..76289bf 100644 --- a/src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstvideobuffer.cpp @@ -42,6 +42,8 @@ #include "qgstvideobuffer.h" +QT_BEGIN_NAMESPACE + QGstVideoBuffer::QGstVideoBuffer(GstBuffer *buffer, int bytesPerLine) : QAbstractVideoBuffer(NoHandle) , m_buffer(buffer) @@ -95,3 +97,5 @@ void QGstVideoBuffer::unmap() m_mode = NotMapped; } +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp b/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp index 5b99817..b2e633d 100644 --- a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.cpp @@ -47,6 +47,9 @@ #include "qgstxvimagebuffer.h" #include "qvideosurfacegstsink.h" + +QT_BEGIN_NAMESPACE + GstBufferClass *QGstXvImageBuffer::parent_class = NULL; GType QGstXvImageBuffer::get_type(void) @@ -274,3 +277,6 @@ void QGstXvImageBufferPool::destroyBuffer(QGstXvImageBuffer *xvBuffer) if (m_imagesToDestroy.size() == 1) QMetaObject::invokeMethod(this, "queuedDestroy", Qt::QueuedConnection); } + +QT_END_NAMESPACE + diff --git a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h b/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h index beeb01f..30f77d1 100644 --- a/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h +++ b/src/plugins/mediaservices/gstreamer/qgstxvimagebuffer.h @@ -56,14 +56,13 @@ #include <X11/extensions/Xv.h> #include <X11/extensions/Xvlib.h> - #include <gst/gst.h> + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE - class QGstXvImageBufferPool; struct QGstXvImageBuffer { @@ -82,7 +81,6 @@ struct QGstXvImageBuffer { const QAbstractVideoBuffer::HandleType XvHandleType = QAbstractVideoBuffer::HandleType(4); -Q_DECLARE_METATYPE(XvImage*) class QGstXvImageBufferPool : public QObject { @@ -125,6 +123,8 @@ private: QT_END_NAMESPACE +Q_DECLARE_METATYPE(::XvImage*) + QT_END_HEADER diff --git a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp index 402a225..76d87ce 100644 --- a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp +++ b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp @@ -52,8 +52,11 @@ #include "qgstxvimagebuffer.h" + Q_DECLARE_METATYPE(QVideoSurfaceFormat) +QT_BEGIN_NAMESPACE + QVideoSurfaceGstDelegate::QVideoSurfaceGstDelegate(QAbstractVideoSurface *surface) : m_surface(surface) , m_renderReturn(GST_FLOW_ERROR) @@ -691,3 +694,6 @@ GstFlowReturn QVideoSurfaceGstSink::render(GstBaseSink *base, GstBuffer *buffer) return sink->delegate->render(buffer); } +QT_END_NAMESPACE + + diff --git a/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp b/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp index 6e282ff..cbd5a76 100644 --- a/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp +++ b/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp @@ -46,7 +46,9 @@ #include "qx11videosurface.h" -Q_DECLARE_METATYPE(XvImage*); +Q_DECLARE_METATYPE(::XvImage*); + +QT_BEGIN_NAMESPACE static QAbstractVideoBuffer::HandleType XvHandleType = QAbstractVideoBuffer::HandleType(4); @@ -507,3 +509,5 @@ void QX11VideoSurface::querySupportedFormats() XFree(attributes); } } + +QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm index a14981a..b046672 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm @@ -132,15 +132,19 @@ static OSStatus readMetaValue(QTMetaDataRef metaDataRef, QTMetaDataItem item, QT UInt32 propFlags; OSStatus err = QTMetaDataGetItemPropertyInfo(metaDataRef, item, propClass, id, &type, &propSize, &propFlags); - - *value = malloc(propSize); - - err = QTMetaDataGetItemProperty(metaDataRef, item, propClass, id, propSize, *value, size); - - if (type == 'code' || type == 'itsk' || type == 'itlk') { - // convert from native endian to big endian - OSTypePtr pType = (OSTypePtr)*value; - *pType = EndianU32_NtoB(*pType); + if (err == noErr) { + *value = malloc(propSize); + if (*value != 0) { + err = QTMetaDataGetItemProperty(metaDataRef, item, propClass, id, propSize, *value, size); + + if (err == noErr && (type == 'code' || type == 'itsk' || type == 'itlk')) { + // convert from native endian to big endian + OSTypePtr pType = (OSTypePtr)*value; + *pType = EndianU32_NtoB(*pType); + } + } + else + return -1; } return err; @@ -153,10 +157,14 @@ static UInt32 getMetaType(QTMetaDataRef metaDataRef, QTMetaDataItem item) OSStatus err = readMetaValue( metaDataRef, item, kPropertyClass_MetaDataItem, kQTMetaDataItemPropertyID_DataType, &value, &ignore); - UInt32 type = *((UInt32 *) value); - if (value) - free(value); - return type; + if (err == noErr) { + UInt32 type = *((UInt32 *) value); + if (value) + free(value); + return type; + } + + return 0; } static QString cFStringToQString(CFStringRef str) @@ -179,23 +187,26 @@ static QString getMetaValue(QTMetaDataRef metaDataRef, QTMetaDataItem item, SInt QTPropertyValuePtr value = 0; ByteCount size = 0; OSStatus err = readMetaValue(metaDataRef, item, kPropertyClass_MetaDataItem, id, &value, &size); - QString string; - UInt32 dataType = getMetaType(metaDataRef, item); - switch (dataType){ - case kQTMetaDataTypeUTF8: - case kQTMetaDataTypeMacEncodedText: - string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF8, false)); - break; - case kQTMetaDataTypeUTF16BE: - string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF16BE, false)); - break; - default: - break; + + if (err == noErr) { + UInt32 dataType = getMetaType(metaDataRef, item); + switch (dataType){ + case kQTMetaDataTypeUTF8: + case kQTMetaDataTypeMacEncodedText: + string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF8, false)); + break; + case kQTMetaDataTypeUTF16BE: + string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF16BE, false)); + break; + default: + break; + } + + if (value) + free(value); } - if (value) - free(value); return string; } @@ -234,10 +245,11 @@ void QT7PlayerMetaDataControl::updateTags() #ifdef QUICKTIME_C_API_AVAILABLE QTMetaDataRef metaDataRef; OSStatus err = QTCopyMovieMetaData([movie quickTimeMovie], &metaDataRef); - - readFormattedData(metaDataRef, kQTMetaDataStorageFormatUserData, metaMap); - readFormattedData(metaDataRef, kQTMetaDataStorageFormatQuickTime, metaMap); - readFormattedData(metaDataRef, kQTMetaDataStorageFormatiTunes, metaMap); + if (err == noErr) { + readFormattedData(metaDataRef, kQTMetaDataStorageFormatUserData, metaMap); + readFormattedData(metaDataRef, kQTMetaDataStorageFormatQuickTime, metaMap); + readFormattedData(metaDataRef, kQTMetaDataStorageFormatiTunes, metaMap); + } #else NSString *name = [movie attributeForKey:@"QTMovieDisplayNameAttribute"]; metaMap.insert(QLatin1String("nam"), QString::fromUtf8([name UTF8String])); diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm index faf75d1..205e862 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE QT7PlayerService::QT7PlayerService(QObject *parent): QMediaService(parent) { - m_session = new QT7PlayerSession; + m_session = new QT7PlayerSession(this); m_control = new QT7PlayerControl(this); m_control->setSession(m_session); @@ -102,6 +102,7 @@ QT7PlayerService::QT7PlayerService(QObject *parent): QT7PlayerService::~QT7PlayerService() { + m_session->setVideoOutput(0); } QMediaControl *QT7PlayerService::control(const char *name) const diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h index 4742e2e..0ba3041 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h @@ -107,7 +107,7 @@ public slots: void setMuted(bool muted); void processEOS(); - void processStateChange(); + void processLoadStateChange(); void processVolumeChange(); void processNaturalSizeChange(); @@ -138,6 +138,10 @@ private: bool m_muted; int m_volume; qreal m_rate; + + qint64 m_duration; + bool m_videoAvailable; + bool m_audioAvailable; }; QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm index 28e220c..d83c0e3 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm @@ -68,7 +68,9 @@ - (QTMovieObserver *) initWithPlayerSession:(QT7PlayerSession*)session; - (void) setMovie:(QTMovie *)movie; - (void) processEOS:(NSNotification *)notification; -- (void) processStateChange:(NSNotification *)notification; +- (void) processLoadStateChange:(NSNotification *)notification; +- (void) processVolumeChange:(NSNotification *)notification; +- (void) processNaturalSizeChange :(NSNotification *)notification; @end @implementation QTMovieObserver @@ -101,7 +103,7 @@ object:m_movie]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(processStateChange:) + selector:@selector(processLoadStateChange:) name:QTMovieLoadStateDidChangeNotification object:m_movie]; @@ -129,10 +131,10 @@ m_session->processEOS(); } -- (void) processStateChange:(NSNotification *)notification +- (void) processLoadStateChange:(NSNotification *)notification { Q_UNUSED(notification); - m_session->processStateChange(); + m_session->processLoadStateChange(); } - (void) processVolumeChange:(NSNotification *)notification @@ -167,6 +169,9 @@ QT7PlayerSession::QT7PlayerSession(QObject *parent) , m_muted(false) , m_volume(100) , m_rate(1.0) + , m_duration(0) + , m_videoAvailable(false) + , m_audioAvailable(false) { m_movieObserver = [[QTMovieObserver alloc] initWithPlayerSession:this]; } @@ -175,6 +180,7 @@ QT7PlayerSession::~QT7PlayerSession() { [(QTMovieObserver*)m_movieObserver setMovie:nil]; [(QTMovieObserver*)m_movieObserver release]; + [(QTMovie*)m_QTMovie release]; } void *QT7PlayerSession::movie() const @@ -423,7 +429,7 @@ void QT7PlayerSession::setMedia(const QMediaContent &content, QIODevice *stream) m_videoOutput->setMovie(m_QTMovie); m_videoOutput->setEnabled(true); } - processStateChange(); + processLoadStateChange(); [(QTMovie*)m_QTMovie setMuted:m_muted]; setVolume(m_volume); @@ -455,8 +461,11 @@ void QT7PlayerSession::processEOS() emit mediaStatusChanged(m_mediaStatus); } -void QT7PlayerSession::processStateChange() +void QT7PlayerSession::processLoadStateChange() { + if (!m_QTMovie) + return; + signed long state = [[(QTMovie*)m_QTMovie attributeForKey:QTMovieLoadStateAttribute] longValue]; // qDebug() << "Moview load state changed:" << state; @@ -484,32 +493,30 @@ void QT7PlayerSession::processStateChange() if (state == kMovieLoadStateError) { newStatus = QMediaPlayer::InvalidMedia; - emit error(QMediaPlayer::FormatError, tr("Playback failed")); + emit error(QMediaPlayer::FormatError, tr("Failed to load media")); + emit stateChanged(m_state = QMediaPlayer::StoppedState); } - if (newStatus != m_mediaStatus) { - switch (newStatus) { - case QMediaPlayer::BufferedMedia: - case QMediaPlayer::BufferingMedia: - //delayed playback start is necessary for network sources - if (m_state == QMediaPlayer::PlayingState) { - QMetaObject::invokeMethod(this, "play", Qt::QueuedConnection); - } - //fall - case QMediaPlayer::LoadedMedia: - case QMediaPlayer::LoadingMedia: - emit durationChanged(duration()); - emit audioAvailableChanged(isAudioAvailable()); - emit videoAvailableChanged(isVideoAvailable()); - break; - case QMediaPlayer::InvalidMedia: - emit stateChanged(m_state = QMediaPlayer::StoppedState); - default: - break; - } + if (state >= kMovieLoadStatePlayable && + m_state == QMediaPlayer::PlayingState && + [(QTMovie*)m_QTMovie rate] == 0) { + QMetaObject::invokeMethod(this, "play", Qt::QueuedConnection); + } - emit mediaStatusChanged(m_mediaStatus = newStatus); + if (state >= kMovieLoadStateLoaded) { + qint64 currentDuration = duration(); + if (m_duration != currentDuration) + emit durationChanged(m_duration = currentDuration); + + if (m_audioAvailable != isAudioAvailable()) + emit audioAvailableChanged(m_audioAvailable = !m_audioAvailable); + + if (m_videoAvailable != isVideoAvailable()) + emit videoAvailableChanged(m_videoAvailable = !m_videoAvailable); } + + if (newStatus != m_mediaStatus) + emit mediaStatusChanged(m_mediaStatus = newStatus); } void QT7PlayerSession::processVolumeChange() diff --git a/src/plugins/mediaservices/qt7/qt7movierenderer.mm b/src/plugins/mediaservices/qt7/qt7movierenderer.mm index 6b9fd21..1c1f5e4 100644 --- a/src/plugins/mediaservices/qt7/qt7movierenderer.mm +++ b/src/plugins/mediaservices/qt7/qt7movierenderer.mm @@ -58,6 +58,8 @@ QT_BEGIN_NAMESPACE +//#define USE_MAIN_MONITOR_COLOR_SPACE 1 + class CVGLTextureVideoBuffer : public QAbstractVideoBuffer { public: @@ -233,7 +235,24 @@ bool QT7MovieRenderer::createPixelBufferVisualContext() &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFDictionarySetValue(visualContextOptions, kQTVisualContextPixelBufferAttributesKey, pixelBufferOptions); - CFDictionarySetValue(visualContextOptions, kQTVisualContextWorkingColorSpaceKey, CGColorSpaceCreateDeviceRGB()); + + CGColorSpaceRef colorSpace = NULL; + +#if USE_MAIN_MONITOR_COLOR_SPACE + CMProfileRef sysprof = NULL; + + // Get the Systems Profile for the main display + if (CMGetSystemProfile(&sysprof) == noErr) { + // Create a colorspace with the systems profile + colorSpace = CGColorSpaceCreateWithPlatformColorSpace(sysprof); + CMCloseProfile(sysprof); + } +#endif + + if (!colorSpace) + colorSpace = CGColorSpaceCreateDeviceRGB(); + + CFDictionarySetValue(visualContextOptions, kQTVisualContextOutputColorSpaceKey, colorSpace); OSStatus err = QTPixelBufferContextCreate(kCFAllocatorDefault, visualContextOptions, diff --git a/src/plugins/mediaservices/qt7/qt7movievideowidget.mm b/src/plugins/mediaservices/qt7/qt7movievideowidget.mm index 4043330..00ceffc 100644 --- a/src/plugins/mediaservices/qt7/qt7movievideowidget.mm +++ b/src/plugins/mediaservices/qt7/qt7movievideowidget.mm @@ -199,7 +199,6 @@ QT7MovieVideoWidget::QT7MovieVideoWidget(QObject *parent) } } - bool QT7MovieVideoWidget::createVisualContext() { #ifdef QUICKTIME_C_API_AVAILABLE @@ -210,8 +209,20 @@ bool QT7MovieVideoWidget::createVisualContext() NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; CGLPixelFormatObj cglPixelFormat = static_cast<CGLPixelFormatObj>([nsglPixelFormat CGLPixelFormatObj]); - CFTypeRef keys[] = { kQTVisualContextWorkingColorSpaceKey }; - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CFTypeRef keys[] = { kQTVisualContextOutputColorSpaceKey }; + CGColorSpaceRef colorSpace = NULL; + CMProfileRef sysprof = NULL; + + // Get the Systems Profile for the main display + if (CMGetSystemProfile(&sysprof) == noErr) { + // Create a colorspace with the systems profile + colorSpace = CGColorSpaceCreateWithPlatformColorSpace(sysprof); + CMCloseProfile(sysprof); + } + + if (!colorSpace) + colorSpace = CGColorSpaceCreateDeviceRGB(); + CFDictionaryRef textureContextAttributes = CFDictionaryCreate(kCFAllocatorDefault, (const void **)keys, (const void **)&colorSpace, 1, |