Clip.h 4.73 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
        Clip( Media *parent, const QString& uuid = QString() );
46 47 48 49 50
        Clip( Media *parent, qint64 begin, qint64 end = -1 );
        Clip( Clip *creator, qint64 begin, qint64 end );
        Clip( const Clip *clip );
        Clip( const QUuid &uuid, qint64 begin = 0, qint64 end = -1 );
        Clip( Media *parent, qint64 begin, qint64 end, const QUuid &uuid );
51
        virtual ~Clip();
52

53 54
        qint64              begin() const;
        qint64              end() const;
55

56 57 58
        void                setBegin( qint64 begin, bool updateMax = false );
        void                setEnd( qint64 end, bool updateMax = false );
        void                setBoundaries( qint64 newBegin, qint64 newEnd, bool updateMax = false );
59

60
        /**
61
            \return         Returns the clip length in frame.
62
        */
63
        qint64              length() const;
64

65
        /**
66
            \return         Returns the clip length in seconds.
67
        */
68
        qint64              lengthSecond() const;
69

70
        /**
71
            \return         Returns the Media that the clip was basep uppon.
72
        */
73
        Media*              getParent();
74 75

        /**
76 77
            \brief          Returns an unique Uuid for this clip (which is NOT the
                            parent's Uuid).
78

79
            \return         The Clip's Uuid as a QUuid
80
        */
81
        const QUuid         &uuid() const;
82
        void                setUuid( const QUuid &uuid );
83

84 85 86
        const QStringList   &metaTags() const;
        void                setMetaTags( const QStringList &tags );
        bool                matchMetaTag( const QString &tag ) const;
87

88 89
        const QString       &notes() const;
        void                setNotes( const QString &notes );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
90

91 92
        qint64              maxBegin() const;
        qint64              maxEnd() const;
93

94
        void                computeLength();
95

96
    private:
97
        Media               *m_parent;
98 99 100 101
        /**
         *  \brief  This represents the beginning of the Clip in frames, from the
         *          beginning of the parent Media.
         */
102
        qint64              m_begin;
103 104 105 106
        /**
         *  \brief  This represents the end of the Clip in frames, from the
         *          beginning of the parent Media.
         */
107
        qint64              m_end;
108 109 110 111

        /**
         *  \brief  The length in frames
         */
112
        qint64              m_length;
113 114 115
        /**
         *  \brief  The length in seconds (Be carreful, VLC uses MILLIseconds)
         */
116
        qint64              m_lengthSeconds;
117 118 119 120 121
        /**
         *  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.
         */
122
        QUuid               m_uuid;
123 124
        QStringList         m_metaTags;
        QString             m_notes;
125

126 127 128 129
        /**
         *  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.
         */
130
        qint64              m_maxBegin;
131 132 133 134 135

        /**
         *  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.
         */
136
        qint64              m_maxEnd;
137

138
    signals:
139
        void                lengthUpdated();
140 141 142
};

#endif //CLIP_H__