Media.h 5.43 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 44 45 46 47 48 49 50 51 52 53
struct          audioData
{
    void*               datas;
    unsigned int*       freq;
    unsigned int*       nbChannels;
    unsigned int*       fourCCFormat;
    unsigned int*       frameSize;
    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 66 67 68 69 70 71
    /**
     *  \enum fType
     *  \brief enum to determine file type
     */
    enum FileType
    {
        Audio,
        Video,
        Image
    };
72
    Media( const QString& filePath );
73
    virtual ~Media();
74

75
    void                        loadMedia( const QString& mrl );
76 77 78 79 80 81 82 83 84
    /**
     *  \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();
85
    LibVLCpp::Media*            getVLCMedia() { return m_vlcMedia; }
86

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

90
    const QFileInfo*            getFileInfo() const;
91

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

105 106
    int                         getWidth() const;
    void                        setWidth( int width );
107

108 109
    int                         getHeight() const;
    void                        setHeight( int height );
110

111 112 113
    unsigned int                getFps() const;
    void                        setFps( unsigned int fps );

114
    const QUuid&                getUuid() const;
115

116
    FileType                    getFileType() const;
117 118 119
    static const QString        VideoExtensions;
    static const QString        AudioExtensions;
    static const QString        ImageExtensions;
120

121 122 123 124 125 126 127
    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; }

128
    void                        emitMetaDataComputed();
129

130 131 132
private:
    void                        setFileType();

133
protected:
134 135
    static QPixmap*             defaultSnapshot;

136 137
    LibVLCpp::Media*            m_vlcMedia;
    QString                     m_mrl;
138
    QList<QString>              m_volatileParameters;
139
    QPixmap*                    m_snapshot;
140
    QUuid                       m_uuid;
141 142 143 144
    QFileInfo*                  m_fileInfo;
    qint64                      m_length;
    unsigned int                m_width;
    unsigned int                m_height;
145
    unsigned int                m_fps;
146 147
    int*                        m_audioSpectrum;
    audioData                   m_audioData;
148
    FileType                    m_fileType;
149 150

signals:
151 152
    void                        metaDataComputed();
    void                        metaDataComputed( Media* );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
153 154
};

155
#endif // CLIP_H__