Media.h 6.22 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
 * Authors: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * 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 <QXmlStreamWriter>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
39

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

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

50 51 52
/**
  * Represents a basic container for media informations.
  */
53 54 55
#ifdef WITH_GUI
class       Media : public GUIMedia
#else
56
class       Media : public QObject
57
#endif
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 78 79 80 81
    static const QString        VideoExtensions;
    static const QString        AudioExtensions;
    static const QString        ImageExtensions;
    static const QString        streamPrefix;

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

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

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

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

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

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

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

130
    qint64                      nbFrames() const;
131

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

139
    FileType                    fileType() const;
140

141
    InputType                   inputType() const;
142

143
    void                        emitMetaDataComputed();
144

145
    Clip*                       baseClip() { return m_baseClip; }
146
    const Clip*                 baseClip() const { return m_baseClip; }
147
    void                        setBaseClip( Clip* clip );
148

149 150
    bool                        isMetadataComputed() const;

151 152
    void                        save( QXmlStreamWriter& project );

153 154
    bool                        isInWorkspace() const;

155 156 157 158 159 160 161
    /**
     *  \brief      Just an helper to compute metadata.
     *
     *  Actual computing is performed by MetadataManager
     */
    void                        computeMetadata();

162 163 164
private:
    void                        setFileType();

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

signals:
186
    void                        metaDataComputed( const Media* );
187
    void                        workspaceStateChanged( bool );
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
188 189
};

190
#endif // MEDIA_H__