qtmobility/plugins/multimedia/symbian/mmf/mediaplayer/s60videooverlay.cpp
changeset 4 90517678cc4f
child 11 06b8e2af4411
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include <QVideoSurfaceFormat>
       
    43 #include "s60videooverlay.h"
       
    44 #include "s60videosurface.h"
       
    45 
       
    46 S60VideoOverlay::S60VideoOverlay(QObject *parent)
       
    47     : QVideoWindowControl(parent)
       
    48     , m_surface(new S60VideoSurface)
       
    49     , m_aspectRatioMode(Qt::KeepAspectRatio)
       
    50     , m_fullScreen(false)
       
    51 {
       
    52     connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
       
    53             this, SLOT(surfaceFormatChanged()));
       
    54 }
       
    55 
       
    56 S60VideoOverlay::~S60VideoOverlay()
       
    57 {
       
    58     delete m_surface;
       
    59 }
       
    60 
       
    61 WId S60VideoOverlay::winId() const
       
    62 {
       
    63     return m_surface->winId();
       
    64 }
       
    65 
       
    66 void S60VideoOverlay::setWinId(WId id)
       
    67 {
       
    68     m_surface->setWinId(id);
       
    69 }
       
    70 
       
    71 QRect S60VideoOverlay::displayRect() const
       
    72 {
       
    73     return m_displayRect;
       
    74 }
       
    75 
       
    76 void S60VideoOverlay::setDisplayRect(const QRect &rect)
       
    77 {
       
    78     m_displayRect = rect;
       
    79 
       
    80     setScaledDisplayRect();
       
    81 }
       
    82 
       
    83 Qt::AspectRatioMode S60VideoOverlay::aspectRatioMode() const
       
    84 {
       
    85     return m_aspectRatioMode;
       
    86 }
       
    87 
       
    88 void S60VideoOverlay::setAspectRatioMode(Qt::AspectRatioMode ratio)
       
    89 {
       
    90     m_aspectRatioMode = ratio;
       
    91 
       
    92     setScaledDisplayRect();
       
    93 }
       
    94 
       
    95 QSize S60VideoOverlay::customAspectRatio() const
       
    96 {
       
    97     return m_aspectRatio;
       
    98 }
       
    99 
       
   100 void S60VideoOverlay::setCustomAspectRatio(const QSize &customRatio)
       
   101 {
       
   102     m_aspectRatio = customRatio;
       
   103 
       
   104     setScaledDisplayRect();
       
   105 }
       
   106 
       
   107 void S60VideoOverlay::repaint()
       
   108 {
       
   109 }
       
   110 
       
   111 int S60VideoOverlay::brightness() const
       
   112 {
       
   113     return m_surface->brightness();
       
   114 }
       
   115 
       
   116 void S60VideoOverlay::setBrightness(int brightness)
       
   117 {
       
   118     m_surface->setBrightness(brightness);
       
   119 
       
   120     emit brightnessChanged(m_surface->brightness());
       
   121 }
       
   122 
       
   123 int S60VideoOverlay::contrast() const
       
   124 {
       
   125     return m_surface->contrast();
       
   126 }
       
   127 
       
   128 void S60VideoOverlay::setContrast(int contrast)
       
   129 {
       
   130     m_surface->setContrast(contrast);
       
   131 
       
   132     emit contrastChanged(m_surface->contrast());
       
   133 }
       
   134 
       
   135 int S60VideoOverlay::hue() const
       
   136 {
       
   137     return m_surface->hue();
       
   138 }
       
   139 
       
   140 void S60VideoOverlay::setHue(int hue)
       
   141 {
       
   142     m_surface->setHue(hue);
       
   143 
       
   144     emit hueChanged(m_surface->hue());
       
   145 }
       
   146 
       
   147 int S60VideoOverlay::saturation() const
       
   148 {
       
   149     return m_surface->saturation();
       
   150 }
       
   151 
       
   152 void S60VideoOverlay::setSaturation(int saturation)
       
   153 {
       
   154     m_surface->setSaturation(saturation);
       
   155 
       
   156     emit saturationChanged(m_surface->saturation());
       
   157 }
       
   158 
       
   159 bool S60VideoOverlay::isFullScreen() const
       
   160 {
       
   161     return m_fullScreen;
       
   162 }
       
   163 
       
   164 void S60VideoOverlay::setFullScreen(bool fullScreen)
       
   165 {
       
   166     emit fullScreenChanged(m_fullScreen = fullScreen);
       
   167 }
       
   168 
       
   169 QSize S60VideoOverlay::nativeSize() const
       
   170 {
       
   171     return m_surface->surfaceFormat().sizeHint();
       
   172 }
       
   173 
       
   174 QAbstractVideoSurface *S60VideoOverlay::surface() const
       
   175 {
       
   176     return m_surface;
       
   177 }
       
   178 
       
   179 void S60VideoOverlay::surfaceFormatChanged()
       
   180 {
       
   181     setScaledDisplayRect();
       
   182 
       
   183     emit nativeSizeChanged();
       
   184 }
       
   185 
       
   186 void S60VideoOverlay::setScaledDisplayRect()
       
   187 {
       
   188     switch (m_aspectRatioMode) {
       
   189     case Qt::KeepAspectRatio:
       
   190         {
       
   191             QSize size = m_surface->surfaceFormat().viewport().size();
       
   192 
       
   193             size.scale(m_displayRect.size(), Qt::KeepAspectRatio);
       
   194 
       
   195             QRect rect(QPoint(0, 0), size);
       
   196             rect.moveCenter(m_displayRect.center());
       
   197 
       
   198             m_surface->setDisplayRect(rect);
       
   199         }
       
   200         break;
       
   201     case Qt::IgnoreAspectRatio:
       
   202         m_surface->setDisplayRect(m_displayRect);
       
   203         break;
       
   204     };
       
   205 }