Media.h 4.24 KB
Newer Older
1
/*****************************************************************************
2
 * Media.h : Represents a basic container for media informations.
3
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
5
 *
6
 * Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
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
  * It contains a ISource and some extra helpers.
26 27 28
  * It's used by the Library
  */

29 30
#ifndef MEDIA_H__
#define MEDIA_H__
31

32
#include "config.h"
33 34
#include <QList>
#include <QString>
35
#include <QUuid>
36
#include <QObject>
37
#include <QFileInfo>
38
#include <QXmlStreamWriter>
39

40
#ifdef WITH_GUI
41 42
#include <QPixmap>
#include <QImage>
43 44
#endif

45
namespace Backend
46
{
47
    class   ISource;
48
}
49 50
class Clip;

51 52 53
/**
  * Represents a basic container for media informations.
  */
54
class       Media : public QObject
55
{
56 57
    Q_OBJECT

58
public:
59 60 61 62
    /**
     *  \enum fType
     *  \brief enum to determine file type
     */
63
    enum    FileType
64 65 66 67 68
    {
        Audio,
        Video,
        Image
    };
69 70 71 72 73
    enum    InputType
    {
        File,
        Stream
    };
74 75 76 77 78
    static const QString        VideoExtensions;
    static const QString        AudioExtensions;
    static const QString        ImageExtensions;
    static const QString        streamPrefix;

79
    Media( const QString& path );
80
    virtual ~Media();
81

82 83 84
    const QFileInfo             *fileInfo() const;
    const QString               &mrl() const;
    const QString               &fileName() const;
85 86
    Backend::ISource *source();
    const Backend::ISource *source() const;
87 88 89 90 91
    /**
     *  \brief                  Set this media's path.
     *
     *  \param      path        The media path. This should be an absolute path.
     */
92
    void                        setFilePath( const QString& path );
93

94
    void                        setNbFrames( qint64 nbFrames );
95

96
    qint64                      nbFrames() const;
97

98
    FileType                    fileType() const;
99
    void                        setFileType( FileType type );
100

101
    InputType                   inputType() const;
102

103
    Clip*                       baseClip() { return m_baseClip; }
104
    const Clip*                 baseClip() const { return m_baseClip; }
105
    void                        setBaseClip( Clip* clip );
106

107 108
    bool                        isMetadataComputed() const;

109 110
    void                        save( QXmlStreamWriter& project );

111 112
    bool                        isInWorkspace() const;

113 114 115 116
    void                        onMetaDataComputed();

    // This has to be called from the GUI thread.
    QPixmap&                    snapshot();
117

118
private:
119
    void                        computeFileType();
120

121
protected:
122
    Backend::ISource*           m_source;
123
    QString                     m_mrl;
124
    QFileInfo*                  m_fileInfo;
125
    qint64                      m_nbFrames;
126
    FileType                    m_fileType;
127
    InputType                   m_inputType;
128
    QString                     m_fileName;
129
    Clip*                       m_baseClip;
130
    bool                        m_metadataComputed;
131
    bool                        m_inWorkspace;
132
    QString                     m_workspacePath;
133

134 135 136 137
    static QPixmap*             defaultSnapshot;
    QPixmap                     m_snapshot;
    QImage*                     m_snapshotImage;

138
signals:
139
    void                        metaDataComputed();
140
    void                        workspaceStateChanged( bool );
141
    void                        snapshotAvailable();
142 143
};

144
#endif // MEDIA_H__