Warning, file /libraries/phonon-vlc/src/video/videowidget.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 Copyright (C) 2007-2008 Tanguy Krotoff <tkrotoff@gmail.com> 0003 Copyright (C) 2008 Lukas Durfina <lukas.durfina@gmail.com> 0004 Copyright (C) 2009 Fathi Boudra <fabo@kde.org> 0005 Copyright (C) 2009-2011 vlc-phonon AUTHORS <kde-multimedia@kde.org> 0006 Copyright (C) 2011-2019 Harald Sitter <sitter@kde.org> 0007 0008 This library is free software; you can redistribute it and/or 0009 modify it under the terms of the GNU Lesser General Public 0010 License as published by the Free Software Foundation; either 0011 version 2.1 of the License, or (at your option) any later version. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 */ 0021 0022 #ifndef PHONON_VLC_VIDEOWIDGET_H 0023 #define PHONON_VLC_VIDEOWIDGET_H 0024 0025 #include <QWidget> 0026 0027 #include <phonon/videowidgetinterface.h> 0028 0029 #ifdef Q_OS_MAC 0030 #include "video/mac/vlcmacwidget.h" 0031 typedef VlcMacWidget BaseWidget; 0032 #else 0033 typedef QWidget BaseWidget; 0034 #endif 0035 0036 #include "sinknode.h" 0037 0038 namespace Phonon { 0039 namespace VLC { 0040 0041 class SurfacePainter; 0042 0043 /** \brief Implements the Phonon VideoWidget MediaNode, responsible for displaying video 0044 * 0045 * Phonon video is displayed using this widget. It implements the VideoWidgetInterface. 0046 * It is connected to a media object that provides the video source. Methods to control 0047 * video settings such as brightness or contrast are provided. 0048 */ 0049 class VideoWidget : public BaseWidget, public SinkNode, public VideoWidgetInterface44 0050 { 0051 Q_OBJECT 0052 Q_INTERFACES(Phonon::VideoWidgetInterface44) 0053 public: 0054 /** 0055 * Constructs a new VideoWidget with the given parent. The video settings members 0056 * are set to their default values. 0057 */ 0058 explicit VideoWidget(QWidget *parent); 0059 0060 /** 0061 * Death to the VideoWidget! 0062 */ 0063 ~VideoWidget(); 0064 0065 /** 0066 * Connects the VideoWidget to a media object by setting the video widget 0067 * window system identifier of the media object to that of the owned private 0068 * video widget. It also connects the signal from the mediaObject regarding 0069 * a resize of the video. 0070 * 0071 * If the mediaObject was connected to another VideoWidget, the connection is 0072 * lost. 0073 * 0074 * \see MediaObject 0075 * \param mediaObject What media object to connect to 0076 * \reimp 0077 */ 0078 void handleConnectToMediaObject(MediaObject *mediaObject) override; 0079 /** \reimp */ 0080 void handleDisconnectFromMediaObject(MediaObject *mediaObject) override; 0081 /** \reimp */ 0082 void handleAddToMedia(Media *media) override; 0083 0084 /** 0085 * \return The aspect ratio previously set for the video widget 0086 */ 0087 Phonon::VideoWidget::AspectRatio aspectRatio() const override; 0088 0089 /** 0090 * Set the aspect ratio of the video. 0091 * VLC accepted formats are x:y (4:3, 16:9, etc...) expressing the global image aspect. 0092 */ 0093 void setAspectRatio(Phonon::VideoWidget::AspectRatio aspect) override; 0094 0095 /** 0096 * \return The scale mode previously set for the video widget 0097 */ 0098 Phonon::VideoWidget::ScaleMode scaleMode() const override; 0099 0100 /** 0101 * Set how the video is scaled, keeping the aspect ratio into account when the video is resized. 0102 * 0103 * The ScaleMode enumeration describes how to treat aspect ratio during resizing of video. 0104 * \li Phonon::VideoWidget::FitInView - the video will be fitted to fill the view keeping aspect ratio 0105 * \li Phonon::VideoWidget::ScaleAndCrop - the video is scaled 0106 */ 0107 void setScaleMode(Phonon::VideoWidget::ScaleMode scale) override; 0108 0109 /** 0110 * \return The brightness previously set for the video widget 0111 */ 0112 qreal brightness() const override; 0113 0114 /** 0115 * Set the brightness of the video 0116 */ 0117 Q_INVOKABLE void setBrightness(qreal brightness) override; 0118 0119 /** 0120 * \return The contrast previously set for the video widget 0121 */ 0122 qreal contrast() const override; 0123 0124 /** 0125 * Set the contrast of the video 0126 */ 0127 Q_INVOKABLE void setContrast(qreal contrast) override; 0128 0129 /** 0130 * \return The hue previously set for the video widget 0131 */ 0132 qreal hue() const override; 0133 0134 /** 0135 * Set the hue of the video 0136 */ 0137 Q_INVOKABLE void setHue(qreal hue) override; 0138 0139 /** 0140 * \return The saturation previously set for the video widget 0141 */ 0142 qreal saturation() const override; 0143 0144 /** 0145 * Set the saturation of the video 0146 */ 0147 Q_INVOKABLE void setSaturation(qreal saturation) override; 0148 0149 /** 0150 * \return The owned widget that is used for the actual draw. 0151 */ 0152 QWidget *widget() override; 0153 0154 /// \reimp 0155 QSize sizeHint() const override; 0156 0157 void setVisible(bool visible) override; 0158 0159 private Q_SLOTS: 0160 /// Updates the sizeHint to match the native size of the video. 0161 /// \param hasVideo \c true when there is a video, \c false otherwise 0162 void updateVideoSize(bool hasVideo); 0163 0164 /** 0165 * Sets all pending video adjusts (hue, brightness etc.) that the application 0166 * wanted to set before the vidoe became available. 0167 * 0168 * \param videoAvailable whether or not video is available at the time of calling 0169 */ 0170 void processPendingAdjusts(bool videoAvailable); 0171 0172 /** 0173 * Clears all pending video adjusts (hue, brightness etc.). 0174 */ 0175 void clearPendingAdjusts(); 0176 0177 protected: 0178 /// \reimp 0179 void paintEvent(QPaintEvent *event) override; 0180 0181 private: 0182 /** 0183 * Sets whether filter adjust is active or not. 0184 * 0185 * \param adjust true if adjust is supposed to be activated, false if not 0186 * 0187 * \returns whether the adjust request was accepted, if not the callee should 0188 * add the request to m_pendingAdjusts for later processing once a video 0189 * became available. Adjusts get accepted always except when 0190 * MediaObject::hasVideo() is false, so it is not related to the 0191 * actual execution of the request. 0192 */ 0193 bool enableFilterAdjust(bool adjust = true); 0194 0195 /** 0196 * Converts a Phonon range to a VLC value range. 0197 * 0198 * A Phonon range is always a qreal between -1.0 and 1.0, a VLC range however 0199 * can be any between 0 and 360. This function maps the Phonon value to an 0200 * appropriate value within a specified target range. 0201 * 0202 * \param phononValue the incoming Phonon specific value, should be -1.0:1.0 0203 * should it however not be within that range will it be 0204 * manually locked (i.e. exceeding values become either -1.0 or 1.0) 0205 * \param upperBoundary the upper boundary for the target range. The lower 0206 * boundary is currently always assumed to be 0 0207 * \param shift whether or not to shift the Phonon range to positive values 0208 * before mapping to VLC values (useful when our 0 must be a VLC 0). 0209 * Please note that if you do not shift the range will be reduced to 0210 * 0:1, phononValue < 0 will be set to 0. 0211 * 0212 * \returns float usable to VLC 0213 */ 0214 static float phononRangeToVlcRange(qreal phononValue, float upperBoundary, 0215 bool shift = true); 0216 0217 /** 0218 * \return The snapshot of the current video frame. 0219 */ 0220 QImage snapshot() const override; 0221 0222 /** 0223 * Enables the mighty surface painter (qpaints frames). 0224 */ 0225 void enableSurfacePainter(); 0226 0227 /** 0228 * Pending video adjusts the application tried to set before we actually 0229 * had a video to set them on. 0230 */ 0231 QHash<QByteArray, qreal> m_pendingAdjusts; 0232 0233 /** 0234 * Original size of the video, needed for sizeHint(). 0235 */ 0236 QSize m_videoSize; 0237 0238 Phonon::VideoWidget::AspectRatio m_aspectRatio; 0239 Phonon::VideoWidget::ScaleMode m_scaleMode; 0240 0241 bool m_filterAdjustActivated; 0242 qreal m_brightness; 0243 qreal m_contrast; 0244 qreal m_hue; 0245 qreal m_saturation; 0246 0247 SurfacePainter *m_surfacePainter; 0248 }; 0249 0250 } // namespace VLC 0251 } // namespace Phonon 0252 0253 #endif // PHONON_VLC_VIDEOWIDGET_H