Media.h 6.58 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
    bool                        addClip( Clip* clip );
144
    void                        removeClip( const QUuid& uuid );
145
146
147
    Clip*                       clip( const QUuid& uuid );
    quint32                     clipsCount() const;
    const QHash<QUuid, Clip*>   &clips() const;
148

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

151
    Clip*                       baseClip() { return m_baseClip; }
152

153
154
155
private:
    void                        setFileType();

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

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

186
#endif // CLIP_H__