Media.h 6.24 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
#include "config.h"
33 34
#include <QList>
#include <QString>
35
#include <QUuid>
36
#include <QObject>
37
#include <QFileInfo>
38
#include <QHash>
39
#include <QXmlStreamWriter>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
40

41
#ifdef WITH_GUI
42
#include "media/GuiMedia.h"
43 44
#endif

45 46 47 48
namespace LibVLCpp
{
    class   Media;
}
49 50
class Clip;

51 52 53
/**
  * Represents a basic container for media informations.
  */
54 55 56
#ifdef WITH_GUI
class       Media : public GUIMedia
#else
57
class       Media : public QObject
58
#endif
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
59
{
60 61
    Q_OBJECT

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
62
public:
63 64 65 66
    /**
     *  \enum fType
     *  \brief enum to determine file type
     */
67
    enum    FileType
68 69 70 71 72
    {
        Audio,
        Video,
        Image
    };
73 74 75 76 77
    enum    InputType
    {
        File,
        Stream
    };
78 79 80 81 82
    static const QString        VideoExtensions;
    static const QString        AudioExtensions;
    static const QString        ImageExtensions;
    static const QString        streamPrefix;

83
    Media( const QString& filePath );
84
    virtual ~Media();
85

86
    /**
87 88
     *  \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.
89 90 91 92 93 94 95
     */
    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();
96
    LibVLCpp::Media             *vlcMedia() { return m_vlcMedia; }
97

98 99 100
    const QFileInfo             *fileInfo() const;
    const QString               &mrl() const;
    const QString               &fileName() const;
101 102 103 104 105
    /**
     *  \brief                  Set this media's path.
     *
     *  \param      path        The media path. This should be an absolute path.
     */
106
    void                        setFilePath( const QString& path );
107

108 109 110 111
    /**
        \return                 Returns the length of this media (ie the
                                video duration) in milliseconds.
    */
112
    qint64                      lengthMS() const;
113 114 115 116 117 118
    /**
        \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 !
    */
119
    void                        setLength( qint64 length );
120
    void                        setNbFrames( qint64 nbFrames );
121

122
    int                         width() const;
123
    void                        setWidth( int width );
124

125
    int                         height() const;
126
    void                        setHeight( int height );
127

128
    float                       fps() const;
129
    void                        setFps( float fps );
130

131
    qint64                      nbFrames() const;
132

133 134
    bool                        hasAudioTrack() const;
    bool                        hasVideoTrack() const;
135 136
    void                        setNbAudioTrack( int nbTrack );
    void                        setNbVideoTrack( int nbTrack );
137 138
    int                         nbAudioTracks() const;
    int                         nbVideoTracks() const;
139

140
    FileType                    fileType() const;
141

142
    InputType                   inputType() const;
143

144
    void                        emitMetaDataComputed();
145
    void                        emitAudioSpectrumComuted();
146

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

149
    Clip*                       baseClip() { return m_baseClip; }
150
    const Clip*                 baseClip() const { return m_baseClip; }
151
    void                        setBaseClip( Clip* clip );
152

153 154
    bool                        isMetadataComputed() const;

155 156
    void                        save( QXmlStreamWriter& project );

157 158
    bool                        isInWorkspace() const;

159 160 161
private:
    void                        setFileType();

162 163 164
protected:
    LibVLCpp::Media*            m_vlcMedia;
    QString                     m_mrl;
165
    QList<QString>              m_volatileParameters;
166
    QFileInfo*                  m_fileInfo;
167
    qint64                      m_lengthMS;
168
    qint64                      m_nbFrames;
169 170
    unsigned int                m_width;
    unsigned int                m_height;
171
    float                       m_fps;
172
    FileType                    m_fileType;
173
    InputType                   m_inputType;
174
    QString                     m_fileName;
175
    Clip*                       m_baseClip;
176
    QList<int>*                 m_audioValueList;
177 178
    int                         m_nbAudioTracks;
    int                         m_nbVideoTracks;
179
    bool                        m_metadataComputed;
180
    bool                        m_inWorkspace;
181
    QString                     m_workspacePath;
182 183

signals:
184
    void                        metaDataComputed( const Media* );
185
    void                        audioSpectrumComputed( const QUuid& );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
186 187
};

188
#endif // MEDIA_H__