TrackHandler.h 4.46 KB
Newer Older
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*****************************************************************************
 * TrackHandler.h : Handle multiple track of a kind (audio or video)
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * 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 TRACKHANDLER_H
#define TRACKHANDLER_H

#include <QObject>
#include "Toggleable.hpp"
#include "TrackWorkflow.h"
29
#include "EffectsEngine.h"
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
30 31 32 33 34

class   TrackHandler : public QObject
{
    Q_OBJECT
    public:
35
        TrackHandler( unsigned int nbTracks, TrackWorkflow::TrackType trackType, EffectsEngine* effectsEngine );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
        ~TrackHandler();

        void                    addClip( Clip* clip, unsigned int trackId, qint64 start );
        /**
         *  Returns the number of tracks in this handler
         */
        unsigned int            getTrackCount() const;
        qint64                  getLength() const;
        void                    startRender();
        void                    getOutput( qint64 currentFrame );
        void                    pause();
        void                    unpause();
        void                    activateAll();
        qint64                  getClipPosition( const QUuid& uuid, unsigned int trackId ) const;
        void                    stop();
        void                    moveClip( const QUuid& clipUuid, unsigned int oldTrack,
52
                                          unsigned int newTrack, qint64 startingFrame );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
53 54 55 56 57 58
        Clip*                   removeClip( const QUuid& uuid, unsigned int trackId );
        void                    muteTrack( unsigned int trackId );
        void                    unmuteTrack( unsigned int trackId );
        Clip*                   getClip( const QUuid& uuid, unsigned int trackId );
        void                    clear();
        void                    setFullSpeedRender( bool value );
59
        void*                   getSynchroneOutput();
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
60 61 62 63 64 65 66 67 68

        bool                    isPaused() const;
        bool                    allTracksRendered() const;

    private:
        void                    computeLength();
        void                    activateTrack( unsigned int tracKId );

    private:
69
        static LightVideoFrame*         nullOutput;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
70 71 72 73 74 75 76 77 78 79
        Toggleable<TrackWorkflow*>*     m_tracks;
        unsigned int                    m_trackCount;
        QAtomicInt                      m_nbTracksToPause;
        QAtomicInt                      m_nbTracksToUnpause;
        TrackWorkflow::TrackType        m_trackType;
        qint64                          m_length;
        QMutex*                         m_highestTrackNumberMutex;
        unsigned int                    m_highestTrackNumber;
        unsigned int                    m_nbTracksToRender;
        QMutex*                         m_nbTracksToRenderMutex;
80
        void*                           m_synchroneRenderingBuffer;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
81 82 83 84 85 86 87
        bool                            m_paused;
        /**
         *  \brief  This flag is used to know if all tracks handled
         *          have been rendered.
         *          This is for internal synchronisation only.
         */
        bool                            m_renderCompleted;
88
        EffectsEngine*                  m_effectEngine;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102


    private slots:
        void                            trackEndReached( unsigned int trackId );
        void                            trackPaused();
        void                            trackUnpaused();
        void                            tracksRenderCompleted( unsigned int trackId );

    signals:
        void                            tracksPaused();
        void                            allTracksRenderCompleted();
};

#endif // TRACKHANDLER_H