diff options
11 files changed, 58 insertions, 15 deletions
diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h index 8187f72..4742e2e 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.h @@ -109,6 +109,7 @@ public slots: void processEOS(); void processStateChange(); void processVolumeChange(); + void processNaturalSizeChange(); signals: void positionChanged(qint64 position); diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm index 9ea33e4..d1381fe 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playersession.mm @@ -104,6 +104,9 @@ QT_BEGIN_NAMESPACE [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(processVolumeChange:) name: QTMovieVolumeDidChangeNotification object: m_movie]; + [[NSNotificationCenter defaultCenter] addObserver: self selector: + @selector(processNaturalSizeChange:) name: QTMovieNaturalSizeDidChangeNotification object: m_movie]; + [movie retain]; } } @@ -126,6 +129,11 @@ QT_BEGIN_NAMESPACE m_session->processVolumeChange(); } +- (void) processNaturalSizeChange :(NSNotification *)notification +{ + Q_UNUSED(notification); + m_session->processNaturalSizeChange(); +} @end @@ -353,6 +361,8 @@ void QT7PlayerSession::setMedia(const QMediaContent &content, QIODevice *stream) else return; + qDebug() << "Open media" << url; + NSError *err = 0; NSString *urlString = (NSString *)qString2CFStringRef(url.toString()); @@ -415,7 +425,7 @@ void QT7PlayerSession::processStateChange() { signed long state = [[(QTMovie*)m_QTMovie attributeForKey:QTMovieLoadStateAttribute] longValue]; - //qDebug() << "new State:" << state; + qDebug() << "Moview load state changed:" << state; #ifndef QUICKTIME_C_API_AVAILABLE enum { @@ -457,11 +467,6 @@ void QT7PlayerSession::processStateChange() emit durationChanged(duration()); emit audioAvailableChanged(isAudioAvailable()); emit videoAvailableChanged(isVideoAvailable()); - - //give output a change to re-read movie properties - if (m_videoOutput) - m_videoOutput->setMovie(m_QTMovie); - break; case QMediaPlayer::InvalidMedia: emit stateChanged(m_state = QMediaPlayer::StoppedState); @@ -485,6 +490,15 @@ void QT7PlayerSession::processVolumeChange() } } +void QT7PlayerSession::processNaturalSizeChange() +{ + if (m_videoOutput) { + NSSize size = [[(QTMovie*)m_QTMovie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; + qDebug() << "Native size changed:" << QSize(size.width, size.height); + m_videoOutput->updateNaturalSize(QSize(size.width, size.height)); + } +} + #include "moc_qt7playersession.cpp" QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/qt7/qt7movierenderer.h b/src/plugins/mediaservices/qt7/qt7movierenderer.h index 4543152..a547329 100644 --- a/src/plugins/mediaservices/qt7/qt7movierenderer.h +++ b/src/plugins/mediaservices/qt7/qt7movierenderer.h @@ -76,6 +76,7 @@ public: void setEnabled(bool); void setMovie(void *movie); + void updateNaturalSize(const QSize &newSize); QAbstractVideoSurface *surface() const; void setSurface(QAbstractVideoSurface *surface); diff --git a/src/plugins/mediaservices/qt7/qt7movierenderer.mm b/src/plugins/mediaservices/qt7/qt7movierenderer.mm index 9a35f5d..587f3b9 100644 --- a/src/plugins/mediaservices/qt7/qt7movierenderer.mm +++ b/src/plugins/mediaservices/qt7/qt7movierenderer.mm @@ -374,17 +374,18 @@ void QT7MovieRenderer::setMovie(void *movie) [(QTMovie*)m_movie retain]; setupVideoOutput(); - } else { - if (m_movie) { - //reset video output if native size was changed - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; - if (m_nativeSize != QSize(size.width, size.height)) - setupVideoOutput(); - } } #endif } +void QT7MovieRenderer::updateNaturalSize(const QSize &newSize) +{ + if (m_nativeSize != newSize) { + m_nativeSize = newSize; + setupVideoOutput(); + } +} + QAbstractVideoSurface *QT7MovieRenderer::surface() const { return m_surface; diff --git a/src/plugins/mediaservices/qt7/qt7movievideowidget.h b/src/plugins/mediaservices/qt7/qt7movievideowidget.h index 266dad4..3acd373 100644 --- a/src/plugins/mediaservices/qt7/qt7movievideowidget.h +++ b/src/plugins/mediaservices/qt7/qt7movievideowidget.h @@ -74,6 +74,7 @@ public: void setEnabled(bool); void setMovie(void *movie); + void updateNaturalSize(const QSize &newSize); QWidget *videoWidget(); diff --git a/src/plugins/mediaservices/qt7/qt7movievideowidget.mm b/src/plugins/mediaservices/qt7/qt7movievideowidget.mm index e1e0162..6e74fcd 100644 --- a/src/plugins/mediaservices/qt7/qt7movievideowidget.mm +++ b/src/plugins/mediaservices/qt7/qt7movievideowidget.mm @@ -256,7 +256,7 @@ void QT7MovieVideoWidget::setupVideoOutput() return; } - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieCurrentSizeAttribute"] sizeValue]; + NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; m_nativeSize = QSize(size.width, size.height); m_videoWidget->setNativeSize(m_nativeSize); @@ -290,6 +290,14 @@ void QT7MovieVideoWidget::setMovie(void *movie) setupVideoOutput(); } +void QT7MovieVideoWidget::updateNaturalSize(const QSize &newSize) +{ + if (m_nativeSize != newSize) { + m_nativeSize = newSize; + setupVideoOutput(); + } +} + bool QT7MovieVideoWidget::isFullScreen() const { return m_fullscreen; diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h b/src/plugins/mediaservices/qt7/qt7movieviewoutput.h index 7f3ff91..30eefa7 100644 --- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h +++ b/src/plugins/mediaservices/qt7/qt7movieviewoutput.h @@ -65,6 +65,7 @@ public: void setEnabled(bool); void setMovie(void *movie); + void updateNaturalSize(const QSize &newSize); WId winId() const; void setWinId(WId id); diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm index 8182797..b549487 100644 --- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm +++ b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm @@ -177,7 +177,7 @@ void QT7MovieViewOutput::setupVideoOutput() if (m_movie == 0 || m_winId <= 0) return; - NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieCurrentSizeAttribute"] sizeValue]; + NSSize size = [[(QTMovie*)m_movie attributeForKey:@"QTMovieNaturalSizeAttribute"] sizeValue]; m_nativeSize = QSize(size.width, size.height); if (!m_movieView) @@ -201,6 +201,11 @@ void QT7MovieViewOutput::setMovie(void *movie) setupVideoOutput(); } +void QT7MovieViewOutput::updateNaturalSize(const QSize &newSize) +{ + m_nativeSize = newSize; +} + WId QT7MovieViewOutput::winId() const { return m_winId; diff --git a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h index 6f381f8..336006c 100644 --- a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h +++ b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.h @@ -69,6 +69,7 @@ public: void setEnabled(bool); void setMovie(void *movie); + void updateNaturalSize(const QSize &newSize); QAbstractVideoSurface *surface() const; void setSurface(QAbstractVideoSurface *surface); diff --git a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm index e08d0f3..342feb8 100644 --- a/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm +++ b/src/plugins/mediaservices/qt7/qt7movieviewrenderer.mm @@ -298,6 +298,14 @@ void QT7MovieViewRenderer::setMovie(void *movie) setupVideoOutput(); } +void QT7MovieViewRenderer::updateNaturalSize(const QSize &newSize) +{ + if (m_nativeSize != newSize) { + m_nativeSize = newSize; + setupVideoOutput(); + } +} + QAbstractVideoSurface *QT7MovieViewRenderer::surface() const { return m_surface; diff --git a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h b/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h index 2faf6bb..2c60919 100644 --- a/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h +++ b/src/plugins/mediaservices/qt7/qt7videooutputcontrol.h @@ -43,6 +43,7 @@ #define QT7VIDEOOUTPUTCONTROL_H #include <QtCore/qobject.h> +#include <QtCore/qsize.h> #include <QtMultimedia/qvideooutputcontrol.h> #include <QtMultimedia/qvideowindowcontrol.h> @@ -68,6 +69,7 @@ public: virtual ~QT7VideoOutput() {} virtual void setEnabled(bool enabled) = 0; virtual void setMovie(void *movie) = 0; + virtual void updateNaturalSize(const QSize &newSize) = 0; }; class QT7VideoWindowControl : public QVideoWindowControl, public QT7VideoOutput |