Media.h 6.1 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
    Media( const QString& filePath );
79
    virtual ~Media();
80

81
    /**
82 83
     *  \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.
84 85 86 87 88 89 90
     */
    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();
91
    LibVLCpp::Media             *vlcMedia() { return m_vlcMedia; }
92

93 94 95
    const QFileInfo             *fileInfo() const;
    const QString               &mrl() const;
    const QString               &fileName() const;
96
    void                        setFilePath( const QString& path );
97

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

112
    int                         width() const;
113
    void                        setWidth( int width );
114

115
    int                         height() const;
116
    void                        setHeight( int height );
117

118
    float                       fps() const;
119
    void                        setFps( float fps );
120

121
    qint64                      nbFrames() const;
122

123 124
    bool                        hasAudioTrack() const;
    bool                        hasVideoTrack() const;
125 126
    void                        setNbAudioTrack( int nbTrack );
    void                        setNbVideoTrack( int nbTrack );
127 128
    int                         nbAudioTracks() const;
    int                         nbVideoTracks() const;
129

130
    FileType                    fileType() const;
131 132 133
    static const QString        VideoExtensions;
    static const QString        AudioExtensions;
    static const QString        ImageExtensions;
134
    InputType                   inputType() const;
135
    static const QString        streamPrefix;
136

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

140
    QList<int>*                 audioValues() { return m_audioValueList; }
141

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

146 147
    bool                        isMetadataComputed() const;

148 149
    void                        save( QXmlStreamWriter& project );

150 151 152
    bool                        isInWorkspace() const;
    void                        setInWorkspace( bool inWorkspace );

153 154 155
private:
    void                        setFileType();

156 157 158
protected:
    LibVLCpp::Media*            m_vlcMedia;
    QString                     m_mrl;
159
    QList<QString>              m_volatileParameters;
160
    QFileInfo*                  m_fileInfo;
161
    qint64                      m_lengthMS;
162
    qint64                      m_nbFrames;
163 164
    unsigned int                m_width;
    unsigned int                m_height;
165
    float                       m_fps;
166
    FileType                    m_fileType;
167
    InputType                   m_inputType;
168
    QString                     m_fileName;
169
    Clip*                       m_baseClip;
170
    QList<int>*                 m_audioValueList;
171 172
    int                         m_nbAudioTracks;
    int                         m_nbVideoTracks;
173
    bool                        m_metadataComputed;
174
    bool                        m_inWorkspace;
175 176

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

181
#endif // MEDIA_H__