Media.h 6.25 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 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * 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>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
38

39 40
#include "VLCMedia.h"

41 42 43
struct          audioData
{
    void*               datas;
44 45 46 47
    unsigned int*       freq;
    unsigned int*       nbChannels;
    unsigned int*       fourCCFormat;
    unsigned int*       frameSize;
48 49 50 51 52 53
    unsigned int        nbSample;
    unsigned char*      buffer;
    size_t              buffSize;
    QVector<int*>       frameList;
};

54 55 56
/**
  * Represents a basic container for media informations.
  */
57
class       Media : public QObject
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
58
{
59 60
    Q_OBJECT

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

80 81 82 83 84 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.
     */
    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();
89
    LibVLCpp::Media*            getVLCMedia() { return m_vlcMedia; }
90

91 92
    void                        setSnapshot( QPixmap* snapshot );
    const QPixmap&              getSnapshot() const;
93

94
    const QFileInfo*            getFileInfo() const;
95 96
    const QString&              getMrl() const;
    const QString&              getFileName() const;
97

98 99 100 101
    /**
        \return                 Returns the length of this media (ie the
                                video duration) in milliseconds.
    */
102
    qint64                      getLength() 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 113
    int                         getWidth() const;
    void                        setWidth( int width );
114

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

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

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
121
    qint64                      getNbFrames() const;
122

123
    const QUuid&                getUuid() const;
124
    void                        setUuid( const QUuid& uuid );
125

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

133 134 135 136 137 138 139
    void                        initAudioData( void* datas, unsigned int* freq, unsigned int* nbChannels, unsigned int* fourCCFormat, unsigned int* frameSize );
    void                        addAudioFrame( void* datas, unsigned char* buffer, size_t buffSize, unsigned int nbSample );

    audioData*                  getAudioData() { return &m_audioData; }
    QVector<int*>               getAudioFrameList() { return m_audioData.frameList; }
    unsigned int                getAudioNbSample() { return m_audioData.nbSample; }

140 141 142 143
    const QStringList&          getMetaTags() const;
    void                        setMetaTags( const QStringList& tags );
    bool                        matchMetaTag( const QString& tag ) const;

144
    void                        emitMetaDataComputed();
145

146 147
    bool                        hasMetadata() const;

148 149 150
private:
    void                        setFileType();

151
protected:
152 153
    static QPixmap*             defaultSnapshot;

154 155
    LibVLCpp::Media*            m_vlcMedia;
    QString                     m_mrl;
156
    QList<QString>              m_volatileParameters;
157
    QPixmap*                    m_snapshot;
158
    QUuid                       m_uuid;
159 160
    QFileInfo*                  m_fileInfo;
    qint64                      m_length;
161
    qint64                      m_nbFrames;
162 163
    unsigned int                m_width;
    unsigned int                m_height;
164
    float                       m_fps;
165 166
    int*                        m_audioSpectrum;
    audioData                   m_audioData;
167
    FileType                    m_fileType;
168
    InputType                   m_inputType;
169
    bool                        m_metadataParsed;
170
    QString                     m_fileName;
171
    QStringList                 m_metaTags;
172 173

signals:
174
    void                        metaDataComputed( Media* );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
175 176
};

177
#endif // CLIP_H__