GenericRenderer.h 6.02 KB
Newer Older
1
/*****************************************************************************
2
 * GenericRenderer.h: Describe a common behavior for every renderers
3
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
5
 *
6
 * Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

23 24
#ifndef GENERICRENDERER_H
#define GENERICRENDERER_H
25

26 27
#include "config.h"

28
#include <QObject>
29 30 31
#ifdef WITH_GUI
# include <QWidget>
#endif
32

33
#include "EffectUser.h"
34
#include "Types.h"
35
#include "RendererEventWatcher.h"
36

37 38 39
class   Clip;
class   Media;

40 41 42
/**
 *  \class  Common base for every renderer.
 */
43
class   GenericRenderer : public EffectUser
44 45
{
    Q_OBJECT
46
    Q_DISABLE_COPY( GenericRenderer )
47

48
protected:
49
    explicit GenericRenderer();
50 51

public:
52
    virtual ~GenericRenderer();
53

54
#ifdef WITH_GUI
55 56 57 58 59
    /**
     *  \brief  Set the widget used for rendering the output.
     *  \param  renderWidget    The widget to use for render.
     *  \sa     setPreviewLabel( QLabel* )
     */
60
    void                setRenderWidget( QWidget* renderWidget );
61
#endif
62 63 64 65 66 67

    /**
     *  \brief  Set the output volume.
     *  \param  volume the volume (int)
     *  \sa     getVolume()
     */
68
    virtual void        setVolume( int volume ) = 0;
69

70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
    /**
     *  \brief          Play or pause the media.
     *
     *  This method is renderer dependant. It has to be implemented in the
     *  underlying renderer implementation.
     *  When this method is called :
     *      - if the render has not started and forcePause is false, the render is started
     *      - if the render has not started and forcePause is true, nothing happens.
     *      - if the render has started and is not paused, the render will pause
     *      - if the render has started, and is paused, the render will unpause if
     *          forcePause is false.
     *  \param  forcePause  Will force the pause if true.
     *  \sa     stop()
     */
    virtual void        togglePlayPause( bool forcePause = false ) = 0;
85 86

    /**
87 88
     *  \brief Render the next frame
     *  \sa     previousFrame()
89
     */
90
    virtual void                    nextFrame() = 0;
91 92

    /**
93 94
     *  \brief  Render the previous frame
     *  \sa     nextFrame();
95
     */
96
    virtual void                    previousFrame() = 0;
97 98

    /**
99 100
     *  \brief Stop the renderer.
     *  \sa togglePlayPause( bool );
101
     */
102
    virtual void                    stop() = 0;
103

104 105 106 107 108 109 110
    /**
     *  \brief   Return the volume
     *  \return  The Return the volume the audio level (int)
     *  \sa     setVolume( int )
     */
    virtual int                     getVolume() const = 0;

111
    /**
112 113 114
     * \brief   Return the length in milliseconds
     * \return  The length of the underlying rendered target in milliseconds
     *  \sa     getLength()
115
     */
116
    virtual qint64                  getLengthMs() const = 0;
117 118

    /**
119 120
     *  \brief  Return the current frame number
     *  \return The current frame
121
     */
122
    virtual qint64                  getCurrentFrame() const = 0;
123 124

    /**
125 126
     *  \brief Return the number of frames per second
     *  \return     The current fps
127
     */
128
    virtual float                   getFps() const = 0;
129

130
    /**
131 132 133 134 135
     *  \brief      Return the length in frames
     *  \warning    The returned value may not be accurate as it depends on FPS, that
     *              can be badly computed
     *  \return     The length that has to be rendered in frames
     *  \sa         getLengthMs()
136
     */
137
    virtual qint64                  length() const = 0;
138 139

    /**
140 141
     *  \brief  Return true if the renderer is paused
     *  \return true if the renderer is paused. false otherwise.
142
     */
143 144 145 146
    bool                            isPaused() const
    {
        return m_paused;
    }
147 148

    /**
149 150 151 152
     *  \brief      Return true if the renderer is currently rendering.
     *  \return     true if the renderer is currently rendering. false otherwise.
     *              Note that a paused renderer is still rendering
     *  \sa         isPaused()
153
     */
154 155 156 157
    bool                            isRendering() const
    {
        return m_isRendering;
    }
158

159 160 161 162
    EffectUser::Type                effectType() const
    {
        return EffectUser::GlobalEffectUser;
    }
163

164 165
    RendererEventWatcher*           eventWatcher();

166
protected:
167 168 169
    Backend::ISourceRenderer*       m_sourceRenderer;
    RendererEventWatcher*           m_eventWatcher;

170 171 172 173
    /**
     *  \brief  This flag allows us to know if the render is paused
     *          or not, without using libvlc, especially for the render preview.
     *  If the video is stopped, then this flag will be equal to false
174
     *  \warning    This is not thread safe.
175
     *  \sa         isPaused()
176 177
     */
    bool                            m_paused;
178

179
    QWidget*                        m_renderWidget;
180

181
public slots:
182 183 184 185 186 187 188
    /**
     *  \brief      This SLOT will be called when the time cursor has changed.
     *
     *  This mainly means that the current rendered frame should change.
     *  \param      newFrame    The new frame to render from.
     */
    virtual void                    previewWidgetCursorChanged( qint64 newFrame ) = 0;
189

190 191

signals:
192
    void                            frameChanged( qint64 newFrame,
193
                                                Vlmc::FrameChangedReason reason );
194 195
};

196
#endif // GENERICRENDERER_H