src/3rdparty/phonon/mmf/videowidget.cpp
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /*  This file is part of the KDE project.
       
     2 
       
     3 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 
       
     5 This library is free software: you can redistribute it and/or modify
       
     6 it under the terms of the GNU Lesser General Public License as published by
       
     7 the Free Software Foundation, either version 2.1 or 3 of the License.
       
     8 
       
     9 This library is distributed in the hope that it will be useful,
       
    10 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 GNU Lesser General Public License for more details.
       
    13 
       
    14 You should have received a copy of the GNU Lesser General Public License
       
    15 along with this library.  If not, see <http://www.gnu.org/licenses/>.
       
    16 
       
    17 */
       
    18 
       
    19 #include "mediaobject.h"
       
    20 #include "utils.h"
       
    21 #include "videooutput.h"
       
    22 
       
    23 #include "videowidget.h"
       
    24 
       
    25 QT_BEGIN_NAMESPACE
       
    26 
       
    27 using namespace Phonon;
       
    28 using namespace Phonon::MMF;
       
    29 
       
    30 /*! \class MMF::VideoWidget
       
    31   \internal
       
    32 */
       
    33 
       
    34 //-----------------------------------------------------------------------------
       
    35 // Constants
       
    36 //-----------------------------------------------------------------------------
       
    37 
       
    38 static const Phonon::VideoWidget::AspectRatio DefaultAspectRatio =
       
    39     Phonon::VideoWidget::AspectRatioAuto;
       
    40 static const qreal DefaultBrightness = 1.0;
       
    41 static const Phonon::VideoWidget::ScaleMode DefaultScaleMode =
       
    42     Phonon::VideoWidget::FitInView;
       
    43 static const qreal DefaultContrast = 1.0;
       
    44 static const qreal DefaultHue = 1.0;
       
    45 static const qreal DefaultSaturation = 1.0;
       
    46 
       
    47 
       
    48 //-----------------------------------------------------------------------------
       
    49 // Constructor / destructor
       
    50 //-----------------------------------------------------------------------------
       
    51 
       
    52 MMF::VideoWidget::VideoWidget(QWidget* parent)
       
    53         :   MediaNode(parent)
       
    54         ,   m_widget(new VideoOutput(parent))
       
    55         ,   m_aspectRatio(DefaultAspectRatio)
       
    56         ,   m_brightness(DefaultBrightness)
       
    57         ,   m_scaleMode(DefaultScaleMode)
       
    58         ,   m_contrast(DefaultContrast)
       
    59         ,   m_hue(DefaultHue)
       
    60         ,   m_saturation(DefaultSaturation)
       
    61 {
       
    62     TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi);
       
    63     TRACE_ENTRY_0();
       
    64 
       
    65     TRACE_EXIT_0();
       
    66 }
       
    67 
       
    68 MMF::VideoWidget::~VideoWidget()
       
    69 {
       
    70     TRACE_CONTEXT(VideoWidget::~VideoWidget, EVideoApi);
       
    71     TRACE_ENTRY_0();
       
    72 
       
    73     TRACE_EXIT_0();
       
    74 }
       
    75 
       
    76 
       
    77 //-----------------------------------------------------------------------------
       
    78 // VideoWidgetInterface
       
    79 //-----------------------------------------------------------------------------
       
    80 
       
    81 Phonon::VideoWidget::AspectRatio MMF::VideoWidget::aspectRatio() const
       
    82 {
       
    83     return m_aspectRatio;
       
    84 }
       
    85 
       
    86 void MMF::VideoWidget::setAspectRatio
       
    87 (Phonon::VideoWidget::AspectRatio aspectRatio)
       
    88 {
       
    89     TRACE_CONTEXT(VideoWidget::setAspectRatio, EVideoApi);
       
    90     TRACE("aspectRatio %d", aspectRatio);
       
    91 
       
    92     m_aspectRatio = aspectRatio;
       
    93 }
       
    94 
       
    95 qreal MMF::VideoWidget::brightness() const
       
    96 {
       
    97     return m_brightness;
       
    98 }
       
    99 
       
   100 void MMF::VideoWidget::setBrightness(qreal brightness)
       
   101 {
       
   102     TRACE_CONTEXT(VideoWidget::setBrightness, EVideoApi);
       
   103     TRACE("brightness %f", brightness);
       
   104 
       
   105     m_brightness = brightness;
       
   106 }
       
   107 
       
   108 Phonon::VideoWidget::ScaleMode MMF::VideoWidget::scaleMode() const
       
   109 {
       
   110     return m_scaleMode;
       
   111 }
       
   112 
       
   113 void MMF::VideoWidget::setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode)
       
   114 {
       
   115     TRACE_CONTEXT(VideoWidget::setScaleMode, EVideoApi);
       
   116     TRACE("setScaleMode %d", setScaleMode);
       
   117 
       
   118     m_scaleMode = scaleMode;
       
   119 }
       
   120 
       
   121 qreal MMF::VideoWidget::contrast() const
       
   122 {
       
   123     return m_contrast;
       
   124 }
       
   125 
       
   126 void MMF::VideoWidget::setContrast(qreal contrast)
       
   127 {
       
   128     TRACE_CONTEXT(VideoWidget::setContrast, EVideoApi);
       
   129     TRACE("contrast %f", contrast);
       
   130 
       
   131     m_contrast = contrast;
       
   132 }
       
   133 
       
   134 qreal MMF::VideoWidget::hue() const
       
   135 {
       
   136     return m_hue;
       
   137 }
       
   138 
       
   139 void MMF::VideoWidget::setHue(qreal hue)
       
   140 {
       
   141     TRACE_CONTEXT(VideoWidget::setHue, EVideoApi);
       
   142     TRACE("hue %f", hue);
       
   143 
       
   144     m_hue = hue;
       
   145 }
       
   146 
       
   147 qreal MMF::VideoWidget::saturation() const
       
   148 {
       
   149     return m_saturation;
       
   150 }
       
   151 
       
   152 void MMF::VideoWidget::setSaturation(qreal saturation)
       
   153 {
       
   154     TRACE_CONTEXT(VideoWidget::setSaturation, EVideoApi);
       
   155     TRACE("saturation %f", saturation);
       
   156 
       
   157     m_saturation = saturation;
       
   158 }
       
   159 
       
   160 QWidget* MMF::VideoWidget::widget()
       
   161 {
       
   162     return m_widget.data();
       
   163 }
       
   164 
       
   165 VideoOutput& MMF::VideoWidget::videoOutput()
       
   166 {
       
   167     return *static_cast<VideoOutput*>(widget());
       
   168 }
       
   169 
       
   170 bool MMF::VideoWidget::activateOnMediaObject(MediaObject *mo)
       
   171 {
       
   172     mo->setVideoOutput(&videoOutput());
       
   173     return true;
       
   174 }
       
   175 
       
   176 QT_END_NAMESPACE
       
   177