summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin McPherson <justin.mcpherson@nokia.com>2010-02-25 05:45:21 (GMT)
committerJustin McPherson <justin.mcpherson@nokia.com>2010-02-25 05:45:21 (GMT)
commitf3abaf5ee7cdef1c963df383885668abd55427c3 (patch)
tree57e68d2bc2445f56534fa04dc4ad411db8da5b3e
parent77f722aca2c5243f07733dcb302035fb3c454f3a (diff)
parentf4d15309c2c44bb2fdc18a8c89629c6f415f0b67 (diff)
downloadQt-f3abaf5ee7cdef1c963df383885668abd55427c3.zip
Qt-f3abaf5ee7cdef1c963df383885668abd55427c3.tar.gz
Qt-f3abaf5ee7cdef1c963df383885668abd55427c3.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-multimedia-staging
-rw-r--r--src/multimedia/base/qmediacontent.cpp9
-rw-r--r--src/multimedia/base/qmediacontent.h1
-rw-r--r--src/plugins/mediaservices/qt7/mediaplayer/qt7playerservice.mm3
-rw-r--r--src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h6
-rw-r--r--src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm63
-rw-r--r--src/plugins/mediaservices/qt7/qt7movierenderer.mm21
-rw-r--r--src/plugins/mediaservices/qt7/qt7movievideowidget.mm17
-rw-r--r--tests/auto/qmediacontent/tst_qmediacontent.cpp1
8 files changed, 87 insertions, 34 deletions
diff --git a/src/multimedia/base/qmediacontent.cpp b/src/multimedia/base/qmediacontent.cpp
index fd519c6..dd0c315 100644
--- a/src/multimedia/base/qmediacontent.cpp
+++ b/src/multimedia/base/qmediacontent.cpp
@@ -206,6 +206,15 @@ QUrl QMediaContent::canonicalUrl() const
}
/*!
+ Returns a QNetworkRequest that represents that canonical resource for this media content.
+*/
+
+QNetworkRequest QMediaContent::canonicalRequest() const
+{
+ return canonicalResource().request();
+}
+
+/*!
Returns a QMediaResource that represents that canonical resource for this media content.
*/
diff --git a/src/multimedia/base/qmediacontent.h b/src/multimedia/base/qmediacontent.h
index b6f3017..5a279c1 100644
--- a/src/multimedia/base/qmediacontent.h
+++ b/src/multimedia/base/qmediacontent.h
@@ -75,6 +75,7 @@ public:
bool isNull() const;
QUrl canonicalUrl() const;
+ QNetworkRequest canonicalRequest() const;
QMediaResource canonicalResource() const;
QMediaResourceList resources() const;
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,
diff --git a/tests/auto/qmediacontent/tst_qmediacontent.cpp b/tests/auto/qmediacontent/tst_qmediacontent.cpp
index 8987241..a0a9bdb 100644
--- a/tests/auto/qmediacontent/tst_qmediacontent.cpp
+++ b/tests/auto/qmediacontent/tst_qmediacontent.cpp
@@ -85,6 +85,7 @@ void tst_QMediaContent::testRequestCtor()
QMediaContent media(request);
+ QCOMPARE(media.canonicalRequest(), request);
QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov"));
QCOMPARE(media.canonicalResource().request(), request);
QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov"));