TrackWorkflow.h 5.55 KB
Newer Older
1 2 3
/*****************************************************************************
 * TrackWorkflow.h : Will query the Clip workflow for each successive clip in the track
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
 *
 * 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.
 *****************************************************************************/

#ifndef TRACKWORKFLOW_H
#define TRACKWORKFLOW_H

26
#include "MainWorkflow.h"
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
27
#include "StackedBuffer.hpp"
28

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#include <QObject>

class   ClipWorkflow;
class   LightVideoFrame;

class   QDomElement;
class   QDomElement;
template <typename T>
class   QList;
template <typename T, typename U>
class   QMap;
class   QMutex;
class   QReadWriteLock;
class   QWaitCondition;

44 45
//TODO: REMOVE THIS
#ifndef FPS
46
#define FPS     30
47
#endif
48

49 50 51 52
#ifndef MAX_TRACKS
#define MAX_TRACKS 64
#endif

53 54 55 56 57
class   TrackWorkflow : public QObject
{
    Q_OBJECT

    public:
58
        TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type );
59
        ~TrackWorkflow();
60

61
        void*                                   getOutput( qint64 currentFrame,
62
                                                           qint64 subFrame, bool paused );
63
        qint64                                  getLength() const;
64
        void                                    stop();
65 66
        void                                    moveClip( const QUuid& id, qint64 startingFrame );
        Clip*                                   removeClip( const QUuid& id );
67
        ClipWorkflow*                           removeClipWorkflow( const QUuid& id );
68
        void                                    addClip( Clip*, qint64 start );
69
        void                                    addClip( ClipWorkflow*, qint64 start );
70
        qint64                                  getClipPosition( const QUuid& uuid ) const;
71
        Clip*                                   getClip( const QUuid& uuid );
72

73
        //FIXME: this won't be reliable as soon as we change the fps from the configuration
74
        static const unsigned int               nbFrameBeforePreload = 60;
75

76
        void                                    save( QDomDocument& doc, QDomElement& trackNode ) const;
77
        void                                    clear();
78

79
        void                                    forceRepositionning();
80
        void                                    renderOneFrame();
81

82 83 84 85 86
        /**
         *  \sa     MainWorkflow::setFullSpeedRender();
         */
        void                                    setFullSpeedRender( bool val );

87 88 89 90 91 92 93 94 95
        /**
         *  \brief      Mute a clip
         *
         *  Mutting a clip will prevent it to be rendered.
         *  \param  uuid    The uuid of the clip to mute.
         */
        void                                    muteClip( const QUuid& uuid );
        void                                    unmuteClip( const QUuid& uuid );

96
    private:
97
        void                                    computeLength();
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
98
        void*                                   renderClip( ClipWorkflow* cw, qint64 currentFrame,
99
                                                            qint64 start, bool needRepositioning,
100
                                                            bool renderOneFrame, bool paused );
101
        void                                    preloadClip( ClipWorkflow* cw );
102
        void                                    stopClipWorkflow( ClipWorkflow* cw );
103
        bool                                    checkEnd( qint64 currentFrame ) const;
104
        void                                    adjustClipTime( qint64 currentFrame, qint64 start, ClipWorkflow* cw );
105
        void                                    releasePreviousRender();
106

107

108
    private:
109 110
        unsigned int                            m_trackId;

111
        QMap<qint64, ClipWorkflow*>             m_clips;
112

113
        /**
114
         *  \brief      The track length in frames.
115 116
        */
        qint64                                  m_length;
117

118 119 120 121 122 123
        /**
         *  \brief      If a clip was moved, we may have to force repositionning.
         *              If this flag is set to true, we will force it anyway.
         */
        bool                                    m_forceRepositionning;
        QMutex*                                 m_forceRepositionningMutex;
124 125
        bool                                    m_renderOneFrame;
        QMutex                                  *m_renderOneFrameMutex;
126

127
        QReadWriteLock*                         m_clipsLock;
128

129
        MainWorkflow::TrackType                 m_trackType;
130
        qint64                                  m_lastFrame;
131 132
        StackedBuffer<LightVideoFrame*>*                    m_videoStackedBuffer;
        StackedBuffer<AudioClipWorkflow::AudioSample*>*     m_audioStackedBuffer;
133

134
    signals:
135
        void                                    trackEndReached( unsigned int );
136 137 138
};

#endif // TRACKWORKFLOW_H