Media.h 6.52 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
     *  \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.
75 76 77 78 79 80 81
     */
    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();
82
    LibVLCpp::Media             *vlcMedia() { return m_vlcMedia; }
83

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

87 88 89
    const QFileInfo             *fileInfo() const;
    const QString               &mrl() const;
    const QString               &fileName() const;
90

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

105
    int                         width() const;
106
    void                        setWidth( int width );
107

108
    int                         height() const;
109
    void                        setHeight( int height );
110

111
    float                       fps() const;
112
    void                        setFps( float fps );
113

114
    qint64                      nbFrames() const;
115

116
    const QUuid                 &uuid() const;
117
    void                        setUuid( const QUuid& uuid );
118

119 120
    bool                        hasAudioTrack() const;
    bool                        hasVideoTrack() const;
121 122
    void                        setNbAudioTrack( int nbTrack );
    void                        setNbVideoTrack( int nbTrack );
123 124
    int                         nbAudioTracks() const;
    int                         nbVideoTracks() const;
125

126
    FileType                    fileType() const;
127 128 129
    static const QString        VideoExtensions;
    static const QString        AudioExtensions;
    static const QString        ImageExtensions;
130
    InputType                   inputType() const;
131
    static const QString        streamPrefix;
132

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

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

141
//    bool                        hasMetadata() const;
142

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

148
    QList<int>*                 audioValues() { return m_audioValueList; }
149

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

152 153 154
private:
    void                        setFileType();

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

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

184
#endif // CLIP_H__