| 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 |
|
| 22 |
#include "videowidget.h" |
| 23 |
|
| 24 |
#ifdef PHONON_MMF_VIDEO_SURFACES |
| 25 |
#include "videooutput_surface.h" |
| 26 |
#else |
| 27 |
#include "videooutput_dsa.h" |
| 28 |
#endif |
| 29 |
|
| 30 |
QT_BEGIN_NAMESPACE |
| 31 |
|
| 32 |
using namespace Phonon; |
| 33 |
using namespace Phonon::MMF; |
| 34 |
|
| 35 |
/*! \class MMF::VideoWidget |
| 36 |
\internal |
| 37 |
*/ |
| 38 |
|
| 39 |
//----------------------------------------------------------------------------- |
| 40 |
// Constants |
| 41 |
//----------------------------------------------------------------------------- |
| 42 |
|
| 43 |
static const qreal DefaultBrightness = 1.0; |
| 44 |
static const qreal DefaultContrast = 1.0; |
| 45 |
static const qreal DefaultHue = 1.0; |
| 46 |
static const qreal DefaultSaturation = 1.0; |
| 47 |
|
| 48 |
|
| 49 |
//----------------------------------------------------------------------------- |
| 50 |
// Constructor / destructor |
| 51 |
//----------------------------------------------------------------------------- |
| 52 |
|
| 53 |
MMF::VideoWidget::VideoWidget(QWidget *parent) |
| 54 |
: MediaNode(parent) |
| 55 |
#ifdef PHONON_MMF_VIDEO_SURFACES |
| 56 |
, m_videoOutput(new SurfaceVideoOutput(parent)) |
| 57 |
#else |
| 58 |
, m_videoOutput(new DsaVideoOutput(parent)) |
| 59 |
#endif |
| 60 |
, m_brightness(DefaultBrightness) |
| 61 |
, m_contrast(DefaultContrast) |
| 62 |
, m_hue(DefaultHue) |
| 63 |
, m_saturation(DefaultSaturation) |
| 64 |
{ |
| 65 |
TRACE_CONTEXT(VideoWidget::VideoWidget, EVideoApi); |
| 66 |
TRACE_ENTRY_0(); |
| 67 |
|
| 68 |
parent->setProperty("_q_DummyWindowSurface", true); |
| 69 |
|
| 70 |
TRACE_EXIT_0(); |
| 71 |
} |
| 72 |
|
| 73 |
MMF::VideoWidget::~VideoWidget() |
| 74 |
{ |
| 75 |
TRACE_CONTEXT(VideoWidget::~VideoWidget, EVideoApi); |
| 76 |
TRACE_ENTRY_0(); |
| 77 |
|
| 78 |
TRACE_EXIT_0(); |
| 79 |
} |
| 80 |
|
| 81 |
#ifndef PHONON_MMF_VIDEO_SURFACES |
| 82 |
void MMF::VideoWidget::setAncestorMoveMonitor(AncestorMoveMonitor *monitor) |
| 83 |
{ |
| 84 |
static_cast<DsaVideoOutput *>(m_videoOutput.data())->setAncestorMoveMonitor(monitor); |
| 85 |
} |
| 86 |
#endif |
| 87 |
|
| 88 |
|
| 89 |
//----------------------------------------------------------------------------- |
| 90 |
// VideoWidgetInterface |
| 91 |
//----------------------------------------------------------------------------- |
| 92 |
|
| 93 |
Phonon::VideoWidget::AspectRatio MMF::VideoWidget::aspectRatio() const |
| 94 |
{ |
| 95 |
return m_videoOutput->aspectRatio(); |
| 96 |
} |
| 97 |
|
| 98 |
void MMF::VideoWidget::setAspectRatio |
| 99 |
(Phonon::VideoWidget::AspectRatio aspectRatio) |
| 100 |
{ |
| 101 |
TRACE_CONTEXT(VideoWidget::setAspectRatio, EVideoApi); |
| 102 |
TRACE("aspectRatio %d", aspectRatio); |
| 103 |
|
| 104 |
m_videoOutput->setAspectRatio(aspectRatio); |
| 105 |
} |
| 106 |
|
| 107 |
qreal MMF::VideoWidget::brightness() const |
| 108 |
{ |
| 109 |
return m_brightness; |
| 110 |
} |
| 111 |
|
| 112 |
void MMF::VideoWidget::setBrightness(qreal brightness) |
| 113 |
{ |
| 114 |
TRACE_CONTEXT(VideoWidget::setBrightness, EVideoApi); |
| 115 |
TRACE("brightness %f", brightness); |
| 116 |
|
| 117 |
m_brightness = brightness; |
| 118 |
} |
| 119 |
|
| 120 |
Phonon::VideoWidget::ScaleMode MMF::VideoWidget::scaleMode() const |
| 121 |
{ |
| 122 |
return m_videoOutput->scaleMode(); |
| 123 |
} |
| 124 |
|
| 125 |
void MMF::VideoWidget::setScaleMode(Phonon::VideoWidget::ScaleMode scaleMode) |
| 126 |
{ |
| 127 |
TRACE_CONTEXT(VideoWidget::setScaleMode, EVideoApi); |
| 128 |
TRACE("setScaleMode %d", scaleMode); |
| 129 |
|
| 130 |
m_videoOutput->setScaleMode(scaleMode); |
| 131 |
} |
| 132 |
|
| 133 |
qreal MMF::VideoWidget::contrast() const |
| 134 |
{ |
| 135 |
return m_contrast; |
| 136 |
} |
| 137 |
|
| 138 |
void MMF::VideoWidget::setContrast(qreal contrast) |
| 139 |
{ |
| 140 |
TRACE_CONTEXT(VideoWidget::setContrast, EVideoApi); |
| 141 |
TRACE("contrast %f", contrast); |
| 142 |
|
| 143 |
m_contrast = contrast; |
| 144 |
} |
| 145 |
|
| 146 |
qreal MMF::VideoWidget::hue() const |
| 147 |
{ |
| 148 |
return m_hue; |
| 149 |
} |
| 150 |
|
| 151 |
void MMF::VideoWidget::setHue(qreal hue) |
| 152 |
{ |
| 153 |
TRACE_CONTEXT(VideoWidget::setHue, EVideoApi); |
| 154 |
TRACE("hue %f", hue); |
| 155 |
|
| 156 |
m_hue = hue; |
| 157 |
} |
| 158 |
|
| 159 |
qreal MMF::VideoWidget::saturation() const |
| 160 |
{ |
| 161 |
return m_saturation; |
| 162 |
} |
| 163 |
|
| 164 |
void MMF::VideoWidget::setSaturation(qreal saturation) |
| 165 |
{ |
| 166 |
TRACE_CONTEXT(VideoWidget::setSaturation, EVideoApi); |
| 167 |
TRACE("saturation %f", saturation); |
| 168 |
|
| 169 |
m_saturation = saturation; |
| 170 |
} |
| 171 |
|
| 172 |
QWidget* MMF::VideoWidget::widget() |
| 173 |
{ |
| 174 |
return m_videoOutput.data(); |
| 175 |
} |
| 176 |
|
| 177 |
//----------------------------------------------------------------------------- |
| 178 |
// MediaNode |
| 179 |
//----------------------------------------------------------------------------- |
| 180 |
|
| 181 |
void MMF::VideoWidget::connectMediaObject(MediaObject *mediaObject) |
| 182 |
{ |
| 183 |
mediaObject->setVideoOutput(m_videoOutput.data()); |
| 184 |
} |
| 185 |
|
| 186 |
void MMF::VideoWidget::disconnectMediaObject(MediaObject *mediaObject) |
| 187 |
{ |
| 188 |
mediaObject->setVideoOutput(0); |
| 189 |
} |
| 190 |
|
| 191 |
QT_END_NAMESPACE |