src/3rdparty/phonon/mmf/abstractvideoplayer.cpp
changeset 33 3e2da88830cd
parent 22 79de32ba3296
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    64         m_window = m_videoOutput->videoWindow();
    64         m_window = m_videoOutput->videoWindow();
    65     }
    65     }
    66 
    66 
    67     createPlayer();
    67     createPlayer();
    68 
    68 
       
    69     m_player->RegisterForVideoLoadingNotification(*this);
       
    70 
    69     TRACE_EXIT_0();
    71     TRACE_EXIT_0();
    70 }
    72 }
    71 
    73 
    72 MMF::AbstractVideoPlayer::~AbstractVideoPlayer()
    74 MMF::AbstractVideoPlayer::~AbstractVideoPlayer()
    73 {
    75 {
   209 void MMF::AbstractVideoPlayer::aspectRatioChanged()
   211 void MMF::AbstractVideoPlayer::aspectRatioChanged()
   210 {
   212 {
   211     TRACE_CONTEXT(AbstractVideoPlayer::aspectRatioChanged, EVideoInternal);
   213     TRACE_CONTEXT(AbstractVideoPlayer::aspectRatioChanged, EVideoInternal);
   212     TRACE_ENTRY("state %d aspectRatio %d", state());
   214     TRACE_ENTRY("state %d aspectRatio %d", state());
   213 
   215 
   214     updateScaleFactors(m_videoOutput->videoWindowSize());
   216     if (m_videoOutput)
       
   217         updateScaleFactors(m_videoOutput->videoWindowSize());
   215 
   218 
   216     TRACE_EXIT_0();
   219     TRACE_EXIT_0();
   217 }
   220 }
   218 
   221 
   219 void MMF::AbstractVideoPlayer::scaleModeChanged()
   222 void MMF::AbstractVideoPlayer::scaleModeChanged()
   220 {
   223 {
   221     TRACE_CONTEXT(AbstractVideoPlayer::scaleModeChanged, EVideoInternal);
   224     TRACE_CONTEXT(AbstractVideoPlayer::scaleModeChanged, EVideoInternal);
   222     TRACE_ENTRY("state %d", state());
   225     TRACE_ENTRY("state %d", state());
   223 
   226 
   224     updateScaleFactors(m_videoOutput->videoWindowSize());
   227     if (m_videoOutput)
       
   228         updateScaleFactors(m_videoOutput->videoWindowSize());
   225 
   229 
   226     TRACE_EXIT_0();
   230     TRACE_EXIT_0();
   227 }
   231 }
   228 
   232 
   229 
   233 
   355     TRACE_EXIT_0();
   359     TRACE_EXIT_0();
   356 }
   360 }
   357 
   361 
   358 void MMF::AbstractVideoPlayer::initVideoOutput()
   362 void MMF::AbstractVideoPlayer::initVideoOutput()
   359 {
   363 {
       
   364     Q_ASSERT(m_videoOutput);
       
   365 
   360     bool connected = connect(
   366     bool connected = connect(
   361         m_videoOutput, SIGNAL(videoWindowChanged()),
   367         m_videoOutput, SIGNAL(videoWindowChanged()),
   362         this, SLOT(videoWindowChanged())
   368         this, SLOT(videoWindowChanged())
   363     );
   369     );
   364     Q_ASSERT(connected);
   370     Q_ASSERT(connected);
   376     Q_ASSERT(connected);
   382     Q_ASSERT(connected);
   377 
   383 
   378     // Suppress warnings in release builds
   384     // Suppress warnings in release builds
   379     Q_UNUSED(connected);
   385     Q_UNUSED(connected);
   380 
   386 
   381     // Do these after all connections are complete, to ensure
       
   382     // that any signals generated get to their destinations.
       
   383     m_videoOutput->winId();
       
   384     m_videoOutput->setVideoSize(m_videoFrameSize);
   387     m_videoOutput->setVideoSize(m_videoFrameSize);
   385 }
   388 }
   386 
   389 
   387 // Helper function for aspect ratio / scale mode handling
   390 // Helper function for aspect ratio / scale mode handling
   388 QSize scaleToAspect(const QSize &srcRect, int aspectWidth, int aspectHeight)
   391 QSize scaleToAspect(const QSize &srcRect, int aspectWidth, int aspectHeight)
   398     return QSize(width, height);
   401     return QSize(width, height);
   399 }
   402 }
   400 
   403 
   401 void MMF::AbstractVideoPlayer::updateScaleFactors(const QSize &windowSize, bool apply)
   404 void MMF::AbstractVideoPlayer::updateScaleFactors(const QSize &windowSize, bool apply)
   402 {
   405 {
       
   406     Q_ASSERT(m_videoOutput);
       
   407 
   403     if (m_videoFrameSize.isValid()) {
   408     if (m_videoFrameSize.isValid()) {
   404         QRect videoRect;
   409         QRect videoRect;
   405 
   410 
   406         // Calculate size of smallest rect which contains video frame size
   411         // Calculate size of smallest rect which contains video frame size
   407         // and conforms to aspect ratio
   412         // and conforms to aspect ratio