TrackHandler.h 4.21 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
/*****************************************************************************
 * 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"
28
#include "EffectsEngine.h"
29 30
#include "MainWorkflow.h"

31 32 33
//TEMPORARY:
#include "AudioClipWorkflow.h"

34
class   TrackWorkflow;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
35 36 37 38 39

class   TrackHandler : public QObject
{
    Q_OBJECT
    public:
40
        TrackHandler( unsigned int nbTracks, MainWorkflow::TrackType trackType, EffectsEngine* effectsEngine );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
41 42 43 44 45 46 47 48 49
        ~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();
50 51 52 53 54
        /**
         *  \param      currentFrame    The current rendering frame (ie the video frame, in all case)
         *  \todo       This should probably be partialy handled by the trackHandler, as the work
         *              is exactly the same for both audio and video trackWorkflow in most of the case... or not.
         */
55
        void                    getOutput( qint64 currentFrame );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
56 57 58 59 60 61
        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,
62
                                          unsigned int newTrack, qint64 startingFrame );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
63 64 65 66 67 68
        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();

69
        //FIXME: remove this. This should go by the effect engine.
70
        AudioClipWorkflow::AudioSample* getTmpAudioBuffer() { return m_tmpAudioBuffer; }
71

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
72
        bool                    isPaused() const;
73
        bool                    endIsReached() const;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
74

75 76
        void                    save( QDomDocument& doc, QDomElement& timelineNode ) const;

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
77 78 79 80 81
    private:
        void                    computeLength();
        void                    activateTrack( unsigned int tracKId );

    private:
82
        static LightVideoFrame*         nullOutput;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
83 84
        Toggleable<TrackWorkflow*>*     m_tracks;
        unsigned int                    m_trackCount;
85
        MainWorkflow::TrackType         m_trackType;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
86 87 88
        qint64                          m_length;
        unsigned int                    m_highestTrackNumber;
        bool                            m_paused;
89
        bool                            m_endReached;
90
        EffectsEngine*                  m_effectEngine;
91
        AudioClipWorkflow::AudioSample* m_tmpAudioBuffer;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
92 93 94 95 96 97


    private slots:
        void                            trackEndReached( unsigned int trackId );

    signals:
98
        void                            tracksEndReached();
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
99 100 101
};

#endif // TRACKHANDLER_H