Library.h 5.57 KB
Newer Older
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
1
2
3
/*****************************************************************************
 * Library.h: Multimedia library
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * 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
25
 * This file the library contains class declaration/definition.
 * It's the the backend part of the Library widget of vlmc.
26
 * It can load and unload Medias (Medias.h/Media.cpp)
27
28
 * It can load and unload Clips (Clip.h/Clip.cpp)
 */
29

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

33
34
#include "Singleton.hpp"

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
35
#include <QHash>
36
#include <QObject>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
37
#include <QUuid>
38
39
40
41
42
#include <QFileInfo>
#include <QMutex>
#include <QMutexLocker>
#include <QDomElement>
#include <QProgressDialog>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
43

Ludovic Fauvet's avatar
Ludovic Fauvet committed
44
45
46
47
class QDomDocument;
class QDomElement;

class Clip;
48
class Media;
Ludovic Fauvet's avatar
Ludovic Fauvet committed
49

50
51
52
53
54
/**
 *  \class Library
 *  \brief Library Object that handles medias
 */
class Library : public QObject, public Singleton<Library>
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
55
56
57
58
{
    Q_OBJECT
    Q_DISABLE_COPY( Library );
public:
59
    /**
60
61
62
     *  \brief  returns the media that match the unique identifier
     *  \param  uuid    the unique identifier of the media
     *  \return a pointer to the required media, or NULL if no medias matches
63
     *  \sa     clip( const QUuid& uuid )
64
     */
65
    Media*  media( const QUuid& uuid );
66
67
68
69
    /**
     *  \brief  returns the clip that match the unique identifier
     *  \param  uuid    the unique identifier of the media
     *  \return a pointer to the required clip, or NULL if no clips matches
70
71
72
     *  \sa     media( const QUuid& uuid )
     */
    Clip*   clip( const QUuid& uuid );
73
74
75
76
77
78
79
80
    /**
     *  \brief  returns the clip that match the unique identifier
     *  \param  mediaUuid the unique identifier of the media
     *  \param  clipUuid the unique identifier of the clip
     *  \return a pointer to the required clip, or NULL if no clips matches
     *  \sa     media( const QUuid& uuid )
     */
    Clip*   clip( const QUuid& mediaUuid, const QUuid& clipUuid );
81

82
    /**
83
     *  \brief  Add a file to the media library
84
85
86
87
88
     *
     *  This method will also handle metadata parsing. Right now, this is only meant to be
     *  used when loading a project.
     *  \param  fileInfo    the file info of the media
     *  \return             true if the media was successfully loaded. false otherwise.
89
90
91
92
     *  \sa     addClip( Clip* clip )
     *  \sa     media( const QUuid& uuid)
     *  \sa     clip( const QUuid& uuid )
     */
93
    bool    addMedia( const QFileInfo& fileInfo, const QString& uuid = QString() );
94

95
96
97
98
99
100
    /**
     *  \brief  Add an already preparsed media.
     *
     *  \param  media   The media to add to the library
     */
    void    addMedia( Media *media );
101

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
102
103
104
105
106
107
108
    /**
     *  \brief  Check if a file has already been loaded into library.
     *  \param  fileInfo    The file infos
     *  \return true if the file is already loaded, false otherwhise
     */
    bool    mediaAlreadyLoaded( const QFileInfo& fileInfo );

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
109
private:
110
    /**
111
     *  \brief Library Object Constructor
112
     */
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
113
    Library();
114
    /**
115
116
117
118
119
120
     *  \brief  This method is used to load a media directly from it's
     *          path, with a specified UUID.
     *          It shouldn't used for something else that loading a project file
     *  \param  path The path of the media file
     *  \param  uuid The uuid you want for the new media
     */
121

122
123
124
    /**
     *  \brief The List of medias loaded into the library
     */
125
    QHash<QUuid, Media*>    m_medias;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
126
127

public slots:
128
129
130
131
    /**
     *  \brief This slot must be called when you want a media to be removed from library
     *  \param uuid The uuid of the media to be removed
     */
132
133
134
135
136
137
    void    removingMediaAsked( const QUuid& uuid );
    /**
     *  \brief  Delete the media when it's ready
     *  \param  uuid the unique identifier of the media to delete
     */
    void    deleteMedia( const QUuid& uuid );
138
    /**
139
     *  \brief
140
     */
141
    void    loadProject( const QDomElement& project );
142
    /**
143
     *  \brief
144
     */
145
    void    saveProject( QDomDocument& doc, QDomElement& rootNode );
146
147
148
    /**
     *  \brief  Clear the library (remove all the loaded media and delete them)
     */
149
    void    clear();
150
151
152
153
    /**
     *  \brief Remove a clip from a media
     */
    void    removeClip( const QUuid& mediaId, const QUuid& clipId );
154

Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
155
signals:
156
    /**
157
158
     *  \brief          This signal should be emitted to tell a new media have been added
     *  \param media    The newly added media
159
     */
160
    void    newMediaLoaded( Media* );
161
162
163
164
    /**
     *  \brief This signal should be emiteted when a media has been removed
     *  \param uuid The removed media uuid
     */
165
    void    mediaRemoved( const QUuid& );
166
    /**
167
     *  \brief
168
     */
169
170
171
172
173
174
    void    projectLoaded();
    /**
     *  \brief
     */
    void    updateMediaRequested( const QUuid& uuid );
    friend class    Singleton<Library>;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
175
176
177
};

#endif // LIBRARY_H