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

/** \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 39 40
//TODO: REMOVE THIS
#ifndef FPS
#define FPS     30
#endif

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

    public:
46
        Clip( Media* parent );
47 48
        Clip( Media* parent, float begin, float end );
        Clip( Clip* creator, float begin, float end );
49
        Clip( Clip* clip );
50
        Clip( const QUuid& uuid, float begin = .0f, float end = 1.0f );
51
        virtual ~Clip();
52

53 54 55 56 57 58
        /**
          \brief    Returns the clip starting point. This value will be in
                    vlc positition units (0 to 1)
          \return   A value between 0 and 1, where 0 is the real Media begin,
                    and 1 the real Media end.
        */
59
        float           getBegin() const;
60 61 62 63 64 65 66

        /**
          \brief    Returns the clip ending point. This value will be in
                    vlc positition units (0 to 1)
          \return   A value between 0 and 1, where 0 is the real Media end,
                    and 1 the real Media end.
        */
67
        float           getEnd() const;
68

69 70 71
        void            setBegin( float begin );
        void            setEnd( float end );

72 73 74
        /**
            \return     Returns the clip length in frame.
        */
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
75
        qint64          getLength() const;
76

77 78 79 80 81
        /**
            \return     Returns the clip length in seconds.
        */
        qint64          getLengthSecond() const;

82 83 84 85
        /**
            \return     Returns the Media that the clip was basep uppon.

        */
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
86
        Media*          getParent();
87 88 89 90 91 92 93

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

            \return     The Clip's Uuid as a QUuid
        */
94
        const QUuid&        getUuid() const;
95 96 97 98 99

        const QStringList&  getMetaTags() const;
        void                setMetaTags( const QStringList& tags );
        bool                matchMetaTag( const QString& tag ) const;

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
100 101 102
        const QString&      getNotes() const;
        void                setNotes( const QString& notes );

103 104 105 106
        /**
         *  \brief  Split this clip in two parts.
         *  \param  newEnd  The new end for this Clip. This will be the beginning of the
         *                  newly created Clip.
107
         *  \returns A new Clip starting at newEnd.
108 109 110
         */
        Clip*               split( float newEnd );

111 112 113 114 115 116 117
        /**
         * \brief Split this clip in two parts (provided for compatibility)
         * \param newEnd The new end for this clip (provided for compatibility)
         * \returns A new Clip starting at endFrame.
         */
        Clip*               split( qint64 endFrame );

118
    private:
119 120
        void        computeLength();

121
        Media*      m_parent;
122 123
        float       m_begin;
        float       m_end;
124
        qint64      m_length;
125
        qint64      m_lengthSeconds;
126 127 128 129 130
        /**
         *  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.
         */
131
        QUuid       m_Uuid;
132
        QStringList m_metaTags;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
133
        QString     m_notes;
134

135 136
    signals:
        void        lengthUpdated();
137 138 139
};

#endif //CLIP_H__