Clip.h 5.81 KB
Newer Older
1
/*****************************************************************************
2
 * Clip.h : Represents a basic container for media informations.
3
 *****************************************************************************
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 26 27 28 29 30 31
 *
 * 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.
 *****************************************************************************/

/** \file
  * This file contains the Clip class declaration/definition.
  * It's used by the timeline in order to represent a subset of a media
  */

#ifndef CLIP_H__
# define CLIP_H__

#include <QObject>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
32
#include <QUuid>
33 34 35

#include "Media.h"

36

37 38
class Media;

39 40 41 42 43
class   Clip : public QObject
{
    Q_OBJECT

    public:
44
        static const int DefaultFPS;
45 46 47 48 49 50 51
        /**
         *  \brief  Construct the base clip for a Media.
         *
         *  This clip will represent the whole media as a Clip.
         *  \param  parent  The media to represent.
         *  \param  uuid    A forced unique id. If not given, a new unique id will be generated.
         */
52
        Clip( Media *parent, const QString& uuid = QString() );
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
        /**
         *  \brief  Constructs a Clip that is a subpart of a Media.
         *
         *  \param  parent  The media to represent.
         *  \param  begin   The clip beginning (in frames, from the parent's beginning)
         *  \param  end     The end, in frames, from the parent's beginning. If not given,
         *                  the end of the parent will be used.
         *  \param  uuid    A unique identifier. If not given, one will be generated.
         */
        Clip( Media *parent, qint64 begin, qint64 end = -1, const QString &uuid = QString() );
        /**
         *  \brief  Clones a Clip, potentially with a new begin and end.
         *
         *  \param  creator The clip to clone.
         *  \param  begin   The clip beginning (in frames, from the parent's beginning).
         *                  If not given, 0 is assumed.
         *  \param  end     The end, in frames, from the parent's beginning. If not given,
         *                  the end of the parent will be used.
         */
        Clip( Clip *creator, qint64 begin = -1, qint64 end = -1 );
73
        virtual ~Clip();
74

75 76
        qint64              begin() const;
        qint64              end() const;
77

78 79 80
        void                setBegin( qint64 begin, bool updateMax = false );
        void                setEnd( qint64 end, bool updateMax = false );
        void                setBoundaries( qint64 newBegin, qint64 newEnd, bool updateMax = false );
81

82
        /**
83
            \return         Returns the clip length in frame.
84
        */
85
        qint64              length() const;
86

87
        /**
88
            \return         Returns the clip length in seconds.
89
        */
90
        qint64              lengthSecond() const;
91

92
        /**
93
            \return         Returns the Media that the clip was basep uppon.
94
        */
95
        Media*              getParent();
96 97

        /**
98 99
            \brief          Returns an unique Uuid for this clip (which is NOT the
                            parent's Uuid).
100

101
            \return         The Clip's Uuid as a QUuid
102
        */
103
        const QUuid         &uuid() const;
104
        void                setUuid( const QUuid &uuid );
105

106 107 108
        const QStringList   &metaTags() const;
        void                setMetaTags( const QStringList &tags );
        bool                matchMetaTag( const QString &tag ) const;
109

110 111
        const QString       &notes() const;
        void                setNotes( const QString &notes );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
112

113 114
        qint64              maxBegin() const;
        qint64              maxEnd() const;
115

116
        void                computeLength();
117

118
    private:
119
        Media               *m_parent;
120 121 122 123
        /**
         *  \brief  This represents the beginning of the Clip in frames, from the
         *          beginning of the parent Media.
         */
124
        qint64              m_begin;
125 126 127 128
        /**
         *  \brief  This represents the end of the Clip in frames, from the
         *          beginning of the parent Media.
         */
129
        qint64              m_end;
130 131 132 133

        /**
         *  \brief  The length in frames
         */
134
        qint64              m_length;
135 136 137
        /**
         *  \brief  The length in seconds (Be carreful, VLC uses MILLIseconds)
         */
138
        qint64              m_lengthSeconds;
139 140 141 142 143
        /**
         *  The Clip's timeline UUID. Used to identify the Clip in the
         *  timeline, as a unique object, even if this clip is present more than
         *  once.
         */
144
        QUuid               m_uuid;
145 146
        QStringList         m_metaTags;
        QString             m_notes;
147

148 149 150 151
        /**
         *  This is used for the resize. The clip won't be abble to be resized beyond this value.
         *  ie this clip won't start before m_maxBegin.
         */
152
        qint64              m_maxBegin;
153 154 155 156 157

        /**
         *  This is used for the resize. The clip won't be abble to be resized beyond this value
         *  ie this clip won't end before m_maxEnd.
         */
158
        qint64              m_maxEnd;
159

160
    signals:
161
        void                lengthUpdated();
162 163 164
};

#endif //CLIP_H__