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
 *****************************************************************************
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
class   QXmlStreamWriter;

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

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

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

86
    void                        setSnapshot( QPixmap* snapshot );
87
    const QPixmap               &snapshot() const;
88

89 90 91
    const QFileInfo             *fileInfo() const;
    const QString               &mrl() const;
    const QString               &fileName() const;
92

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

107
    int                         width() const;
108
    void                        setWidth( int width );
109

110
    int                         height() const;
111
    void                        setHeight( int height );
112

113
    float                       fps() const;
114
    void                        setFps( float fps );
115

116
    qint64                      nbFrames() const;
117

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

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

132
    void                        emitMetaDataComputed();
133
    void                        emitSnapshotComputed();
134
    void                        emitAudioSpectrumComuted();
135

136
//    bool                        hasMetadata() const;
137

138
    QList<int>*                 audioValues() { return m_audioValueList; }
139

140
    Clip*                       baseClip() { return m_baseClip; }
141
    const Clip*                 baseClip() const { return m_baseClip; }
142
    void                        setBaseClip( Clip* clip );
143

144 145
    bool                        isMetadataComputed() const;

146 147
    void                        save( QXmlStreamWriter& project );

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
    QFileInfo*                  m_fileInfo;
158
    qint64                      m_lengthMS;
159
    qint64                      m_nbFrames;
160 161
    unsigned int                m_width;
    unsigned int                m_height;
162
    float                       m_fps;
163
    FileType                    m_fileType;
164
    InputType                   m_inputType;
165
    QString                     m_fileName;
166
    Clip*                       m_baseClip;
167
    QList<int>*                 m_audioValueList;
168 169
    int                         m_nbAudioTracks;
    int                         m_nbVideoTracks;
170
    bool                        m_metadataComputed;
171 172

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

178
#endif // CLIP_H__