Media.h 6.16 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 69 70 71 72 73
    enum    MetadataState
    {
        None,
        ParsedWithoutSnapshot,
        ParsedWithSnapshot
    };
74
    Media( const QString& filePath, const QString& uuid = QString() );
75
    virtual ~Media();
76

77 78 79 80 81 82 83 84 85
    /**
     *  \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();
86
    LibVLCpp::Media*            getVLCMedia() { return m_vlcMedia; }
87

88 89
    void                        setSnapshot( QPixmap* snapshot );
    const QPixmap&              getSnapshot() const;
90

91
    const QFileInfo*            getFileInfo() const;
92 93
    const QString&              getMrl() const;
    const QString&              getFileName() const;
94

95 96 97 98
    /**
        \return                 Returns the length of this media (ie the
                                video duration) in milliseconds.
    */
99
    qint64                      getLengthMS() const;
100 101 102 103 104 105
    /**
        \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 !
    */
106
    void                        setLength( qint64 length );
107
    void                        setNbFrames( qint64 nbFrames );
108

109 110
    int                         getWidth() const;
    void                        setWidth( int width );
111

112 113
    int                         getHeight() const;
    void                        setHeight( int height );
114

115
    float                       getFps() const;
116
    void                        setFps( float fps );
117

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
118
    qint64                      getNbFrames() const;
119

120
    const QUuid&                getUuid() const;
121
    void                        setUuid( const QUuid& uuid );
122

123
    FileType                    getFileType() const;
124 125 126
    static const QString        VideoExtensions;
    static const QString        AudioExtensions;
    static const QString        ImageExtensions;
127 128
    InputType                   getInputType() const;
    static const QString        streamPrefix;
129

130 131 132 133
    const QStringList&          getMetaTags() const;
    void                        setMetaTags( const QStringList& tags );
    bool                        matchMetaTag( const QString& tag ) const;

134 135
    void                        emitMetaDataComputed( bool hasMetadata );
    void                        emitSnapshotComputed();
136

137 138
//    bool                        hasMetadata() const;
    MetadataState               getMetadata() const;
139

140 141 142 143 144
    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; }

145
    QList<int>*                 getAudioValues() { return m_audioValueList; }
146

147

148 149 150
private:
    void                        setFileType();

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

signals:
173
    void                        metaDataComputed( Media* );
174
    void                        snapshotComputed( Media* );
175
    void                        audioSpectrumComputed( Media* );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
176 177
};

178
#endif // CLIP_H__