Clip.h 6.27 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"

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
36
class   MediaContainer;
37

38
39
class Media;

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

    public:
45
        static const int DefaultFPS;
46
47
48
49
50
51
52
53
54
        /**
         *  \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.
         */
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
55
        Clip( Media *parent, qint64 begin = 0, qint64 end = -1, const QString &uuid = QString() );
56
57
58
59
60
61
62
63
64
        /**
         *  \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.
         */
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
65
        Clip( Clip *creator, qint64 begin = -1, qint64 end = -1, const QString& uuid = QString() );
66
        virtual ~Clip();
67

68
69
        qint64              begin() const;
        qint64              end() const;
70

71
72
73
        void                setBegin( qint64 begin, bool updateMax = false );
        void                setEnd( qint64 end, bool updateMax = false );
        void                setBoundaries( qint64 newBegin, qint64 newEnd, bool updateMax = false );
74

75
        /**
76
            \return         Returns the clip length in frame.
77
        */
78
        qint64              length() const;
79

80
        /**
81
            \return         Returns the clip length in seconds.
82
        */
83
        qint64              lengthSecond() const;
84

85
        /**
86
            \return         Returns the Media that the clip was basep uppon.
87
        */
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
88
        Media*              getMedia();
89
        const Media*        getMedia() const;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
90
91
92
93
94

        Clip                *getParent();
        const Clip          *getParent() const;
        MediaContainer*     getChilds();
        const MediaContainer*     getChilds() const;
95
96

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

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

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

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

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

115
        void                computeLength();
116

117
118
        bool                isRootClip() const;
        Clip*               rootClip();
119

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
120
121
122
123
124
        /**
         *  \brief          Clear all the clip subclips recursively.
         */
        void                clear();

125
        bool                addSubclip( Clip* clip );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
126

127
    private:
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
128
        Media               *m_media;
129
130
131
132
        /**
         *  \brief  This represents the beginning of the Clip in frames, from the
         *          beginning of the parent Media.
         */
133
        qint64              m_begin;
134
135
136
137
        /**
         *  \brief  This represents the end of the Clip in frames, from the
         *          beginning of the parent Media.
         */
138
        qint64              m_end;
139
140
141
142

        /**
         *  \brief  The length in frames
         */
143
        qint64              m_length;
144
145
146
        /**
         *  \brief  The length in seconds (Be carreful, VLC uses MILLIseconds)
         */
147
        qint64              m_lengthSeconds;
148
149
150
151
152
        /**
         *  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.
         */
153
        QUuid               m_uuid;
154
155
        QStringList         m_metaTags;
        QString             m_notes;
156

157
158
159
160
        /**
         *  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.
         */
161
        qint64              m_maxBegin;
162
163
164
165
166

        /**
         *  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.
         */
167
        qint64              m_maxEnd;
168

169
170
171
172
173
174
175
        /**
         *  \brief          Return the root clip.
         *
         *  The root clip is the base clip for the parent media.
         */
        Clip*               m_rootClip;

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
176
177
178
179
        MediaContainer*     m_childs;

        Clip*               m_parent;

180
    signals:
181
        void                lengthUpdated();
182
183
184
};

#endif //CLIP_H__