Media.h 3.52 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
 * Copyright (C) 2008-2016 VideoLAN
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
5
 *
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
6
 * Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
7
 *          Yikei Lu    <luyikei.qmltu@gmail.com>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *
 * 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.
 *****************************************************************************/

24
/** \file
25
  * This file contains the Media class declaration/definition.
26
  * It contains a ISource and some extra helpers.
27
28
29
  * It's used by the Library
  */

30
31
#ifndef MEDIA_H__
#define MEDIA_H__
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
32

33
#include "config.h"
34
35
36

#include <memory>

37
#include <QEnableSharedFromThis>
38
#include <QString>
39
#include <QObject>
40
#include <QXmlStreamWriter>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
41

42
43
44
45
46
#include "Backend/MLT/MLTInput.h"

#include <medialibrary/IMedia.h>
#include <medialibrary/IFile.h>

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
47
#ifdef HAVE_GUI
48
49
#include <QPixmap>
#include <QImage>
50
51
#endif

52
namespace Backend
53
{
luyikei's avatar
luyikei committed
54
class   IInput;
55
56
57
58
namespace VLC
{
    class   VLCSource;
}
59
}
60
61
class Clip;

62
63
64
/**
  * Represents a basic container for media informations.
  */
65
class       Media : public QObject, public QEnableSharedFromThis<Media>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
66
{
67
68
    Q_OBJECT

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
69
public:
70
71
72
73
    /**
     *  \enum fType
     *  \brief enum to determine file type
     */
74
    enum    FileType
75
76
77
78
79
    {
        Audio,
        Video,
        Image
    };
80
81
82
83
84
    static const QString        VideoExtensions;
    static const QString        AudioExtensions;
    static const QString        ImageExtensions;
    static const QString        streamPrefix;

85
    Media( medialibrary::MediaPtr media );
86

87
    QString                     mrl() const;
88
    FileType                    fileType() const;
89
    QString                     title() const;
90
    qint64                      id() const;
91

92
    Clip*                       baseClip() { return m_baseClip; }
93
    const Clip*                 baseClip() const { return m_baseClip; }
94
95
96
97
98
99
100
    /**
     * @brief cut   Creates a clip to represent a cut of a media
     * @param begin The first frame of the cut
     * @param end   The last frame of the cut
     * @return      A new Clip, representing the media from [begin] to [end]
     */
    Clip*                       cut( qint64 begin, qint64 end );
101

luyikei's avatar
luyikei committed
102
103
    QVariant                    toVariant() const;

luyikei's avatar
luyikei committed
104
105
    Backend::IInput*         input();
    const Backend::IInput*   input() const;
106

107
    static QSharedPointer<Media> fromVariant( const QVariant& v );
108

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
109
#ifdef HAVE_GUI
110
111
    // This has to be called from the GUI thread.
    QPixmap&                    snapshot();
112
#endif
113
protected:
luyikei's avatar
luyikei committed
114
    std::unique_ptr<Backend::IInput>         m_input;
115
116
    medialibrary::MediaPtr      m_mlMedia;
    medialibrary::FilePtr       m_mlFile;
117
    Clip*                       m_baseClip;
118

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
119
#ifdef HAVE_GUI
120
121
    static QPixmap*             defaultSnapshot;
    QPixmap                     m_snapshot;
122
#endif
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
123
124
};

125
#endif // MEDIA_H__