Media.h 6.11 KB
Newer Older
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
1
/*****************************************************************************
2
 * Media.h : Represents a basic container for media informations.
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *****************************************************************************
 * 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.
 *****************************************************************************/

23
/** \file
24
  * This file contains the Media class declaration/definition.
25 26 27 28
  * It contains a VLCMedia and the meta-datas.
  * It's used by the Library
  */

29 30
#ifndef MEDIA_H__
#define MEDIA_H__
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
31

32 33 34
#include <QList>
#include <QString>
#include <QPixmap>
35
#include <QUuid>
36
#include <QObject>
37
#include <QFileInfo>
38
#include <QHash>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
39

40
#include "VLCMedia.h"
41
#include "Clip.h"
42

43 44
class Clip;

45 46 47
/**
  * Represents a basic container for media informations.
  */
48
class       Media : public QObject
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
49
{
50 51
    Q_OBJECT

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
52
public:
53 54 55 56
    /**
     *  \enum fType
     *  \brief enum to determine file type
     */
57
    enum    FileType
58 59 60 61 62
    {
        Audio,
        Video,
        Image
    };
63 64 65 66 67
    enum    InputType
    {
        File,
        Stream
    };
68
    Media( const QString& filePath, const QString& uuid = QString() );
69
    virtual ~Media();
70

71 72 73 74 75 76 77 78 79
    /**
     *  \brief  This method adds a parameter that will stay constant though the whole life of this media (unless it is explicitely overided), even if it is cloned.
     */
    void                        addConstantParam( const QString& param );
    /**
     *  \brief  This method will add a parameter that will be restored to defaultValue when the flushVolatileParameter is called
     */
    void                        addVolatileParam( const QString& param, const QString& defaultValue );
    void                        flushVolatileParameters();
80
    LibVLCpp::Media*            getVLCMedia() { return m_vlcMedia; }
81

82 83
    void                        setSnapshot( QPixmap* snapshot );
    const QPixmap&              getSnapshot() const;
84

85
    const QFileInfo*            getFileInfo() const;
86 87
    const QString&              getMrl() const;
    const QString&              getFileName() const;
88

89 90 91 92
    /**
        \return                 Returns the length of this media (ie the
                                video duration) in milliseconds.
    */
93
    qint64                      getLengthMS() const;
94 95 96 97 98 99
    /**
        \brief                  This methods is most of an entry point for the
                                MetadataManager than enything else.
                                If you use it to set a inconsistant media length
                                you'll just have to blame yourself !
    */
100
    void                        setLength( qint64 length );
101
    void                        setNbFrames( qint64 nbFrames );
102

103 104
    int                         getWidth() const;
    void                        setWidth( int width );
105

106 107
    int                         getHeight() const;
    void                        setHeight( int height );
108

109
    float                       getFps() const;
110
    void                        setFps( float fps );
111

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
112
    qint64                      getNbFrames() const;
113

114
    const QUuid&                getUuid() const;
115
    void                        setUuid( const QUuid& uuid );
116

117
    FileType                    getFileType() const;
118 119 120
    static const QString        VideoExtensions;
    static const QString        AudioExtensions;
    static const QString        ImageExtensions;
121 122
    InputType                   getInputType() const;
    static const QString        streamPrefix;
123

124 125 126 127
    const QStringList&          getMetaTags() const;
    void                        setMetaTags( const QStringList& tags );
    bool                        matchMetaTag( const QString& tag ) const;

128
    void                        emitMetaDataComputed();
129
    void                        emitSnapshotComputed();
130
    void                        emitAudioSpectrumComuted();
131

132
//    bool                        hasMetadata() const;
133

134 135 136 137 138
    void                        addClip( Clip* clip );
    void                        removeClip( const QUuid& uuid );
    Clip*                       clip( const QUuid& uuid ) const { return m_clips[uuid]; }
    const QHash<QUuid, Clip*>*  clips() const { return &m_clips; }

139
    QList<int>*                 getAudioValues() { return m_audioValueList; }
140

141
    const Clip*                 baseClip() const { return m_baseClip; }
142

143 144 145
private:
    void                        setFileType();

146
protected:
147
    static QPixmap*             defaultSnapshot;
148 149
    LibVLCpp::Media*            m_vlcMedia;
    QString                     m_mrl;
150
    QList<QString>              m_volatileParameters;
151
    QPixmap*                    m_snapshot;
152
    QUuid                       m_uuid;
153
    QFileInfo*                  m_fileInfo;
154
    qint64                      m_lengthMS;
155
    qint64                      m_nbFrames;
156 157
    unsigned int                m_width;
    unsigned int                m_height;
158
    float                       m_fps;
159
    FileType                    m_fileType;
160
    InputType                   m_inputType;
161
    QString                     m_fileName;
162
    QStringList                 m_metaTags;
163
    Clip*                       m_baseClip;
164
    QHash<QUuid, Clip*>         m_clips;
165
    QList<int>*                 m_audioValueList;
166 167

signals:
168
    void                        metaDataComputed( Media* );
169
    void                        snapshotComputed( Media* );
170
    void                        audioSpectrumComputed( const QUuid& );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
171 172
};

173
#endif // CLIP_H__