Media.h 6.55 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
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * 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 41 42 43
namespace LibVLCpp
{
    class   Media;
}
44 45
class Clip;

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

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

72 73 74 75 76 77 78 79 80
    /**
     *  \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();
81
    LibVLCpp::Media*            getVLCMedia() { return m_vlcMedia; }
82

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

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

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

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

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

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

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

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

118 119
    bool                        hasAudioTrack() const;
    bool                        hasVideoTrack() const;
120 121 122 123
    void                        setNbAudioTrack( int nbTrack );
    void                        setNbVideoTrack( int nbTrack );
    int                         getNbAudioTracks() const;
    int                         getNbVideoTracks() const;
124

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

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

136
    void                        emitMetaDataComputed();
137
    void                        emitSnapshotComputed();
138
    void                        emitAudioSpectrumComuted();
139

140
//    bool                        hasMetadata() const;
141

142 143 144 145 146
    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; }

147
    QList<int>*                 getAudioValues() { return m_audioValueList; }
148

149
    const Clip*                 baseClip() const { return m_baseClip; }
150

151 152 153
private:
    void                        setFileType();

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

signals:
178
    void                        metaDataComputed( Media* );
179
    void                        snapshotComputed( Media* );
180
    void                        audioSpectrumComputed( const QUuid& );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
181 182
};

183
#endif // CLIP_H__