TrackHandler.h 5.12 KB
Newer Older
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
1 2 3
/*****************************************************************************
 * TrackHandler.h : Handle multiple track of a kind (audio or video)
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * 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 29
#include "MainWorkflow.h"

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

33
class   EffectEngine;
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
        /**
         *  \param      currentFrame    The current rendering frame (ie the video frame, in all case)
52 53 54
         *  \param      subFrame        The type-dependent frame. IE, for a video track,
         *                              it's the same as currentFrame, but for an audio
         *                              track, it will be different.
55
         *  \param      paused          The renderer paused state
56 57 58
         *  \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.
         */
59 60
        void                    getOutput( qint64 currentFrame, qint64 subFrame,
                                           bool paused );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
61 62 63 64
        void                    activateAll();
        qint64                  getClipPosition( const QUuid& uuid, unsigned int trackId ) const;
        void                    stop();
        void                    moveClip( const QUuid& clipUuid, unsigned int oldTrack,
65
                                          unsigned int newTrack, qint64 startingFrame );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
66 67 68 69 70 71
        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();

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

75
        bool                    endIsReached() const;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
76

77 78
        void                    save( QDomDocument& doc, QDomElement& timelineNode ) const;

79 80 81 82 83 84 85
        /**
         *  \brief      Will configure the track workflow so they render only one frame
         *
         *  \sa MainWorkflow::renderOneFrame()
         */
        void                    renderOneFrame();

86 87 88 89
        /**
         *  \sa     MainWorkflow::setFullSpeedRender();
         */
        void                    setFullSpeedRender( bool val );
90

91 92 93 94 95 96 97 98 99
        /**
         *  \brief  Will mute a clip in the given track.
         *
         *  \param  uuid    The uuid of the clip to mute.
         *  \param  trackId The id of the track holding the clip.
         */
        void                    muteClip( const QUuid& uuid, quint32 trackId );
        void                    unmuteClip( const QUuid& uuid, quint32 trackId );

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
100 101 102 103 104
    private:
        void                    computeLength();
        void                    activateTrack( unsigned int tracKId );

    private:
105
        static LightVideoFrame*         nullOutput;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
106 107
        Toggleable<TrackWorkflow*>*     m_tracks;
        unsigned int                    m_trackCount;
108
        MainWorkflow::TrackType         m_trackType;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
109 110
        qint64                          m_length;
        unsigned int                    m_highestTrackNumber;
111
        bool                            m_endReached;
112
        EffectsEngine*                  m_effectEngine;
113
        AudioClipWorkflow::AudioSample* m_tmpAudioBuffer;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
114 115 116 117 118 119


    private slots:
        void                            trackEndReached( unsigned int trackId );

    signals:
120
        void                            tracksEndReached();
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
121 122 123
};

#endif // TRACKHANDLER_H